Skip to content

Commit a369379

Browse files
committed
test(docker): CI tests use case parallel execution
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
1 parent 0571fe7 commit a369379

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

.github/workflows/test-video.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ concurrency:
44

55
on:
66
workflow_dispatch:
7+
inputs:
8+
request-timeout:
9+
description: 'Test parameter for different request timeout'
10+
required: false
11+
default: '400'
12+
parallel-hardening:
13+
description: 'Test parameter to enable hardening parallel tests'
14+
required: false
15+
default: 'true'
16+
log-level:
17+
description: 'Test parameter for different log level'
18+
required: false
19+
default: 'INFO'
720
push:
821
paths-ignore:
922
- '**.md'
@@ -23,7 +36,7 @@ jobs:
2336
strategy:
2437
fail-fast: false
2538
matrix:
26-
test-strategy: [test_video, test_parallel, test_parallel_likely_autoscaling]
39+
test-strategy: [test_video, test_parallel]
2740
steps:
2841
- uses: actions/checkout@main
2942
- name: Output Docker info
@@ -47,6 +60,22 @@ jobs:
4760
run: echo ${BRANCH}
4861
- name: Sets build date
4962
run: echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
63+
- name: Pre-build to reduce logs in test phase
64+
run: |
65+
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make hub
66+
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chrome
67+
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make firefox
68+
VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make edge
69+
- name: Set test parameters
70+
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
71+
run: |
72+
echo "LOG_LEVEL=${LOG_LEVEL}" >> $GITHUB_ENV
73+
echo "TEST_PARALLEL_HARDENING=${TEST_PARALLEL_HARDENING}" >> $GITHUB_ENV
74+
echo "REQUEST_TIMEOUT=${REQUEST_TIMEOUT}" >> $GITHUB_ENV
75+
env:
76+
LOG_LEVEL: ${{ github.event.inputs.log-level || 'INFO' }}
77+
TEST_PARALLEL_HARDENING: ${{ github.event.inputs.parallel-hardening || 'true' }}
78+
REQUEST_TIMEOUT: ${{ github.event.inputs.request-timeout || '400' }}
5079
- name: Run Docker Compose to ${{ matrix.test-strategy }}
5180
run: USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make ${{ matrix.test-strategy }}
5281
- name: Upload recorded Chrome video

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,17 @@ test_firefox:
382382
test_firefox_standalone:
383383
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneFirefox
384384

385-
test_parallel_likely_autoscaling:
386-
TEST_DRAIN_AFTER_SESSION_COUNT=3 TEST_PARALLEL_HARDENING=false make test_parallel
387-
388385
test_parallel: hub chrome firefox edge
389-
for node in DeploymentAutoscaling ; do \
386+
for node in DeploymentAutoscaling JobAutoscaling ; do \
390387
cd ./tests || true ; \
391388
echo TAG=$(TAG_VERSION) > .env ; \
392389
echo TEST_DRAIN_AFTER_SESSION_COUNT=$(or $(TEST_DRAIN_AFTER_SESSION_COUNT), 0) >> .env ; \
393-
echo TEST_PARALLEL_HARDENING=$(or $(TEST_PARALLEL_HARDENING), "true") >> .env ; \
390+
echo TEST_PARALLEL_HARDENING=$(or $(TEST_PARALLEL_HARDENING), "false") >> .env ; \
391+
echo LOG_LEVEL=$(or $(LOG_LEVEL), "INFO") >> .env ; \
392+
echo REQUEST_TIMEOUT=$(or $(REQUEST_TIMEOUT), 300) >> .env ; \
394393
echo NODE=$$node >> .env ; \
395394
echo UID=$$(id -u) >> .env ; \
396-
docker-compose -f docker-compose-v3-test-parallel.yml up --exit-code-from tests --build ; \
395+
docker-compose -f docker-compose-v3-test-parallel.yml up --no-log-prefix --exit-code-from tests --build ; \
397396
done
398397

399398
# This should run on its own CI job. There is no need to combine it with the other tests.

tests/SeleniumTests/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def run(self, test_classes):
187187
start_times[test] = time.time()
188188
futures.append(executor.submit(test))
189189
tests.append(test)
190+
print(f"Number of tests were added to worker: {len(tests)}")
190191
failed_tests = []
191192
for future, test in zip(concurrent.futures.as_completed(futures), tests):
192193
try:
@@ -220,12 +221,16 @@ def test_parallel_autoscaling(self):
220221
if not TEST_PARALLEL_HARDENING:
221222
runner.run([FirefoxTests, EdgeTests, ChromeTests])
222223
else:
223-
runner.run([FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests])
224+
runner.run([FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,
225+
FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,
226+
FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,])
224227

225228
class JobAutoscalingTests(unittest.TestCase):
226229
def test_parallel_autoscaling(self):
227230
runner = Autoscaling()
228231
if not TEST_PARALLEL_HARDENING:
229232
runner.run([FirefoxTests, EdgeTests, ChromeTests])
230233
else:
231-
runner.run([FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests])
234+
runner.run([FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,
235+
FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,
236+
FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests, FirefoxTests, EdgeTests, ChromeTests,])

tests/charts/make/chart_test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ HELM_COMMAND_SET_IMAGES=" \
9494
--set global.seleniumGrid.logLevel=${LOG_LEVEL} \
9595
"
9696

97+
if [ -n "${SET_MAX_REPLICAS}" ]; then
98+
HELM_COMMAND_SET_IMAGES="${HELM_COMMAND_SET_IMAGES} \
99+
--set autoscaling.scaledOptions.maxReplicaCount=${SET_MAX_REPLICAS} \
100+
"
101+
fi
102+
97103
if [ "${CHART_ENABLE_INGRESS_HOSTNAME}" = "true" ]; then
98104
if [[ ! $(cat /etc/hosts) == *"${HOSTNAME_ADDRESS}"* ]]; then
99105
sudo -- sh -c -e "echo \"$(hostname -i) ${HOSTNAME_ADDRESS}\" >> /etc/hosts"

tests/docker-compose-v3-test-parallel.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
chrome:
77
deploy:
88
mode: replicated
9-
replicas: 5
9+
replicas: 10
1010
image: selenium/node-chrome:${TAG}
1111
user: ${UID}
1212
shm_size: 2gb
@@ -18,11 +18,12 @@ services:
1818
- SE_EVENT_BUS_PUBLISH_PORT=4442
1919
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
2020
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=true
21+
- SE_LOG_LEVEL=${LOG_LEVEL}
2122

2223
firefox:
2324
deploy:
2425
mode: replicated
25-
replicas: 5
26+
replicas: 10
2627
image: selenium/node-firefox:${TAG}
2728
user: ${UID}
2829
shm_size: 2gb
@@ -34,11 +35,12 @@ services:
3435
- SE_EVENT_BUS_PUBLISH_PORT=4442
3536
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
3637
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=true
38+
- SE_LOG_LEVEL=${LOG_LEVEL}
3739

3840
edge:
3941
deploy:
4042
mode: replicated
41-
replicas: 5
43+
replicas: 10
4244
image: selenium/node-edge:${TAG}
4345
user: ${UID}
4446
shm_size: 2gb
@@ -50,6 +52,7 @@ services:
5052
- SE_EVENT_BUS_PUBLISH_PORT=4442
5153
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
5254
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=true
55+
- SE_LOG_LEVEL=${LOG_LEVEL}
5356

5457
selenium-hub:
5558
image: selenium/hub:${TAG}
@@ -59,6 +62,9 @@ services:
5962
- "4442:4442"
6063
- "4443:4443"
6164
- "4444:4444"
65+
environment:
66+
- SE_LOG_LEVEL=${LOG_LEVEL}
67+
- SE_SESSION_REQUEST_TIMEOUT=${REQUEST_TIMEOUT}
6268

6369
tests:
6470
image: docker-selenium-tests:latest

0 commit comments

Comments
 (0)