From 13f4105f4ff44afdd51756e7d6d3d4f4f8979013 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 17 Dec 2024 09:45:26 +0700 Subject: [PATCH] K8s: Add test multiple browser versions scale Signed-off-by: Viet Nguyen Duc --- Makefile | 11 ++++++-- charts/selenium-grid/CONFIGURATION.md | 6 ++++- .../selenium-grid/cross-browsers-values.yaml | 26 +++++++++++++++++++ charts/selenium-grid/templates/_helpers.tpl | 8 ++++++ charts/selenium-grid/values.yaml | 10 ++++++- tests/SeleniumTests/__init__.py | 22 ++++++++++++++++ tests/charts/make/chart_test.sh | 10 +++++++ 7 files changed, 89 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 57170d1cd..d2237ba02 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ SBOM_OUTPUT := $(or $(SBOM_OUTPUT),$(SBOM_OUTPUT),package_versions.txt) KEDA_TAG_PREV_VERSION := $(or $(KEDA_TAG_PREV_VERSION),$(KEDA_TAG_PREV_VERSION),2.16.0-selenium-grid) KEDA_TAG_VERSION := $(or $(KEDA_TAG_VERSION),$(KEDA_TAG_VERSION),2.16.0-selenium-grid) KEDA_BASED_NAME := $(or $(KEDA_BASED_NAME),$(KEDA_BASED_NAME),ndviet) -KEDA_BASED_TAG := $(or $(KEDA_BASED_TAG),$(KEDA_BASED_TAG),2.16.0-selenium-grid-20241212) +KEDA_BASED_TAG := $(or $(KEDA_BASED_TAG),$(KEDA_BASED_TAG),2.16.0-selenium-grid-20241224) all: hub \ distributor \ @@ -930,7 +930,7 @@ chart_test_autoscaling_disabled: ./tests/charts/make/chart_test.sh NoAutoscaling chart_test_autoscaling_deployment_https: - PLATFORMS=$(PLATFORMS) CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_BASIC_AUTH=true TEST_EXTERNAL_DATASTORE=postgresql \ + PLATFORMS=$(PLATFORMS) CHART_FULL_DISTRIBUTED_MODE=true CHART_ENABLE_BASIC_AUTH=true TEST_EXTERNAL_DATASTORE=postgresql TEST_MULTIPLE_VERSIONS=true \ SECURE_INGRESS_ONLY_DEFAULT=true INGRESS_DISABLE_USE_HTTP2=true SELENIUM_GRID_PROTOCOL=https CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PORT=443 \ SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=0 MAX_SESSIONS_FIREFOX=1 MAX_SESSIONS_EDGE=1 MAX_SESSIONS_CHROME=1 TEST_NAME_OVERRIDE=true \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \ @@ -960,8 +960,15 @@ chart_test_autoscaling_job_hostname: TEMPLATE_OUTPUT_FILENAME="k8s_enableTracing_basicAuth_secureIngress_externalCerts_ingressPublicIP_autoScaling_originKEDA_scaledJob_subPath.yaml" \ ./tests/charts/make/chart_test.sh JobAutoscaling +chart_test_autoscaling_job_multiple_versions_without_explicit: + TEST_MULTIPLE_VERSIONS=true TEST_MULTIPLE_VERSIONS_EXPLICIT=false make chart_test_autoscaling_job + +chart_test_autoscaling_job_without_multiple_versions: + TEST_MULTIPLE_VERSIONS=false make chart_test_autoscaling_job + chart_test_autoscaling_job: PLATFORMS=$(PLATFORMS) TEST_EXISTING_KEDA=true TEST_CHROMIUM=true RELEASE_NAME=selenium CHART_ENABLE_TRACING=true CHART_FULL_DISTRIBUTED_MODE=true SELENIUM_GRID_MONITORING=false \ + CLEAR_POD_HISTORY=true TEST_MULTIPLE_VERSIONS=$(or $(TEST_MULTIPLE_VERSIONS), "true") TEST_MULTIPLE_VERSIONS_EXPLICIT=$(or $(TEST_MULTIPLE_VERSIONS_EXPLICIT), "true") \ SECURE_INGRESS_ONLY_CONFIG_INLINE=true SECURE_USE_EXTERNAL_CERT=true CHART_ENABLE_INGRESS_HOSTNAME=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_HOST=selenium-grid.prod SUB_PATH=/ SELENIUM_GRID_PORT=443 \ VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) KEDA_BASED_NAME=$(KEDA_BASED_NAME) KEDA_BASED_TAG=$(KEDA_BASED_TAG) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) BASE_VERSION=$(BASE_VERSION) \ TEMPLATE_OUTPUT_FILENAME="k8s_fullDistributed_secureIngress_externalCerts_ingressHostName_ingressTLSInline_autoScaling_scaledJob_existingKEDA_prefixSelenium_nodeChromium_enableTracing.yaml" \ diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index c9f10fbd7..ba0f590a7 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -96,7 +96,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | ingress.nginx.proxyBuffer.number | int | `4` | Set buffer number to corresponding annotations for NGINX Ingress Controller | | ingress.nginx.sslPassthrough | bool | `true` | Enable corresponding annotations for NGINX Ingress Controller | | ingress.nginx.sslSecret | string | `""` | Specify a Secret with the certificate `tls.crt`, key `tls.key`, the name in the form "namespace/secretName" for NGINX Ingress Controller | -| ingress.nginx.useHttp2 | bool | `true` | Enables or disables HTTP/2 support in secure connections via annotations for NGINX Ingress Controller | +| ingress.nginx.useHttp2 | bool | `false` | Enables or disables HTTP/2 support in secure connections via annotations for NGINX Ingress Controller | | ingress.nginx.upstreamKeepalive | object | `{"connections":10000,"requests":10000,"time":"1h"}` | Apply upstream keepalive settings once HTTP/2 is enabled | | ingress.nginx.upstreamKeepalive.connections | int | `10000` | Set keepalive connections to corresponding annotations for NGINX Ingress Controller | | ingress.nginx.upstreamKeepalive.time | string | `"1h"` | Set keepalive timeout to corresponding annotations for NGINX Ingress Controller | @@ -406,6 +406,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | chromeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for chrome nodes | | chromeNode.hpa.browserName | string | `"chrome"` | browserName from the capability | | chromeNode.hpa.sessionBrowserName | string | `"chrome"` | sessionBrowserName if the browserName is different from the sessionBrowserName | +| chromeNode.hpa.browserVersion | string | `""` | browserVersion from the capability | | chromeNode.hpa.platformName | string | `"linux"` | platformName from the capability | | chromeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint | | chromeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option | @@ -457,6 +458,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | firefoxNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for firefox nodes | | firefoxNode.hpa.browserName | string | `"firefox"` | browserName from the capability | | firefoxNode.hpa.sessionBrowserName | string | `"firefox"` | sessionBrowserName if the browserName is different from the sessionBrowserName | +| firefoxNode.hpa.browserVersion | string | `""` | browserVersion from the capability | | firefoxNode.hpa.platformName | string | `"linux"` | platformName from the capability | | firefoxNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint | | firefoxNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option | @@ -508,6 +510,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | edgeNode.scaledObjectOptions | string | `nil` | Override the scaledObjectOptions for edge nodes | | edgeNode.hpa.browserName | string | `"MicrosoftEdge"` | browserName from the capability | | edgeNode.hpa.sessionBrowserName | string | `"msedge"` | sessionBrowserName if the browserName is different from the sessionBrowserName | +| edgeNode.hpa.browserVersion | string | `""` | browserVersion from the capability | | edgeNode.hpa.platformName | string | `"linux"` | platformName from the capability | | edgeNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint | | edgeNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option | @@ -560,6 +563,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes | relayNode.hpa.browserName | string | `"chrome"` | browserName from the capability | | relayNode.hpa.sessionBrowserName | string | `""` | sessionBrowserName if the browserName is different from the sessionBrowserName | | relayNode.hpa.platformName | string | `"Android"` | platformName from the capability | +| relayNode.hpa.browserVersion | string | `""` | browserVersion from the capability | | relayNode.hpa.unsafeSsl | string | `"{{ template \"seleniumGrid.graphqlURL.unsafeSsl\" . }}"` | Skip check SSL when connecting to the Graphql endpoint | | relayNode.initContainers | list | `[]` | It is used to add initContainers in the same pod of the browser node. It should be set using the --set-json option | | relayNode.sidecars | list | `[]` | It is used to add sidecars proxy in the same pod of the browser node. It means it will add a new container to the deployment itself. It should be set using the --set-json option | diff --git a/charts/selenium-grid/cross-browsers-values.yaml b/charts/selenium-grid/cross-browsers-values.yaml index bfd950dbb..4de496387 100644 --- a/charts/selenium-grid/cross-browsers-values.yaml +++ b/charts/selenium-grid/cross-browsers-values.yaml @@ -2,6 +2,12 @@ crossBrowsers: chromeNode: # Keep the first iteration with latest version of Chrome - nameOverride: + hpa: + browserVersion: '' + - nameOverride: '{{ $.Release.Name }}-node-chrome-131' + imageTag: '131.0' + hpa: + browserVersion: '131.0' - nameOverride: '{{ $.Release.Name }}-node-chrome-130' imageTag: '130.0' hpa: @@ -17,6 +23,20 @@ crossBrowsers: firefoxNode: # Keep the first iteration with latest version of Firefox - nameOverride: + hpa: + browserVersion: '' + - nameOverride: '{{ $.Release.Name }}-node-firefox-133' + imageTag: '133.0' + hpa: + browserVersion: '133.0' + - nameOverride: '{{ $.Release.Name }}-node-firefox-132' + imageTag: '132.0' + hpa: + browserVersion: '132.0' + - nameOverride: '{{ $.Release.Name }}-node-firefox-131' + imageTag: '131.0' + hpa: + browserVersion: '131.0' - nameOverride: '{{ $.Release.Name }}-node-firefox-130' imageTag: '130.0' hpa: @@ -32,6 +52,12 @@ crossBrowsers: edgeNode: # Keep the first iteration with latest version of Edge - nameOverride: + hpa: + browserVersion: '' + - nameOverride: '{{ $.Release.Name }}-node-edge-131' + imageTag: '131.0' + hpa: + browserVersion: '131.0' - nameOverride: '{{ $.Release.Name }}-node-edge-130' imageTag: '130.0' hpa: diff --git a/charts/selenium-grid/templates/_helpers.tpl b/charts/selenium-grid/templates/_helpers.tpl index ed1053538..43a1c47f1 100644 --- a/charts/selenium-grid/templates/_helpers.tpl +++ b/charts/selenium-grid/templates/_helpers.tpl @@ -343,6 +343,14 @@ template: {{- end }} - name: SE_DRAIN_AFTER_SESSION_COUNT value: {{ and (eq (include "seleniumGrid.useKEDA" $) "true") (eq .Values.autoscaling.scalingType "job") | ternary $nodeMaxSessions 0 | quote }} + {{- if and (eq (include "seleniumGrid.useKEDA" $) "true") }} + - name: SE_NODE_BROWSER_VERSION + value: {{ default "" .node.hpa.browserVersion | quote }} + {{- end }} + {{- if and (eq (include "seleniumGrid.useKEDA" $) "true") }} + - name: SE_NODE_PLATFORM_NAME + value: {{ default "Linux" .node.hpa.platformName | quote }} + {{- end }} - name: SE_NODE_CONTAINER_NAME valueFrom: fieldRef: diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 92c1434f9..3a59bade1 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -201,7 +201,7 @@ ingress: # -- Specify a Secret with the certificate `tls.crt`, key `tls.key`, the name in the form "namespace/secretName" for NGINX Ingress Controller sslSecret: "" # -- Enables or disables HTTP/2 support in secure connections via annotations for NGINX Ingress Controller - useHttp2: true + useHttp2: false # -- Apply upstream keepalive settings once HTTP/2 is enabled upstreamKeepalive: # -- Set keepalive connections to corresponding annotations for NGINX Ingress Controller @@ -1117,6 +1117,8 @@ chromeNode: browserName: "chrome" # -- sessionBrowserName if the browserName is different from the sessionBrowserName sessionBrowserName: "chrome" + # -- browserVersion from the capability + browserVersion: "" # -- platformName from the capability platformName: "linux" # browserVersion: '91.0' # Optional. Only required when supporting multiple versions of browser in your Selenium Grid. @@ -1300,6 +1302,8 @@ firefoxNode: browserName: "firefox" # -- sessionBrowserName if the browserName is different from the sessionBrowserName sessionBrowserName: "firefox" + # -- browserVersion from the capability + browserVersion: "" # -- platformName from the capability platformName: "linux" # -- Skip check SSL when connecting to the Graphql endpoint @@ -1482,6 +1486,8 @@ edgeNode: browserName: "MicrosoftEdge" # -- sessionBrowserName if the browserName is different from the sessionBrowserName sessionBrowserName: "msedge" + # -- browserVersion from the capability + browserVersion: "" # -- platformName from the capability platformName: "linux" # -- Skip check SSL when connecting to the Graphql endpoint @@ -1666,6 +1672,8 @@ relayNode: sessionBrowserName: "" # -- platformName from the capability platformName: "Android" + # -- browserVersion from the capability + browserVersion: "" # browserVersion: '91.0' # Optional. Only required when supporting multiple versions of browser in your Selenium Grid. # -- Skip check SSL when connecting to the Graphql endpoint unsafeSsl: '{{ template "seleniumGrid.graphqlURL.unsafeSsl" . }}' # Optional diff --git a/tests/SeleniumTests/__init__.py b/tests/SeleniumTests/__init__.py index 9c612324f..aee7d5b26 100644 --- a/tests/SeleniumTests/__init__.py +++ b/tests/SeleniumTests/__init__.py @@ -31,6 +31,14 @@ TEST_FIREFOX_INSTALL_LANG_PACKAGE = os.environ.get('TEST_FIREFOX_INSTALL_LANG_PACKAGE', 'false').lower() == 'true' TEST_ADD_CAPS_RECORD_VIDEO = os.environ.get('TEST_ADD_CAPS_RECORD_VIDEO', 'true').lower() == 'true' TEST_CUSTOM_SPECIFIC_NAME = os.environ.get('TEST_CUSTOM_SPECIFIC_NAME', 'false').lower() == 'true' +TEST_MULTIPLE_VERSIONS = os.environ.get('TEST_MULTIPLE_VERSIONS', 'false').lower() == 'true' +TEST_MULTIPLE_VERSIONS_EXPLICIT = os.environ.get('TEST_MULTIPLE_VERSIONS_EXPLICIT', 'true').lower() == 'true' +LIST_CHROMIUM_VERSIONS = ['130.0', '129.0', '128.0'] +LIST_FIREFOX_VERSIONS = ['132.0', '131.0', '130.0', '129.0', '128.0'] + +if not TEST_MULTIPLE_VERSIONS_EXPLICIT: + LIST_CHROMIUM_VERSIONS.append(None) + LIST_FIREFOX_VERSIONS.append(None) SELENIUM_GRID_URL = f"{SELENIUM_GRID_PROTOCOL}://{SELENIUM_GRID_HOST}:{SELENIUM_GRID_PORT}" CLIENT_CONFIG = ClientConfig( @@ -153,6 +161,10 @@ def setUp(self): options.set_capability('se:screenResolution', '1920x1080') if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('--headless=new') + if TEST_MULTIPLE_VERSIONS: + browser_version = random.choice(LIST_CHROMIUM_VERSIONS) + if browser_version: + options.set_capability('browserVersion', browser_version) if TEST_NODE_RELAY == 'Android': options.set_capability('platformName', TEST_NODE_RELAY) options.set_capability('appium:platformVersion', TEST_ANDROID_PLATFORM_API) @@ -195,6 +207,11 @@ def setUp(self): options.set_capability('se:screenResolution', '1920x1080') if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('--headless=new') + if TEST_MULTIPLE_VERSIONS: + browser_version = random.choice(LIST_CHROMIUM_VERSIONS) + if browser_version: + options.set_capability('browserVersion', browser_version) + options.set_capability('platformName', 'Linux') start_time = time.time() self.driver = webdriver.Remote( options=options, @@ -229,6 +246,11 @@ def setUp(self): options.set_capability('se:screenResolution', '1920x1080') if SELENIUM_GRID_TEST_HEADLESS: options.add_argument('-headless') + if TEST_MULTIPLE_VERSIONS: + browser_version = random.choice(LIST_FIREFOX_VERSIONS) + if browser_version: + options.set_capability('browserVersion', browser_version) + options.set_capability('platformName', 'Linux') start_time = time.time() self.driver = webdriver.Remote( options=options, diff --git a/tests/charts/make/chart_test.sh b/tests/charts/make/chart_test.sh index ba84d0053..f9207de8f 100755 --- a/tests/charts/make/chart_test.sh +++ b/tests/charts/make/chart_test.sh @@ -63,6 +63,8 @@ TEST_PATCHED_KEDA=${TEST_PATCHED_KEDA:-"true"} BASIC_AUTH_EMBEDDED_URL=${BASIC_AUTH_EMBEDDED_URL:-"false"} SELENIUM_GRID_MONITORING=${SELENIUM_GRID_MONITORING:-"true"} TEST_EXISTING_PTS=${TEST_EXISTING_PTS:-"false"} +TEST_MULTIPLE_VERSIONS=${TEST_MULTIPLE_VERSIONS:-"false"} +TEST_MULTIPLE_VERSIONS_EXPLICIT=${TEST_MULTIPLE_VERSIONS_EXPLICIT:-"true"} cleanup() { # Get the list of pods @@ -386,6 +388,12 @@ if [ "${SELENIUM_GRID_PROTOCOL}" = "https" ]; then " fi +if [ "${TEST_MULTIPLE_VERSIONS}" = "true" ]; then + HELM_COMMAND_SET_BASE_VALUES="${HELM_COMMAND_SET_BASE_VALUES} \ + --values ${CHART_PATH}/cross-browsers-values.yaml \ + " +fi + HELM_COMMAND_SET_BASE_VALUES="${HELM_COMMAND_SET_BASE_VALUES} \ --values ${MATRIX_BROWSER_VALUES_FILE} \ " @@ -460,6 +468,8 @@ export TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST:-"0"} export TEST_PLATFORMS=${TEST_PLATFORMS} export TEST_NODE_MAX_SESSIONS=${TEST_NODE_MAX_SESSIONS} export TEST_AUTOSCALING_ITERATIONS=${TEST_AUTOSCALING_ITERATIONS:-"20"} +export TEST_MULTIPLE_VERSIONS=${TEST_MULTIPLE_VERSIONS} +export TEST_MULTIPLE_VERSIONS_EXPLICIT=${TEST_MULTIPLE_VERSIONS_EXPLICIT} if [ "${MATRIX_BROWSER}" = "NoAutoscaling" ]; then ./tests/bootstrap.sh NodeFirefox if [ "${TEST_PLATFORMS}" = "linux/amd64" ]; then