diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index 83cdf5406..1ca0d565c 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -5,6 +5,23 @@ 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}" + 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 @@ -40,10 +57,6 @@ if [[ -z "${SE_SESSION_QUEUE_PORT}" ]]; then exit 1 fi -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi - if [ ! -z "$SE_DISTRIBUTOR_HOST" ]; then echo "Using SE_DISTRIBUTOR_HOST: ${SE_DISTRIBUTOR_HOST}" HOST_CONFIG="--host ${SE_DISTRIBUTOR_HOST}" @@ -55,23 +68,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 @@ -92,28 +101,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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" 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="" @@ -141,11 +145,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} distributor \ diff --git a/EventBus/start-selenium-grid-eventbus.sh b/EventBus/start-selenium-grid-eventbus.sh index 5742c8ce3..fd928b96a 100755 --- a/EventBus/start-selenium-grid-eventbus.sh +++ b/EventBus/start-selenium-grid-eventbus.sh @@ -5,6 +5,23 @@ 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}" + 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}" @@ -15,28 +32,20 @@ if [ ! -z "$SE_EVENT_BUS_PORT" ]; then PORT_CONFIG="--port ${SE_EVENT_BUS_PORT}" fi -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -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 @@ -57,12 +66,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 @@ -91,11 +98,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} event-bus \ diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index 60cb5086e..3525dea4e 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -3,9 +3,24 @@ # set -e: exit asap if a command exits with a non-zero status set -e -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi +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}" + 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_HUB_HOST" ]; then echo "Using SE_HUB_HOST: ${SE_HUB_HOST}" @@ -23,23 +38,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 @@ -60,43 +71,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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" 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}" fi if [ ! -z "$SE_ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" + append_se_opts "--password" "${SE_ROUTER_PASSWORD}" 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="" @@ -124,11 +127,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} hub \ diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index f9d6f6a68..70d98a016 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -12,6 +12,23 @@ pacmd set-default-source v1.monitor rm -f /tmp/.X*lock +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}" + 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 @@ -27,58 +44,44 @@ 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 - echo "Appending Selenium options: --session-timeout ${SE_NODE_SESSION_TIMEOUT}" - SE_OPTS="$SE_OPTS --session-timeout ${SE_NODE_SESSION_TIMEOUT}" + append_se_opts "--session-timeout" "${SE_NODE_SESSION_TIMEOUT}" fi if [ ! -z "$SE_NODE_ENABLE_MANAGED_DOWNLOADS" ]; then - echo "Appending Selenium options: --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" - SE_OPTS="$SE_OPTS --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" + append_se_opts "--enable-managed-downloads" "${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" fi if [ ! -z "$SE_NODE_ENABLE_CDP" ]; then - echo "Appending Selenium options: --enable-cdp ${SE_NODE_ENABLE_CDP}" - SE_OPTS="$SE_OPTS --enable-cdp ${SE_NODE_ENABLE_CDP}" + append_se_opts "--enable-cdp" "${SE_NODE_ENABLE_CDP}" fi if [ ! -z "$SE_NODE_REGISTER_PERIOD" ]; then - echo "Appending Selenium options: --register-period ${SE_NODE_REGISTER_PERIOD}" - SE_OPTS="$SE_OPTS --register-period ${SE_NODE_REGISTER_PERIOD}" + append_se_opts "--register-period" "${SE_NODE_REGISTER_PERIOD}" fi if [ ! -z "$SE_NODE_REGISTER_CYCLE" ]; then - echo "Appending Selenium options: --register-cycle ${SE_NODE_REGISTER_CYCLE}" - SE_OPTS="$SE_OPTS --register-cycle ${SE_NODE_REGISTER_CYCLE}" + append_se_opts "--register-cycle" "${SE_NODE_REGISTER_CYCLE}" fi if [ ! -z "$SE_NODE_HEARTBEAT_PERIOD" ]; then - echo "Appending Selenium options: --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" - SE_OPTS="$SE_OPTS --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" + append_se_opts "--heartbeat-period" "${SE_NODE_HEARTBEAT_PERIOD}" 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 @@ -99,18 +102,15 @@ 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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" fi if [ "$GENERATE_CONFIG" = true ]; then @@ -144,7 +144,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 @@ -157,6 +157,10 @@ CHROME_DRIVER_PATH_PROPERTY=-Dwebdriver.chrome.driver=/usr/bin/chromedriver EDGE_DRIVER_PATH_PROPERTY=-Dwebdriver.edge.driver=/usr/bin/msedgedriver GECKO_DRIVER_PATH_PROPERTY=-Dwebdriver.gecko.driver=/usr/bin/geckodriver +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${CHROME_DRIVER_PATH_PROPERTY} \ ${EDGE_DRIVER_PATH_PROPERTY} \ diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index 4b39ecd32..8c34a7222 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -5,6 +5,23 @@ set -e echo "Starting Selenium Grid Node Docker..." +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}" + 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 @@ -20,33 +37,25 @@ 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_GRID_URL" ]; then echo "Appending Grid url: ${SE_NODE_GRID_URL}" SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" 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 @@ -67,12 +76,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 @@ -101,11 +108,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} node \ diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index c7e5e5ca2..8a72c60f9 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -5,6 +5,23 @@ set -e echo "Starting Selenium Grid Router..." +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}" + 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_SESSIONS_MAP_HOST}" ]]; then echo "SE_SESSIONS_MAP_HOST not set, exiting!" 1>&2 exit 1 @@ -40,10 +57,6 @@ if [ ! -z "$SE_SUB_PATH" ]; then SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}" fi -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi - if [ ! -z "$SE_ROUTER_HOST" ]; then echo "Using SE_ROUTER_HOST: ${SE_ROUTER_HOST}" HOST_CONFIG="--host ${SE_ROUTER_HOST}" @@ -55,23 +68,19 @@ if [ ! -z "$SE_ROUTER_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 @@ -92,33 +101,27 @@ 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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" 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}" fi if [ ! -z "$SE_ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" + append_se_opts "--password" "${SE_ROUTER_PASSWORD}" fi EXTRA_LIBS="" @@ -146,11 +149,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} router \ diff --git a/SessionQueue/start-selenium-grid-session-queue.sh b/SessionQueue/start-selenium-grid-session-queue.sh index e96d75ca3..b512f00bb 100755 --- a/SessionQueue/start-selenium-grid-session-queue.sh +++ b/SessionQueue/start-selenium-grid-session-queue.sh @@ -5,9 +5,22 @@ set -e echo "Starting Selenium Grid SessionQueue..." -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi +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}" + 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_SESSION_QUEUE_HOST" ]; then echo "Using SE_SESSION_QUEUE_HOST: ${SE_SESSION_QUEUE_HOST}" @@ -20,23 +33,19 @@ if [ ! -z "$SE_SESSION_QUEUE_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 @@ -57,18 +66,15 @@ 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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" fi EXTRA_LIBS="" @@ -96,11 +102,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} sessionqueue \ diff --git a/Sessions/start-selenium-grid-sessions.sh b/Sessions/start-selenium-grid-sessions.sh index 142168cc4..b5f73268e 100755 --- a/Sessions/start-selenium-grid-sessions.sh +++ b/Sessions/start-selenium-grid-sessions.sh @@ -5,6 +5,23 @@ set -e echo "Starting Selenium Grid Sessions..." +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}" + 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 @@ -20,10 +37,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_SESSIONS_HOST" ]; then echo "Using SE_SESSIONS_HOST: ${SE_SESSIONS_HOST}" HOST_CONFIG="--host ${SE_SESSIONS_HOST}" @@ -35,23 +48,19 @@ if [ ! -z "$SE_SESSIONS_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 @@ -72,18 +81,15 @@ 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 ${SE_REGISTRATION_SECRET}" - SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}" + append_se_opts "--registration-secret" "${SE_REGISTRATION_SECRET}" fi EXTRA_LIBS="" @@ -111,11 +117,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} sessions \ diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 8514453cf..4c918d71a 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -12,73 +12,74 @@ pacmd set-default-sink v1 # set the monitor of v1 sink to be the default source pacmd set-default-source v1.monitor +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}" + 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_SUB_PATH" ]; then echo "Using SE_SUB_PATH: ${SE_SUB_PATH}" SUB_PATH_CONFIG="--sub-path ${SE_SUB_PATH}" fi -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -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}" fi if [ ! -z "$SE_ROUTER_PASSWORD" ]; then - echo "Appending Selenium options: --password ${SE_ROUTER_PASSWORD}" - SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}" + append_se_opts "--password" "${SE_ROUTER_PASSWORD}" fi if [ ! -z "$SE_NODE_ENABLE_MANAGED_DOWNLOADS" ]; then - echo "Appending Selenium options: --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" - SE_OPTS="$SE_OPTS --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" + append_se_opts "--enable-managed-downloads" "${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" fi if [ ! -z "$SE_NODE_ENABLE_CDP" ]; then - echo "Appending Selenium options: --enable-cdp ${SE_NODE_ENABLE_CDP}" - SE_OPTS="$SE_OPTS --enable-cdp ${SE_NODE_ENABLE_CDP}" + append_se_opts "--enable-cdp" "${SE_NODE_ENABLE_CDP}" fi if [ ! -z "$SE_NODE_REGISTER_PERIOD" ]; then - echo "Appending Selenium options: --register-period ${SE_NODE_REGISTER_PERIOD}" - SE_OPTS="$SE_OPTS --register-period ${SE_NODE_REGISTER_PERIOD}" + append_se_opts "--register-period" "${SE_NODE_REGISTER_PERIOD}" fi if [ ! -z "$SE_NODE_REGISTER_CYCLE" ]; then - echo "Appending Selenium options: --register-cycle ${SE_NODE_REGISTER_CYCLE}" - SE_OPTS="$SE_OPTS --register-cycle ${SE_NODE_REGISTER_CYCLE}" + append_se_opts "--register-cycle" "${SE_NODE_REGISTER_CYCLE}" fi if [ ! -z "$SE_NODE_HEARTBEAT_PERIOD" ]; then - echo "Appending Selenium options: --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" - SE_OPTS="$SE_OPTS --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" + append_se_opts "--heartbeat-period" "${SE_NODE_HEARTBEAT_PERIOD}" 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 @@ -99,23 +100,19 @@ 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_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 /opt/bin/generate_config @@ -150,7 +147,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 @@ -159,6 +156,10 @@ CHROME_DRIVER_PATH_PROPERTY=-Dwebdriver.chrome.driver=/usr/bin/chromedriver EDGE_DRIVER_PATH_PROPERTY=-Dwebdriver.edge.driver=/usr/bin/msedgedriver GECKO_DRIVER_PATH_PROPERTY=-Dwebdriver.gecko.driver=/usr/bin/geckodriver +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ ${CHROME_DRIVER_PATH_PROPERTY} \ ${EDGE_DRIVER_PATH_PROPERTY} \ diff --git a/StandaloneDocker/start-selenium-grid-docker.sh b/StandaloneDocker/start-selenium-grid-docker.sh index 573afb664..9b61f4fae 100755 --- a/StandaloneDocker/start-selenium-grid-docker.sh +++ b/StandaloneDocker/start-selenium-grid-docker.sh @@ -5,9 +5,22 @@ set -e echo "Starting Selenium Grid Standalone Docker..." -if [ ! -z "$SE_OPTS" ]; then - echo "Appending Selenium options: ${SE_OPTS}" -fi +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}" + 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_NODE_GRID_URL" ]; then echo "Appending Grid url: ${SE_NODE_GRID_URL}" @@ -15,48 +28,39 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then fi if [ ! -z "$SE_NODE_ENABLE_MANAGED_DOWNLOADS" ]; then - echo "Appending Selenium options: --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" - SE_OPTS="$SE_OPTS --enable-managed-downloads ${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" + append_se_opts "--enable-managed-downloads" "${SE_NODE_ENABLE_MANAGED_DOWNLOADS}" fi if [ ! -z "$SE_NODE_ENABLE_CDP" ]; then - echo "Appending Selenium options: --enable-cdp ${SE_NODE_ENABLE_CDP}" - SE_OPTS="$SE_OPTS --enable-cdp ${SE_NODE_ENABLE_CDP}" + append_se_opts "--enable-cdp" "${SE_NODE_ENABLE_CDP}" fi if [ ! -z "$SE_NODE_REGISTER_PERIOD" ]; then - echo "Appending Selenium options: --register-period ${SE_NODE_REGISTER_PERIOD}" - SE_OPTS="$SE_OPTS --register-period ${SE_NODE_REGISTER_PERIOD}" + append_se_opts "--register-period" "${SE_NODE_REGISTER_PERIOD}" fi if [ ! -z "$SE_NODE_REGISTER_CYCLE" ]; then - echo "Appending Selenium options: --register-cycle ${SE_NODE_REGISTER_CYCLE}" - SE_OPTS="$SE_OPTS --register-cycle ${SE_NODE_REGISTER_CYCLE}" + append_se_opts "--register-cycle" "${SE_NODE_REGISTER_CYCLE}" fi if [ ! -z "$SE_NODE_HEARTBEAT_PERIOD" ]; then - echo "Appending Selenium options: --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" - SE_OPTS="$SE_OPTS --heartbeat-period ${SE_NODE_HEARTBEAT_PERIOD}" + append_se_opts "--heartbeat-period" "${SE_NODE_HEARTBEAT_PERIOD}" 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 @@ -77,12 +81,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 @@ -111,11 +113,15 @@ 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 +if [ ! -z "$SE_OPTS" ]; then + echo "All Selenium options: ${SE_OPTS}" +fi + java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ -jar /opt/selenium/selenium-server.jar \ ${EXTRA_LIBS} standalone \