From 3ac9eff83d7fc768295b46c8814ff8da7d6ba28f Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 13 Feb 2024 09:07:03 +0530 Subject: [PATCH] update: add var SE_SESSION_REQUEST_TIMEOUT to standalone, distributor Signed-off-by: Viet Nguyen Duc --- .github/workflows/helm-chart-test.yml | 19 ++++++++++++++++++- Distributor/Dockerfile | 5 +++++ .../start-selenium-grid-distributor.sh | 2 ++ Router/Dockerfile | 2 +- Standalone/Dockerfile | 4 ++++ Standalone/start-selenium-standalone.sh | 2 ++ StandaloneDocker/Dockerfile | 4 ++++ .../start-selenium-grid-docker.sh | 2 ++ tests/SeleniumTests/__init__.py | 14 ++++++++++++++ .../ci/DeploymentAutoscaling-values.yaml | 2 ++ tests/charts/ci/JobAutoscaling-values.yaml | 2 +- tests/charts/ci/base-auth-ingress-values.yaml | 3 --- tests/charts/ci/base-tracing-values.yaml | 8 ++++++++ tests/charts/make/chart_test.sh | 2 ++ 14 files changed, 65 insertions(+), 6 deletions(-) diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index 0cc6e53c1..e1908bcd5 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -10,6 +10,13 @@ on: paths-ignore: - '**.md' workflow_dispatch: + inputs: + request-timeout: + description: 'Test parameter for different request timeout' + required: false + default: '370' + schedule: + - cron: '0 0 * * *' permissions: contents: read @@ -65,9 +72,19 @@ jobs: - name: Test chart template run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_test_template - name: Setup Kubernetes cluster - run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_cluster_setup + uses: nick-invision/retry@master + with: + timeout_minutes: 10 + max_attempts: 3 + command: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_cluster_setup - name: Build Docker images run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build + - name: Set test parameters + if: (matrix.test-strategy == 'job' || matrix.test-strategy == 'deployment') && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') + run: | + echo "AUTOSCALING_POLL_INTERVAL=${AUTOSCALING_POLL_INTERVAL}" >> $GITHUB_ENV + env: + AUTOSCALING_POLL_INTERVAL: ${{ github.event.inputs.request-timeout || '370' }} - name: Test Selenium Grid on Kubernetes (Autoscaling ${{ matrix.test-strategy }}) uses: nick-invision/retry@master with: diff --git a/Distributor/Dockerfile b/Distributor/Dockerfile index ce901ceeb..68dd3a303 100644 --- a/Distributor/Dockerfile +++ b/Distributor/Dockerfile @@ -16,3 +16,8 @@ COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-distributor.sh \ /opt/bin/ COPY selenium-grid-distributor.conf /etc/supervisor/conf.d/ + +# In seconds, maps to "--session-request-timeout" +ENV SE_SESSION_REQUEST_TIMEOUT 300 +# In seconds, maps to "--session-retry-interval" +ENV SE_SESSION_RETRY_INTERVAL 15 diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index 7a761832d..e4e58215c 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -112,6 +112,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \ --publish-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_PUBLISH_PORT}" \ --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_SUBSCRIBE_PORT}" \ + --session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \ + --session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \ --bind-host ${SE_BIND_HOST} \ --bind-bus false \ ${HOST_CONFIG} \ diff --git a/Router/Dockerfile b/Router/Dockerfile index 3410b932f..5a495b22e 100644 --- a/Router/Dockerfile +++ b/Router/Dockerfile @@ -13,7 +13,7 @@ USER ${SEL_UID} # In seconds, maps to "--session-request-timeout" ENV SE_SESSION_REQUEST_TIMEOUT 300 # In seconds, maps to "--session-retry-interval" -ENV SE_SESSION_RETRY_INTERVAL 0 +ENV SE_SESSION_RETRY_INTERVAL 5 EXPOSE 4444 diff --git a/Standalone/Dockerfile b/Standalone/Dockerfile index 690753222..422e6164a 100644 --- a/Standalone/Dockerfile +++ b/Standalone/Dockerfile @@ -20,6 +20,10 @@ COPY selenium.conf /etc/supervisor/conf.d/ # Copying configuration script generator COPY --chown="${SEL_UID}:${SEL_GID}" generate_config /opt/bin/generate_config +# In seconds, maps to "--session-request-timeout" +ENV SE_SESSION_REQUEST_TIMEOUT 300 +# In seconds, maps to "--session-retry-interval" +ENV SE_SESSION_RETRY_INTERVAL 15 # Boolean value, maps "--relax-checks" ENV SE_RELAX_CHECKS true diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 04e46806b..fa4fd6817 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -88,6 +88,8 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${GECKO_DRIVER_PATH_PROPERTY} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} standalone \ + --session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \ + --session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \ --bind-host ${SE_BIND_HOST} \ --config /opt/selenium/config.toml \ ${SUB_PATH_CONFIG} \ diff --git a/StandaloneDocker/Dockerfile b/StandaloneDocker/Dockerfile index e2d1f5de9..055196e4c 100644 --- a/StandaloneDocker/Dockerfile +++ b/StandaloneDocker/Dockerfile @@ -14,5 +14,9 @@ EXPOSE 4444 COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-docker.sh /opt/bin/ +# In seconds, maps to "--session-request-timeout" +ENV SE_SESSION_REQUEST_TIMEOUT 300 +# In seconds, maps to "--session-retry-interval" +ENV SE_SESSION_RETRY_INTERVAL 15 # Boolean value, maps "--relax-checks" ENV SE_RELAX_CHECKS true diff --git a/StandaloneDocker/start-selenium-grid-docker.sh b/StandaloneDocker/start-selenium-grid-docker.sh index cf75e5279..0f5c92184 100755 --- a/StandaloneDocker/start-selenium-grid-docker.sh +++ b/StandaloneDocker/start-selenium-grid-docker.sh @@ -58,6 +58,8 @@ fi java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} standalone \ + --session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \ + --session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \ --relax-checks ${SE_RELAX_CHECKS} \ --detect-drivers false \ --bind-host ${SE_BIND_HOST} \ diff --git a/tests/SeleniumTests/__init__.py b/tests/SeleniumTests/__init__.py index a1465d61e..29b2b7b6c 100644 --- a/tests/SeleniumTests/__init__.py +++ b/tests/SeleniumTests/__init__.py @@ -2,6 +2,7 @@ import concurrent.futures import os import traceback +import time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait @@ -99,10 +100,13 @@ def setUp(self): options.set_capability('se:recordVideo', True) if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('--headless=new') + start_time = time.time() self.driver = webdriver.Remote( options=options, command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) ) + end_time = time.time() + print(f"<< {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") class EdgeTests(SeleniumGenericTests): def setUp(self): @@ -112,10 +116,13 @@ def setUp(self): options.set_capability('se:recordVideo', True) if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('--headless=new') + start_time = time.time() self.driver = webdriver.Remote( options=options, command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) ) + end_time = time.time() + print(f"<< {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") class FirefoxTests(SeleniumGenericTests): @@ -129,10 +136,13 @@ def setUp(self): options.set_capability('se:recordVideo', True) if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('-headless') + start_time = time.time() self.driver = webdriver.Remote( options=options, command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) ) + end_time = time.time() + print(f"<< {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") def test_title_and_maximize_window(self): self.driver.get('https://the-internet.herokuapp.com') @@ -144,14 +154,18 @@ def run(self, test_classes): with concurrent.futures.ThreadPoolExecutor() as executor: futures = [] tests = [] + start_times = {} for test_class in test_classes: suite = unittest.TestLoader().loadTestsFromTestCase(test_class) for test in suite: + start_times[test] = time.time() futures.append(executor.submit(test)) tests.append(test) failed_tests = [] for future, test in zip(concurrent.futures.as_completed(futures), tests): try: + completion_time = time.time() - start_times[test] + print(f">> {str(test)} completed in {str(completion_time)} (s)") if not future.result().wasSuccessful(): raise Exception except Exception as e: diff --git a/tests/charts/ci/DeploymentAutoscaling-values.yaml b/tests/charts/ci/DeploymentAutoscaling-values.yaml index f249d96b2..740e0465d 100644 --- a/tests/charts/ci/DeploymentAutoscaling-values.yaml +++ b/tests/charts/ci/DeploymentAutoscaling-values.yaml @@ -1,3 +1,5 @@ +isolateComponents: false + autoscaling: enableWithExistingKEDA: true scalingType: deployment diff --git a/tests/charts/ci/JobAutoscaling-values.yaml b/tests/charts/ci/JobAutoscaling-values.yaml index 475ee9a07..63b9d364f 100644 --- a/tests/charts/ci/JobAutoscaling-values.yaml +++ b/tests/charts/ci/JobAutoscaling-values.yaml @@ -1,4 +1,4 @@ -isolateComponents: false +isolateComponents: true autoscaling: enableWithExistingKEDA: true diff --git a/tests/charts/ci/base-auth-ingress-values.yaml b/tests/charts/ci/base-auth-ingress-values.yaml index 9d4ab3055..0d069fa56 100644 --- a/tests/charts/ci/base-auth-ingress-values.yaml +++ b/tests/charts/ci/base-auth-ingress-values.yaml @@ -9,9 +9,6 @@ ingress: nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/rewrite-target: /$2 nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium" - nginx.ingress.kubernetes.io/proxy-connect-timeout: "360" - nginx.ingress.kubernetes.io/proxy-read-timeout: "360" - nginx.ingress.kubernetes.io/proxy-send-timeout: "360" ingressClassName: nginx hostname: "" paths: diff --git a/tests/charts/ci/base-tracing-values.yaml b/tests/charts/ci/base-tracing-values.yaml index aea8964ed..6520f52ce 100644 --- a/tests/charts/ci/base-tracing-values.yaml +++ b/tests/charts/ci/base-tracing-values.yaml @@ -1,5 +1,9 @@ hub: extraEnvironmentVariables: + - name: SE_SESSION_REQUEST_TIMEOUT + value: "800" + - name: SE_SESSION_RETRY_INTERVAL + value: "5" - name: SE_REJECT_UNSUPPORTED_CAPS value: "false" - name: SE_ENABLE_TRACING @@ -9,6 +13,10 @@ hub: components: extraEnvironmentVariables: + - name: SE_SESSION_REQUEST_TIMEOUT + value: "800" + - name: SE_SESSION_RETRY_INTERVAL + value: "5" - name: SE_REJECT_UNSUPPORTED_CAPS value: "false" - name: SE_ENABLE_TRACING diff --git a/tests/charts/make/chart_test.sh b/tests/charts/make/chart_test.sh index e6686ca31..d18f5f90d 100755 --- a/tests/charts/make/chart_test.sh +++ b/tests/charts/make/chart_test.sh @@ -21,6 +21,7 @@ WAIT_TIMEOUT=${WAIT_TIMEOUT:-"90s"} HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL:-45} HUB_CHECKS_MAX_ATTEMPTS=${HUB_CHECKS_MAX_ATTEMPTS:-6} WEB_DRIVER_WAIT_TIMEOUT=${WEB_DRIVER_WAIT_TIMEOUT:-120} +AUTOSCALING_POLL_INTERVAL=${AUTOSCALING_POLL_INTERVAL:-20} SKIP_CLEANUP=${SKIP_CLEANUP:-"false"} # For debugging purposes, retain the cluster after the test run CHART_CERT_PATH=${CHART_CERT_PATH:-"${CHART_PATH}/certs/selenium.pem"} SSL_CERT_DIR=${SSL_CERT_DIR:-"/etc/ssl/certs"} @@ -63,6 +64,7 @@ HELM_COMMAND_SET_IMAGES=" \ --set global.seleniumGrid.imageTag=${VERSION} \ --set global.seleniumGrid.nodesImageTag=${VERSION} \ --set global.seleniumGrid.videoImageTag=${VIDEO_TAG} \ +--set autoscaling.scaledOptions.pollingInterval=${AUTOSCALING_POLL_INTERVAL} \ " if [ "${SELENIUM_GRID_AUTOSCALING}" = "true" ]; then