Skip to content

Commit

Permalink
chart(update): update env vars and health check scripts (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Jul 30, 2024
1 parent 695a397 commit 1f519c6
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 145 deletions.
1 change: 1 addition & 0 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ USER ${SEL_UID}:${SEL_GID}
#======================================
# Boolean value, maps "--bind-host"
ENV SE_BIND_HOST=false \
SE_SERVER_PROTOCOL="http" \
# Boolean value, maps "--reject-unsupported-caps"
SE_REJECT_UNSUPPORTED_CAPS=false \
SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \
Expand Down
12 changes: 6 additions & 6 deletions Hub/start-selenium-grid-hub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
fi

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

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

if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then
Expand Down
4 changes: 2 additions & 2 deletions NodeBase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ ENV LANG_WHICH=${LANG_WHICH} \
#============================
# Some configuration options
#============================
SE_SCREEN_WIDTH=1360 \
SE_SCREEN_HEIGHT=1020 \
SE_SCREEN_WIDTH=1920 \
SE_SCREEN_HEIGHT=1080 \
SE_SCREEN_DEPTH=24 \
SE_SCREEN_DPI=96 \
SE_START_XVFB=true \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ $ docker run -d -p 4444:4444 -e SE_SUB_PATH=/selenium-grid/ --name selenium-hub

### Setting Screen Resolution

By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96.
By default, nodes start with a screen resolution of 1920 x 1080 with a color depth of 24 bits and a dpi of 96.
These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI`
environmental variables when starting the container.

Expand Down
12 changes: 6 additions & 6 deletions Router/start-selenium-grid-router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
fi

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

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

EXTRA_LIBS=""
Expand Down
12 changes: 6 additions & 6 deletions Standalone/start-selenium-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ if [ ! -z "$SE_DISABLE_UI" ]; then
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
fi

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

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

if [ ! -z "$SE_NODE_ENABLE_MANAGED_DOWNLOADS" ]; then
Expand Down
5 changes: 3 additions & 2 deletions Video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ CMD ["/opt/bin/entry_point.sh"]

ENV DISPLAY_NUM=99 \
DISPLAY_CONTAINER_NAME=selenium \
SE_SCREEN_WIDTH=1360 \
SE_SCREEN_HEIGHT=1020 \
SE_SERVER_PROTOCOL="http" \
SE_SCREEN_WIDTH=1920 \
SE_SCREEN_HEIGHT=1080 \
SE_FRAME_RATE=15 \
SE_CODEC=libx264 \
SE_PRESET="-preset ultrafast" \
Expand Down
33 changes: 9 additions & 24 deletions charts/selenium-grid/configs/distributor/distributorProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,27 @@ max_time=3
retry_time=3
probe_name="Probe.${1:-"Liveness"}"
ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"}
ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/selenium"}

if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then
BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@"
fi

if [[ ${SE_SUB_PATH} == */ ]]; then
GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql"
else
GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql"
fi

if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}"
else
GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}"
fi
GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh)

if [ -z "${SE_GRID_GRAPHQL_URL}" ] && [ -n "${SE_HUB_HOST:-${SE_ROUTER_HOST}}" ] && [ -n "${SE_HUB_PORT:-${SE_ROUTER_PORT}}" ]; then
SE_GRID_GRAPHQL_URL="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}"
elif [ -z "${SE_GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, it can be set directly via SE_GRID_GRAPHQL_URL. Bypass the probe checks for now."
if [ -z "${GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now."
exit 0
fi

GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${SE_GRID_GRAPHQL_URL})
GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${GRID_GRAPHQL_URL})

if [ ${GRAPHQL_PRE_CHECK} -ne 200 ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${SE_GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}."
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}."
exit 1
fi

SESSION_QUEUE_SIZE=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionQueueSize } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionQueueSize')
SESSION_QUEUE_SIZE=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionQueueSize } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionQueueSize')

SESSION_COUNT=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query": "{ grid { sessionCount } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionCount')
SESSION_COUNT=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query": "{ grid { sessionCount } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.sessionCount')

MAX_SESSION=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { maxSession } }"}' -s ${SE_GRID_GRAPHQL_URL} | jq -r '.data.grid.maxSession')
MAX_SESSION=$(curl --noproxy "*" --retry ${retry_time} -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { maxSession } }"}' -s ${GRID_GRAPHQL_URL} | jq -r '.data.grid.maxSession')

if [ ${SESSION_QUEUE_SIZE} -gt 0 ] && [ ${SESSION_COUNT} -eq 0 ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Session Queue Size: ${SESSION_QUEUE_SIZE}, Session Count: ${SESSION_COUNT}, Max Session: ${MAX_SESSION}"
Expand Down
33 changes: 33 additions & 0 deletions charts/selenium-grid/configs/node/nodeGridUrl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

max_time=3

if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
grid_url=""
else
if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then
BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@"
fi
if [ "${SE_SUB_PATH}" = "/" ]; then
SE_SUB_PATH=""
fi
grid_url=${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
fi

if [ -z "${grid_url}" ]; then
grid_url="${SE_NODE_GRID_URL}"
fi

if [ -z "${grid_url}" ]; then
return 0
fi

grid_url_checks=$(curl --noproxy "*" -m ${max_time} -s -k -o /dev/null -w "%{http_code}" ${grid_url})
if [ "${grid_url_checks}" = "401" ]; then
return ${grid_url_checks}
fi
if [ "${grid_url_checks}" = "404" ]; then
return ${grid_url_checks}
fi

echo "${grid_url}"
54 changes: 7 additions & 47 deletions charts/selenium-grid/configs/node/nodePreStop.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

probe_name="lifecycle.${1:-"preStop"}"
NODE_CONFIG_DIRECTORY=${NODE_CONFIG_DIRECTORY:-"/opt/selenium"}

max_time=3
retry_time=5
Expand All @@ -26,53 +27,13 @@ else
HEADERS="X-REGISTRATION-SECRET;"
fi

function is_full_distributed_mode() {
if [ -n "${SE_DISTRIBUTOR_HOST}" ] && [ -n "${SE_DISTRIBUTOR_PORT}" ]; then
DISTRIBUTED_MODE=true
echo "$(date +%FT%T%Z) [${probe_name}] - Detected full distributed mode: ${DISTRIBUTED_MODE}. Since SE_DISTRIBUTOR_HOST and SE_DISTRIBUTOR_PORT are set in Node ConfigMap"
else
DISTRIBUTED_MODE=false
echo "$(date +%FT%T%Z) [${probe_name}] - Detected full distributed mode: ${DISTRIBUTED_MODE}"
fi
}
is_full_distributed_mode

function get_grid_url() {
if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB or ROUTER host. preStop ignores to send drain request to upstream."
grid_url=""
fi
if [ -n "${SE_BASIC_AUTH}" ] && [ "${SE_BASIC_AUTH}" != "*@" ]; then
SE_BASIC_AUTH="${SE_BASIC_AUTH}@"
fi
if [ "${SE_SUB_PATH}" = "/" ]; then
SE_SUB_PATH=""
fi
grid_url=${SE_SERVER_PROTOCOL}://${SE_BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
grid_url_checks=$(curl --noproxy "*" -m ${max_time} -s -o /dev/null -w "%{http_code}" ${grid_url})
if [ "${grid_url_checks}" = "401" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Host requires Basic Auth. Please add the credentials to the SE_BASIC_AUTH variable (e.g: user:password). preStop ignores to send drain request to upstream."
grid_url=""
fi
if [ "${grid_url_checks}" = "404" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - The Grid is not available or it might have /subPath configured. Please wait a moment or check the SE_SUB_PATH variable if needed."
fi
}

function signal_distributor_to_drain_node() {
if [ "${DISTRIBUTED_MODE}" = true ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Distributor to drain node"
curl --noproxy "*" -m ${max_time} -k -X POST ${SE_SERVER_PROTOCOL}://${SE_DISTRIBUTOR_HOST}:${SE_DISTRIBUTOR_PORT}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
fi
}

function signal_hub_to_drain_node() {
if [ "${DISTRIBUTED_MODE}" = false ]; then
get_grid_url
if [ -n "${grid_url}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub to drain node"
curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
fi
grid_url=$(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh)
if [ -n "${grid_url}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Signaling Hub/Router to drain node"
curl --noproxy "*" -m ${max_time} -k -X POST ${grid_url}/se/grid/distributor/node/${NODE_ID}/drain --header "${HEADERS}"
else
echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB/ROUTER host or SE_NODE_GRID_URL isn't set. preStop ignores to send drain request to upstream."
fi
}

Expand All @@ -85,7 +46,6 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE
NODE_ID=$(jq -r '.value.node.nodeId' ${tmp_node_file} || "")
if [ -n "${NODE_ID}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Current Node ID is: ${NODE_ID}"
signal_distributor_to_drain_node
signal_hub_to_drain_node
echo
fi
Expand Down
28 changes: 2 additions & 26 deletions charts/selenium-grid/configs/node/nodeProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

max_time=3
probe_name="Probe.${1:-"Startup"}"
NODE_CONFIG_DIRECTORY=${NODE_CONFIG_DIRECTORY:-"/opt/selenium"}

ID=$(echo $RANDOM)
tmp_node_file="/tmp/nodeProbe${ID}"
Expand All @@ -23,31 +24,6 @@ function help_message() {
echo "$(date +%FT%T%Z) [${probe_name}] - If you believe Node is registered successfully but probe still report this message and fail for a long time. Workaround by set 'global.seleniumGrid.defaultNodeStartupProbe' to 'httpGet' and report us an issue for Chart improvement with your scenario."
}

function get_grid_url() {
if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - There is no configured HUB or ROUTER host. Probe ignores the registration checks on upstream."
exit 0
fi
if [[ -n "${SE_BASIC_AUTH}" && "${SE_BASIC_AUTH}" != *@ ]]; then
SE_BASIC_AUTH="${SE_BASIC_AUTH}@"
fi
if [ "${SE_SUB_PATH}" = "/" ]; then
SE_SUB_PATH=""
fi
grid_url=${SE_SERVER_PROTOCOL}://${SE_BASIC_AUTH}${SE_HUB_HOST:-$SE_ROUTER_HOST}:${SE_HUB_PORT:-$SE_ROUTER_PORT}${SE_SUB_PATH}
grid_url_checks=$(curl --noproxy "*" -m ${max_time} -skf -o /dev/null -w "%{http_code}" ${grid_url})
if [ "${grid_url_checks}" = "401" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - Host requires Basic Auth. Please add the credentials to the SE_BASIC_AUTH variable (e.g: user:password)."
help_message
exit 1
fi
if [ "${grid_url_checks}" = "404" ]; then
echo "$(date +%FT%T%Z) [${probe_name}] - The Grid is not available or it might have /subPath configured. Please wait a moment or check the SE_SUB_PATH variable if needed."
help_message
exit 1
fi
}

if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE_NODE_PORT}/status -o ${tmp_node_file}; then
NODE_ID=$(jq -r '.value.node.nodeId' ${tmp_node_file} || "")
NODE_STATUS=$(jq -r '.value.node.availability' ${tmp_node_file} || "")
Expand All @@ -58,7 +34,7 @@ if curl --noproxy "*" -m ${max_time} -sfk ${SE_SERVER_PROTOCOL}://127.0.0.1:${SE
exit 1
fi

get_grid_url
grid_url=$(bash ${NODE_CONFIG_DIRECTORY}/nodeGridUrl.sh)

curl --noproxy "*" -m ${max_time} -sfk "${grid_url}/status" -o ${tmp_grid_file}
GRID_NODE_ID=$(jq -e ".value.nodes[].id|select(. == \"${NODE_ID}\")" ${tmp_grid_file} | tr -d '"' || "")
Expand Down
25 changes: 25 additions & 0 deletions charts/selenium-grid/configs/router/routerGraphQLUrl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if [ -z "${SE_HUB_HOST:-$SE_ROUTER_HOST}" ] || [ -z "${SE_HUB_PORT:-$SE_ROUTER_PORT}" ]; then
graphql_url=""
else
if [ -n "${SE_ROUTER_USERNAME}" ] && [ -n "${SE_ROUTER_PASSWORD}" ]; then
BASIC_AUTH="${SE_ROUTER_USERNAME}:${SE_ROUTER_PASSWORD}@"
fi

if [[ ${SE_SUB_PATH} == */ ]]; then
GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql"
else
GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql"
fi

if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}"
else
GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}"
fi

graphql_url="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}"
fi

echo "${graphql_url}"
27 changes: 6 additions & 21 deletions charts/selenium-grid/configs/router/routerProbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,19 @@ max_time=3
retry_time=3
probe_name="Probe.${1:-"Liveness"}"
ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"+%T.%3N"}
ROUTER_CONFIG_DIRECTORY=${ROUTER_CONFIG_DIRECTORY:-"/opt/selenium"}

if [ -n "${ROUTER_USERNAME}" ] && [ -n "${ROUTER_PASSWORD}" ]; then
BASIC_AUTH="${ROUTER_USERNAME}:${ROUTER_PASSWORD}@"
fi

if [[ ${SE_SUB_PATH} == */ ]]; then
GRAPHQL_ENDPOINT="${SE_SUB_PATH}graphql"
else
GRAPHQL_ENDPOINT="${SE_SUB_PATH}/graphql"
fi

if [[ ${GRAPHQL_ENDPOINT} == /* ]]; then
GRAPHQL_ENDPOINT="${GRAPHQL_ENDPOINT}"
else
GRAPHQL_ENDPOINT="/${GRAPHQL_ENDPOINT}"
fi
GRID_GRAPHQL_URL=$(bash ${ROUTER_CONFIG_DIRECTORY}/routerGraphQLUrl.sh)

if [ -z "${SE_GRID_GRAPHQL_URL}" ] && [ -n "${SE_HUB_HOST:-${SE_ROUTER_HOST}}" ] && [ -n "${SE_HUB_PORT:-${SE_ROUTER_PORT}}" ]; then
SE_GRID_GRAPHQL_URL="${SE_SERVER_PROTOCOL}://${BASIC_AUTH}${SE_HUB_HOST:-${SE_ROUTER_HOST}}:${SE_HUB_PORT:-${SE_ROUTER_PORT}}${GRAPHQL_ENDPOINT}"
elif [ -z "${SE_GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, it can be set directly via SE_GRID_GRAPHQL_URL. Bypass the probe checks for now."
if [ -z "${GRID_GRAPHQL_URL}" ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - Could not construct GraphQL endpoint, please provide SE_HUB_HOST (or SE_ROUTER_HOST) and SE_HUB_PORT (or SE_ROUTER_PORT). Bypass the probe checks for now."
exit 0
fi

GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${SE_GRID_GRAPHQL_URL})
GRAPHQL_PRE_CHECK=$(curl --noproxy "*" -m ${max_time} -k -X POST -H "Content-Type: application/json" --data '{"query":"{ grid { sessionCount } }"}' -s -o /dev/null -w "%{http_code}" ${GRID_GRAPHQL_URL})

if [ ${GRAPHQL_PRE_CHECK} -ne 200 ]; then
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint ${SE_GRID_GRAPHQL_URL} is not reachable. Status code: ${GRAPHQL_PRE_CHECK}."
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint is not reachable. Status code: ${GRAPHQL_PRE_CHECK}."
exit 1
else
echo "$(date ${ts_format}) DEBUG [${probe_name}] - GraphQL endpoint is healthy."
Expand Down
1 change: 0 additions & 1 deletion charts/selenium-grid/templates/distributor-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
SE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" $ }}'
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.distributorConfigMap.extraScriptsImportFrom }}
{{- $fileName := base $path -}}
Expand Down
Loading

0 comments on commit 1f519c6

Please sign in to comment.