From 99448dff9d6a3f2112a5da24a13395b0132cf1b9 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Sun, 3 Dec 2023 07:01:04 +0700 Subject: [PATCH] bug(#1824): Container ENV SE_NODE_SESSION_TIMEOUT not take effect (#2044) * bug(#1824): Container ENV SE_NODE_SESSION_TIMEOUT not take effect Signed-off-by: Viet Nguyen Duc * Update helm-chart-test.yml for SNAPSHOT CI build * Update helm-chart-test.yml for SNAPSHOT CI build Signed-off-by: Viet Nguyen Duc * Revert test Signed-off-by: Viet Nguyen Duc --------- Signed-off-by: Viet Nguyen Duc --- .github/workflows/helm-chart-test.yml | 17 +++++++-- .gitignore | 1 + Makefile | 37 +++++++++---------- NodeBase/start-selenium-node.sh | 5 +++ charts/selenium-grid/TESTING.md | 9 +++-- .../make/{chart_lint.sh => chart_build.sh} | 10 ++++- .../make/{chart_install.sh => chart_test.sh} | 17 ++++++--- 7 files changed, 64 insertions(+), 32 deletions(-) rename tests/charts/make/{chart_lint.sh => chart_build.sh} (67%) rename tests/charts/make/{chart_install.sh => chart_test.sh} (81%) diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index 29f3d3925..f363d728d 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -37,19 +37,30 @@ jobs: run: | echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV echo "IMAGE_REGISTRY=artifactory/selenium" >> $GITHUB_ENV - - name: Build Docker images - run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build - name: Setup Kubernetes environment run: make chart_setup_env + - name: Build Docker images + run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build + - name: Build and lint charts + run: | + BUILD_DATE=${BUILD_DATE} make chart_build + echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV + echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV - name: Setup Kubernetes cluster run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_cluster_setup - name: Test Selenium Grid on Kubernetes uses: nick-invision/retry@v2.9.0 with: - timeout_minutes: 20 + timeout_minutes: 30 max_attempts: 3 command: | NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_test - name: Cleanup Kubernetes cluster if: always() run: make chart_cluster_cleanup + - name: Upload Helm chart package + if: always() + uses: actions/upload-artifact@v3 + with: + name: ${{ env.CHART_FILE_NAME }} + path: ${{ env.CHART_PACKAGE_PATH }} diff --git a/.gitignore b/.gitignore index fc44914b7..f77615fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -149,3 +149,4 @@ ENV/ .DS_Store /charts/*/charts /charts/*/**.lock +/charts/*.tgz diff --git a/Makefile b/Makefile index b2ac24195..cc75317b8 100644 --- a/Makefile +++ b/Makefile @@ -366,32 +366,31 @@ test_video: video hub chrome firefox edge chart_setup_env: ./tests/charts/make/chart_setup_env.sh -chart_test: chart_lint \ - chart_test_template \ - chart_install_chrome \ - chart_install_firefox \ - chart_install_edge - -chart_test_template: - ./tests/charts/bootstrap.sh - chart_cluster_setup: VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_cluster_setup.sh -chart_lint: - ./tests/charts/make/chart_lint.sh +chart_cluster_cleanup: + ./tests/charts/make/chart_cluster_cleanup.sh + +chart_build: + VERSION=$(TAG_VERSION) ./tests/charts/make/chart_build.sh + +chart_test: chart_test_template \ + chart_test_chrome \ + chart_test_firefox \ + chart_test_edge -chart_install_chrome: - VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_install.sh NodeChrome +chart_test_template: + ./tests/charts/bootstrap.sh -chart_install_firefox: - VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_install.sh NodeFirefox +chart_test_chrome: + VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_test.sh NodeChrome -chart_install_edge: - VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_install.sh NodeEdge +chart_test_firefox: + VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_test.sh NodeFirefox -chart_cluster_cleanup: - ./tests/charts/make/chart_cluster_cleanup.sh +chart_test_edge: + VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_test.sh NodeEdge .PHONY: \ all \ diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 6fe30497b..4b069c7dd 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -31,6 +31,11 @@ if [ ! -z "$SE_OPTS" ]; then echo "Appending Selenium options: ${SE_OPTS}" fi +if [ ! -z "$SE_NODE_SESSION_TIMEOUT" ]; then + SE_OPTS="$SE_OPTS --session-timeout $SE_NODE_SESSION_TIMEOUT" + echo "Appending Selenium node session timeout via SE_OPTS: ${SE_OPTS}" +fi + if [ "$GENERATE_CONFIG" = true ]; then echo "Generating Selenium Config" /opt/bin/generate_config diff --git a/charts/selenium-grid/TESTING.md b/charts/selenium-grid/TESTING.md index 90c57c115..9003e27e9 100644 --- a/charts/selenium-grid/TESTING.md +++ b/charts/selenium-grid/TESTING.md @@ -36,7 +36,7 @@ All related testing to this helm chart will be documented in this file. cd ../.. # Build chart dependencies and lint -make chart_lint +make chart_build # Test chart template make chart_test_template @@ -51,11 +51,14 @@ Run entire commands to build and test Docker images with Helm charts in local en # Back to root directory cd ../.. +# Setup Kubernetes environment +make chart_setup_env + # Build Docker images make build -# Setup Kubernetes environment -make chart_setup_env +# Build and lint charts +make chart_build # Setup Kubernetes cluster make chart_cluster_setup diff --git a/tests/charts/make/chart_lint.sh b/tests/charts/make/chart_build.sh similarity index 67% rename from tests/charts/make/chart_lint.sh rename to tests/charts/make/chart_build.sh index db92cf0e0..5d57e4277 100755 --- a/tests/charts/make/chart_lint.sh +++ b/tests/charts/make/chart_build.sh @@ -1,4 +1,6 @@ #!/bin/bash + +CHART_PATH=${CHART_PATH:-"charts/selenium-grid"} # Function to be executed on command failure on_failure() { local exit_status=$? @@ -22,8 +24,14 @@ python -m pip install yamale==4.0.4 \ | grep -v 'Requirement already satisfied' cd .. -rm -rf ./charts/**/Chart.lock +rm -rf ${CHART_PATH}/Chart.lock ct lint --all --config tests/charts/config/ct.yaml +# Helm dependencies build and lint is done by `ct lint` command +rm -rf ${CHART_PATH}/../*.tgz +helm package ${CHART_PATH} --version ${VERSION} --destination ${CHART_PATH}/.. + +readlink -f ${CHART_PATH}/../*.tgz > /tmp/selenium_chart_version +cat /tmp/selenium_chart_version if [ "${CI:-false}" = "false" ]; then deactivate diff --git a/tests/charts/make/chart_install.sh b/tests/charts/make/chart_test.sh similarity index 81% rename from tests/charts/make/chart_install.sh rename to tests/charts/make/chart_test.sh index d89f96487..2d87c799e 100755 --- a/tests/charts/make/chart_install.sh +++ b/tests/charts/make/chart_test.sh @@ -40,14 +40,19 @@ on_failure() { # Trap ERR signal and call on_failure function trap 'on_failure' ERR +HELM_COMMAND_SET_AUTOSCALING="" +if [ "${SELENIUM_GRID_AUTOSCALING}" = "true" ]; then + HELM_COMMAND_SET_AUTOSCALING="--values ${TEST_VALUES_PATH}/autoscaling-values.yaml \ + --set autoscaling.enableWithExistingKEDA=${SELENIUM_GRID_AUTOSCALING} \ + --set autoscaling.scaledOptions.minReplicaCount=${SELENIUM_GRID_AUTOSCALING_MIN_REPLICA}" +fi + echo "Deploy Selenium Grid Chart" helm upgrade --install ${RELEASE_NAME} \ --f ${TEST_VALUES_PATH}/auth-ingress-values.yaml \ --f ${TEST_VALUES_PATH}/tracing-values.yaml \ --f ${TEST_VALUES_PATH}/${MATRIX_BROWSER}-values.yaml \ --f ${TEST_VALUES_PATH}/autoscaling-values.yaml \ ---set autoscaling.enableWithExistingKEDA=${SELENIUM_GRID_AUTOSCALING} \ ---set autoscaling.scaledOptions.minReplicaCount=${SELENIUM_GRID_AUTOSCALING_MIN_REPLICA} \ +--values ${TEST_VALUES_PATH}/auth-ingress-values.yaml \ +--values ${TEST_VALUES_PATH}/tracing-values.yaml \ +--values ${TEST_VALUES_PATH}/${MATRIX_BROWSER}-values.yaml \ +${HELM_COMMAND_SET_AUTOSCALING} \ --set global.seleniumGrid.imageTag=${VERSION} --set global.seleniumGrid.imageRegistry=${NAMESPACE} \ --set global.seleniumGrid.nodesImageTag=${VERSION} \ ${CHART_PATH} --namespace ${SELENIUM_NAMESPACE} --create-namespace