diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index e8fdb273..9723a83c 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -43,5 +43,13 @@ convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtur convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os.json" "Service cannot be created because of missing port." +###### +# Tests related to docker-compose file in /script/test/fixtures/ports-with-proto +# kubernetes test +convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/docker-compose.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/output-k8s.json" +# openshift test +convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/docker-compose.yml convert --stdout --dc" "$KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/output-os.json" + + exit $EXIT_STATUS diff --git a/script/test/fixtures/ports-with-proto/docker-compose.yml b/script/test/fixtures/ports-with-proto/docker-compose.yml new file mode 100644 index 00000000..c508f86d --- /dev/null +++ b/script/test/fixtures/ports-with-proto/docker-compose.yml @@ -0,0 +1,20 @@ +version: "2" + +services: + web: + image: tuna/docker-counter23 + ports: + - "5000:5000/tcp" + links: + - redis + networks: + - default + + redis: + image: redis:3.0 + networks: + - default + ports: + - "6379/tcp" + - "1234:1235/udp" + diff --git a/script/test/fixtures/ports-with-proto/output-k8s.json b/script/test/fixtures/ports-with-proto/output-k8s.json new file mode 100644 index 00000000..a766bc1b --- /dev/null +++ b/script/test/fixtures/ports-with-proto/output-k8s.json @@ -0,0 +1,145 @@ +{ + "kind": "List", + "apiVersion": "v1", + "metadata": {}, + "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "web", + "creationTimestamp": null, + "labels": { + "service": "web" + } + }, + "spec": { + "ports": [ + { + "name": "5000", + "protocol": "TCP", + "port": 5000, + "targetPort": 5000 + } + ], + "selector": { + "service": "web" + } + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "redis", + "creationTimestamp": null, + "labels": { + "service": "redis" + } + }, + "spec": { + "ports": [ + { + "name": "6379", + "protocol": "TCP", + "port": 6379, + "targetPort": 6379 + }, + { + "name": "1234", + "protocol": "UDP", + "port": 1234, + "targetPort": 1235 + } + ], + "selector": { + "service": "redis" + } + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Deployment", + "apiVersion": "extensions/v1beta1", + "metadata": { + "name": "web", + "creationTimestamp": null + }, + "spec": { + "replicas": 1, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "service": "web" + } + }, + "spec": { + "containers": [ + { + "name": "web", + "image": "tuna/docker-counter23", + "ports": [ + { + "containerPort": 5000, + "protocol": "TCP" + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + }, + "strategy": {} + }, + "status": {} + }, + { + "kind": "Deployment", + "apiVersion": "extensions/v1beta1", + "metadata": { + "name": "redis", + "creationTimestamp": null + }, + "spec": { + "replicas": 1, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "service": "redis" + } + }, + "spec": { + "containers": [ + { + "name": "redis", + "image": "redis:3.0", + "ports": [ + { + "containerPort": 6379, + "protocol": "TCP" + }, + { + "containerPort": 1235, + "protocol": "UDP" + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + }, + "strategy": {} + }, + "status": {} + } + ] +} diff --git a/script/test/fixtures/ports-with-proto/output-os.json b/script/test/fixtures/ports-with-proto/output-os.json new file mode 100644 index 00000000..a5d78d3b --- /dev/null +++ b/script/test/fixtures/ports-with-proto/output-os.json @@ -0,0 +1,165 @@ +{ + "kind": "List", + "apiVersion": "v1", + "metadata": {}, + "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "redis", + "creationTimestamp": null, + "labels": { + "service": "redis" + } + }, + "spec": { + "ports": [ + { + "name": "6379", + "protocol": "TCP", + "port": 6379, + "targetPort": 6379 + }, + { + "name": "1234", + "protocol": "UDP", + "port": 1234, + "targetPort": 1235 + } + ], + "selector": { + "service": "redis" + } + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "web", + "creationTimestamp": null, + "labels": { + "service": "web" + } + }, + "spec": { + "ports": [ + { + "name": "5000", + "protocol": "TCP", + "port": 5000, + "targetPort": 5000 + } + ], + "selector": { + "service": "web" + } + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "redis", + "creationTimestamp": null, + "labels": { + "service": "redis" + } + }, + "spec": { + "strategy": { + "resources": {} + }, + "triggers": null, + "replicas": 1, + "test": false, + "selector": { + "service": "redis" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "service": "redis" + } + }, + "spec": { + "containers": [ + { + "name": "redis", + "image": "redis:3.0", + "ports": [ + { + "containerPort": 6379, + "protocol": "TCP" + }, + { + "containerPort": 1235, + "protocol": "UDP" + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + } + }, + "status": {} + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "web", + "creationTimestamp": null, + "labels": { + "service": "web" + } + }, + "spec": { + "strategy": { + "resources": {} + }, + "triggers": null, + "replicas": 1, + "test": false, + "selector": { + "service": "web" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "service": "web" + } + }, + "spec": { + "containers": [ + { + "name": "web", + "image": "tuna/docker-counter23", + "ports": [ + { + "containerPort": 5000, + "protocol": "TCP" + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } + } + }, + "status": {} + } + ] +}