diff --git a/.ci/clusters/global_env.yaml b/.ci/clusters/global_env.yaml index 6fd3447b..d8d796c5 100644 --- a/.ci/clusters/global_env.yaml +++ b/.ci/clusters/global_env.yaml @@ -4,3 +4,4 @@ metadata: name: mesh-global-env data: global1: globalvalue1 + shared1: fromglobal diff --git a/.ci/tests/global.env b/.ci/tests/global.env deleted file mode 100644 index 9d9500fc..00000000 --- a/.ci/tests/global.env +++ /dev/null @@ -1 +0,0 @@ -global1=globalvalue1 diff --git a/.ci/tests/integration/cases/global-and-namespaced-env/env.yaml b/.ci/tests/integration/cases/global-and-namespaced-env/env.yaml index 75711494..02fc101f 100644 --- a/.ci/tests/integration/cases/global-and-namespaced-env/env.yaml +++ b/.ci/tests/integration/cases/global-and-namespaced-env/env.yaml @@ -5,3 +5,4 @@ metadata: namespace: default data: namespaced1: namespacedvalue1 + shared1: fromnamespace diff --git a/.ci/tests/integration/cases/global-and-namespaced-env/verify.sh b/.ci/tests/integration/cases/global-and-namespaced-env/verify.sh index abd11460..5de2bc37 100644 --- a/.ci/tests/integration/cases/global-and-namespaced-env/verify.sh +++ b/.ci/tests/integration/cases/global-and-namespaced-env/verify.sh @@ -61,6 +61,15 @@ if [ $? -ne 0 ]; then exit 1 fi +# if global and namespaced env has same key, the value from namespace should be used +verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromnamespace 2>&1) +if [ $? -ne 0 ]; then + echo "$verify_env_result" + kubectl delete -f "${env_file}" > /dev/null 2>&1 + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true + exit 1 +fi + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true # delete the namespaced env, the function can start successfully but without namespaced env injected @@ -81,6 +90,13 @@ if [ $? -ne 0 ]; then exit 1 fi +verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromglobal 2>&1) +if [ $? -ne 0 ]; then + echo "$verify_env_result" + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true + exit 1 +fi + verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 "" 2>&1) if [ $? -eq 0 ]; then echo "e2e-test: ok" | yq eval -