Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions examples/sample-app/application-template-custombuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"kind": "ImageRepository",
"apiVersion": "v1beta1",
"dockerImageRepository": "172.30.17.3:5001/openshift/origin-ruby-sample",
"dockerImageRepository": "172.30.17.3:5001/test/origin-ruby-sample",
"labels": {
"name": "origin-ruby-sample"
}
Expand Down Expand Up @@ -106,7 +106,7 @@
}
},
"output": {
"imageTag": "openshift/origin-ruby-sample:latest",
"imageTag": "test/origin-ruby-sample:latest",
"registry": "172.30.17.3:5001"
},
},
Expand All @@ -128,7 +128,7 @@
"containerNames": [
"ruby-helloworld"
],
"repositoryName": "172.30.17.3:5001/openshift/origin-ruby-sample",
"repositoryName": "172.30.17.3:5001/test/origin-ruby-sample",
"tag": "latest"
}
}
Expand All @@ -149,7 +149,7 @@
"containers": [
{
"name": "ruby-helloworld",
"image": "172.30.17.3:5001/openshift/origin-ruby-sample",
"image": "172.30.17.3:5001/test/origin-ruby-sample",
"env": [
{
"name": "ADMIN_USERNAME",
Expand Down Expand Up @@ -206,7 +206,7 @@
}
],
"template": {
"strategy":{
"strategy": {
"type":"Recreate"
},
"controllerTemplate": {
Expand Down
8 changes: 4 additions & 4 deletions examples/sample-app/application-template-dockerbuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"kind": "ImageRepository",
"apiVersion": "v1beta1",
"dockerImageRepository": "172.30.17.3:5001/openshift/origin-ruby-sample",
"dockerImageRepository": "172.30.17.3:5001/test/origin-ruby-sample",
"labels": {
"name": "origin-ruby-sample"
}
Expand Down Expand Up @@ -102,7 +102,7 @@
"type": "Docker"
},
"output": {
"imageTag": "openshift/origin-ruby-sample:latest",
"imageTag": "test/origin-ruby-sample:latest",
"registry": "172.30.17.3:5001"
},
},
Expand All @@ -124,7 +124,7 @@
"containerNames": [
"ruby-helloworld"
],
"repositoryName": "172.30.17.3:5001/openshift/origin-ruby-sample",
"repositoryName": "172.30.17.3:5001/test/origin-ruby-sample",
"tag": "latest"
}
}
Expand All @@ -145,7 +145,7 @@
"containers": [
{
"name": "ruby-helloworld",
"image": "172.30.17.3:5001/openshift/origin-ruby-sample",
"image": "172.30.17.3:5001/test/origin-ruby-sample",
"env": [
{
"name": "ADMIN_USERNAME",
Expand Down
80 changes: 40 additions & 40 deletions examples/sample-app/application-template-stibuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"kind": "ImageRepository",
"apiVersion": "v1beta1",
"dockerImageRepository": "172.30.17.3:5001/openshift/origin-ruby-sample",
"dockerImageRepository": "172.30.17.3:5001/test/origin-ruby-sample",
"labels": {
"name": "origin-ruby-sample"
}
Expand Down Expand Up @@ -106,7 +106,7 @@
}
},
"output": {
"imageTag": "openshift/origin-ruby-sample:latest",
"imageTag": "test/origin-ruby-sample:latest",
"registry": "172.30.17.3:5001"
},
},
Expand All @@ -128,7 +128,7 @@
"containerNames": [
"ruby-helloworld"
],
"repositoryName": "172.30.17.3:5001/openshift/origin-ruby-sample",
"repositoryName": "172.30.17.3:5001/test/origin-ruby-sample",
"tag": "latest"
}
}
Expand All @@ -149,7 +149,7 @@
"containers": [
{
"name": "ruby-helloworld",
"image": "172.30.17.3:5001/openshift/origin-ruby-sample",
"image": "172.30.17.3:5001/test/origin-ruby-sample",
"env": [
{
"name": "ADMIN_USERNAME",
Expand Down Expand Up @@ -206,43 +206,43 @@
}
],
"template": {
"strategy": {
"type":"Recreate"
},
"controllerTemplate": {
"replicas": 1,
"replicaSelector": {
"name": "database"
},
"podTemplate": {
"desiredState": {
"manifest": {
"version": "v1beta1",
"containers": [
{
"name": "ruby-helloworld-database",
"image": "mysql",
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "${MYSQL_ROOT_PASSWORD}"
},
{
"name": "MYSQL_DATABASE",
"value": "${MYSQL_DATABASE}"
}
],
"ports": [
{
"containerPort": 3306
}
]
}
]
}
},
"labels": {
"strategy": {
"type":"Recreate"
},
"controllerTemplate": {
"replicas": 1,
"replicaSelector": {
"name": "database"
},
"podTemplate": {
"desiredState": {
"manifest": {
"version": "v1beta1",
"containers": [
{
"name": "ruby-helloworld-database",
"image": "mysql",
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "${MYSQL_ROOT_PASSWORD}"
},
{
"name": "MYSQL_DATABASE",
"value": "${MYSQL_DATABASE}"
}
],
"ports": [
{
"containerPort": 3306
}
]
}
]
}
},
"labels": {
"name": "database"
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ KUBELET_PORT="${KUBELET_PORT:-10250}"

CONFIG_FILE="${LOG_DIR}/appConfig.json"
BUILD_CONFIG_FILE="${LOG_DIR}/buildConfig.json"
FIXTURE_DIR="${OS_ROOT}/examples/sample-app"
GO_OUT="${OS_ROOT}/_output/local/go/bin"

# set path so OpenShift is available
export PATH="${GO_OUT}:${PATH}"
pushd "${GO_OUT}" > /dev/null
ln -fs "openshift" "osc"
ln -fs "$(pwd)/openshift" "osc"
popd > /dev/null

# teardown
Expand All @@ -70,8 +69,7 @@ function teardown()
echo "[INFO] Dumping build log to $LOG_DIR"

set +e
BUILD_ID=`osc get -n test builds -o template -t "{{with index .items 0}}{{.metadata.name}}{{end}}"`
osc build-logs -n test $BUILD_ID > $LOG_DIR/build.log
osc get -n test builds -o template -t '{{ range .items }}{{.metadata.name}}{{ "\n" }}{{end}}' | xargs -r -l osc build-logs -n test >$LOG_DIR/build.log

curl -L http://localhost:4001/v2/keys/?recursive=true > $ARTIFACT_DIR/etcd_dump.json
set -e
Expand All @@ -83,10 +81,10 @@ function teardown()
set +e
echo "[INFO] Tearing down test"
stop_openshift_server
echo "[INFO] Stopping docker containers"; docker stop $(docker ps -a -q)
echo "[INFO] Stopping docker containers"; docker ps -aq | xargs -l -r docker stop
set +u
if [ "$SKIP_IMAGE_CLEANUP" != "1" ]; then
echo "[INFO] Removing docker containers"; docker rm $(docker ps -a -q)
echo "[INFO] Removing docker containers"; docker ps -aq | xargs -l -r docker rm
fi
set -u
set -e
Expand All @@ -112,7 +110,7 @@ wait_for_url "http://localhost:8080/healthz" "[INFO] apiserver: "

# Deploy private docker registry
echo "[INFO] Deploying private Docker registry"
osc apply -n test -f ${FIXTURE_DIR}/docker-registry-config.json
osc apply -n test -f examples/sample-app/docker-registry-config.json

echo "[INFO] Waiting for Docker registry pod to start"
wait_for_command "osc get -n test pods | grep registrypod | grep -i Running" $((5*TIME_MIN))
Expand All @@ -136,7 +134,7 @@ echo "[INFO] Pushed centos7"

# Process template and apply
echo "[INFO] Submitting application template json for processing..."
osc process -n test -f ${FIXTURE_DIR}/application-template-${BUILD_TYPE}build.json > "${CONFIG_FILE}"
osc process -n test -f examples/sample-app/application-template-${BUILD_TYPE}build.json > "${CONFIG_FILE}"
# substitute the default IP address with the address where we actually ended up
# TODO: make this be unnecessary by fixing images
# This is no longer needed because the docker registry explicitly requests the 172.30.17.3 ip address.
Expand Down
29 changes: 22 additions & 7 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
_ "github.com/openshift/origin/pkg/api/latest"
"github.com/openshift/origin/pkg/api/v1beta1"
config "github.com/openshift/origin/pkg/config/api"
image "github.com/openshift/origin/pkg/image/api"
template "github.com/openshift/origin/pkg/template/api"
)

Expand Down Expand Up @@ -78,6 +79,14 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
// TODO: replace with structured type definition
j.Items = []runtime.RawExtension{}
},
func(j *image.Image, c fuzz.Continue) {
c.Fuzz(&j.ObjectMeta)
c.Fuzz(&j.DockerImageMetadata)
j.DockerImageMetadata.APIVersion = ""
j.DockerImageMetadata.Kind = ""
j.DockerImageMetadataVersion = []string{"pre012", "1.0"}[c.Rand.Intn(2)]
j.DockerImageReference = c.RandString()
},
func(j *config.Config, c fuzz.Continue) {
c.Fuzz(&j.ObjectMeta)
// TODO: replace with structured type definition
Expand Down Expand Up @@ -127,12 +136,12 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
name := reflect.TypeOf(source).Elem().Name()
apiObjectFuzzer.Fuzz(source)
j, err := meta.Accessor(source)
if err != nil {
t.Fatalf("Unexpected error %v for %#v", err, source)
if j, err := meta.TypeAccessor(source); err == nil {
j.SetKind("")
j.SetAPIVersion("")
} else {
t.Logf("Unable to set apiversion/kind to empty on %v", reflect.TypeOf(source))
}
j.SetKind("")
j.SetAPIVersion("")

data, err := codec.Encode(source)
if err != nil {
Expand Down Expand Up @@ -161,6 +170,10 @@ func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
}
}

var skipStandardVersions = map[string][]string{
"DockerImage": {"pre012", "1.0"},
}

func TestTypes(t *testing.T) {
for kind, reflectType := range api.Scheme.KnownTypes("") {
if !strings.Contains(reflectType.PkgPath(), "/origin/") {
Expand All @@ -174,8 +187,10 @@ func TestTypes(t *testing.T) {
t.Errorf("Couldn't make a %v? %v", kind, err)
continue
}
if _, err := meta.Accessor(item); err != nil {
t.Logf("%s is not a ObjectMeta and cannot be round tripped: %v", kind, err)
if versions, ok := skipStandardVersions[kind]; ok {
for _, v := range versions {
runTest(t, runtime.CodecFor(api.Scheme, v), item)
}
continue
}
runTest(t, v1beta1.Codec, item)
Expand Down
Loading