Skip to content

Commit

Permalink
test(chart): parallel with autoscalingType deployment & job
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Feb 6, 2024
1 parent c88bc0c commit a065ede
Show file tree
Hide file tree
Showing 27 changed files with 364 additions and 133 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Build & test
concurrency:
group: ${{ github.workflow }}

on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
Expand All @@ -19,11 +22,11 @@ jobs:
matrix:
use-random-user: [false, true]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Output Docker info
run: docker info
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@main
with:
python-version: '3.11'
check-latest: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Deploys

on:
workflow_dispatch:
push:
branches:
- trunk
Expand All @@ -14,7 +15,7 @@ jobs:
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@main
with:
persist-credentials: false
fetch-depth: 0
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/helm-chart-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Release Charts
concurrency:
group: ${{ github.workflow }}

on:
push:
Expand All @@ -14,7 +16,7 @@ jobs:
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@main
with:
fetch-depth: 0

Expand All @@ -24,7 +26,7 @@ jobs:
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
uses: helm/chart-releaser-action@main
with:
mark_as_latest: false
skip_existing: true
Expand Down
33 changes: 18 additions & 15 deletions .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Test Helm Charts
concurrency:
group: ${{ github.workflow }}

on:
push:
Expand All @@ -19,21 +21,20 @@ jobs:
strategy:
fail-fast: false
matrix:
test-strategy: [chart_test, chart_test_parallel_autoscaling, chart_test_https, chart_test_parallel_autoscaling_https]
test-strategy:
- job
- job_https
- deployment
- deployment_https
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Output Docker info
run: docker info
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@main
with:
python-version: '3.11'
check-latest: true
- name: Install CA certificates
run: |
sudo apt install openssl -y
sudo apt install ca-certificates -y
sudo update-ca-certificates --fresh
- name: Get branch name (only for push to branch)
if: github.event_name == 'push'
run: echo "BRANCH=$(echo ${PUSH_BRANCH##*/})" >> $GITHUB_ENV
Expand All @@ -52,34 +53,36 @@ jobs:
echo "IMAGE_REGISTRY=artifactory/selenium" >> $GITHUB_ENV
- name: Setup Kubernetes environment
run: make chart_setup_env
- name: Build Docker images
run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build
- name: Build and lint charts
- name: Build Helm charts
run: |
BUILD_DATE=${BUILD_DATE} make chart_build
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV
- 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
- name: Test Selenium Grid on Kubernetes
- name: Build Docker images
run: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build
- name: Test Selenium Grid on Kubernetes (Autoscaling ${{ matrix.test-strategy }})
uses: nick-invision/retry@master
with:
timeout_minutes: 30
max_attempts: 3
command: |
NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${{ matrix.test-strategy }}
NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_test_autoscaling_${{ matrix.test-strategy }}
- name: Cleanup Kubernetes cluster
if: always()
run: make chart_cluster_cleanup
- name: Upload Helm chart package
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@main
with:
name: ${{ matrix.test-strategy }}_${{ env.CHART_FILE_NAME }}
path: ${{ env.CHART_PACKAGE_PATH }}
- name: Upload chart test artifacts
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@main
with:
name: ${{ matrix.test-strategy }}-artifacts
path: ./tests/tests/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Label Commenter
uses: peaceiris/actions-label-commenter@v1
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@main
with:
persist-credentials: false
fetch-depth: 0
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Create release notes (release_notes.md)
run: ./generate_release_notes.sh ${LATEST_TAG} origin/trunk ${GRID_VERSION} ${BUILD_DATE}
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@main
with:
python-version: '3.11'
check-latest: true
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/scan-dockerfile.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Scan Dockerfile vulnerabilities
concurrency:
group: ${{ github.workflow }}

on:
push:
Expand All @@ -17,7 +19,7 @@ jobs:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Set severity for PRs
if: github.event_name == 'pull_request' || github.event_name == 'push'
run: |
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/test-video.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Test video files
concurrency:
group: ${{ github.workflow }}

on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
Expand All @@ -16,11 +19,11 @@ jobs:
name: Test video recorded through Docker Selenium
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Output Docker info
run: docker info
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@main
with:
python-version: '3.11'
check-latest: true
Expand All @@ -41,17 +44,17 @@ jobs:
- name: Run Docker Compose to record video
run: USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make test_video
- name: Upload recorded Chrome video
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@main
with:
name: chrome_video
path: ./tests/videos/chrome_video.mp4
- name: Upload recorded Edge video
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@main
with:
name: edge_video
path: ./tests/videos/edge_video.mp4
- name: Upload recorded Firefox video
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@main
with:
name: firefox_video
path: ./tests/videos/firefox_video.mp4
9 changes: 5 additions & 4 deletions .github/workflows/update-chart-changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: Update Chart CHANGELOG

on:
release:
types: [published]
push:
branches:
- trunk
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
if: ${{ contains(github.event.release.tag_name, 'selenium-grid') || github.event_name == 'workflow_dispatch' }}
if: contains(toJson(github.event.commits), 'Update tag in docs and files') == true
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@main
with:
persist-credentials: false
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-dev-beta-browser-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
CHANNEL: ${{ matrix.channel }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@main
- name: Setup environment variables
run: |
export SELENIUM_VERSION=$(grep BASE_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
Expand Down
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ chart_setup_env:
./tests/charts/make/chart_setup_env.sh

chart_cluster_setup:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/charts/make/chart_cluster_setup.sh
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) BUILD_DATE=$(BUILD_DATE) ./tests/charts/make/chart_cluster_setup.sh

chart_cluster_cleanup:
./tests/charts/make/chart_cluster_cleanup.sh
Expand All @@ -439,14 +439,6 @@ chart_build_nightly:
chart_build:
VERSION=$(TAG_VERSION) ./tests/charts/make/chart_build.sh

chart_test_https:
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_PORT=443 make chart_test

chart_test: chart_test_template \
chart_test_chrome \
chart_test_firefox \
chart_test_edge

chart_test_template:
./tests/charts/bootstrap.sh

Expand All @@ -462,10 +454,17 @@ chart_test_edge:
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) UPLOADER_TAG=$(RCLONE_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) \
./tests/charts/make/chart_test.sh NodeEdge

chart_test_parallel_autoscaling_https:
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_PORT=443 make chart_test_parallel_autoscaling
chart_test_autoscaling_deployment_https:
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_PORT=443 make chart_test_autoscaling_deployment

chart_test_autoscaling_deployment:
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) UPLOADER_TAG=$(RCLONE_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) \
./tests/charts/make/chart_test.sh DeploymentAutoscaling

chart_test_autoscaling_job_https:
SELENIUM_GRID_TEST_HEADLESS=true SELENIUM_GRID_PROTOCOL=https SELENIUM_GRID_PORT=443 make chart_test_autoscaling_job

chart_test_parallel_autoscaling:
chart_test_autoscaling_job:
VERSION=$(TAG_VERSION) VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) UPLOADER_TAG=$(RCLONE_TAG_VERSION)-$(BUILD_DATE) NAMESPACE=$(NAMESPACE) \
./tests/charts/make/chart_test.sh JobAutoscaling

Expand Down
4 changes: 2 additions & 2 deletions charts/selenium-grid/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ make chart_build
make chart_cluster_setup

# Test Selenium Grid on Kubernetes
make chart_test
make chart_test_autoscaling_deployment

# make chart_test_parallel_autoscaling
make chart_test_autoscaling_job

# Cleanup Kubernetes cluster
make chart_cluster_cleanup
Expand Down
10 changes: 9 additions & 1 deletion charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ template:
spec:
serviceAccountName: {{ template "seleniumGrid.serviceAccount.fullname" . }}
serviceAccount: {{ template "seleniumGrid.serviceAccount.fullname" . }}
restartPolicy: {{ and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "Never" "Always" }}
restartPolicy: {{ template "seleniumGrid.node.restartPolicy" . }}
{{- with .node.hostAliases }}
hostAliases: {{ toYaml . | nindent 6 }}
{{- end }}
Expand Down Expand Up @@ -712,6 +712,14 @@ Define terminationGracePeriodSeconds of the node pod.
{{- $period -}}
{{- end -}}

{{- define "seleniumGrid.node.restartPolicy" -}}
{{- $restartPolicy := "Always" -}}
{{- if and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") -}}
{{- $restartPolicy = "Never" -}}
{{- end -}}
{{- $restartPolicy -}}
{{- end -}}

{{- define "seleniumGrid.video.volumeMounts.default" -}}
{{- range $fileName, $value := .Values.recorderConfigMap.extraScripts }}
- name: {{ tpl (toYaml $.Values.recorderConfigMap.scriptVolumeMountName) $ }}
Expand Down
2 changes: 1 addition & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.11-slim

WORKDIR /usr/src/app

Expand Down
Loading

0 comments on commit a065ede

Please sign in to comment.