Skip to content

Commit

Permalink
test(chart): Parallel tests execution against autoscaling in Kubernet…
Browse files Browse the repository at this point in the history
…es (#2046)

* test(chart): Parallel tests execution against autoscaling in Kubernetes

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>

* Correct name of ENV var, start with SE_ only

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>

---------

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Dec 5, 2023
1 parent 99448df commit c4e4024
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 5 additions & 2 deletions charts/selenium-grid/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ All related testing to this helm chart will be documented in this file.
| | Auto scaling with `scalingType` is `job` | &check; | Cluster |
| | Auto scaling with `scalingType` is `deployment` | &cross; | |
| | Auto scaling with `autoscaling.scaledOptions.minReplicaCount` is `0` | &check; | Cluster |
| | Parallel tests execution against node autoscaling | &check; | Cluster |
| Ingress | Ingress is enabled without `hostname` | &check; | Cluster |
| | Ingress is enabled with `hostname` is set | &cross; | |
| | Hub `sub-path` is set with Ingress `ImplementationSpecific` paths | &check; | Cluster |
| Distributed components | `isolateComponents` is enabled | &check; | Cluster |
| | `isolateComponents` is disabled | &cross; | |
| | `isolateComponents` is disabled | &check; | Cluster |
| Browser Nodes | Node `nameOverride` is set | &check; | Cluster |
| | Sanity tests in node | &check; | Cluster |
| | Video recorder is enabled in node | &cross; | |
| | Node `extraEnvironmentVariables` is set value | &check; | Cluster |
| General | Set new image registry via `global.seleniumGrid.imageRegistry` | &check; | Cluster |
| | Components are able to set `.affinity` | &check; | Template |
| Tracing | Enable tracing via `SE_ENABLE_TRACING` | &check; | Cluster |
| | Disable tracing via `SE_ENABLE_TRACING` | &cross; | |
| | Disable tracing via `SE_ENABLE_TRACING` | &check; | Cluster |

## Test Chart Template
- By using `helm template` command, the chart template is tested without installing it to Kubernetes cluster.
Expand Down Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" .}}'
17 changes: 17 additions & 0 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import concurrent.futures
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
Expand Down Expand Up @@ -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])
40 changes: 40 additions & 0 deletions tests/charts/ci/ParallelAutoscaling-values.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
# Firefox Images
'NodeFirefox': 'FirefoxTests',
'StandaloneFirefox': 'FirefoxTests',

# Chart Parallel Test
'ParallelAutoscaling': 'ParallelAutoscalingTests'
}

FROM_IMAGE_ARGS = {
Expand Down

0 comments on commit c4e4024

Please sign in to comment.