Skip to content

Commit

Permalink
Docker: set/unset stereotype via env var SE_NODE_BROWSER_VERSION and …
Browse files Browse the repository at this point in the history
…SE_BROWSER_BINARY_LOCATION (#2520)

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 authored Dec 19, 2024
1 parent 2741b81 commit 170f936
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ENV LANG_WHICH=${LANG_WHICH} \
SE_OTEL_SERVICE_NAME="selenium-node" \
# Setting Selenium Manager to work offline
SE_OFFLINE=true \
SE_NODE_BROWSER_VERSION="stable" \
#============================
# Some configuration options
#============================
Expand Down
8 changes: 4 additions & 4 deletions NodeBase/generate_config
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ echo "max-sessions = ${SE_NODE_MAX_CONCURRENCY:-${SE_NODE_MAX_SESSIONS}}
if [ -f /opt/selenium/browser_name ]; then
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
fi
if [ -f /opt/selenium/browser_version ]; then
if [ -f /opt/selenium/browser_version ] && [ "${SE_NODE_BROWSER_VERSION}" = "stable" ]; then
SE_NODE_BROWSER_VERSION=$(short_version $(cat /opt/selenium/browser_version))
fi
if [ -f /opt/selenium/browser_binary_location ]; then
SE__BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location)
if [ -f /opt/selenium/browser_binary_location ] && [ -z "${SE_BROWSER_BINARY_LOCATION}" ]; then
SE_BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location)
fi

# 'browserName' is mandatory for default stereotype
if [[ -z "${SE_NODE_STEREOTYPE}" ]] && [[ -n "${SE_NODE_BROWSER_NAME}" ]]; then
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE__BROWSER_BINARY_LOCATION}, \"se:containerName\": \"${SE_NODE_CONTAINER_NAME}\"}"
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE_BROWSER_BINARY_LOCATION}, \"se:containerName\": \"${SE_NODE_CONTAINER_NAME}\"}"
else
SE_NODE_STEREOTYPE="${SE_NODE_STEREOTYPE}"
fi
Expand Down
14 changes: 10 additions & 4 deletions Standalone/generate_config
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_S
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >>"$FILENAME"

SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
SE_NODE_BROWSER_VERSION=$(short_version $(cat /opt/selenium/browser_version))
SE__BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location)
if [ -f /opt/selenium/browser_name ]; then
SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name)
fi
if [ -f /opt/selenium/browser_version ] && [ "${SE_NODE_BROWSER_VERSION}" = "stable" ]; then
SE_NODE_BROWSER_VERSION=$(short_version $(cat /opt/selenium/browser_version))
fi
if [ -f /opt/selenium/browser_binary_location ] && [ -z "${SE_BROWSER_BINARY_LOCATION}" ]; then
SE_BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location)
fi

if [[ -z "$SE_NODE_STEREOTYPE" ]]; then
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE__BROWSER_BINARY_LOCATION}, \"se:containerName\": \"${SE_NODE_CONTAINER_NAME}\"}"
SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE_BROWSER_BINARY_LOCATION}, \"se:containerName\": \"${SE_NODE_CONTAINER_NAME}\"}"
else
SE_NODE_STEREOTYPE="$SE_NODE_STEREOTYPE"
fi
Expand Down
3 changes: 3 additions & 0 deletions tests/docker-compose-v3-test-parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- ./videos/certs:/opt/selenium/secrets
- ./videos:/videos
environment:
- SE_NODE_BROWSER_VERSION=
- SE_ENABLE_TRACING=false
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand Down Expand Up @@ -53,6 +54,7 @@ services:
- ./videos/certs:/opt/selenium/secrets
- ./videos:/videos
environment:
- SE_NODE_BROWSER_VERSION=
- SE_ENABLE_TRACING=false
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand Down Expand Up @@ -84,6 +86,7 @@ services:
volumes:
- ./videos/certs:/opt/selenium/secrets
environment:
- SE_NODE_BROWSER_VERSION=
- SE_ENABLE_TRACING=false
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand Down
1 change: 1 addition & 0 deletions tests/docker-compose-v3-test-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
depends_on:
- browser_video
environment:
- SE_NODE_BROWSER_VERSION=
- SE_ENABLE_TRACING=false
- SE_NODE_MAX_SESSIONS=1
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
Expand Down

0 comments on commit 170f936

Please sign in to comment.