Skip to content

Commit

Permalink
[test]: Setting custom capabilities for matching specific Nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Oct 10, 2024
1 parent 5802c32 commit 839e5f6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ test_node_relay: hub node_base standalone_firefox
done

test_standalone_docker: standalone_docker
DOCKER_COMPOSE_FILE=docker-compose-v3-test-standalone-docker.yaml CONFIG_FILE=standalone_docker_config.toml HUB_CHECKS_INTERVAL=45 \
DOCKER_COMPOSE_FILE=docker-compose-v3-test-standalone-docker.yaml CONFIG_FILE=standalone_docker_config.toml HUB_CHECKS_INTERVAL=45 TEST_CUSTOM_SPECIFIC_NAME=true \
RECORD_STANDALONE=true GRID_URL=http://0.0.0.0:4444 LIST_OF_TESTS_AMD64="DeploymentAutoscaling" TEST_PARALLEL_HARDENING=true TEST_DELAY_AFTER_TEST=2 \
SELENIUM_ENABLE_MANAGED_DOWNLOADS=true LOG_LEVEL=SEVERE SKIP_CHECK_DOWNLOADS_VOLUME=true make test_node_docker

Expand Down Expand Up @@ -822,6 +822,7 @@ test_node_docker: hub standalone_docker standalone_chrome standalone_firefox sta
echo RECORD_STANDALONE=$(or $(RECORD_STANDALONE), "true") >> .env ; \
echo GRID_URL=$(or $(GRID_URL), "") >> .env ; \
echo HUB_CHECKS_INTERVAL=$(or $(HUB_CHECKS_INTERVAL), 20) >> .env ; \
echo TEST_CUSTOM_SPECIFIC_NAME=$(or $(TEST_CUSTOM_SPECIFIC_NAME), "true") >> .env ; \
echo NODE=$$node >> .env ; \
echo UID=$$(id -u) >> .env ; \
echo BINDING_VERSION=$(BINDING_VERSION) >> .env ; \
Expand Down
13 changes: 13 additions & 0 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
TEST_PLATFORMS = os.environ.get('TEST_PLATFORMS', 'linux/amd64')
TEST_FIREFOX_INSTALL_LANG_PACKAGE = os.environ.get('TEST_FIREFOX_INSTALL_LANG_PACKAGE', 'false').lower() == 'true'
TEST_ADD_CAPS_RECORD_VIDEO = os.environ.get('TEST_ADD_CAPS_RECORD_VIDEO', 'true').lower() == 'true'
TEST_CUSTOM_SPECIFIC_NAME = os.environ.get('TEST_CUSTOM_SPECIFIC_NAME', 'false').lower() == 'true'

if SELENIUM_GRID_USERNAME and SELENIUM_GRID_PASSWORD:
SELENIUM_GRID_HOST = f"{SELENIUM_GRID_USERNAME}:{SELENIUM_GRID_PASSWORD}@{SELENIUM_GRID_HOST}"
Expand Down Expand Up @@ -114,6 +115,9 @@ def test_download_file(self):
self.assertTrue(str(driver.get_downloadable_files()[0]).endswith(file_name))

def tearDown(self):
if TEST_CUSTOM_SPECIFIC_NAME:
self.assertTrue(str(self.driver.capabilities['myApp:version']) == 'beta')
self.assertTrue(str(self.driver.capabilities['myApp:publish']) == 'internal')
try:
if TEST_DELAY_AFTER_TEST:
time.sleep(TEST_DELAY_AFTER_TEST)
Expand All @@ -133,6 +137,9 @@ def setUp(self):
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
if TEST_CUSTOM_SPECIFIC_NAME:
options.set_capability('myApp:version', 'beta')
options.set_capability('myApp:publish', 'internal')
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
Expand Down Expand Up @@ -171,6 +178,9 @@ def setUp(self):
options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2')
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
if TEST_CUSTOM_SPECIFIC_NAME:
options.set_capability('myApp:version', 'beta')
options.set_capability('myApp:publish', 'internal')
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
Expand Down Expand Up @@ -201,6 +211,9 @@ def setUp(self):
options.profile = profile
if TEST_ADD_CAPS_RECORD_VIDEO:
options.set_capability('se:recordVideo', True)
if TEST_CUSTOM_SPECIFIC_NAME:
options.set_capability('myApp:version', 'beta')
options.set_capability('myApp:publish', 'internal')
options.set_capability('se:name', f"{self._testMethodName} ({self.__class__.__name__})")
options.set_capability('se:screenResolution', '1920x1080')
if SELENIUM_GRID_TEST_HEADLESS:
Expand Down
10 changes: 7 additions & 3 deletions tests/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[docker]
configs = [
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}'
]

host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
Expand All @@ -12,6 +15,7 @@ url = "http://127.0.0.1:2375"
video-image = "${NAMESPACE}/video:${VIDEO_TAG}"

[node]
detect-drivers = false
enable-managed-downloads = "${SELENIUM_ENABLE_MANAGED_DOWNLOADS}"
override-max-sessions = true
max-sessions = 3
3 changes: 3 additions & 0 deletions tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- selenium-hub
- ftp_server
environment:
- SE_ENABLE_TRACING=false
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
Expand All @@ -42,6 +43,7 @@ services:
user: ${UID}
container_name: selenium-hub
environment:
- SE_ENABLE_TRACING=false
- SE_LOG_LEVEL=${LOG_LEVEL}
- SE_SESSION_REQUEST_TIMEOUT=${REQUEST_TIMEOUT}
ports:
Expand Down Expand Up @@ -75,4 +77,5 @@ services:
- SELENIUM_ENABLE_MANAGED_DOWNLOADS=${SELENIUM_ENABLE_MANAGED_DOWNLOADS}
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
- HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL}
- TEST_CUSTOM_SPECIFIC_NAME=${TEST_CUSTOM_SPECIFIC_NAME}
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]
2 changes: 2 additions & 0 deletions tests/docker-compose-v3-test-standalone-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- ./videos/config.toml:/opt/selenium/config.toml
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SE_ENABLE_TRACING=false
- SE_VNC_NO_PASSWORD=true
- SE_START_VNC=true
- SE_LOG_LEVEL=${LOG_LEVEL}
Expand Down Expand Up @@ -62,4 +63,5 @@ services:
- TEST_PARALLEL_HARDENING=${TEST_PARALLEL_HARDENING}
- TEST_DELAY_AFTER_TEST=${TEST_DELAY_AFTER_TEST}
- HUB_CHECKS_INTERVAL=${HUB_CHECKS_INTERVAL}
- TEST_CUSTOM_SPECIFIC_NAME=${TEST_CUSTOM_SPECIFIC_NAME}
command: ["/bin/bash", "-c", "./bootstrap.sh ${NODE}"]
10 changes: 7 additions & 3 deletions tests/standalone_docker_config.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
[docker]
configs = [
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux"}'
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}'
]

url = "http://127.0.0.1:2375"

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

[node]
detect-drivers = false
enable-managed-downloads = "${SELENIUM_ENABLE_MANAGED_DOWNLOADS}"
override-max-sessions = true
max-sessions = 16
Expand Down

0 comments on commit 839e5f6

Please sign in to comment.