This is an automated email from the ASF dual-hosted git repository.

gyfora pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 207d394c [FLINK-30519] Add dynamic config e2e
207d394c is described below

commit 207d394c956a0853b40336890b324c19f1342ac0
Author: Peter Huang <[email protected]>
AuthorDate: Wed Oct 18 07:38:47 2023 -0700

    [FLINK-30519] Add dynamic config e2e
---
 .github/workflows/ci.yml         | 15 +++++++++++++++
 e2e-tests/test_dynamic_config.sh | 38 ++++++++++++++++++++++++++++++++++++++
 e2e-tests/utils.sh               | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c4572b54..40933119 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -73,6 +73,7 @@ jobs:
         test:
           - test_application_kubernetes_ha.sh
           - test_application_operations.sh
+          - test_dynamic_config.sh
           - test_sessionjob_kubernetes_ha.sh
           - test_sessionjob_operations.sh
           - test_multi_sessionjob.sh
@@ -97,16 +98,30 @@ jobs:
             test: test_multi_sessionjob.sh
           - namespace: default
             test: test_autoscaler.sh
+          - namespace: default
+            test: test_dynamic_config.sh
           - mode: standalone
             test: test_autoscaler.sh
+          - mode: standalone
+            test: test_dynamic_config.sh
           - version: v1_13
             test: test_autoscaler.sh
+          - version: v1_13
+            test: test_dynamic_config.sh
           - version: v1_14
             test: test_autoscaler.sh
+          - version: v1_14
+            test: test_dynamic_config.sh
           - version: v1_15
             test: test_autoscaler.sh
+          - version: v1_15
+            test: test_dynamic_config.sh
           - version: v1_16
             test: test_autoscaler.sh
+          - version: v1_16
+            test: test_dynamic_config.sh
+          - version: v1_17
+            test: test_dynamic_config.sh
     name: e2e_ci
     steps:
       - uses: actions/checkout@v2
diff --git a/e2e-tests/test_dynamic_config.sh b/e2e-tests/test_dynamic_config.sh
new file mode 100644
index 00000000..26dfef3d
--- /dev/null
+++ b/e2e-tests/test_dynamic_config.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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 permissions and
+# limitations under the License.
+################################################################################
+
+# This script tests the operator dynamic config on watched namespace:
+# 1. Create a new namespace
+# 2. Change the watched namespaces by patching on the flink-config-override
+# 3. Monitor the operator log to find the watched namespace changed info
+SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
+source "${SCRIPT_DIR}/utils.sh"
+
+on_exit operator_cleanup_and_exit
+
+TIMEOUT=360
+
+operator_namespace=${get_operator_pod_namespace}
+create_namespace dynamic
+
+kubectl config set-context --current --namespace="${operator_namespace}"
+patch_flink_config '{"data": {"flink-conf.yaml": 
"kubernetes.operator.watched.namespaces: default,flink,dynamic"}}'
+wait_for_operator_logs "Setting default configuration to 
{kubernetes.operator.watched.namespaces=default,flink,dynamic}" ${TIMEOUT} || 
exit 1
+
+echo "Successfully run the dynamic property test"
diff --git a/e2e-tests/utils.sh b/e2e-tests/utils.sh
index adaba65f..7f5513c5 100755
--- a/e2e-tests/utils.sh
+++ b/e2e-tests/utils.sh
@@ -36,6 +36,26 @@ function wait_for_logs {
   exit 1
 }
 
+function wait_for_operator_logs {
+  local successful_response_regex=$1
+  local timeout=$2
+  operator_pod_name=$(get_operator_pod_name)
+  operator_pod_namespace=$(get_operator_pod_namespace)
+
+    # wait or timeout until the log shows up
+  echo "Waiting for operator log \"$1\"..."
+  for i in $(seq 1 ${timeout}); do
+    if kubectl logs $operator_pod_name -c flink-kubernetes-operator -n 
"${operator_pod_namespace}" | grep -E "${successful_response_regex}" 
>/dev/null; then
+      echo "Log \"$1\" shows up."
+      return
+    fi
+
+    sleep 1
+  done
+  echo "Log $1 does not show up within a timeout of ${timeout} sec"
+  exit 1
+}
+
 function wait_for_status {
   local resource=$1
   local status_path=$2
@@ -156,6 +176,13 @@ function get_flink_version() {
   kubectl get -oyaml $resource | yq ".spec.flinkVersion"
 }
 
+function patch_flink_config() {
+  local patch=$1
+  operator_pod_namespace=$(get_operator_pod_namespace)
+  echo "Patch flink-operator-config with config: ${patch}"
+
+  kubectl patch cm flink-operator-config -n "${operator_pod_namespace}" --type 
merge -p "${patch}"
+}
 
 function check_operator_log_for_errors {
   local ignore=$1
@@ -290,6 +317,14 @@ function cleanup_and_exit() {
     echo "Cleanup completed"
 }
 
+function operator_cleanup_and_exit() {
+  echo "Starting cleanup"
+
+  if [ $TRAPPED_EXIT_CODE != 0 ];then
+    debug_and_show_logs
+  fi
+}
+
 function _on_exit_callback {
   # Export the exit code so that it could be used by the callback commands
   export TRAPPED_EXIT_CODE=$?

Reply via email to