diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index f363d728d..feedc3472 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -10,8 +10,11 @@ permissions: jobs: build-and-test: - name: Build & test Docker images with Helm charts + name: Test Helm charts runs-on: ubuntu-latest + strategy: + matrix: + test-strategy: [chart_test, chart_test_parallel_autoscaling] steps: - uses: actions/checkout@v4 - name: Output Docker info @@ -54,7 +57,7 @@ jobs: timeout_minutes: 30 max_attempts: 3 command: | - NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_test + NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${{ matrix.test-strategy }} - name: Cleanup Kubernetes cluster if: always() run: make chart_cluster_cleanup @@ -64,3 +67,10 @@ jobs: with: name: ${{ env.CHART_FILE_NAME }} path: ${{ env.CHART_PACKAGE_PATH }} + - name: Upload Helm chart template rendered + if: always() + uses: actions/upload-artifact@v3 + with: + name: chart_template_rendered.yaml + path: ./tests/tests/output_deployment.yaml + if-no-files-found: ignore diff --git a/Makefile b/Makefile index cc75317b8..cf025422d 100644 --- a/Makefile +++ b/Makefile @@ -392,6 +392,9 @@ chart_test_firefox: chart_test_edge: VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_test.sh NodeEdge +chart_test_parallel_autoscaling: + VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_test.sh ParallelAutoscaling + .PHONY: \ all \ base \ diff --git a/charts/selenium-grid/TESTING.md b/charts/selenium-grid/TESTING.md index 9003e27e9..e4fafe63e 100644 --- a/charts/selenium-grid/TESTING.md +++ b/charts/selenium-grid/TESTING.md @@ -12,11 +12,12 @@ All related testing to this helm chart will be documented in this file. | | Auto scaling with `scalingType` is `job` | ✓ | Cluster | | | Auto scaling with `scalingType` is `deployment` | ✗ | | | | Auto scaling with `autoscaling.scaledOptions.minReplicaCount` is `0` | ✓ | Cluster | +| | Parallel tests execution against node autoscaling | ✓ | Cluster | | Ingress | Ingress is enabled without `hostname` | ✓ | Cluster | | | Ingress is enabled with `hostname` is set | ✗ | | | | Hub `sub-path` is set with Ingress `ImplementationSpecific` paths | ✓ | Cluster | | Distributed components | `isolateComponents` is enabled | ✓ | Cluster | -| | `isolateComponents` is disabled | ✗ | | +| | `isolateComponents` is disabled | ✓ | Cluster | | Browser Nodes | Node `nameOverride` is set | ✓ | Cluster | | | Sanity tests in node | ✓ | Cluster | | | Video recorder is enabled in node | ✗ | | @@ -24,7 +25,7 @@ All related testing to this helm chart will be documented in this file. | General | Set new image registry via `global.seleniumGrid.imageRegistry` | ✓ | Cluster | | | Components are able to set `.affinity` | ✓ | Template | | Tracing | Enable tracing via `SE_ENABLE_TRACING` | ✓ | Cluster | -| | Disable tracing via `SE_ENABLE_TRACING` | ✗ | | +| | Disable tracing via `SE_ENABLE_TRACING` | ✓ | Cluster | ## Test Chart Template - By using `helm template` command, the chart template is tested without installing it to Kubernetes cluster. @@ -66,6 +67,8 @@ make chart_cluster_setup # Test Selenium Grid on Kubernetes make chart_test +# make chart_test_parallel_autoscaling + # Cleanup Kubernetes cluster make chart_cluster_cleanup ``` diff --git a/charts/selenium-grid/templates/node-configmap.yaml b/charts/selenium-grid/templates/node-configmap.yaml index 08d6d4981..da4edab40 100644 --- a/charts/selenium-grid/templates/node-configmap.yaml +++ b/charts/selenium-grid/templates/node-configmap.yaml @@ -12,5 +12,5 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} data: - DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}' + SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}' SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}' diff --git a/tests/SeleniumTests/__init__.py b/tests/SeleniumTests/__init__.py index acdaa4bda..31cd3903b 100644 --- a/tests/SeleniumTests/__init__.py +++ b/tests/SeleniumTests/__init__.py @@ -1,4 +1,5 @@ import unittest +import concurrent.futures import os from selenium import webdriver from selenium.webdriver.common.by import By @@ -113,3 +114,19 @@ def test_title_and_maximize_window(self): self.driver.get('https://the-internet.herokuapp.com') self.driver.maximize_window() self.assertTrue(self.driver.title == 'The Internet') + +class ParallelAutoscaling(): + def run(self, test_classes): + with concurrent.futures.ThreadPoolExecutor() as executor: + futures = [] + for test_class in test_classes: + suite = unittest.TestLoader().loadTestsFromTestCase(test_class) + for test in suite: + futures.append(executor.submit(test)) + for future in concurrent.futures.as_completed(futures): + future.result() + +class ParallelAutoscalingTests(unittest.TestCase): + def test_parallel_autoscaling(self): + runner = ParallelAutoscaling() + runner.run([ChromeTests, EdgeTests, FirefoxTests]) diff --git a/tests/charts/ci/ParallelAutoscaling-values.yaml b/tests/charts/ci/ParallelAutoscaling-values.yaml new file mode 100644 index 000000000..39ea9434c --- /dev/null +++ b/tests/charts/ci/ParallelAutoscaling-values.yaml @@ -0,0 +1,40 @@ +isolateComponents: false +autoscaling: + strategy: default + scaledOptions: + minReplicaCount: 0 + maxReplicaCount: 5 +chromeNode: + nameOverride: my-chrome-name + extraEnvironmentVariables: + - name: SE_OPTS + value: "--enable-managed-downloads true" +# Configuration for edge nodes +edgeNode: + nameOverride: my-edge-name + extraEnvironmentVariables: + - name: SE_OPTS + value: "--enable-managed-downloads true" +# Configuration for firefox nodes +firefoxNode: + nameOverride: my-firefox-name + extraEnvironmentVariables: + - name: SE_OPTS + value: "--enable-managed-downloads true" + +ingress: + paths: + - path: /selenium(/|$)(.*) + pathType: ImplementationSpecific + backend: + service: + name: '{{ template "seleniumGrid.hub.fullname" $ }}' + port: + number: 4444 + - path: /(/?)(session/.*/se/vnc) + pathType: ImplementationSpecific + backend: + service: + name: '{{ template "seleniumGrid.hub.fullname" $ }}' + port: + number: 4444 diff --git a/tests/test.py b/tests/test.py index 7568d755b..b8b462c2b 100644 --- a/tests/test.py +++ b/tests/test.py @@ -55,6 +55,9 @@ # Firefox Images 'NodeFirefox': 'FirefoxTests', 'StandaloneFirefox': 'FirefoxTests', + + # Chart Parallel Test + 'ParallelAutoscaling': 'ParallelAutoscalingTests' } FROM_IMAGE_ARGS = {