|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +set -e |
| 22 | + |
| 23 | +E2E_DIR=$(dirname "$0") |
| 24 | +BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd) |
| 25 | +PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"} |
| 26 | +PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"} |
| 27 | +E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"} |
| 28 | + |
| 29 | +source "${BASE_DIR}"/.ci/helm.sh |
| 30 | + |
| 31 | +if [ ! "$KUBECONFIG" ]; then |
| 32 | + export KUBECONFIG=${E2E_KUBECONFIG} |
| 33 | +fi |
| 34 | + |
| 35 | +manifests_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/manifests.yaml |
| 36 | +mesh_config_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/mesh-config.yaml |
| 37 | +global_mesh_config_file="${BASE_DIR}"/.ci/clusters/global_backend_config.yaml |
| 38 | + |
| 39 | +kubectl apply -f "${mesh_config_file}" > /dev/null 2>&1 |
| 40 | +kubectl apply -f "${manifests_file}" > /dev/null 2>&1 |
| 41 | + |
| 42 | +verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1) |
| 43 | +if [ $? -ne 0 ]; then |
| 44 | + echo "$verify_fm_result" |
| 45 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 46 | + exit 1 |
| 47 | +fi |
| 48 | + |
| 49 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 global1=globalvalue1 2>&1) |
| 50 | +if [ $? -ne 0 ]; then |
| 51 | + echo "$verify_env_result" |
| 52 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 53 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | + |
| 57 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1) |
| 58 | +if [ $? -ne 0 ]; then |
| 59 | + echo "$verify_env_result" |
| 60 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 61 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | + |
| 65 | +# if global and namespaced config has same key, the value from namespace should be used |
| 66 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1) |
| 67 | +if [ $? -ne 0 ]; then |
| 68 | + echo "$verify_env_result" |
| 69 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 70 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 71 | + exit 1 |
| 72 | +fi |
| 73 | + |
| 74 | +# verify liveness config |
| 75 | +verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1) |
| 76 | +if [ $? -ne 0 ]; then |
| 77 | + echo "$verify_liveness_result" |
| 78 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 79 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | + |
| 83 | +# update the namespaced config, it should not trigger the reconcile since the autoUpdate is false |
| 84 | +kubectl patch BackendConfig backend-config --type='json' -p='[{"op": "replace", "path": "/spec/env/shared1", "value": "newvalue"}]' > /dev/null 2>&1 |
| 85 | +sleep 30 |
| 86 | + |
| 87 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1) |
| 88 | +if [ $? -ne 0 ]; then |
| 89 | + echo "$verify_env_result" |
| 90 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 91 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 92 | + exit 1 |
| 93 | +fi |
| 94 | + |
| 95 | +# delete the namespaced config, the source should not be reconciled since the autoUpdate is false |
| 96 | +kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 97 | +sleep 30 |
| 98 | + |
| 99 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1) |
| 100 | +if [ $? -ne 0 ]; then |
| 101 | + echo "$verify_env_result" |
| 102 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 103 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 104 | + exit 1 |
| 105 | +fi |
| 106 | + |
| 107 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1) |
| 108 | +if [ $? -ne 0 ]; then |
| 109 | + echo "$verify_env_result" |
| 110 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 111 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 112 | + exit 1 |
| 113 | +fi |
| 114 | + |
| 115 | +verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1) |
| 116 | +if [ $? -ne 0 ]; then |
| 117 | + echo "$verify_liveness_result" |
| 118 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 119 | + exit 1 |
| 120 | +fi |
| 121 | + |
| 122 | +# delete the global config, the source should be reconciled since the autoUpdate is true in the global config |
| 123 | +kubectl delete -f "${global_mesh_config_file}" -n $FUNCTION_MESH_NAMESPACE > /dev/null 2>&1 || true |
| 124 | +sleep 30 |
| 125 | + |
| 126 | +verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1) |
| 127 | +if [ $? -ne 0 ]; then |
| 128 | + echo "$verify_fm_result" |
| 129 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 130 | + exit 1 |
| 131 | +fi |
| 132 | + |
| 133 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 "" 2>&1) |
| 134 | +if [ $? -ne 0 ]; then |
| 135 | + echo "$verify_env_result" |
| 136 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 137 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 138 | + exit 1 |
| 139 | +fi |
| 140 | + |
| 141 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 "" 2>&1) |
| 142 | +if [ $? -ne 0 ]; then |
| 143 | + echo "$verify_env_result" |
| 144 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 145 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 146 | + exit 1 |
| 147 | +fi |
| 148 | + |
| 149 | +verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 "" 2>&1) |
| 150 | +if [ $? -ne 0 ]; then |
| 151 | + echo "$verify_env_result" |
| 152 | + kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 |
| 153 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 154 | + exit 1 |
| 155 | +fi |
| 156 | + |
| 157 | +# it should use liveness config from namespaced config |
| 158 | +verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 "" 2>&1) |
| 159 | +if [ $? -eq 0 ]; then |
| 160 | + echo "e2e-test: ok" | yq eval - |
| 161 | +else |
| 162 | + echo "$verify_liveness_result" |
| 163 | + kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
| 164 | + exit 1 |
| 165 | +fi |
| 166 | + |
| 167 | +kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
0 commit comments