diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index 0cc3f9d5..4cb4b69c 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -45,7 +45,7 @@ unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1) # kubernetes test convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-k8s.json" "Kubernetes provider doesn't support build key - ignoring" # openshift test -convert::expect_success_warning "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-os.json" "Buildconfig using https://github.com/kubernetes-incubator/kompose.git::master as source." +convert::expect_success_and_warning "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/ngnix-node-redis/output-os.json" "Buildconfig using https://github.com/kubernetes-incubator/kompose.git::HEAD as source." ###### # Tests related to docker-compose file in /script/test/fixtures/entrypoint-command @@ -92,7 +92,7 @@ convert::expect_success_and_warning "kompose --provider=openshift -f $KOMPOSE_RO ###### # Tests related to docker-compose file in /script/test/fixtures/envvars-separators # kubernetes test -convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-separators/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/envvars-separators/output-k8s.json" +convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-separators/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/envvars-separators/output-k8s.json" "Unsupported volume_driver key - ignoring" ###### # Tests related to unknown arguments with cli commands @@ -121,10 +121,10 @@ convert::expect_success_and_warning "kompose --bundle $KOMPOSE_ROOT/script/test/ # Test related to restart options in docker-compose # kubernetes test convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-no.json" -convert::failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" "Controller object cannot be specified with restart: 'on-failure'" +convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-onfail.json" # openshift test convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml --provider openshift convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-no.json" -convert::failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout -j" "Controller object cannot be specified with restart: 'on-failure'" +convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-onfail.json" ###### diff --git a/script/test/fixtures/ngnix-node-redis/output-os.json b/script/test/fixtures/ngnix-node-redis/output-os.json index ab278cbc..23a6689f 100644 --- a/script/test/fixtures/ngnix-node-redis/output-os.json +++ b/script/test/fixtures/ngnix-node-redis/output-os.json @@ -3,32 +3,6 @@ "apiVersion": "v1", "metadata": {}, "items": [ - { - "kind": "Service", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "nginx" - } - }, - "spec": { - "ports": [ - { - "name": "80", - "port": 80, - "targetPort": 80 - } - ], - "selector": { - "io.kompose.service": "nginx" - } - }, - "status": { - "loadBalancer": {} - } - }, { "kind": "Service", "apiVersion": "v1", @@ -134,121 +108,29 @@ } }, { - "kind": "DeploymentConfig", + "kind": "Service", "apiVersion": "v1", "metadata": { "name": "nginx", "creationTimestamp": null, "labels": { - "service": "nginx" + "io.kompose.service": "nginx" } }, "spec": { - "strategy": { - "resources": {} - }, - "triggers": [ + "ports": [ { - "type": "ConfigChange" - }, - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "nginx" - ], - "from": { - "kind": "ImageStreamTag", - "name": "nginx:latest" - } - } + "name": "80", + "port": 80, + "targetPort": 80 } ], - "replicas": 1, - "test": false, "selector": { - "service": "nginx" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "io.kompose.service": "nginx" - } - }, - "spec": { - "containers": [ - { - "name": "nginx", - "image": " ", - "ports": [ - { - "containerPort": 80 - } - ], - "resources": {} - } - ], - "restartPolicy": "Always" - } + "io.kompose.service": "nginx" } }, - "status": {} - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null - }, - "spec": {}, "status": { - "dockerImageRepository": "" - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null - }, - "spec": { - "triggers": [ - { - "type": "ConfigChange" - }, - { - "type": "ImageChange" - } - ], - "runPolicy": "Serial", - "source": { - "type": "Git", - "git": { - "uri": "git@github.com:procrypt/kompose.git", - "ref": "empty_vols" - }, - "contextDir": "script/test/fixtures/ngnix-node-redis/nginx" - }, - "strategy": { - "type": "Docker", - "dockerStrategy": {} - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "nginx:latest" - } - }, - "resources": {}, - "postCommit": {}, - "nodeSelector": null - }, - "status": { - "lastVersion": 0 + "loadBalancer": {} } }, { @@ -258,7 +140,7 @@ "name": "node1", "creationTimestamp": null, "labels": { - "service": "node1" + "io.kompose.service": "node1" } }, "spec": { @@ -286,7 +168,7 @@ "replicas": 1, "test": false, "selector": { - "service": "node1" + "io.kompose.service": "node1" }, "template": { "metadata": { @@ -319,7 +201,10 @@ "apiVersion": "v1", "metadata": { "name": "node1", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node1" + } }, "spec": {}, "status": { @@ -346,8 +231,8 @@ "source": { "type": "Git", "git": { - "uri": "git@github.com:procrypt/kompose.git", - "ref": "empty_vols" + "uri": "https://github.com/kubernetes-incubator/kompose.git", + "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" }, @@ -376,7 +261,7 @@ "name": "node2", "creationTimestamp": null, "labels": { - "service": "node2" + "io.kompose.service": "node2" } }, "spec": { @@ -404,7 +289,7 @@ "replicas": 1, "test": false, "selector": { - "service": "node2" + "io.kompose.service": "node2" }, "template": { "metadata": { @@ -437,7 +322,10 @@ "apiVersion": "v1", "metadata": { "name": "node2", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node2" + } }, "spec": {}, "status": { @@ -464,8 +352,8 @@ "source": { "type": "Git", "git": { - "uri": "git@github.com:procrypt/kompose.git", - "ref": "empty_vols" + "uri": "https://github.com/kubernetes-incubator/kompose.git", + "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" }, @@ -494,7 +382,7 @@ "name": "node3", "creationTimestamp": null, "labels": { - "service": "node3" + "io.kompose.service": "node3" } }, "spec": { @@ -522,7 +410,7 @@ "replicas": 1, "test": false, "selector": { - "service": "node3" + "io.kompose.service": "node3" }, "template": { "metadata": { @@ -555,7 +443,10 @@ "apiVersion": "v1", "metadata": { "name": "node3", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node3" + } }, "spec": {}, "status": { @@ -582,8 +473,8 @@ "source": { "type": "Git", "git": { - "uri": "git@github.com:procrypt/kompose.git", - "ref": "empty_vols" + "uri": "https://github.com/kubernetes-incubator/kompose.git", + "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" }, @@ -612,7 +503,7 @@ "name": "redis", "creationTimestamp": null, "labels": { - "service": "redis" + "io.kompose.service": "redis" } }, "spec": { @@ -640,7 +531,7 @@ "replicas": 1, "test": false, "selector": { - "service": "redis" + "io.kompose.service": "redis" }, "template": { "metadata": { @@ -673,7 +564,10 @@ "apiVersion": "v1", "metadata": { "name": "redis", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "redis" + } }, "spec": { "tags": [ @@ -692,6 +586,127 @@ "status": { "dockerImageRepository": "" } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": { + "strategy": { + "resources": {} + }, + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "nginx" + ], + "from": { + "kind": "ImageStreamTag", + "name": "nginx:latest" + } + } + } + ], + "replicas": 1, + "test": false, + "selector": { + "io.kompose.service": "nginx" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": { + "containers": [ + { + "name": "nginx", + "image": " ", + "ports": [ + { + "containerPort": 80 + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + } + }, + "status": {} + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": {}, + "status": { + "dockerImageRepository": "" + } + }, + { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null + }, + "spec": { + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange" + } + ], + "runPolicy": "Serial", + "source": { + "type": "Git", + "git": { + "uri": "https://github.com/kubernetes-incubator/kompose.git", + "ref": "HEAD" + }, + "contextDir": "script/test/fixtures/ngnix-node-redis/nginx" + }, + "strategy": { + "type": "Docker", + "dockerStrategy": {} + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "nginx:latest" + } + }, + "resources": {}, + "postCommit": {}, + "nodeSelector": null + }, + "status": { + "lastVersion": 0 + } } ] -} +} \ No newline at end of file diff --git a/script/test/fixtures/restart-options/output-k8s-restart-onfail.json b/script/test/fixtures/restart-options/output-k8s-restart-onfail.json new file mode 100644 index 00000000..5fa99de7 --- /dev/null +++ b/script/test/fixtures/restart-options/output-k8s-restart-onfail.json @@ -0,0 +1,36 @@ +{ + "kind": "List", + "apiVersion": "v1", + "metadata": {}, + "items": [ + { + "kind": "Pod", + "apiVersion": "v1", + "metadata": { + "name": "foo", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "foo" + } + }, + "spec": { + "containers": [ + { + "name": "foo", + "image": "foobar", + "env": [ + { + "name": "GITHUB", + "value": "surajssd" + } + ], + "resources": {} + } + ], + "restartPolicy": "OnFailure" + }, + "status": {} + } + ] +} + diff --git a/script/test/fixtures/restart-options/output-os-restart-onfail.json b/script/test/fixtures/restart-options/output-os-restart-onfail.json index e7748763..dc286df6 100644 --- a/script/test/fixtures/restart-options/output-os-restart-onfail.json +++ b/script/test/fixtures/restart-options/output-os-restart-onfail.json @@ -10,7 +10,7 @@ "name": "foo", "creationTimestamp": null, "labels": { - "service": "foo" + "io.kompose.service": "foo" } }, "spec": {