Skip to content
Open
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
3 changes: 3 additions & 0 deletions ENV_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,6 @@
| SE_DISTRIBUTOR_BACKEND_URL | | Redis URL for Distributor connection when using RedisBackedDistributor implementation, e.g. redis://redis:6379 | --distributor-backend-url |
| SE_DISTRIBUTOR_IMPLEMENTATION | | Configure external datastore for Distributor. When enabled, all replicas share state through the backend (node registrations, slot reservations, health-check coordination) | --distributor-implementation |
| SE_TCP_TUNNEL | false | | --tcp-tunnel |
| SE_SESSION_QUEUE_BACKEND_URL | | | |
| SE_SESSION_QUEUE_IMPLEMENTATION | | | |
| SE_VIDEO_SESSION_SUBFOLDER | false | | |
20 changes: 13 additions & 7 deletions SessionQueue/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

USER ${SEL_UID}
USER root

#========================
# Selenium SessionQueue Configuration
#========================

COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-session-queue.sh generate_config \
/opt/bin/
RUN chmod +x /opt/bin/start-selenium-grid-session-queue.sh /opt/bin/generate_config

COPY selenium-grid-session-queue.conf /etc/supervisor/conf.d/

USER ${SEL_UID}

# In seconds, maps to "--session-request-timeout"
ENV SE_SESSION_REQUEST_TIMEOUT="300" \
# In seconds, maps to "--session-retry-interval"
SE_SESSION_RETRY_INTERVAL="15" \
SE_SESSION_QUEUE_PORT="5559" \
SE_OTEL_SERVICE_NAME="selenium-session-queue"
SE_OTEL_SERVICE_NAME="selenium-session-queue" \
GENERATE_CONFIG="true" \
SE_SESSION_QUEUE_IMPLEMENTATION="" \
SE_SESSION_QUEUE_BACKEND_URL=""

EXPOSE 5559

COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-session-queue.sh \
/opt/bin/

COPY selenium-grid-session-queue.conf /etc/supervisor/conf.d/
17 changes: 17 additions & 0 deletions SessionQueue/generate_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [[ -z "$CONFIG_FILE" ]]; then
FILENAME="/opt/selenium/config.toml"
else
FILENAME="$CONFIG_FILE"
fi

echo "[sessionqueue]" >"$FILENAME"

if [[ -n "${SE_SESSION_QUEUE_IMPLEMENTATION}" ]]; then
echo "implementation = \"${SE_SESSION_QUEUE_IMPLEMENTATION}\"" >>"$FILENAME"
fi

if [[ -n "${SE_SESSION_QUEUE_BACKEND_URL}" ]]; then
echo "backend-url = \"${SE_SESSION_QUEUE_BACKEND_URL}\"" >>"$FILENAME"
fi
9 changes: 9 additions & 0 deletions SessionQueue/start-selenium-grid-session-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ if [ ! -z "$SE_REGISTRATION_SECRET" ]; then
append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" "false"
fi

if [ "$GENERATE_CONFIG" = true ]; then
echo "Generating Selenium Config for SessionQueue"
/opt/bin/generate_config
fi

if [ ! -z "${CONFIG_FILE}" ]; then
append_se_opts "--config" "${CONFIG_FILE}"
fi

EXTRA_LIBS=""
if [ -n "${SE_EXTRA_LIBS}" ]; then
EXTRA_LIBS="--ext ${SE_EXTRA_LIBS}"
Expand Down
4 changes: 4 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| components.sessionQueue.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy (see https://kubernetes.io/docs/concepts/containers/images/#updating-images) |
| components.sessionQueue.imagePullSecret | string | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) |
| components.sessionQueue.sessionRequestTimeout | string | `""` | Override global sessionRequestTimeout |
| components.sessionQueue.externalDatastore | object | `{"backend":"redis","enabled":false,"redis":{"implementation":"org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue","url":"redis://{{ $.Release.Name }}-redis:6379"}}` | Configure external datastore for SessionQueue. When enabled, all replicas share the queue state in Redis, allowing the tier to scale out horizontally behind a load balancer or Kubernetes Service. |
| components.sessionQueue.externalDatastore.enabled | bool | `false` | Enable external datastore for SessionQueue |
| components.sessionQueue.externalDatastore.backend | string | `"redis"` | Backend for external datastore (supported: redis) |
| components.sessionQueue.externalDatastore.redis | object | `{"implementation":"org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue","url":"redis://{{ $.Release.Name }}-redis:6379"}` | Configure Redis backed SessionQueue |
| components.sessionQueue.extraEnvironmentVariables | list | `[]` | Specify extra environment variables for Session Queue |
| components.sessionQueue.extraEnvFrom | list | `[]` | Specify extra environment variables from ConfigMap and Secret for Session Queue |
| components.sessionQueue.affinity | object | `{}` | Specify affinity for Session Queue pods, this overwrites global.seleniumGrid.affinity parameter |
Expand Down
11 changes: 11 additions & 0 deletions charts/selenium-grid/templates/session-queue-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ metadata:
labels:
{{- include "seleniumGrid.commonLabels" $ | nindent 4 }}
data:
{{- if .Values.components.sessionQueue.externalDatastore.enabled }}
{{- $backend := .Values.components.sessionQueue.externalDatastore.backend -}}
{{- with (get .Values.components.sessionQueue.externalDatastore $backend) }}
{{- with .implementation }}
SE_SESSION_QUEUE_IMPLEMENTATION: {{ tpl . $ | quote }}
{{- end }}
{{- with .url }}
SE_SESSION_QUEUE_BACKEND_URL: {{ tpl . $ | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- range $key, $value := $.Values.sessionQueueConfigMap.data }}
{{ $key }}: {{ tpl $value $ | quote }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/templates/session-queue-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ spec:
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "seleniumGrid.sessionQueue.configmap.fullname" . }}
- configMapRef:
name: {{ template "seleniumGrid.logging.configmap.fullname" $ }}
- configMapRef:
Expand Down
13 changes: 13 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,19 @@ components:
# -- Override global sessionRequestTimeout
sessionRequestTimeout: ""

# -- Configure external datastore for SessionQueue. When enabled, all replicas share the queue
# state in Redis, allowing the tier to scale out horizontally behind a load balancer or
# Kubernetes Service.
externalDatastore:
# -- Enable external datastore for SessionQueue
enabled: false
# -- Backend for external datastore (supported: redis)
backend: redis
# -- Configure Redis backed SessionQueue
redis:
implementation: "org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue"
url: "redis://{{ $.Release.Name }}-redis:6379"

# -- Specify extra environment variables for Session Queue
extraEnvironmentVariables: []
# -- Specify extra environment variables from ConfigMap and Secret for Session Queue
Expand Down
3 changes: 3 additions & 0 deletions docker-compose-v3-full-grid-external-redis-backed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ services:
container_name: selenium-session-queue
ports:
- "5559:5559"
environment:
- SE_SESSION_QUEUE_IMPLEMENTATION=org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue
- SE_SESSION_QUEUE_BACKEND_URL=redis://redis:6379

selenium-distributor:
image: selenium/distributor:4.44.0-20260505
Expand Down
9 changes: 9 additions & 0 deletions scripts/generate_list_env_vars/description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,12 @@
- name: SE_TCP_TUNNEL
description: ''
cli: --tcp-tunnel
- name: SE_SESSION_QUEUE_BACKEND_URL
description: ''
cli: ''
- name: SE_SESSION_QUEUE_IMPLEMENTATION
description: ''
cli: ''
- name: SE_VIDEO_SESSION_SUBFOLDER
description: ''
cli: ''
6 changes: 6 additions & 0 deletions scripts/generate_list_env_vars/value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@
default: ''
- name: SE_SESSIONS_MAP_PORT
default: '5556'
- name: SE_SESSION_QUEUE_BACKEND_URL
default: ''
- name: SE_SESSION_QUEUE_HOST
default: ''
- name: SE_SESSION_QUEUE_IMPLEMENTATION
default: ''
- name: SE_SESSION_QUEUE_PORT
default: '5559'
- name: SE_SESSION_REQUEST_TIMEOUT
Expand Down Expand Up @@ -320,6 +324,8 @@
default: '1'
- name: SE_VIDEO_RECORD_STANDALONE
default: ''
- name: SE_VIDEO_SESSION_SUBFOLDER
default: 'false'
- name: SE_VIDEO_UPLOAD_BATCH_CHECK
default: ''
- name: SE_VIDEO_UPLOAD_ENABLED
Expand Down
4 changes: 4 additions & 0 deletions tests/charts/make/chart_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ elif [ "${TEST_EXTERNAL_DATASTORE}" = "redis" ]; then
--set components.distributor.externalDatastore.enabled=true \
--set components.distributor.externalDatastore.backend=redis \
"
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
--set components.sessionQueue.externalDatastore.enabled=true \
--set components.sessionQueue.externalDatastore.backend=redis \
"
fi

if [ "${SELENIUM_GRID_MONITORING}" = "true" ] && [ "${TEST_EXISTING_PTS}" = "true" ]; then
Expand Down
Loading