Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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` | ✓ | 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 | ✗ | |
| | Node `extraEnvironmentVariables` is set value | ✓ | Cluster |
| 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.
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