Skip to content

Commit

Permalink
fix: Conflict CLI options from SE_OPTS and corresponding env variables
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Aug 24, 2024
1 parent fdc9fe2 commit 706aa62
Show file tree
Hide file tree
Showing 27 changed files with 231 additions and 155 deletions.
17 changes: 12 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,25 @@ jobs:
echo 'export BRANCH="${CIRCLE_BRANCH//\//-}"' >> $BASH_ENV
cat $BASH_ENV
source $BASH_ENV
- checkout
- run:
name: "Setup environment"
command: |
make chart_setup_env
make set_containerd_image_store
- run:
name: "Print system info"
command: |
uname -a
docker info
- checkout
- run:
name: "Build Docker images"
command: |
N=3
while [ $N -gt 0 ]; do
PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build || true
if [ $? -eq 0 ]; then
output=$(eval "PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build")
status=$?
if [ $status -eq 0 ]; then
echo "Build images passed"
exit 0
else
Expand All @@ -174,8 +180,9 @@ jobs:
command: |
N=3
while [ $N -gt 0 ]; do
USE_RANDOM_USER_ID=${USE_RANDOM_USER} PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${TEST_STRATEGY} || true
if [ $? -eq 0 ]; then
output=$(eval "USE_RANDOM_USER_ID=${USE_RANDOM_USER} PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${TEST_STRATEGY}")
status=$?
if [ $status -eq 0 ]; then
echo "Tests passed"
exit 0
else
Expand Down
4 changes: 2 additions & 2 deletions Distributor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NAMESPACE
ARG VERSION
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}
Expand Down
48 changes: 29 additions & 19 deletions Distributor/start-selenium-grid-distributor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ set -e

echo "Starting Selenium Grid Distributor..."

function append_se_opts() {
local option="${1}"
local value="${2:-""}"
local log_message="${3:-true}"
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
if [ "${log_message}" = "true" ]; then
echo "Appending Selenium option: ${option} ${value}"
else
echo "Appending Selenium option: ${option} $(mask ${value})"
fi
SE_OPTS="${SE_OPTS} ${option}"
if [ ! -z "${value}" ]; then
SE_OPTS="${SE_OPTS} ${value}"
fi
else
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
fi
}

if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then
echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2
exit 1
Expand Down Expand Up @@ -55,23 +74,19 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then
fi

if [ ! -z "$SE_LOG_LEVEL" ]; then
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
fi

if [ ! -z "$SE_HTTP_LOGS" ]; then
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
fi

if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
fi

if [ ! -z "$SE_EXTERNAL_URL" ]; then
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
fi

if [ "${SE_ENABLE_TLS}" = "true" ]; then
Expand All @@ -92,28 +107,23 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
# Configure certificate and private key for component communication
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
fi
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
fi
fi

if [ ! -z "$SE_REGISTRATION_SECRET" ]; then
echo "Appending Selenium options: --registration-secret $(mask ${SE_REGISTRATION_SECRET})"
SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}"
append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" "false"
fi

if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then
echo "Appending Selenium options: --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
SE_OPTS="$SE_OPTS --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
append_se_opts "--reject-unsupported-caps" "${SE_REJECT_UNSUPPORTED_CAPS}"
fi

if [ ! -z "$SE_NEW_SESSION_THREAD_POOL_SIZE" ]; then
echo "Appending Selenium options: --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
SE_OPTS="$SE_OPTS --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
append_se_opts "--newsession-threadpool-size" "${SE_NEW_SESSION_THREAD_POOL_SIZE}"
fi

EXTRA_LIBS=""
Expand Down Expand Up @@ -141,7 +151,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
fi
else
SE_OPTS="$SE_OPTS --tracing false"
append_se_opts "--tracing" "false"
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
echo "Tracing is disabled"
fi
Expand Down
4 changes: 2 additions & 2 deletions EventBus/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NAMESPACE
ARG VERSION
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}
Expand Down
39 changes: 26 additions & 13 deletions EventBus/start-selenium-grid-eventbus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ set -e

echo "Starting Selenium Grid EventBus..."

function append_se_opts() {
local option="${1}"
local value="${2:-""}"
local log_message="${3:-true}"
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
if [ "${log_message}" = "true" ]; then
echo "Appending Selenium option: ${option} ${value}"
else
echo "Appending Selenium option: ${option} $(mask ${value})"
fi
SE_OPTS="${SE_OPTS} ${option}"
if [ ! -z "${value}" ]; then
SE_OPTS="${SE_OPTS} ${value}"
fi
else
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
fi
}

if [ ! -z "$SE_EVENT_BUS_HOST" ]; then
echo "Using SE_EVENT_BUS_HOST: ${SE_EVENT_BUS_HOST}"
HOST_CONFIG="--host ${SE_EVENT_BUS_HOST}"
Expand All @@ -20,23 +39,19 @@ if [ ! -z "$SE_OPTS" ]; then
fi

if [ ! -z "$SE_LOG_LEVEL" ]; then
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
fi

if [ ! -z "$SE_HTTP_LOGS" ]; then
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
fi

if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
fi

if [ ! -z "$SE_EXTERNAL_URL" ]; then
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
fi

if [ "${SE_ENABLE_TLS}" = "true" ]; then
Expand All @@ -57,12 +72,10 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
# Configure certificate and private key for component communication
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
fi
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
fi
fi

Expand Down Expand Up @@ -91,7 +104,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
fi
else
SE_OPTS="$SE_OPTS --tracing false"
append_se_opts "--tracing" "false"
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
echo "Tracing is disabled"
fi
Expand Down
4 changes: 2 additions & 2 deletions Hub/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NAMESPACE
ARG VERSION
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}
Expand Down
59 changes: 34 additions & 25 deletions Hub/start-selenium-grid-hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
# set -e: exit asap if a command exits with a non-zero status
set -e

echo "Starting Selenium Grid Hub..."

function append_se_opts() {
local option="${1}"
local value="${2:-""}"
local log_message="${3:-true}"
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
if [ "${log_message}" = "true" ]; then
echo "Appending Selenium option: ${option} ${value}"
else
echo "Appending Selenium option: ${option} $(mask ${value})"
fi
SE_OPTS="${SE_OPTS} ${option}"
if [ ! -z "${value}" ]; then
SE_OPTS="${SE_OPTS} ${value}"
fi
else
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
fi
}

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi
Expand All @@ -23,23 +44,19 @@ if [ ! -z "$SE_SUB_PATH" ]; then
fi

if [ ! -z "$SE_LOG_LEVEL" ]; then
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
fi

if [ ! -z "$SE_HTTP_LOGS" ]; then
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
fi

if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
fi

if [ ! -z "$SE_EXTERNAL_URL" ]; then
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
fi

if [ "${SE_ENABLE_TLS}" = "true" ]; then
Expand All @@ -60,43 +77,35 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
# Configure certificate and private key for component communication
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
fi
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
fi
fi

if [ ! -z "$SE_REGISTRATION_SECRET" ]; then
echo "Appending Selenium options: --registration-secret $(mask ${SE_REGISTRATION_SECRET})"
SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}"
append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" "false"
fi

if [ ! -z "$SE_DISABLE_UI" ]; then
echo "Appending Selenium options: --disable-ui ${SE_DISABLE_UI}"
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
append_se_opts "--disable-ui" "${SE_DISABLE_UI}"
fi

if [ ! -z "$SE_ROUTER_USERNAME" ]; then
echo "Appending Selenium options: --username ${SE_ROUTER_USERNAME}"
SE_OPTS="$SE_OPTS --username ${SE_ROUTER_USERNAME}"
append_se_opts "--username" "${SE_ROUTER_USERNAME}" "false"
fi

if [ ! -z "$SE_ROUTER_PASSWORD" ]; then
echo "Appending Selenium options: --password $(mask ${SE_ROUTER_PASSWORD})"
SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}"
append_se_opts "--password" "${SE_ROUTER_PASSWORD}" "false"
fi

if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then
echo "Appending Selenium options: --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
SE_OPTS="$SE_OPTS --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
append_se_opts "--reject-unsupported-caps" "${SE_REJECT_UNSUPPORTED_CAPS}"
fi

if [ ! -z "$SE_NEW_SESSION_THREAD_POOL_SIZE" ]; then
echo "Appending Selenium options: --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
SE_OPTS="$SE_OPTS --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
append_se_opts "--newsession-threadpool-size" "${SE_NEW_SESSION_THREAD_POOL_SIZE}"
fi

EXTRA_LIBS=""
Expand Down Expand Up @@ -124,7 +133,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
fi
else
SE_OPTS="$SE_OPTS --tracing false"
append_se_opts "--tracing" "false"
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
echo "Tracing is disabled"
fi
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ test_video: video hub chrome firefox edge chromium
if [ "$(PLATFORMS)" = "linux/amd64" ]; then \
list_nodes="$${list_of_tests_amd64}" ; \
else \
list_nodes="${list_of_tests_arm64}" ; \
list_nodes="$${list_of_tests_arm64}" ; \
fi; \
for node in $${list_nodes}; do \
cd ./tests || true ; \
Expand Down
4 changes: 2 additions & 2 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NAMESPACE
ARG VERSION
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}
Expand Down
6 changes: 3 additions & 3 deletions NodeBase/start-selenium-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ function append_se_opts() {
local log_message="${3:-true}"
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
if [ "${log_message}" = "true" ]; then
echo "Appending Selenium option: ${option} ${value}"
echo "Appending Selenium option: ${option} ${value}"
else
echo "Appending Selenium option: ${option} $(mask ${value})"
echo "Appending Selenium option: ${option} $(mask ${value})"
fi
SE_OPTS="${SE_OPTS} ${option}"
if [ ! -z "${value}" ]; then
SE_OPTS="${SE_OPTS} ${value}"
SE_OPTS="${SE_OPTS} ${value}"
fi
else
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
Expand Down
4 changes: 2 additions & 2 deletions NodeChrome/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG NAMESPACE
ARG VERSION
ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/node-base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}
Expand Down
Loading

0 comments on commit 706aa62

Please sign in to comment.