Skip to content

Commit 706aa62

Browse files
committed
fix: Conflict CLI options from SE_OPTS and corresponding env variables
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent fdc9fe2 commit 706aa62

27 files changed

+231
-155
lines changed

.circleci/config.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,25 @@ jobs:
147147
echo 'export BRANCH="${CIRCLE_BRANCH//\//-}"' >> $BASH_ENV
148148
cat $BASH_ENV
149149
source $BASH_ENV
150+
- checkout
151+
- run:
152+
name: "Setup environment"
153+
command: |
154+
make chart_setup_env
155+
make set_containerd_image_store
150156
- run:
151157
name: "Print system info"
152158
command: |
153159
uname -a
154160
docker info
155-
- checkout
156161
- run:
157162
name: "Build Docker images"
158163
command: |
159164
N=3
160165
while [ $N -gt 0 ]; do
161-
PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build || true
162-
if [ $? -eq 0 ]; then
166+
output=$(eval "PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build")
167+
status=$?
168+
if [ $status -eq 0 ]; then
163169
echo "Build images passed"
164170
exit 0
165171
else
@@ -174,8 +180,9 @@ jobs:
174180
command: |
175181
N=3
176182
while [ $N -gt 0 ]; do
177-
USE_RANDOM_USER_ID=${USE_RANDOM_USER} PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${TEST_STRATEGY} || true
178-
if [ $? -eq 0 ]; then
183+
output=$(eval "USE_RANDOM_USER_ID=${USE_RANDOM_USER} PLATFORMS=${PLATFORMS} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${TEST_STRATEGY}")
184+
status=$?
185+
if [ $status -eq 0 ]; then
179186
echo "Tests passed"
180187
exit 0
181188
else

Distributor/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG NAMESPACE
2-
ARG VERSION
1+
ARG NAMESPACE=selenium
2+
ARG VERSION=latest
33
FROM ${NAMESPACE}/base:${VERSION}
44
ARG AUTHORS
55
LABEL authors=${AUTHORS}

Distributor/start-selenium-grid-distributor.sh

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ set -e
55

66
echo "Starting Selenium Grid Distributor..."
77

8+
function append_se_opts() {
9+
local option="${1}"
10+
local value="${2:-""}"
11+
local log_message="${3:-true}"
12+
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
13+
if [ "${log_message}" = "true" ]; then
14+
echo "Appending Selenium option: ${option} ${value}"
15+
else
16+
echo "Appending Selenium option: ${option} $(mask ${value})"
17+
fi
18+
SE_OPTS="${SE_OPTS} ${option}"
19+
if [ ! -z "${value}" ]; then
20+
SE_OPTS="${SE_OPTS} ${value}"
21+
fi
22+
else
23+
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
24+
fi
25+
}
26+
827
if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then
928
echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2
1029
exit 1
@@ -55,23 +74,19 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then
5574
fi
5675

5776
if [ ! -z "$SE_LOG_LEVEL" ]; then
58-
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
59-
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
77+
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
6078
fi
6179

6280
if [ ! -z "$SE_HTTP_LOGS" ]; then
63-
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
64-
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
81+
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
6582
fi
6683

6784
if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
68-
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
69-
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
85+
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
7086
fi
7187

7288
if [ ! -z "$SE_EXTERNAL_URL" ]; then
73-
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
74-
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
89+
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
7590
fi
7691

7792
if [ "${SE_ENABLE_TLS}" = "true" ]; then
@@ -92,28 +107,23 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
92107
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
93108
# Configure certificate and private key for component communication
94109
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
95-
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
96-
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
110+
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
97111
fi
98112
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
99-
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
100-
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
113+
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
101114
fi
102115
fi
103116

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

109121
if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then
110-
echo "Appending Selenium options: --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
111-
SE_OPTS="$SE_OPTS --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
122+
append_se_opts "--reject-unsupported-caps" "${SE_REJECT_UNSUPPORTED_CAPS}"
112123
fi
113124

114125
if [ ! -z "$SE_NEW_SESSION_THREAD_POOL_SIZE" ]; then
115-
echo "Appending Selenium options: --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
116-
SE_OPTS="$SE_OPTS --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
126+
append_se_opts "--newsession-threadpool-size" "${SE_NEW_SESSION_THREAD_POOL_SIZE}"
117127
fi
118128

119129
EXTRA_LIBS=""
@@ -141,7 +151,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
141151
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
142152
fi
143153
else
144-
SE_OPTS="$SE_OPTS --tracing false"
154+
append_se_opts "--tracing" "false"
145155
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
146156
echo "Tracing is disabled"
147157
fi

EventBus/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG NAMESPACE
2-
ARG VERSION
1+
ARG NAMESPACE=selenium
2+
ARG VERSION=latest
33
FROM ${NAMESPACE}/base:${VERSION}
44
ARG AUTHORS
55
LABEL authors=${AUTHORS}

EventBus/start-selenium-grid-eventbus.sh

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ set -e
55

66
echo "Starting Selenium Grid EventBus..."
77

8+
function append_se_opts() {
9+
local option="${1}"
10+
local value="${2:-""}"
11+
local log_message="${3:-true}"
12+
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
13+
if [ "${log_message}" = "true" ]; then
14+
echo "Appending Selenium option: ${option} ${value}"
15+
else
16+
echo "Appending Selenium option: ${option} $(mask ${value})"
17+
fi
18+
SE_OPTS="${SE_OPTS} ${option}"
19+
if [ ! -z "${value}" ]; then
20+
SE_OPTS="${SE_OPTS} ${value}"
21+
fi
22+
else
23+
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
24+
fi
25+
}
26+
827
if [ ! -z "$SE_EVENT_BUS_HOST" ]; then
928
echo "Using SE_EVENT_BUS_HOST: ${SE_EVENT_BUS_HOST}"
1029
HOST_CONFIG="--host ${SE_EVENT_BUS_HOST}"
@@ -20,23 +39,19 @@ if [ ! -z "$SE_OPTS" ]; then
2039
fi
2140

2241
if [ ! -z "$SE_LOG_LEVEL" ]; then
23-
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
24-
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
42+
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
2543
fi
2644

2745
if [ ! -z "$SE_HTTP_LOGS" ]; then
28-
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
29-
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
46+
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
3047
fi
3148

3249
if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
33-
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
34-
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
50+
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
3551
fi
3652

3753
if [ ! -z "$SE_EXTERNAL_URL" ]; then
38-
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
39-
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
54+
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
4055
fi
4156

4257
if [ "${SE_ENABLE_TLS}" = "true" ]; then
@@ -57,12 +72,10 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
5772
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
5873
# Configure certificate and private key for component communication
5974
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
60-
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
61-
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
75+
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
6276
fi
6377
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
64-
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
65-
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
78+
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
6679
fi
6780
fi
6881

@@ -91,7 +104,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
91104
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
92105
fi
93106
else
94-
SE_OPTS="$SE_OPTS --tracing false"
107+
append_se_opts "--tracing" "false"
95108
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
96109
echo "Tracing is disabled"
97110
fi

Hub/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG NAMESPACE
2-
ARG VERSION
1+
ARG NAMESPACE=selenium
2+
ARG VERSION=latest
33
FROM ${NAMESPACE}/base:${VERSION}
44
ARG AUTHORS
55
LABEL authors=${AUTHORS}

Hub/start-selenium-grid-hub.sh

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
# set -e: exit asap if a command exits with a non-zero status
44
set -e
55

6+
echo "Starting Selenium Grid Hub..."
7+
8+
function append_se_opts() {
9+
local option="${1}"
10+
local value="${2:-""}"
11+
local log_message="${3:-true}"
12+
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
13+
if [ "${log_message}" = "true" ]; then
14+
echo "Appending Selenium option: ${option} ${value}"
15+
else
16+
echo "Appending Selenium option: ${option} $(mask ${value})"
17+
fi
18+
SE_OPTS="${SE_OPTS} ${option}"
19+
if [ ! -z "${value}" ]; then
20+
SE_OPTS="${SE_OPTS} ${value}"
21+
fi
22+
else
23+
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"
24+
fi
25+
}
26+
627
if [ ! -z "$SE_OPTS" ]; then
728
echo "Appending Selenium options: ${SE_OPTS}"
829
fi
@@ -23,23 +44,19 @@ if [ ! -z "$SE_SUB_PATH" ]; then
2344
fi
2445

2546
if [ ! -z "$SE_LOG_LEVEL" ]; then
26-
echo "Appending Selenium options: --log-level ${SE_LOG_LEVEL}"
27-
SE_OPTS="$SE_OPTS --log-level ${SE_LOG_LEVEL}"
47+
append_se_opts "--log-level" "${SE_LOG_LEVEL}"
2848
fi
2949

3050
if [ ! -z "$SE_HTTP_LOGS" ]; then
31-
echo "Appending Selenium options: --http-logs ${SE_HTTP_LOGS}"
32-
SE_OPTS="$SE_OPTS --http-logs ${SE_HTTP_LOGS}"
51+
append_se_opts "--http-logs" "${SE_HTTP_LOGS}"
3352
fi
3453

3554
if [ ! -z "$SE_STRUCTURED_LOGS" ]; then
36-
echo "Appending Selenium options: --structured-logs ${SE_STRUCTURED_LOGS}"
37-
SE_OPTS="$SE_OPTS --structured-logs ${SE_STRUCTURED_LOGS}"
55+
append_se_opts "--structured-logs" "${SE_STRUCTURED_LOGS}"
3856
fi
3957

4058
if [ ! -z "$SE_EXTERNAL_URL" ]; then
41-
echo "Appending Selenium options: --external-url ${SE_EXTERNAL_URL}"
42-
SE_OPTS="$SE_OPTS --external-url ${SE_EXTERNAL_URL}"
59+
append_se_opts "--external-url" "${SE_EXTERNAL_URL}"
4360
fi
4461

4562
if [ "${SE_ENABLE_TLS}" = "true" ]; then
@@ -60,43 +77,35 @@ if [ "${SE_ENABLE_TLS}" = "true" ]; then
6077
SE_JAVA_OPTS="$SE_JAVA_OPTS -Djdk.internal.httpclient.disableHostnameVerification=${SE_JAVA_DISABLE_HOSTNAME_VERIFICATION}"
6178
# Configure certificate and private key for component communication
6279
if [ ! -z "$SE_HTTPS_CERTIFICATE" ]; then
63-
echo "Appending Selenium options: --https-certificate ${SE_HTTPS_CERTIFICATE}"
64-
SE_OPTS="$SE_OPTS --https-certificate ${SE_HTTPS_CERTIFICATE}"
80+
append_se_opts "--https-certificate" "${SE_HTTPS_CERTIFICATE}"
6581
fi
6682
if [ ! -z "$SE_HTTPS_PRIVATE_KEY" ]; then
67-
echo "Appending Selenium options: --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
68-
SE_OPTS="$SE_OPTS --https-private-key ${SE_HTTPS_PRIVATE_KEY}"
83+
append_se_opts "--https-private-key" "${SE_HTTPS_PRIVATE_KEY}"
6984
fi
7085
fi
7186

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

7791
if [ ! -z "$SE_DISABLE_UI" ]; then
78-
echo "Appending Selenium options: --disable-ui ${SE_DISABLE_UI}"
79-
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
92+
append_se_opts "--disable-ui" "${SE_DISABLE_UI}"
8093
fi
8194

8295
if [ ! -z "$SE_ROUTER_USERNAME" ]; then
83-
echo "Appending Selenium options: --username ${SE_ROUTER_USERNAME}"
84-
SE_OPTS="$SE_OPTS --username ${SE_ROUTER_USERNAME}"
96+
append_se_opts "--username" "${SE_ROUTER_USERNAME}" "false"
8597
fi
8698

8799
if [ ! -z "$SE_ROUTER_PASSWORD" ]; then
88-
echo "Appending Selenium options: --password $(mask ${SE_ROUTER_PASSWORD})"
89-
SE_OPTS="$SE_OPTS --password ${SE_ROUTER_PASSWORD}"
100+
append_se_opts "--password" "${SE_ROUTER_PASSWORD}" "false"
90101
fi
91102

92103
if [ ! -z "$SE_REJECT_UNSUPPORTED_CAPS" ]; then
93-
echo "Appending Selenium options: --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
94-
SE_OPTS="$SE_OPTS --reject-unsupported-caps ${SE_REJECT_UNSUPPORTED_CAPS}"
104+
append_se_opts "--reject-unsupported-caps" "${SE_REJECT_UNSUPPORTED_CAPS}"
95105
fi
96106

97107
if [ ! -z "$SE_NEW_SESSION_THREAD_POOL_SIZE" ]; then
98-
echo "Appending Selenium options: --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
99-
SE_OPTS="$SE_OPTS --newsession-threadpool-size ${SE_NEW_SESSION_THREAD_POOL_SIZE}"
108+
append_se_opts "--newsession-threadpool-size" "${SE_NEW_SESSION_THREAD_POOL_SIZE}"
100109
fi
101110

102111
EXTRA_LIBS=""
@@ -124,7 +133,7 @@ if [ "$SE_ENABLE_TRACING" = "true" ]; then
124133
SE_JAVA_OPTS="$SE_JAVA_OPTS ${SE_OTEL_JVM_ARGS}"
125134
fi
126135
else
127-
SE_OPTS="$SE_OPTS --tracing false"
136+
append_se_opts "--tracing" "false"
128137
SE_JAVA_OPTS="$SE_JAVA_OPTS -Dwebdriver.remote.enableTracing=false"
129138
echo "Tracing is disabled"
130139
fi

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ test_video: video hub chrome firefox edge chromium
608608
if [ "$(PLATFORMS)" = "linux/amd64" ]; then \
609609
list_nodes="$${list_of_tests_amd64}" ; \
610610
else \
611-
list_nodes="${list_of_tests_arm64}" ; \
611+
list_nodes="$${list_of_tests_arm64}" ; \
612612
fi; \
613613
for node in $${list_nodes}; do \
614614
cd ./tests || true ; \

NodeBase/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG NAMESPACE
2-
ARG VERSION
1+
ARG NAMESPACE=selenium
2+
ARG VERSION=latest
33
FROM ${NAMESPACE}/base:${VERSION}
44
ARG AUTHORS
55
LABEL authors=${AUTHORS}

NodeBase/start-selenium-node.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ function append_se_opts() {
1818
local log_message="${3:-true}"
1919
if [[ "${SE_OPTS}" != *"${option}"* ]]; then
2020
if [ "${log_message}" = "true" ]; then
21-
echo "Appending Selenium option: ${option} ${value}"
21+
echo "Appending Selenium option: ${option} ${value}"
2222
else
23-
echo "Appending Selenium option: ${option} $(mask ${value})"
23+
echo "Appending Selenium option: ${option} $(mask ${value})"
2424
fi
2525
SE_OPTS="${SE_OPTS} ${option}"
2626
if [ ! -z "${value}" ]; then
27-
SE_OPTS="${SE_OPTS} ${value}"
27+
SE_OPTS="${SE_OPTS} ${value}"
2828
fi
2929
else
3030
echo "Selenium option: ${option} already set in env variable SE_OPTS. Ignore new option: ${option} ${value}"

0 commit comments

Comments
 (0)