Skip to content

Commit

Permalink
feat(chart): distribution registry can be set global and individual c…
Browse files Browse the repository at this point in the history
…omponent (#2030)

* test: Sanity tests Selenium Grid chart via Makefile commands

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

* Remove redundant if: statement from workflow [skip ci]

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

* Add event workflow_dispatch to release charts [skip ci]

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

* test: Sanity tests Selenium Grid chart via Makefile commands

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

* Increase nginx ingress timeout

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

* feat: distribution registry can be set global and individual component

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

* feat: distribution registry can be set global and individual component

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

* Update chart values.yaml

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

* Update for Released notes to extract Chrome version after PR #2018

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

---------

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Nov 29, 2023
1 parent e3304b4 commit 7545bc9
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 138 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ permissions:

jobs:
build-and-test:
# Skip job based on the commit message, only works in push to branches for now
if: contains(toJson(github.event.commits), '[skip ci]') == false
name: Build & test Docker images with random user
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
run: |
git config --local user.email "selenium-ci@users.noreply.github.com"
git config --local user.name "Selenium CI Bot"
git commit -m "Update tag in docs and files [skip ci]" -a
git commit -m "Update tag in docs and files" -a
- name: Push changes
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # master
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/helm-chart-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- trunk
paths:
- 'charts/selenium-grid/Chart.yaml'
workflow_dispatch:

jobs:
release:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ permissions:

jobs:
build-and-test:
# Skip job based on the commit message, only works in push to branches for now
if: contains(toJson(github.event.commits), '[skip ci]') == false
name: Build & test Docker images with Helm charts
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test-video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ permissions:

jobs:
build-and-test:
# Skip job based on the commit message, only works in push to branches for now
if: contains(toJson(github.event.commits), '[skip ci]') == false
name: Test video recorded through Docker Selenium
runs-on: ubuntu-latest
steps:
Expand Down
196 changes: 104 additions & 92 deletions charts/selenium-grid/README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions charts/selenium-grid/ci/auth-ingress-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ingress:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "360"
nginx.ingress.kubernetes.io/proxy-read-timeout: "360"
nginx.ingress.kubernetes.io/proxy-send-timeout: "360"
hostname: ""
paths:
- path: /selenium(/|$)(.*)
Expand Down
7 changes: 5 additions & 2 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ template:
containers:
- name: {{.name}}
{{- $imageTag := default .Values.global.seleniumGrid.nodesImageTag .node.imageTag }}
image: {{ printf "%s:%s" .node.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .node.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .node.imageName $imageTag }}
imagePullPolicy: {{ .node.imagePullPolicy }}
{{- with .node.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 10 }}
Expand Down Expand Up @@ -217,7 +218,9 @@ template:
{{- end }}
{{- if .Values.videoRecorder.enabled }}
- name: video
image: {{ printf "%s:%s" .Values.videoRecorder.imageName .Values.videoRecorder.imageTag }}
{{- $imageTag := default .Values.global.seleniumGrid.videoImageTag .Values.videoRecorder.imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.videoRecorder.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.videoRecorder.imageName $imageTag }}
imagePullPolicy: {{ .Values.videoRecorder.imagePullPolicy }}
env:
- name: UPLOAD_DESTINATION_PREFIX
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/distributor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.distributor.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.distributor.imageTag }}
image: {{ printf "%s:%s" .Values.components.distributor.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.components.distributor.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.components.distributor.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.distributor.imagePullPolicy }}
env:
- name: SE_SESSIONS_MAP_HOST
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/event-bus-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.eventBus.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.eventBus.imageTag }}
image: {{ printf "%s:%s" .Values.components.eventBus.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.components.eventBus.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.components.eventBus.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.eventBus.imagePullPolicy }}
ports:
- containerPort: {{ .Values.components.eventBus.port }}
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/hub-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.hub.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.hub.imageTag }}
image: {{ printf "%s:%s" .Values.hub.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.hub.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.hub.imageName $imageTag }}

This comment has been minimized.

Copy link
@xdoncalvox

xdoncalvox Dec 11, 2023

This is causing ImagePullBackOff as the resulting image path shows selenium/selenium/hub instead of selenium/hub

This comment has been minimized.

Copy link
@diemol

diemol Dec 11, 2023

Member

There are new versions released already, check that first please.

imagePullPolicy: {{ .Values.hub.imagePullPolicy }}
ports:
- containerPort: {{ .Values.hub.port }}
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/router-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.router.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.router.imageTag }}
image: {{ printf "%s:%s" .Values.components.router.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.components.router.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.components.router.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.router.imagePullPolicy }}
env:
- name: SE_DISTRIBUTOR_HOST
Expand Down
3 changes: 2 additions & 1 deletion charts/selenium-grid/templates/session-map-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.sessionMap.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionMap.imageTag }}
image: {{ printf "%s:%s" .Values.components.sessionMap.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.components.sessionMap.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.components.sessionMap.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.sessionMap.imagePullPolicy }}
{{- with .Values.components.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ spec:
containers:
- name: {{ template "seleniumGrid.sessionQueue.fullname" . }}
{{- $imageTag := default .Values.global.seleniumGrid.imageTag .Values.components.sessionQueue.imageTag }}
image: {{ printf "%s:%s" .Values.components.sessionQueue.imageName $imageTag }}
{{- $imageRegistry := default .Values.global.seleniumGrid.imageRegistry .Values.components.sessionQueue.imageRegistry }}
image: {{ printf "%s/%s:%s" $imageRegistry .Values.components.sessionQueue.imageName $imageTag }}
imagePullPolicy: {{ .Values.components.sessionQueue.imagePullPolicy }}
{{- with .Values.components.extraEnvironmentVariables }}
env: {{- tpl (toYaml .) $ | nindent 12 }}
Expand Down
36 changes: 25 additions & 11 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
global:
seleniumGrid:
# Image registry for all selenium components
imageRegistry: selenium
# Image tag for all selenium components
imageTag: 4.15.0-20231128
# Image tag for browser's nodes
nodesImageTag: 4.15.0-20231128
# Image tag for browser's video recorder
videoImageTag: ffmpeg-6.0-20231128
# Pull secret for all components, can be overridden individually
imagePullSecret: ""

Expand Down Expand Up @@ -63,8 +67,9 @@ components:

# Configuration for router component
router:
# imageRegistry: selenium
# Router image name
imageName: selenium/router
imageName: router
# Router image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128

Expand Down Expand Up @@ -114,8 +119,9 @@ components:

# Configuration for distributor component
distributor:
# imageRegistry: selenium
# Distributor image name
imageName: selenium/distributor
imageName: distributor
# Distributor image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128

Expand Down Expand Up @@ -145,8 +151,9 @@ components:

# Configuration for Event Bus component
eventBus:
# imageRegistry: selenium
# Event Bus image name
imageName: selenium/event-bus
imageName: event-bus
# Event Bus image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128

Expand Down Expand Up @@ -180,8 +187,9 @@ components:

# Configuration for Session Map component
sessionMap:
# imageRegistry: selenium
# Session Map image name
imageName: selenium/sessions
imageName: sessions
# Session Map image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128

Expand Down Expand Up @@ -210,8 +218,9 @@ components:

# Configuration for Session Queue component
sessionQueue:
# imageRegistry: selenium
# Session Queue image name
imageName: selenium/session-queue
imageName: session-queue
# Session Queue image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128

Expand Down Expand Up @@ -260,8 +269,9 @@ components:

# Configuration for selenium hub deployment (applied only if `isolateComponents: false`)
hub:
# imageRegistry: selenium
# Selenium Hub image name
imageName: selenium/hub
imageName: hub
# Selenium Hub image tag (this overwrites global.seleniumGrid.imageTag parameter)
# imageTag: 4.15.0-20231128
# Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images)
Expand Down Expand Up @@ -400,8 +410,9 @@ chromeNode:

# Number of chrome nodes
replicas: 1
# imageRegistry: selenium
# Image of chrome nodes
imageName: selenium/node-chrome
imageName: node-chrome
# Image of chrome nodes (this overwrites global.seleniumGrid.nodesImageTag)
# imageTag: 4.15.0-20231128
# Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images)
Expand Down Expand Up @@ -532,8 +543,9 @@ firefoxNode:

# Number of firefox nodes
replicas: 1
# imageRegistry: selenium
# Image of firefox nodes
imageName: selenium/node-firefox
imageName: node-firefox
# Image of firefox nodes (this overwrites global.seleniumGrid.nodesImageTag)
# imageTag: 4.15.0-20231128
# Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images)
Expand Down Expand Up @@ -661,8 +673,9 @@ edgeNode:

# Number of edge nodes
replicas: 1
# imageRegistry: selenium
# Image of edge nodes
imageName: selenium/node-edge
imageName: node-edge
# Image of edge nodes (this overwrites global.seleniumGrid.nodesImageTag)
# imageTag: 4.15.0-20231128
# Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images)
Expand Down Expand Up @@ -779,10 +792,11 @@ edgeNode:

videoRecorder:
enabled: false
# imageRegistry: selenium
# Image of video recorder
imageName: selenium/video
imageName: video
# Image of video recorder
imageTag: ffmpeg-6.0-20231128
# imageTag: ffmpeg-6.0-20231128
# Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images)
imagePullPolicy: IfNotPresent
# Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/)
Expand Down
2 changes: 1 addition & 1 deletion generate_release_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "" >> release_notes.md
echo "### Changelog" > release_notes.md
git --no-pager log "${LATEST_TAG}...${HEAD_BRANCH}" --pretty=format:"* [\`%h\`](http://github.com/seleniumhq/docker-selenium/commit/%H) - %s :: %an" --reverse >> release_notes.md

CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $3}')
CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $5}')
EDGE_VERSION=$(docker run --rm selenium/node-edge:${TAG_VERSION} microsoft-edge --version | awk '{print $3}')
CHROMEDRIVER_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} chromedriver --version | awk '{print $2}')
EDGEDRIVER_VERSION=$(docker run --rm selenium/node-edge:${TAG_VERSION} msedgedriver --version | awk '{print $4}')
Expand Down
2 changes: 1 addition & 1 deletion tag_and_push_browser_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ echo "Tagging images for browser ${BROWSER}, version ${VERSION}, build date ${BU
case "${BROWSER}" in

chrome)
CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $3}')
CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $5}')
echo "Chrome version -> "${CHROME_VERSION}
CHROME_SHORT_VERSION="$(short_version ${CHROME_VERSION})"
echo "Short Chrome version -> "${CHROME_SHORT_VERSION}
Expand Down
5 changes: 3 additions & 2 deletions tests/K8s/chart_cluster_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ cleanup() {

# Function to be executed on command failure
on_failure() {
echo "There is step failed with exit status $?"
local exit_status=$?
echo "There is step failed with exit status $exit_status"
cleanup
exit $?
exit $exit_status
}

# Trap ERR signal and call on_failure function
Expand Down
24 changes: 16 additions & 8 deletions tests/K8s/chart_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ MATRIX_BROWSER=${1:-"NodeChrome"}
SELENIUM_GRID_AUTOSCALING=${2:-"true"}
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=${3:-"0"}
WAIT_TIMEOUT=${WAIT_TIMEOUT:-"90s"}
SLEEP_INTERVAL=${SLEEP_INTERVAL:-45}
HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL:-45}
WEB_DRIVER_WAIT_TIMEOUT=${WEB_DRIVER_WAIT_TIMEOUT:-120}
SKIP_CLEANUP=${SKIP_CLEANUP:-"false"} # For debugging purposes, retain the cluster after the test run

cleanup() {
Expand All @@ -28,9 +29,12 @@ cleanup() {

# Function to be executed on command failure
on_failure() {
echo "There is step failed with exit status $?"
local exit_status=$?
echo "Describe all resources in the ${SELENIUM_NAMESPACE} namespace for debugging purposes"
kubectl describe all -n ${SELENIUM_NAMESPACE}
echo "There is step failed with exit status $exit_status"
cleanup
exit $?
exit $exit_status
}

# Trap ERR signal and call on_failure function
Expand All @@ -43,19 +47,23 @@ helm upgrade --install ${RELEASE_NAME} \
-f ${TEST_VALUES_PATH}/${MATRIX_BROWSER}-values.yaml \
--set autoscaling.enableWithExistingKEDA=${SELENIUM_GRID_AUTOSCALING} \
--set autoscaling.scaledOptions.minReplicaCount=${SELENIUM_GRID_AUTOSCALING_MIN_REPLICA} \
--set global.seleniumGrid.imageTag=${VERSION} \
--set global.seleniumGrid.imageTag=${VERSION} --set global.seleniumGrid.imageRegistry=${NAMESPACE} \
${CHART_PATH} --namespace ${SELENIUM_NAMESPACE} --create-namespace

echo "Verify Post Deployment Grid Health and Pod Status"
kubectl get pods -n ${SELENIUM_NAMESPACE}

echo "Run Tests"
export SELENIUM_GRID_HOST=${SELENIUM_GRID_HOST}
export SELENIUM_GRID_PORT=${SELENIUM_GRID_PORT}""${SUB_PATH}
export SELENIUM_GRID_AUTOSCALING=${SELENIUM_GRID_AUTOSCALING}
export SELENIUM_GRID_AUTOSCALING_MIN_REPLICA=${SELENIUM_GRID_AUTOSCALING_MIN_REPLICA}
export RUN_IN_DOCKER_COMPOSE=true
export SLEEP_INTERVAL=${SLEEP_INTERVAL}
export HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL}
export WEB_DRIVER_WAIT_TIMEOUT=${WEB_DRIVER_WAIT_TIMEOUT}
./tests/bootstrap.sh ${MATRIX_BROWSER}

echo "Get pods status"
kubectl get pods -n ${SELENIUM_NAMESPACE}

echo "Get all resources in the ${SELENIUM_NAMESPACE} namespace"
kubectl get all -n ${SELENIUM_NAMESPACE}

cleanup
5 changes: 3 additions & 2 deletions tests/K8s/chart_lint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
# Function to be executed on command failure
on_failure() {
echo "There is step failed with exit status $?"
exit $?
local exit_status=$?
echo "There is step failed with exit status $exit_status"
exit $exit_status
}

# Trap ERR signal and call on_failure function
Expand Down
5 changes: 3 additions & 2 deletions tests/K8s/chart_setup_env.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
# Function to be executed on command failure
on_failure() {
echo "There is step failed with exit status $?"
exit $?
local exit_status=$?
echo "There is step failed with exit status $exit_status"
exit $exit_status
}

# Trap ERR signal and call on_failure function
Expand Down
3 changes: 2 additions & 1 deletion tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

SELENIUM_GRID_HOST = os.environ.get('SELENIUM_GRID_HOST', 'localhost')
SELENIUM_GRID_PORT = os.environ.get('SELENIUM_GRID_PORT', '4444')
WEB_DRIVER_WAIT_TIMEOUT = int(os.environ.get('WEB_DRIVER_WAIT_TIMEOUT', 60))

class SeleniumGenericTests(unittest.TestCase):

Expand Down Expand Up @@ -51,7 +52,7 @@ def test_visit_basic_auth_secured_page(self):
def test_play_video(self):
driver = self.driver
driver.get('https://hls-js.netlify.com/demo/')
wait = WebDriverWait(driver, 30)
wait = WebDriverWait(driver, WEB_DRIVER_WAIT_TIMEOUT)
video = wait.until(
EC.element_to_be_clickable((By.TAG_NAME, 'video'))
)
Expand Down
Loading

0 comments on commit 7545bc9

Please sign in to comment.