diff --git a/Makefile b/Makefile index 09ae0531..fdeb731d 100644 --- a/Makefile +++ b/Makefile @@ -82,12 +82,7 @@ test-openshift: # run commandline tests .PHONY: test-cmd test-cmd: - ./script/test/cmd/tests_new.sh - -# generate commandline tests -.PHONY: gen-cmd -gen-cmd: - ./script/test/cmd/make-test.sh + ./script/test/cmd/tests.sh # run all validation tests .PHONY: validate diff --git a/script/test/cmd/make-test.sh b/script/test/cmd/make-test.sh deleted file mode 100755 index d6e25c10..00000000 --- a/script/test/cmd/make-test.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# Copyright 2017 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing pe#rmissions and -# limitations under the License. - -# This script generates unit tests for Kompose -# Usage: ./script/test/cmd/make-test.sh - -KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) - -# Directory in which the output files have to be generated -# Eg. script/test/fixtures/group-add/ -echo -n "Enter the Test Directory where the files needs to be generated: " -read TEST_DIR - -# One-line description for the test case -echo -ne "\nEnter a description for the tests to be added: " -read TEST_DESCRIPTION - -echo -ne "\nPlease provide the name of docker-compose file to be used (docker-compose.yaml by default): " -read COMPOSE_FILE - -if [ -z $COMPOSE_FILE ]; then - COMPOSE_FILE="docker-compose.yaml" -fi - - -if [ -z $TEST_DIR ] || [ -z "${TEST_DESCRIPTION}" ]; then - echo "Please provide values for TEST_DIR and TEST_DESCRIPTION in the script" - exit 1; -fi - -COMPOSE_FILE=$TEST_DIR/$COMPOSE_FILE - -generate_k8s() { - ./kompose convert -f $COMPOSE_FILE -j -o $TEST_DIR/output-k8s.json - sed -i -e '/.*kompose.cmd.*:/ s/: .*/: "%CMD%"/' -e '/.*kompose.version.*:/ s/: .*/: "%VERSION%"/' ${TEST_DIR}/output-k8s.json -} - -generate_os() { - ./kompose convert --provider=openshift -f $COMPOSE_FILE -j -o $TEST_DIR/output-os.json - sed -i -e '/.*kompose.cmd.*:/ s/: .*/: "%CMD%"/' -e '/.*kompose.version.*:/ s/: .*/: "%VERSION%"/' ${TEST_DIR}/output-os.json -} - -# Generate k8s files -generate_k8s - -# Generate OS files -generate_os - -cat >> $KOMPOSE_ROOT/script/test/cmd/tests.sh < /tmp/output-k8s.json -convert::expect_success "kompose -f \$KOMPOSE_ROOT/$COMPOSE_FILE convert --stdout -j" -# OpenShift test -cmd="kompose --provider=openshift -f \$KOMPOSE_ROOT/${COMPOSE_FILE} convert --stdout -j" -sed -e "s;%VERSION%;\$version;g" -e "s;%CMD%;\$cmd;g" \$KOMPOSE_ROOT/${TEST_DIR}/output-os.json > /tmp/output-os.json -convert::expect_success "kompose --provider=openshift -f \$KOMPOSE_ROOT/$COMPOSE_FILE convert --stdout -j" - -EOF diff --git a/script/test/cmd/tests.sh b/script/test/cmd/tests.sh index 4356b0e9..c683b6ca 100755 --- a/script/test/cmd/tests.sh +++ b/script/test/cmd/tests.sh @@ -14,7 +14,13 @@ # See the License for the specific language governing pe#rmissions and # limitations under the License. -KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) +# for mac +if type "greadlink" > /dev/null; then + KOMPOSE_ROOT=$(greadlink -f $(dirname "${BASH_SOURCE}")/../../..) +else + KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) +fi + source $KOMPOSE_ROOT/script/test/cmd/lib.sh # Get current branch and remote url of git repository @@ -33,878 +39,350 @@ warning="Buildconfig using $uri::$branch as source." # Replacing variables with current branch and uri sed -e "s;%VERSION%;$version;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json -###### -# Tests related to docker-compose file in /script/test/fixtures/etherpad -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout" -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose-no-image.yml convert --stdout" -export $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs) -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/etherpad/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Unsupported depends_on key - ignoring" +# ## TEST V2 +DIR="v2" +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-os.yaml" -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/etherpad/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "Unsupported depends_on key - ignoring" -unset $(cat $KOMPOSE_ROOT/script/test/fixtures/etherpad/envs | cut -d'=' -f1) +convert::expect_success "$k8s_cmd" "$k8s_output" +convert::expect_success "$os_cmd" "$os_output" + +## TEST V3 +DIR="v3.0" +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-os.yaml" + +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" +convert::expect_success_and_warning "$os_cmd" "$os_output" + ###### -# Tests related to docker-compose file in /script/test/fixtures/gitlab -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout -j" -export $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs) -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/gitlab/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/gitlab/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" -unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1) +# Test the output file behavior of kompose convert +# Default behavior without -o +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -j" "redis-deployment.json" "redis-service.json" "web-deployment.json" "web-service.json" +# Behavior with -o +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o output_file -j" "output_file" +# Behavior with -o +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR -j" "$TEMP_DIR/redis-deployment.json" "$TEMP_DIR/redis-service.json" "$TEMP_DIR/web-deployment.json" "$TEMP_DIR/web-service.json" +# Behavior with -o / +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR/output_file -j" "$TEMP_DIR/output_file" +# Behavior with -o / +dst=$TEMP_DIR/output_dir/ +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $dst -j" "${dst}redis-deployment.json" "${dst}redis-service.json" "${dst}web-deployment.json" "${dst}web-service.json" +# Behavior with -o / +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR/output_dir2/output_file -j" "$TEMP_DIR/output_dir2/output_file" +#TEST the pvc-request-size command parameter +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/pvc-request-size/compose.yaml convert -o $TEMP_DIR/output_dir2/output-k8s.json -j --pvc-request-size=300Mi" "$TEMP_DIR/output_dir2/output-k8s.json" +convert::check_artifacts_generated "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/pvc-request-size/compose.yaml convert -o $TEMP_DIR/output_dir2/output-os.json -j --pvc-request-size=300Mi" "$TEMP_DIR/output_dir2/output-os.json" ###### -# Tests related to docker-compose file in /script/test/fixtures/nginx-node-redis -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -# Replacing variables with current branch and uri -# Test BuildConfig -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" - -# Replacing variables with current branch and uri -# Test BuildConfig v3/OpenShift Test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose-v3.yml convert --stdout -j --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template-v3.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" - -#Kubernetes Test for v3 -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose-v3.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-k8s-template-v3.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -###### -# Tests related to docker-compose file in /script/test/fixtures/entrypoint-command -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -###### -# Tests related to docker-compose file in /script/test/fixtures/mem-limit -# kubernetes test - -# Test the "memory limit" conversion -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/mem-limit/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/mem-limit/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# Test the "memory limit" conversion with "Mb" tagged on -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/mem-limit/docker-compose-mb.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/mem-limit/output-mb-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -###### -# Tests merge multiple docker-compose files -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/dev.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-base-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-port-base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-port-prod.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-compose-port-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-port-base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-new-service-prob.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-compose-new-service-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose --provider=openshift convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-port-base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/compose-new-service-prob.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-openshift-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/service-merge-concat-base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/service-merge-concat-override.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-service-merge-concat-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Volume mount on the host \"/override/dir\" isn't supported - ignoring path on the host" - -# Test other top level keys -# In merge -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/other-toplevel-dev.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/other-toplevel-ext.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-other-toplevel-merge-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# In Override -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/other-toplevel-base.yml -f $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/other-toplevel-override.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/merge-multiple-compose/output-other-toplevel-override-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -###### -# Tests related to docker-compose file in /script/test/fixtures/ports-with-proto -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/ports-with-proto/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -###### -# Tests related to docker-compose file in /script/test/fixtures/same-port-different-proto -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/same-port-different-proto/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/same-port-different-proto/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/same-port-different-proto/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/same-port-different-proto/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -###### -# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/simple-vol-mounts -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/simple-vol-mounts/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -###### -# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/named-volume -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose-v3.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/output-k8s-v3.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/named-volume/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -###### -# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/hostpath -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath" -hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose.yml convert --stdout -j --volumes hostPath" -hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml convert --stdout -j --volumes hostPath" -hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/docker-compose-v3.yml convert --stdout -j --volumes hostPath" -hostpath=$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/data_sux -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%HOSTPATH%;$hostpath;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/hostpath/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - - - -###### -# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/volumes-from -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/volumes-from/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/volumes-from/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "ignoring path on the host" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/volumes-from/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/volumes-from/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "ignoring path on the host" - -###### -# Tests related to docker-compose file in /script/test/fixtures/volume-mounts/tmpfs -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/tmpfs/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/tmpfs/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/tmpfs/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/tmpfs/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -###### -# Tests related to docker-compose file in /script/test/fixtures/envvars-separators -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-separators/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/envvars-separators/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Unsupported volume_driver key - ignoring" - - -###### -# Tests related to unknown arguments with cli commands -convert::expect_failure "kompose up $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml -j" "Unknown Argument docker-gitlab.yml" -convert::expect_failure "kompose down $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml -j" "Unknown Argument docker-gitlab.yml" -convert::expect_failure "kompose convert $KOMPOSE_ROOT/script/test/fixtures/gitlab/docker-compose.yml -j" "Unknown Argument docker-gitlab.yml" - -# Test related to multiple-compose files -# Kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/docker-k8s.yml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/docker-os.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Unsupported depends_on key - ignoring" - -# OpenShift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/docker-k8s.yml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/docker-os.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/multiple-compose-files/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "Unsupported depends_on key - ignoring" - - -###### -# Test related to restart options in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-no.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" /tmp/output-k8s.json - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-onfail.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" /tmp/output-k8s.json - -# 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::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" -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-unless-stopped.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-k8s-restart-unless-stopped.json" > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" /tmp/output-k8s.json - -# openshift test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml --provider openshift convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-no.json" > /tmp/output-os.json -convert::expect_success "$cmd" /tmp/output-os.json - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-onfail.json" > /tmp/output-os.json -convert::expect_success "$cmd" /tmp/output-os.json - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-unless-stopped.yml --provider openshift convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-unless-stopped.json" > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" /tmp/output-os.json - - - -##### -# Test related to hostname/domainname in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/domain/docker-compose.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/domain/output-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" /tmp/output-k8s.json - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/domain/docker-compose-v3.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/domain/output-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" /tmp/output-k8s.json - - -# openshift test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/domain/docker-compose.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/domain/output-os.json" > /tmp/output-os.json -convert::expect_success "$cmd" /tmp/output-os.json - -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/domain/docker-compose-v3.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/domain/output-os.json" > /tmp/output-os.json -convert::expect_success "$cmd" /tmp/output-os.json - - -###### -# Test key-only environment variable -export $(cat $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/envs) -cmd="kompose --file $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/env.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -unset $(cat $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/envs | cut -d'=' -f1) - -##### -# Test related to host:port:container in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/ports-with-ip/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/ports-with-ip/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -###### -# Test related to "stdin_open: true" in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/stdin-true/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/stdin-true/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# openshift test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/stdin-true/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/stdin-true/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - - -###### -# Test related to "tty: true" in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/tty-true/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/tty-true/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# openshift test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/tty-true/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/tty-true/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -# Test related to "group_add" in docker-compose -# kubernetes test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/group-add/output-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# openshift test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/group-add/output-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# Test related to Failing "group_add" in docker-compose -# kubernetes test -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose-fail.yml convert --stdout -j" -# openshift test -convert::expect_failure "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/group-add/docker-compose-fail.yml convert --stdout -j" - -# Test related to kompose.service.expose label in docker compose file to ensure that services are exposed properly -#kubernetes tests -# when kompose.service.expose="True" -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose="" -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose="" and kompose.service.expose.tls-secret="" -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname-tls.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-tls.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose="True" and multiple ports in docker compose file (first port should be selected) -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true-multiple-ports.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-true-multiple-ports.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose="" and multiple ports in docker compose file (first port should be selected) -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname-multiple-ports.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-hostname-multiple-ports.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose=";;..." -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-multiple-hostname.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-multiple-hostname.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.service.expose=";;..." and kompose.service.expose.tls-secret="" -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-multiple-hostname-tls.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/kubernetes-expose-multiple-hostname-tls.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -#openshift tests -# when kompose.service.expose="True" -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/openshift-expose-true.json > /tmp/output-os.json -convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true.yml convert --stdout -j" "/tmp/output-os.json" -# when kompose.service.expose="" -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/openshift-expose-hostname.json > /tmp/output-os.json -convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname.yml convert --stdout -j" "/tmp/output-os.json" -# when kompose.service.expose="True" and multiple ports in docker compose file (first port should be selected) -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true-multiple-ports.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/openshift-expose-true-multiple-ports.json > /tmp/output-os.json -convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-true-multiple-ports.yml convert --stdout -j" "/tmp/output-os.json" -# when kompose.service.expose="" and multiple ports in docker compose file (first port should be selected) -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname-multiple-ports.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/expose-service/provider-files/openshift-expose-hostname-multiple-ports.json > /tmp/output-os.json -convert::expect_success "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose-service/compose-files/docker-compose-expose-hostname-multiple-ports.yml convert --stdout -j" "/tmp/output-os.json" - -# Test related to kompose.image-pull-secret label in docker compose file to ensure imagePullSecrets are populated properly. -# Kubernetes Test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/image-pull-secret/compose-files/docker-compose-image-pull-secret.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/image-pull-secret/provider-files/kubernetes-image-pull-secret.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# Test related to kompose.image-pull-secrets label in docker compose file. -# Kubernetes Tests -# when kompose.image-pull-secrets is invalid -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/image-pull-policy/compose-files/v12-fail-image-pull-policy.yml convert --stdout" -# when kompose.image-pull-secrets in v1 and 2 -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/image-pull-policy/compose-files/v12-image-pull-policy.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/image-pull-policy/provider-files/kubernetes-v12-image-pull-policy.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" -# when kompose.image-pull-secrets in v3 -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/image-pull-policy/compose-files/v3-image-pull-policy.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/image-pull-policy/provider-files/kubernetes-v3-image-pull-policy.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test the change in the service name -# Kubernetes Test -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-name-change/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/service-name-change/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Unsupported root level volumes key - ignoring" - - -# Openshift Test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/service-name-change/docker-compose.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/service-name-change/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "Unsupported root level volumes key - ignoring" - -##### -# Test secrets -# Kubernetes Test - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/secrets/docker-compose-secrets-long.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/secrets/output-long-k8s.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "External secrets my_other_secret is not currently supported - ignoring" - -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/secrets/docker-compose-secrets-short.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/secrets/output-short-k8s.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "External secrets my_other_secret is not currently supported - ignoring" - - - -# Openshift Test -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/secrets/docker-compose-secrets-long.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/secrets/output-long-os.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "External secrets my_other_secret is not currently supported - ignoring" - -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/secrets/docker-compose-secrets-short.yml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/secrets/output-short-os.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "External secrets my_other_secret is not currently supported - ignoring" - - -##### -# Test regarding validating dockerfilepath -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/dockerfilepath/docker-compose.yml convert --stdout" - -# Test regarding while label (nodeport or loadbalancer ) is provided but not ports -convert::expect_failure "kompose -f $KOMPOSE_ROOT/script/test/fixtures/label-port/docker-compose.yml convert --stdout" - - -#### -# test node port with port set -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-label/docker-compose.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/service-label/output-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/service-label/docker-compose.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/service-label/output-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-oc.json" - -###### -# Test charts generate with custom dir -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/docker-compose.yml convert -o $TEMP_DIR -j -c" "$TEMP_DIR/Chart.yaml" "$TEMP_DIR/README.md" "$TEMP_DIR/templates/redis-deployment.json" "$TEMP_DIR/templates/redis-service.json" "$TEMP_DIR/templates/web-deployment.json" "$TEMP_DIR/templates/web-service.json" - -#### -# Test regarding build context (running kompose from various directories) -# Replacing variables with current branch and uri -# Test BuildConfig -CURRENT_DIR=$(pwd) -cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/" -cmd="kompose convert --provider openshift --stdout -j --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" -cd "$KOMPOSE_ROOT/script/test/fixtures/" -cmd="kompose convert --provider openshift --stdout -j -f nginx-node-redis/docker-compose.yml --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" -cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/node" -cmd="kompose convert --provider openshift --stdout -j -f ../docker-compose.yml --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" -cd $CURRENT_DIR - - - -#### Test docker build feature -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/docker-compose-dockerfile.yml --stdout -j --build=local" -convert::expect_cmd_success "$cmd" - -cmd="kompose convert --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/docker-compose-dockerfile.yml --stdout -j --build=local" -convert::expect_cmd_success "$cmd" - - -# Test the presence of build args in buildconfig -# Replacing variables with current branch and uri -# Test BuildConfig -cmd="kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/buildargs/docker-compose.yml convert --stdout -j --build build-config" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/buildargs/output-os-template.json > /tmp/output-os.json -export $(cat $KOMPOSE_ROOT/script/test/fixtures/buildargs/envs) -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "$warning" -#rm /tmp/output-buildarg-os.json - -#### -# Test related to change in pvc name if volume used is in the current directory -# kubernetes test -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" "Volume mount on the host "\"."\" isn't supported - ignoring path on the host" - - -# openshift test -cmd="kompose convert --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os-template.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" "Volume mount on the host "\"."\" isn't supported - ignoring path on the host" - -#Failing test for `--volumes` option -convert::expect_failure "kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/docker-compose.yml --volumes foobar" - -# Test related to support docker-compose.yml beside docker-compose.yml -# Store the original path -CURRENT_DIR=$(pwd) -# Kubernetes test -cd "$KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/" -sed -e "s;%VERSION%;$version;g" $KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "kompose convert --stdout -j" "/tmp/output-k8s.json" -cd "$KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/yml" -sed -e "s;%VERSION%;$version;g" $KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/yml/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "kompose convert --stdout -j" "/tmp/output-k8s.json" - -# OpenShift test -cd "$KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/" -sed -e "s;%VERSION%;$version;g" $KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/output-os-template.json > /tmp/output-os.json -convert::expect_success "kompose --provider=openshift convert --stdout -j" "/tmp/output-os.json" -cd "$KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/yml" -sed -e "s;%VERSION%;$version;g" $KOMPOSE_ROOT/script/test/fixtures/yaml-and-yml/yml/output-os-template.json > /tmp/output-os.json -convert::expect_success "kompose --provider=openshift convert --stdout -j" "/tmp/output-os.json" - -# Return back to the original path -cd $CURRENT_DIR - -# Test HealthCheck -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-k8s-template.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-os-template.json" > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose-only-command.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-only-command-k8s-template.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/docker-compose-only-command.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-only-command-os-template.json" > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -# Test ConfigMap generation -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/configmap/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/configmap/output-k8s-template.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test configmap as volume -cmd="kompose convert --stdout -j --volumes=configMap -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/docker-compose.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout --provider=openshift -j --volumes=configMap -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/docker-compose.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-oc.json" > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-oc.json" - - -# Test V3 Support of Docker Compose - -# Test deploy mode: global -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-deploy.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-deploy-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-deploy.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-deploy-os.json" > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# Test support for cpu and memory limits + reservations -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-memcpu.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-memcpu-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-memcpu-partial.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-memcpu-partial-k8s.json" > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# Test volumes are passed correctly -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-volumes.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-volumes-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test environment variables are passed correctly -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-env.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-env-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test unset environment variables are passed correctly -export V3_HOST_ENV_TEST_SET_TO_BAR=BAR -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-unset-env.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-unset-env-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test environment variables substitution -unset foo -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-env-subs.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-env-subs.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test key/value env with env_files -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/env/docker-compose.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/env/output-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/env/docker-compose.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/env/output-os.json > /tmp/output-os.json - convert::expect_success "$cmd" "/tmp/output-os.json" - -# Test that two files that are different versions fail -convert::expect_failure "kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose.yaml -f $KOMPOSE_ROOT/script/test/fixtures/etherpad/docker-compose.yaml" - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-os-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -#### -# Test `--controller` -# kubernetes test (controller=deployment) -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/controller/docker-compose.yml --stdout -j --controller=deployment" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-deployment-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# kubernetes test (controller=daemonset) -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/controller/docker-compose.yml --stdout -j --controller=daemonset" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-daemonset-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -# kubernetes test (controller=replicationcontroller) -cmd="kompose convert -f $KOMPOSE_ROOT/script/test/fixtures/controller/docker-compose.yml --stdout -j --controller=replicationcontroller" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-rc-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -# Test the "full example" from https://raw.githubusercontent.com/aanand/compose-file/master/loader/example1.env - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-full-example.json" > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -# Openshift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-full-example.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-os-full-example.json" > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" - -### Test for docker-compose files present in Examples Directory - -# docker compose - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-v3-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-v3-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# docker compose v3 - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-v3.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-v3-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-v3.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-v3-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# counter - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-counter.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-counter-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-counter.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-counter-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -# counter v3 - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-counter-v3.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-counter-v3-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-compose-counter-v3.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-counter-v3-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - - -# voting - -# Kubernetes -# This test also contains headless service test (not create by default) -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-voting.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-voting-k8s.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-voting.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-voting-os.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# gitlab - -# Kubernetes -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/examples/docker-gitlab.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-gitlab-k8s.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - - -## OpenShift -cmd="kompose convert --provider=openshift --stdout -j -f $KOMPOSE_ROOT/examples/docker-gitlab.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/examples/output-gitlab-os.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" - -## Test compose v3 global deploy -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-global.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-global-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --controller deployment --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-global.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-global-deployment-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -## Test label kompose.controller.type -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-controller-label.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-controller-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --controller deployment --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-controller-label.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-controller-template.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-controller-label-v3.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-k8s-controller-v3-template.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose --provider=openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/controller/compose-controller-label-v3.yml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/controller/output-os-controller-v3-template.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-short.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-config-short.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-short-warning.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-config-short-warning.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-long.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-config-long.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-long-warning.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-config-long-warning.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -## Test compose v3.3 -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-endpoint-mode-1.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-endpoint-mode-1.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-endpoint-mode-2.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-k8s-endpoint-mode-2.json > /tmp/output-k8s.json -convert::expect_success "$cmd" "/tmp/output-k8s.json" - -## Test compose v3.5+ -cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-3.5.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/v3/output-k8s-3.5.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" - -## Test OpenShift for compose v3.3 -cmd="kompose --provider openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-long.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-os-config-long.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" - -cmd="kompose --provider openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-config-short.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-os-config-short.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -cmd="kompose --provider openshift convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/compose-endpoint-mode-1.yaml" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/compose-v3.3-test/output-os-mode-1.json > /tmp/output-os.json -convert::expect_success "$cmd" "/tmp/output-os.json" - -# Testing stdin feature -cmd="kompose convert --stdout -j -f -" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/stdin/output-k8s.json > /tmp/output-k8s.json -cat $KOMPOSE_ROOT/script/test/fixtures/stdin/docker-compose.yaml | $cmd | diff /tmp/output-k8s.json - - -# Network Translation compose -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/network/output-k8s.json > /tmp/output-k8s.json -convert::expect_success_and_warning "$cmd" "/tmp/output-k8s.json" -# OpenShift test -cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/network/docker-compose-v3.yaml convert --stdout -j" -sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" $KOMPOSE_ROOT/script/test/fixtures/network/output-os.json > /tmp/output-os.json -convert::expect_success_and_warning "$cmd" "/tmp/output-os.json" - -echo -e "\n" -go test -v github.com/kubernetes/kompose/script/test/cmd - -rm /tmp/output-k8s.json /tmp/output-os.json -exit $EXIT_STATUS +# Test the path of build image +# Test build v2 absolute compose file +convert::check_artifacts_generated "kompose --build local -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose.yaml convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" +# Test build v2 relative compose file +relative_path=$(realpath --relative-to="$PWD" "$KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose.yaml") +convert::check_artifacts_generated "kompose --build local -f $relative_path convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" +# Test build v3 absolute compose file with context +convert::check_artifacts_generated "kompose --build local -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-v3.yaml convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" +# Test build v3 relative compose file with context +relative_path=$(realpath --relative-to="$PWD" "$KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-v3.yaml") +convert::check_artifacts_generated "kompose --build local -f $relative_path convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" + +# ##### +# Test the build config with push image +# see tests_push_image.sh for local push test +# Should warn when push image disabled +cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-build-no-image.yaml -o $TEMP_DIR/output_file convert --build=local --push-image-registry=whatever" +convert::expect_warning "$cmd" "Push image registry 'whatever' is specified but push image is disabled, skipping pushing to repository" + +#TEST the kompose.volume.storage-class-name label +convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/storage-class-name/compose.yaml convert -o $TEMP_DIR/output-k8s.yaml" "$TEMP_DIR/output-k8s.yaml" +convert::check_artifacts_generated "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/storage-class-name/compose.yaml convert -o $TEMP_DIR/output-os.yaml -j" "$TEMP_DIR/output-os.yaml" + +# TEST the windows volume +# windows host path to windows container +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 + +# # TEST the placement +# should convert placement to affinity +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/deploy/placement/compose-placement.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/deploy/placement/compose-placement.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/deploy/placement/output-placement-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/deploy/placement/output-placement-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 + + +# test configmap volume +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose.yaml convert --stdout --with-kompose-annotation=false --volumes=configMap" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose.yaml convert --stdout --with-kompose-annotation=false --volumes=configMap" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# test configmap volume using service label +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose-withlabel.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose-withlabel.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-os-withlabel.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# test configmap pod generation +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-os.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/compose.yaml convert --stdout --with-kompose-annotation=false" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test that emptyDir works +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --volumes emptyDir" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --volumes emptyDir" +os_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os-empty-vols-template.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test that emptyvols works +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --emptyvols" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --emptyvols" +os_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 + +# test service expose +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml convert --stdout --with-kompose-annotation=false" +ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-k8s.yaml" +ocp_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 + + +# test service group by volume, not support openshift for now +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-group/compose.yaml convert --stdout --with-kompose-annotation=false --service-group-mode=volume --service-group-name=librenms-dispatcher" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/service-group/output-k8s.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 + +# test merge multiple compose files +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout --with-kompose-annotation=false" +ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-k8s.yaml" +ocp_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 + +# test health check +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/compose-healthcheck.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/compose-healthcheck.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# test statefulset +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/compose.yaml convert --stdout --with-kompose-annotation=false --controller statefulset" +ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/compose.yaml convert --stdout --with-kompose-annotation=false --controller statefulset" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-k8s.yaml" +ocp_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 + +# test cronjob +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/cronjob/compose.yaml convert --stdout --with-kompose-annotation=false" +ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/cronjob/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/cronjob/output-k8s.yaml" +ocp_output="$KOMPOSE_ROOT/script/test/fixtures/cronjob/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 + +# test specifying volume type using service label +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test environment variables interpolation +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 + +# Test single file output feature +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/single-file-output/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/single-file-output/output-k8s.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 + +# Test host port and protocol feature +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/compose.yaml convert --stdout --with-kompose-annotation=false" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-k8s.yaml" +os_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test external traffic policy feature with valid configuration, warning is coming from the network policy. +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v1.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v1.yaml convert --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-os-v1.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test external traffic policy feature with warning, because we have nodeport with external traffic policy +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v2.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v2.yaml convert --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-os-v2.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 + +# Test Pod security context fs group +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/fsgroup/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-k8s.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/fsgroup/compose.yaml convert --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test support for compose.yaml file +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-file-support/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-support/output-k8s.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 + +# Test support for compose env interpolation +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-env-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-env-interpolation/output-k8s.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test support for subpath volume +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/vols-subpath/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-k8s.yaml" +os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/vols-subpath/compose.yaml convert --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-os.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test support for network policies generation +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-policies/compose.yaml convert --generate-network-policies --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-policies/output-k8s.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 + +# Test support for namespace generation +k8s_cmd="kompose -f ./script/test/fixtures/namespace/compose.yaml convert --stdout --with-kompose-annotation=false -n web" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/namespace/output-k8s.yaml" +os_cmd="kompose -f ./script/test/fixtures/namespace/compose.yaml convert --stdout --with-kompose-annotation=false -n web --provider openshift" +os_output="$KOMPOSE_ROOT/script/test/fixtures/namespace/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test support for read only root fs +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/read-only/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/read-only/output-k8s.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/read-only/compose.yaml convert --stdout --with-kompose-annotation=false --provider openshift" +os_output="$KOMPOSE_ROOT/script/test/fixtures/read-only/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test env_file support +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-k8s.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# disabled until FormatEnvName can take into account conflicting/duplicate file names +# Test env_file support for multiple env_file with the same name from different dirs +# k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/compose.yaml convert --stdout --with-kompose-annotation=false" +# k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-k8s.yaml" +# os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +# os_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-os.yaml" +# convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +# convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test that if we have no profile a warning should raised +cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/no-profile-warning/compose.yaml convert" +convert::expect_warning "$cmd" "No service selected. The profile specified in services of your compose yaml may not exist." || exit 1 + +# Test COMPOSE_FILE env variable is honored +export COMPOSE_FILE="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/compose.yaml $KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/alternative-compose.yaml" +k8s_cmd="kompose convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/output-k8s.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 + +# Test resources names lowercase +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-k8s.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test resources to generate initcontainer +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/initcontainer/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/initcontainer/output-k8s.yaml" +convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 + +# Test HPA +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/hpa/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/hpa/output-k8s.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 + +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-1.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-1.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-2.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-3.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +# Test network_mode: service: +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-mode-service/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-mode-service/output-k8s.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 + +# Test env var with status +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/compose.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/output-k8s.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/output-os.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 diff --git a/script/test/cmd/tests_new.sh b/script/test/cmd/tests_new.sh deleted file mode 100755 index c683b6ca..00000000 --- a/script/test/cmd/tests_new.sh +++ /dev/null @@ -1,388 +0,0 @@ -#!/bin/bash - -# Copyright 2017 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing pe#rmissions and -# limitations under the License. - -# for mac -if type "greadlink" > /dev/null; then - KOMPOSE_ROOT=$(greadlink -f $(dirname "${BASH_SOURCE}")/../../..) -else - KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) -fi - -source $KOMPOSE_ROOT/script/test/cmd/lib.sh - -# Get current branch and remote url of git repository -branch=$(git branch | grep \* | cut -d ' ' -f2-) - -uri=$(git config --get remote.origin.url) -if [[ $uri != *".git"* ]]; then - uri="${uri}.git" -fi - -# Get version -version=`kompose version` - -# Warning Template -warning="Buildconfig using $uri::$branch as source." -# Replacing variables with current branch and uri -sed -e "s;%VERSION%;$version;g" -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json - - - -# ## TEST V2 -DIR="v2" -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-os.yaml" - -convert::expect_success "$k8s_cmd" "$k8s_output" -convert::expect_success "$os_cmd" "$os_output" - - - -## TEST V3 -DIR="v3.0" -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/$DIR/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/$DIR/output-os.yaml" - -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" -convert::expect_success_and_warning "$os_cmd" "$os_output" - -###### -# Test the output file behavior of kompose convert -# Default behavior without -o -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -j" "redis-deployment.json" "redis-service.json" "web-deployment.json" "web-service.json" -# Behavior with -o -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o output_file -j" "output_file" -# Behavior with -o -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR -j" "$TEMP_DIR/redis-deployment.json" "$TEMP_DIR/redis-service.json" "$TEMP_DIR/web-deployment.json" "$TEMP_DIR/web-service.json" -# Behavior with -o / -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR/output_file -j" "$TEMP_DIR/output_file" -# Behavior with -o / -dst=$TEMP_DIR/output_dir/ -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $dst -j" "${dst}redis-deployment.json" "${dst}redis-service.json" "${dst}web-deployment.json" "${dst}web-service.json" -# Behavior with -o / -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/redis-example/compose.yaml convert -o $TEMP_DIR/output_dir2/output_file -j" "$TEMP_DIR/output_dir2/output_file" - -#TEST the pvc-request-size command parameter -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/pvc-request-size/compose.yaml convert -o $TEMP_DIR/output_dir2/output-k8s.json -j --pvc-request-size=300Mi" "$TEMP_DIR/output_dir2/output-k8s.json" -convert::check_artifacts_generated "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/pvc-request-size/compose.yaml convert -o $TEMP_DIR/output_dir2/output-os.json -j --pvc-request-size=300Mi" "$TEMP_DIR/output_dir2/output-os.json" - -###### -# Test the path of build image -# Test build v2 absolute compose file -convert::check_artifacts_generated "kompose --build local -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose.yaml convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" -# Test build v2 relative compose file -relative_path=$(realpath --relative-to="$PWD" "$KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose.yaml") -convert::check_artifacts_generated "kompose --build local -f $relative_path convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" -# Test build v3 absolute compose file with context -convert::check_artifacts_generated "kompose --build local -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-v3.yaml convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" -# Test build v3 relative compose file with context -relative_path=$(realpath --relative-to="$PWD" "$KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-v3.yaml") -convert::check_artifacts_generated "kompose --build local -f $relative_path convert -o $TEMP_DIR/output_file" "$TEMP_DIR/output_file" - -# ##### -# Test the build config with push image -# see tests_push_image.sh for local push test -# Should warn when push image disabled -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/buildconfig/compose-build-no-image.yaml -o $TEMP_DIR/output_file convert --build=local --push-image-registry=whatever" -convert::expect_warning "$cmd" "Push image registry 'whatever' is specified but push image is disabled, skipping pushing to repository" - -#TEST the kompose.volume.storage-class-name label -convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixtures/storage-class-name/compose.yaml convert -o $TEMP_DIR/output-k8s.yaml" "$TEMP_DIR/output-k8s.yaml" -convert::check_artifacts_generated "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/storage-class-name/compose.yaml convert -o $TEMP_DIR/output-os.yaml -j" "$TEMP_DIR/output-os.yaml" - -# TEST the windows volume -# windows host path to windows container -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/volume-mounts/windows/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 - -# # TEST the placement -# should convert placement to affinity -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/deploy/placement/compose-placement.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/deploy/placement/compose-placement.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/deploy/placement/output-placement-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/deploy/placement/output-placement-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 - - -# test configmap volume -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose.yaml convert --stdout --with-kompose-annotation=false --volumes=configMap" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose.yaml convert --stdout --with-kompose-annotation=false --volumes=configMap" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# test configmap volume using service label -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose-withlabel.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-volume/compose-withlabel.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-volume/output-os-withlabel.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# test configmap pod generation -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-pod/output-os.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/configmap-pod/compose.yaml convert --stdout --with-kompose-annotation=false" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test that emptyDir works -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --volumes emptyDir" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --volumes emptyDir" -os_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os-empty-vols-template.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test that emptyvols works -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --emptyvols" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-k8s.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/change-in-volume/compose.yaml convert --with-kompose-annotation=false --stdout --emptyvols" -os_output="$KOMPOSE_ROOT/script/test/fixtures/change-in-volume/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 - -# test service expose -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml convert --stdout --with-kompose-annotation=false" -ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/expose/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-k8s.yaml" -ocp_output="$KOMPOSE_ROOT/script/test/fixtures/expose/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 - - -# test service group by volume, not support openshift for now -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-group/compose.yaml convert --stdout --with-kompose-annotation=false --service-group-mode=volume --service-group-name=librenms-dispatcher" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/service-group/output-k8s.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 - -# test merge multiple compose files -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout --with-kompose-annotation=false" -ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-k8s.yaml" -ocp_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 - -# test health check -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/compose-healthcheck.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/healthcheck/compose-healthcheck.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/healthcheck/output-healthcheck-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# test statefulset -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/compose.yaml convert --stdout --with-kompose-annotation=false --controller statefulset" -ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/statefulset/compose.yaml convert --stdout --with-kompose-annotation=false --controller statefulset" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-k8s.yaml" -ocp_output="$KOMPOSE_ROOT/script/test/fixtures/statefulset/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 - -# test cronjob -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/cronjob/compose.yaml convert --stdout --with-kompose-annotation=false" -ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/cronjob/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/cronjob/output-k8s.yaml" -ocp_output="$KOMPOSE_ROOT/script/test/fixtures/cronjob/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$ocp_cmd" "$ocp_output" || exit 1 - -# test specifying volume type using service label -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test environment variables interpolation -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 - -# Test single file output feature -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/single-file-output/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/single-file-output/output-k8s.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 - -# Test host port and protocol feature -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/compose.yaml convert --stdout --with-kompose-annotation=false" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-k8s.yaml" -os_output="$KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test external traffic policy feature with valid configuration, warning is coming from the network policy. -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v1.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v1.yaml convert --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-os-v1.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test external traffic policy feature with warning, because we have nodeport with external traffic policy -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v2.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/compose-v2.yaml convert --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-os-v2.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success_and_warning "$os_cmd" "$os_output" || exit 1 - -# Test Pod security context fs group -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/fsgroup/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-k8s.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/fsgroup/compose.yaml convert --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/fsgroup/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test support for compose.yaml file -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-file-support/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-support/output-k8s.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 - -# Test support for compose env interpolation -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-env-interpolation/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-env-interpolation/output-k8s.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test support for subpath volume -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/vols-subpath/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-k8s.yaml" -os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/vols-subpath/compose.yaml convert --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-os.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test support for network policies generation -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-policies/compose.yaml convert --generate-network-policies --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-policies/output-k8s.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 - -# Test support for namespace generation -k8s_cmd="kompose -f ./script/test/fixtures/namespace/compose.yaml convert --stdout --with-kompose-annotation=false -n web" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/namespace/output-k8s.yaml" -os_cmd="kompose -f ./script/test/fixtures/namespace/compose.yaml convert --stdout --with-kompose-annotation=false -n web --provider openshift" -os_output="$KOMPOSE_ROOT/script/test/fixtures/namespace/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test support for read only root fs -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/read-only/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/read-only/output-k8s.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/read-only/compose.yaml convert --stdout --with-kompose-annotation=false --provider openshift" -os_output="$KOMPOSE_ROOT/script/test/fixtures/read-only/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test env_file support -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-k8s.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/env/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# disabled until FormatEnvName can take into account conflicting/duplicate file names -# Test env_file support for multiple env_file with the same name from different dirs -# k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/compose.yaml convert --stdout --with-kompose-annotation=false" -# k8s_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-k8s.yaml" -# os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/env-multiple/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -# os_output="$KOMPOSE_ROOT/script/test/fixtures/env-multiple/output-os.yaml" -# convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -# convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test that if we have no profile a warning should raised -cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/no-profile-warning/compose.yaml convert" -convert::expect_warning "$cmd" "No service selected. The profile specified in services of your compose yaml may not exist." || exit 1 - -# Test COMPOSE_FILE env variable is honored -export COMPOSE_FILE="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/compose.yaml $KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/alternative-compose.yaml" -k8s_cmd="kompose convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/compose-file-env-variable/output-k8s.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 - -# Test resources names lowercase -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-k8s.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test resources to generate initcontainer -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/initcontainer/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/initcontainer/output-k8s.yaml" -convert::expect_success_and_warning "$k8s_cmd" "$k8s_output" || exit 1 - -# Test HPA -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/hpa/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/hpa/output-k8s.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 - -#Test auto configmaps from files/dir -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-1.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-1.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -#Test auto configmaps from files/dir -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-2.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -#Test auto configmaps from files/dir -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-3.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1 - -# Test network_mode: service: -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-mode-service/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-mode-service/output-k8s.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 - -# Test env var with status -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/output-k8s.yaml" -os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/compose.yaml convert --provider openshift --stdout --with-kompose-annotation=false" -os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-with-status/output-os.yaml" -convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 -convert::expect_success "$os_cmd" "$os_output" || exit 1