Skip to content

Commit

Permalink
[test]: fix node relay tests (#2269)
Browse files Browse the repository at this point in the history
[deploy]

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed May 22, 2024
1 parent 8355bd9 commit 8fa9113
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 59 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@main
- name: Set up containerd image store feature
if: matrix.test-strategy != 'test_node_relay'
uses: nick-invision/retry@master
with:
timeout_minutes: 10
Expand Down
4 changes: 2 additions & 2 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ARG VERSION
ARG RELEASE=selenium-${VERSION}
ARG AUTHORS=SeleniumHQ
# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/java/maven_deps.bzl)
ARG OPENTELEMETRY_VERSION=1.36.0
ARG GRPC_VERSION=1.62.2
ARG OPENTELEMETRY_VERSION=1.38.0
ARG GRPC_VERSION=1.64.0
ARG CS_VERSION=2.1.10

#Arguments to define the user running Selenium
Expand Down
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ test_parallel: hub chrome firefox edge chromium
echo NODE_CHROME=chromium >> .env ; \
fi; \
echo TEST_PLATFORMS=$(PLATFORMS) >> .env ; \
docker compose --profile $(PLATFORMS) -f docker-compose-v3-test-parallel.yml up --no-log-prefix --exit-code-from tests ; \
DOCKER_DEFAULT_PLATFORM=$(PLATFORMS) docker compose --profile $(PLATFORMS) -f docker-compose-v3-test-parallel.yml up --no-log-prefix --exit-code-from tests ; \
done

test_video_dynamic_name:
Expand All @@ -578,7 +578,6 @@ test_video_dynamic_name:
# This should run on its own CI job. There is no need to combine it with the other tests.
# Its main purpose is to check that a video file was generated.
test_video: video hub chrome firefox edge chromium
# Running a few tests with docker compose to generate the videos
sudo rm -rf ./tests/tests
sudo rm -rf ./tests/videos; mkdir -p ./tests/videos
if [ "$(PLATFORMS)" = "linux/amd64" ]; then \
Expand Down Expand Up @@ -614,12 +613,12 @@ test_video: video hub chrome firefox edge chromium
echo VIDEO_FILE_NAME=$${VIDEO_FILE_NAME:-"firefox_video.mp4"} >> .env ; \
echo VIDEO_FILE_NAME_SUFFIX=$${VIDEO_FILE_NAME_SUFFIX:-"true"} >> .env ; \
fi ; \
docker compose -f docker-compose-v3-test-video.yml up --abort-on-container-exit ; \
DOCKER_DEFAULT_PLATFORM=$(PLATFORMS) docker compose -f docker-compose-v3-test-video.yml up --abort-on-container-exit ; \
done
make test_video_integrity

test_node_relay: hub node_base standalone_firefox
sudo rm -rf ./tests/tests
sudo rm -rf ./tests/tests ./tests/videos; mkdir -p ./tests/videos ; \
if [ "$(PLATFORMS)" = "linux/amd64" ]; then \
list_nodes="Android NodeFirefox" ; \
else \
Expand All @@ -641,24 +640,29 @@ test_node_relay: hub node_base standalone_firefox
echo TEST_NODE_RELAY=$$node >> .env ; \
echo UID=$$(id -u) >> .env ; \
echo BINDING_VERSION=$(BINDING_VERSION) >> .env ; \
PROFILE="relay_standalone" ; \
if [ $$node = "Android" ] ; then \
echo BROWSER=firefox >> .env && \
PROFILE="relay_appium" ; \
echo BROWSER=firefox >> .env \
&& echo BROWSER_NAME=firefox >> .env ; \
fi ; \
if [ $$node = "NodeChrome" ] ; then \
echo BROWSER=chrome >> .env ; \
echo BROWSER=chrome >> .env \
&& BROWSER_NAMEchrome >> .env ; \
fi ; \
if [ $$node = "NodeChromium" ] ; then \
echo BROWSER=chromium >> .env ; \
echo BROWSER=chromium >> .env \
&& echo BROWSER_NAME=chrome >> .env ; \
fi ; \
if [ $$node = "NodeEdge" ] ; then \
echo BROWSER=edge >> .env ; \
echo BROWSER=edge >> .env \
&& echo BROWSER_NAME=MicrosoftEdge >> .env ; \
fi ; \
if [ $$node = "NodeFirefox" ] ; then \
echo BROWSER=firefox >> .env ; \
echo BROWSER=firefox >> .env \
&& echo BROWSER_NAME=firefox >> .env ; \
fi ; \
docker compose --profile $${PROFILE} -f docker-compose-v3-test-node-relay.yml up --no-log-prefix --exit-code-from tests ; \
export $$(cat .env | xargs) ; \
envsubst < relay_config.toml > ./videos/relay_config.toml ; \
DOCKER_DEFAULT_PLATFORM=$(PLATFORMS) docker compose --profile $$node -f docker-compose-v3-test-node-relay.yml up --no-log-prefix --exit-code-from tests ; \
if [ $$? -ne 0 ]; then exit 1; fi ; \
done

Expand Down Expand Up @@ -701,7 +705,7 @@ test_node_docker: hub standalone_docker standalone_chrome standalone_firefox sta
fi ; \
export $$(cat .env | xargs) ; \
envsubst < config.toml > ./videos/config.toml ; \
docker compose -f docker-compose-v3-test-node-docker.yaml up --no-log-prefix --exit-code-from tests ; \
DOCKER_DEFAULT_PLATFORM=$(PLATFORMS) docker compose -f docker-compose-v3-test-node-docker.yaml up --no-log-prefix --exit-code-from tests ; \
if [ $$? -ne 0 ]; then exit 1; fi ; \
if [ -d "$$DOWNLOADS_DIR" ] && [ $$(ls -1q $$DOWNLOADS_DIR | wc -l) -eq 0 ]; then \
echo "Mounted downloads directory is empty. Downloaded files could not be retrieved!" ; \
Expand Down
70 changes: 30 additions & 40 deletions tests/docker-compose-v3-test-node-relay.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
version: "3"
services:
node-relay-emulator:
profiles:
- relay_appium
image: ${NAMESPACE}/node-base:${TAG}
container_name: node-relay-emulator
shm_size: 2gb
depends_on:
- selenium-hub
- appium-emulator
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_LOG_LEVEL=${LOG_LEVEL}
- SE_NODE_SESSION_TIMEOUT=${SESSION_TIMEOUT}
- SE_NODE_RELAY_URL=http://appium-emulator:4723
- SE_NODE_RELAY_PROTOCOL_VERSION=HTTP/1.1
- SE_NODE_RELAY_MAX_SESSIONS=1
- SE_NODE_RELAY_PLATFORM_NAME=Android
- SE_NODE_RELAY_PLATFORM_VERSION=${ANDROID_PLATFORM_API}
- SE_NODE_RELAY_BROWSER_NAME=chrome
- SE_NODE_RELAY_WEB_VNC=ws://appium-emulator:6080/websockify

node-relay-standalone:
image: ${NAMESPACE}/node-base:${TAG}
container_name: node-relay-standalone
shm_size: 2gb
depends_on:
- selenium-hub
- standalone-receiver
- standalone
volumes:
- ./relay_config.toml:/opt/selenium/config.toml
- ./videos/relay_config.toml:/opt/selenium/config.toml
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_LOG_LEVEL=${LOG_LEVEL}
- GENERATE_CONFIG=false

standalone:
image: ${NAMESPACE}/standalone-${BROWSER}:${TAG}
shm_size: 2gb

selenium-hub:
image: ${NAMESPACE}/hub:${TAG}
container_name: selenium-hub
environment:
- SE_LOG_LEVEL=${LOG_LEVEL}
- SE_SESSION_REQUEST_TIMEOUT=${REQUEST_TIMEOUT}
Expand All @@ -51,7 +29,7 @@ services:
- "4444:4444"

tests:
image: docker-selenium-tests:latest
image: docker-selenium-tests:${TAG}
build:
context: ./
dockerfile: ./Dockerfile
Expand All @@ -67,16 +45,32 @@ services:
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
command: ["./bootstrap.sh", "${NODE}"]

standalone-receiver:
image: ${NAMESPACE}/standalone-${BROWSER}:${TAG}
node-relay-emulator:
profiles:
- Android
image: ${NAMESPACE}/node-base:${TAG}
shm_size: 2gb
container_name: standalone-receiver
depends_on:
- selenium-hub
- emulator
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_LOG_LEVEL=${LOG_LEVEL}
- SE_NODE_SESSION_TIMEOUT=${SESSION_TIMEOUT}
- SE_NODE_RELAY_URL=http://emulator:4723
- SE_NODE_RELAY_PROTOCOL_VERSION=HTTP/1.1
- SE_NODE_RELAY_MAX_SESSIONS=1
- SE_NODE_RELAY_PLATFORM_NAME=Android
- SE_NODE_RELAY_PLATFORM_VERSION=${ANDROID_PLATFORM_API}
- SE_NODE_RELAY_BROWSER_NAME=chrome
- SE_NODE_RELAY_WEB_VNC=ws://emulator:6080/websockify

appium-emulator:
emulator:
profiles:
- relay_appium
platform: linux/amd64
image: ${ANDROID_BASED_NAME}/${ANDROID_BASED_IMAGE}:latest
- Android
image: ${ANDROID_BASED_NAME}/${ANDROID_BASED_IMAGE}:${TAG}
shm_size: 2gb
build:
args:
Expand All @@ -85,7 +79,6 @@ services:
ANDROID_BASED_TAG: ${ANDROID_BASED_TAG}
CHROME_DRIVER_URL: https://chromedriver.storage.googleapis.com/113.0.5672.63/chromedriver_linux64.zip
dockerfile: ./Dockerfile.emulator
container_name: appium-emulator
environment:
- EMULATOR_DEVICE=Nexus 5
- WEB_VNC=true
Expand All @@ -96,6 +89,3 @@ services:
- EMULATOR_NAME=emulator-5554
devices:
- /dev/kvm
ports:
- "6080:6080"
- "4723:4723"
6 changes: 2 additions & 4 deletions tests/relay_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ drain-after-session-count = 0
max-sessions = 1

[relay]
url = "http://standalone-receiver:4444/wd/hub"
url = "http://standalone:4444/wd/hub"
status-endpoint = "/status"
configs = [
'1', '{"browserName":"firefox","platformName":"linux"}',
'1', '{"browserName":"chrome","platformName":"linux"}',
'1', '{"browserName":"MicrosoftEdge","platformName":"linux"}'
'1', '{"browserName":"${BROWSER_NAME}","platformName":"linux"}'
]

0 comments on commit 8fa9113

Please sign in to comment.