Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
[test][dynamic-grid]: share node-docker volume mappings for generated…
Browse files Browse the repository at this point in the history
… browser containers

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Apr 12, 2024
1 parent 6daa776 commit ae4808a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ test_firefox_standalone:
VERSION=$(TAG_VERSION) NAMESPACE=$(NAMESPACE) BINDING_VERSION=$(BINDING_VERSION) ./tests/bootstrap.sh StandaloneFirefox

test_parallel: hub chrome firefox edge
sudo rm -rf ./tests/tests
for node in DeploymentAutoscaling JobAutoscaling ; do \
cd ./tests || true ; \
echo TAG=$(TAG_VERSION) > .env ; \
Expand All @@ -406,7 +407,8 @@ test_parallel: hub chrome firefox edge
# Its main purpose is to check that a video file was generated.
test_video: video hub chrome firefox edge
# Running a few tests with docker compose to generate the videos
rm -rf ./tests/videos; mkdir -p ./tests/videos
sudo rm -rf ./tests/tests
sudo rm -rf ./tests/videos; mkdir -p ./tests/videos
for node in NodeChrome NodeFirefox NodeEdge ; do \
cd ./tests || true ; \
echo VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) > .env ; \
Expand Down Expand Up @@ -435,17 +437,21 @@ test_video: video hub chrome firefox edge
docker run -u $$(id -u) -v $$(pwd):$$(pwd) -w $$(pwd) $(FFMPEG_BASED_NAME)/ffmpeg:$(FFMPEG_BASED_TAG) -v error -i ./tests/videos/edge_video.mp4 -f null - 2>error.log

test_node_docker: hub standalone_docker standalone_chrome standalone_firefox standalone_edge video
rm -rf ./tests/videos; mkdir -p ./tests/videos
sudo chmod 777 ./tests/videos
sudo rm -rf ./tests/tests
sudo rm -rf ./tests/videos; mkdir -p ./tests/videos/Downloads
sudo chmod -R 777 ./tests/videos
for node in DeploymentAutoscaling JobAutoscaling ; do \
cd tests || true ; \
DOWNLOADS_DIR="./videos/Downloads" ; \
sudo rm -rf $$DOWNLOADS_DIR/* ; \
echo NAMESPACE=$(NAME) > .env ; \
echo TAG=$(TAG_VERSION) >> .env ; \
echo VIDEO_TAG=$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) >> .env ; \
echo TEST_DRAIN_AFTER_SESSION_COUNT=$(or $(TEST_DRAIN_AFTER_SESSION_COUNT), 0) >> .env ; \
echo TEST_PARALLEL_HARDENING=$(or $(TEST_PARALLEL_HARDENING), "false") >> .env ; \
echo LOG_LEVEL=$(or $(LOG_LEVEL), "INFO") >> .env ; \
echo REQUEST_TIMEOUT=$(or $(REQUEST_TIMEOUT), 300) >> .env ; \
echo SELENIUM_ENABLE_MANAGED_DOWNLOADS=$(or $(SELENIUM_ENABLE_MANAGED_DOWNLOADS), "false") >> .env ; \
echo NODE=$$node >> .env ; \
echo UID=$$(id -u) >> .env ; \
echo BINDING_VERSION=$(BINDING_VERSION) >> .env ; \
Expand All @@ -454,6 +460,10 @@ test_node_docker: hub standalone_docker standalone_chrome standalone_firefox sta
envsubst < config.toml > ./videos/config.toml ; \
docker compose -f docker-compose-v3-test-node-docker.yaml up --no-log-prefix --exit-code-from tests --build ; \
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!" ; \
exit 1 ; \
fi ; \
done

test_custom_ca_cert:
Expand Down
10 changes: 7 additions & 3 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SELENIUM_GRID_USERNAME = os.environ.get('SELENIUM_GRID_USERNAME', '')
SELENIUM_GRID_PASSWORD = os.environ.get('SELENIUM_GRID_PASSWORD', '')
SELENIUM_GRID_TEST_HEADLESS = os.environ.get('SELENIUM_GRID_TEST_HEADLESS', 'false').lower() == 'true'
SELENIUM_ENABLE_MANAGED_DOWNLOADS = os.environ.get('SELENIUM_ENABLE_MANAGED_DOWNLOADS', 'true').lower() == 'true'
WEB_DRIVER_WAIT_TIMEOUT = int(os.environ.get('WEB_DRIVER_WAIT_TIMEOUT', 60))
TEST_PARALLEL_HARDENING = os.environ.get('TEST_PARALLEL_HARDENING', 'false').lower() == 'true'

Expand Down Expand Up @@ -90,6 +91,9 @@ def test_download_file(self):
)
driver.execute_script("arguments[0].scrollIntoView();", file_link)
file_link.click()
if not SELENIUM_ENABLE_MANAGED_DOWNLOADS:
time.sleep(4)
return
wait.until(
lambda d: str(d.get_downloadable_files()[0]).endswith(file_name)
)
Expand All @@ -108,7 +112,7 @@ class ChromeTests(SeleniumGenericTests):
def setUp(self):
try:
options = ChromeOptions()
options.enable_downloads = True
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
options.set_capability('se:recordVideo', True)
if SELENIUM_GRID_TEST_HEADLESS:
Expand All @@ -129,7 +133,7 @@ class EdgeTests(SeleniumGenericTests):
def setUp(self):
try:
options = EdgeOptions()
options.enable_downloads = True
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
options.set_capability('se:recordVideo', True)
if SELENIUM_GRID_TEST_HEADLESS:
Expand All @@ -154,7 +158,7 @@ def setUp(self):
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "*/*")
options = FirefoxOptions()
options.profile = profile
options.enable_downloads = True
options.enable_downloads = SELENIUM_ENABLE_MANAGED_DOWNLOADS
options.set_capability('se:recordVideo', True)
if SELENIUM_GRID_TEST_HEADLESS:
options.add_argument('-headless')
Expand Down
6 changes: 3 additions & 3 deletions tests/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ configs = [
"${NAMESPACE}/standalone-edge:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
]

host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts"]
host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]

url = "http://127.0.0.1:2375"

video-image = "${NAMESPACE}/video:${VIDEO_TAG}"

[node]
enable-managed-downloads = true
enable-managed-downloads = "${SELENIUM_ENABLE_MANAGED_DOWNLOADS}"
override-max-sessions = true
max-sessions = 4
max-sessions = 3
4 changes: 3 additions & 1 deletion tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
- ./videos:/opt/selenium/assets
- ./videos/config.toml:/opt/bin/config.toml
- /var/run/docker.sock:/var/run/docker.sock
- ./videos/Downloads:/home/seluser/Downloads
dns:
- 8.8.8.8
- 8.8.4.4
Expand All @@ -19,7 +20,7 @@ services:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=true
- SE_NODE_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS}
- SE_LOG_LEVEL=${LOG_LEVEL}

selenium-hub:
Expand All @@ -45,4 +46,5 @@ services:
- RUN_IN_DOCKER_COMPOSE=true
- SELENIUM_GRID_HOST=selenium-hub
- BINDING_VERSION=${BINDING_VERSION}
- SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS}
command: ["./bootstrap.sh", "${NODE}"]

0 comments on commit ae4808a

Please sign in to comment.