Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check CLI options duplicated from env vars and SE_OPTS #2451

Merged
merged 1 commit into from
Nov 1, 2024
Merged
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
1 change: 1 addition & 0 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ RUN /opt/bin/add-jks-helper.sh -d /opt/selenium/secrets \
# Boolean value, maps "--bind-host"
ENV SE_BIND_HOST=false \
SE_SERVER_PROTOCOL="http" \
CONFIG_FILE="/opt/selenium/config.toml" \
# Boolean value, maps "--reject-unsupported-caps"
SE_REJECT_UNSUPPORTED_CAPS=false \
SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \
Expand Down
88 changes: 51 additions & 37 deletions Distributor/start-selenium-grid-distributor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,76 @@ function append_se_opts() {
fi
}

if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then
echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2
exit 1
if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi

if [[ -z "${SE_EVENT_BUS_PUBLISH_PORT}" ]]; then
echo "SE_EVENT_BUS_PUBLISH_PORT not set, exiting!" 1>&2
if [[ ! -z "${SE_EVENT_BUS_HOST}" ]]; then
if [[ ! -z "${SE_EVENT_BUS_PUBLISH_PORT}" ]]; then
append_se_opts "--publish-events" "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}"
else
echo "SE_EVENT_BUS_PUBLISH_PORT not set, exiting!" 1>&2
exit 1
fi
if [[ ! -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then
append_se_opts "--subscribe-events" "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}"
else
echo "SE_EVENT_BUS_SUBSCRIBE_PORT not set, exiting!" 1>&2
exit 1
fi
else
echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2
exit 1
fi

if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then
echo "SE_EVENT_BUS_SUBSCRIBE_PORT not set, exiting!" 1>&2
if [[ ! -z "${SE_SESSIONS_MAP_HOST}" ]]; then
append_se_opts "--sessions-host" "${SE_SESSIONS_MAP_HOST}"
if [[ ! -z "${SE_SESSIONS_MAP_PORT}" ]]; then
append_se_opts "--sessions-port" "${SE_SESSIONS_MAP_PORT}"
else
echo "SE_SESSIONS_MAP_PORT not set, exiting!" 1>&2
exit 1
fi
else
echo "SE_SESSIONS_MAP_HOST not set, exiting!" 1>&2
exit 1
fi

if [[ -z "${SE_SESSIONS_MAP_HOST}" ]]; then
echo "SE_SESSIONS_MAP_HOST not set, exiting!" 1>&2
if [[ ! -z "${SE_SESSION_QUEUE_HOST}" ]]; then
append_se_opts "--sessionqueue-host" "${SE_SESSION_QUEUE_HOST}"
if [[ ! -z "${SE_SESSION_QUEUE_PORT}" ]]; then
append_se_opts "--sessionqueue-port" "${SE_SESSION_QUEUE_PORT}"
else
echo "SE_SESSION_QUEUE_PORT not set, exiting!" 1>&2
exit 1
fi
else
echo "SE_SESSION_QUEUE_HOST not set, exiting!" 1>&2
exit 1
fi

if [[ -z "${SE_SESSIONS_MAP_PORT}" ]]; then
echo "SE_SESSIONS_MAP_PORT not set, exiting!" 1>&2
exit 1
if [ ! -z "$SE_DISTRIBUTOR_HOST" ]; then
append_se_opts "--host" "${SE_DISTRIBUTOR_HOST}"
fi

if [[ -z "${SE_SESSION_QUEUE_HOST}" ]]; then
echo "SE_SESSION_QUEUE_HOST not set, exiting!" 1>&2
exit 1
if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then
append_se_opts "--port" "${SE_DISTRIBUTOR_PORT}"
fi

if [[ -z "${SE_SESSION_QUEUE_PORT}" ]]; then
echo "SE_SESSION_QUEUE_PORT not set, exiting!" 1>&2
exit 1
if [ ! -z "${SE_BIND_HOST}" ]; then
append_se_opts "--bind-host" "${SE_BIND_HOST}"
fi

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
if [ ! -z "${SE_HEALTHCHECK_INTERVAL}" ]; then
append_se_opts "--healthcheck-interval" "${SE_HEALTHCHECK_INTERVAL}"
fi

if [ ! -z "$SE_DISTRIBUTOR_HOST" ]; then
echo "Using SE_DISTRIBUTOR_HOST: ${SE_DISTRIBUTOR_HOST}"
HOST_CONFIG="--host ${SE_DISTRIBUTOR_HOST}"
if [ ! -z "${SE_SESSION_RETRY_INTERVAL}" ]; then
append_se_opts "--session-retry-interval" "${SE_SESSION_RETRY_INTERVAL}"
fi

if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then
echo "Using SE_DISTRIBUTOR_PORT: ${SE_DISTRIBUTOR_PORT}"
PORT_CONFIG="--port ${SE_DISTRIBUTOR_PORT}"
if [ ! -z "${SE_SESSION_REQUEST_TIMEOUT}" ]; then
append_se_opts "--session-request-timeout" "${SE_SESSION_REQUEST_TIMEOUT}"
fi

if [ ! -z "$SE_LOG_LEVEL" ]; then
Expand Down Expand Up @@ -158,16 +181,7 @@ fi

java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
-jar /opt/selenium/selenium-server.jar \
${EXTRA_LIBS} distributor \
--sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port "${SE_SESSIONS_MAP_PORT}" \
--sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \
--publish-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_PUBLISH_PORT}" \
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_SUBSCRIBE_PORT}" \
--session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \
--session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \
--healthcheck-interval ${SE_HEALTHCHECK_INTERVAL} \
--bind-host ${SE_BIND_HOST} \
${EXTRA_LIBS} \
distributor \
--bind-bus false \
${HOST_CONFIG} \
${PORT_CONFIG} \
${SE_OPTS}
45 changes: 29 additions & 16 deletions Hub/start-selenium-grid-hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ if [ ! -z "$SE_OPTS" ]; then
fi

if [ ! -z "$SE_HUB_HOST" ]; then
echo "Using SE_HUB_HOST: ${SE_HUB_HOST}"
HOST_CONFIG="--host ${SE_HUB_HOST}"
append_se_opts "--host" "${SE_HUB_HOST}"
fi

if [ ! -z "$SE_HUB_PORT" ]; then
echo "Using SE_HUB_PORT: ${SE_HUB_PORT}"
PORT_CONFIG="--port ${SE_HUB_PORT}"
append_se_opts "--port" "${SE_HUB_PORT}"
fi

if [ ! -z "$SE_SUB_PATH" ]; then
echo "Using SE_SUB_PATH: ${SE_SUB_PATH}"
SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}"
append_se_opts "--sub-path" "${SE_SUB_PATH}"
fi

if [ ! -z "$SE_LOG_LEVEL" ]; then
Expand Down Expand Up @@ -108,6 +105,30 @@ if [ ! -z "$SE_NEW_SESSION_THREAD_POOL_SIZE" ]; then
append_se_opts "--newsession-threadpool-size" "${SE_NEW_SESSION_THREAD_POOL_SIZE}"
fi

if [ ! -z "${SE_SESSION_REQUEST_TIMEOUT}" ]; then
append_se_opts "--session-request-timeout" "${SE_SESSION_REQUEST_TIMEOUT}"
fi

if [ ! -z "${SE_SESSION_RETRY_INTERVAL}" ]; then
append_se_opts "--session-retry-interval" "${SE_SESSION_RETRY_INTERVAL}"
fi

if [ ! -z "${SE_HEALTHCHECK_INTERVAL}" ]; then
append_se_opts "--healthcheck-interval" "${SE_HEALTHCHECK_INTERVAL}"
fi

if [ ! -z "${SE_RELAX_CHECKS}" ]; then
append_se_opts "--relax-checks" "${SE_RELAX_CHECKS}"
fi

if [ ! -z "${SE_BIND_HOST}" ]; then
append_se_opts "--bind-host" "${SE_BIND_HOST}"
fi

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

EXTRA_LIBS=""

if [ "$SE_ENABLE_TRACING" = "true" ]; then
Expand Down Expand Up @@ -140,14 +161,6 @@ fi

java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
-jar /opt/selenium/selenium-server.jar \
${EXTRA_LIBS} hub \
--session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \
--session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \
--healthcheck-interval ${SE_HEALTHCHECK_INTERVAL} \
--relax-checks ${SE_RELAX_CHECKS} \
--bind-host ${SE_BIND_HOST} \
--config /opt/selenium/config.toml \
${HOST_CONFIG} \
${PORT_CONFIG} \
${SUB_PATH_CONFIG} \
${EXTRA_LIBS} \
hub \
${SE_OPTS}
21 changes: 14 additions & 7 deletions NodeBase/start-selenium-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function append_se_opts() {
fi
}

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi

if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then
echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2
exit 1
Expand All @@ -46,10 +50,6 @@ if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then
exit 1
fi

if [ ! -z "$SE_OPTS" ]; then
echo "Appending Selenium options: ${SE_OPTS}"
fi

if [ ! -z "$SE_NODE_SESSION_TIMEOUT" ]; then
append_se_opts "--session-timeout" "${SE_NODE_SESSION_TIMEOUT}"
fi
Expand Down Expand Up @@ -155,6 +155,14 @@ else
echo "Tracing is disabled"
fi

if [ ! -z "${SE_BIND_HOST}" ]; then
append_se_opts "--bind-host" "${SE_BIND_HOST}"
fi

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

echo "Selenium Grid Node configuration: "
cat "$CONFIG_FILE"
echo "Starting Selenium Grid Node..."
Expand All @@ -168,7 +176,6 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
${EDGE_DRIVER_PATH_PROPERTY} \
${GECKO_DRIVER_PATH_PROPERTY} \
-jar /opt/selenium/selenium-server.jar \
${EXTRA_LIBS} node \
--bind-host ${SE_BIND_HOST} \
--config "$CONFIG_FILE" \
${EXTRA_LIBS} \
node \
${SE_OPTS}
Loading