Skip to content

Commit 92a0ff9

Browse files
committed
Docker: Fix Video not shutting down properly
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
1 parent 2dbdf70 commit 92a0ff9

8 files changed

Lines changed: 87 additions & 10 deletions

File tree

.github/workflows/docker-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ jobs:
133133
os: ubuntu-24.04-arm
134134
firefox-install-lang-package: true
135135
enable-managed-downloads: true
136-
- test-strategy: test_node_docker
136+
- test-strategy: test_node_docker_video_sidecar
137137
use-random-user: false
138138
test-video: true
139139
build-all: false
140140
os: ubuntu-24.04-arm
141141
firefox-install-lang-package: true
142142
enable-managed-downloads: false
143-
- test-strategy: test_standalone_docker
143+
- test-strategy: test_standalone_docker_video_sidecar
144144
use-random-user: false
145145
test-video: true
146146
build-all: false

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,15 +1125,23 @@ test_node_relay: hub node_base standalone_firefox
11251125

11261126
test_standalone_docker: standalone_docker
11271127
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 \
1128-
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 \
1128+
RECORD_STANDALONE=true GRID_URL=http://0.0.0.0:4444 LIST_OF_TESTS_AMD64="DeploymentAutoscaling" TEST_PARALLEL_HARDENING=true TEST_DELAY_AFTER_TEST=0 \
11291129
SELENIUM_ENABLE_MANAGED_DOWNLOADS=true LOG_LEVEL=SEVERE SKIP_CHECK_DOWNLOADS_VOLUME=true make test_node_docker
11301130

1131+
test_standalone_docker_video_sidecar: standalone_docker
1132+
DOCKER_COMPOSE_FILE=docker-compose-v3-test-standalone-docker.yaml CONFIG_FILE=standalone_docker_video_sidecar_config.toml HUB_CHECKS_INTERVAL=45 TEST_CUSTOM_SPECIFIC_NAME=true \
1133+
RECORD_STANDALONE=true GRID_URL=http://0.0.0.0:4444 LIST_OF_TESTS_AMD64="DeploymentAutoscaling" TEST_PARALLEL_HARDENING=true TEST_DELAY_AFTER_TEST=0 \
1134+
SELENIUM_ENABLE_MANAGED_DOWNLOADS=true LOG_LEVEL=SEVERE SKIP_CHECK_DOWNLOADS_VOLUME=true make test_node_docker
1135+
1136+
test_node_docker_video_sidecar:
1137+
CONFIG_FILE=config.toml make test_node_docker
1138+
11311139
test_node_docker: hub standalone_docker standalone_chrome standalone_firefox standalone_edge standalone_chromium video
11321140
sudo rm -rf ./tests/tests
11331141
sudo rm -rf ./tests/videos; mkdir -p ./tests/videos/Downloads; mkdir -p ./tests/videos/upload
11341142
sudo chmod -R 777 ./tests/videos
11351143
docker_compose_file=$(or $(DOCKER_COMPOSE_FILE), docker-compose-v3-test-node-docker.yaml) ; \
1136-
config_file=$(or $(CONFIG_FILE), config.toml) ; \
1144+
config_file=$(or $(CONFIG_FILE), config_video_sidecar.toml) ; \
11371145
list_of_tests_amd64=$(or $(LIST_OF_TESTS_AMD64), "NodeChrome NodeChromium NodeFirefox NodeEdge") ; \
11381146
list_of_tests_arm64=$(or $(LIST_OF_TESTS_ARM64), "NodeFirefox NodeChromium") ; \
11391147
if [ "$(PLATFORMS)" = "linux/amd64" ]; then \

Video/recorder.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ autostart=%(ENV_SE_RECORD_VIDEO)s
66
startsecs=0
77
autorestart=%(ENV_SE_RECORD_VIDEO)s
88
stopsignal=TERM
9-
stopwaitsecs=30
9+
stopwaitsecs=60
1010

1111
;Logs (all activity redirected to stdout so it can be seen through "docker logs"
1212
redirect_stderr=true

Video/video_recorder.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import os
12+
import signal
1213
import subprocess
1314
import sys
1415

@@ -29,10 +30,22 @@ def main():
2930
print(f"Failed to import video service: {e}")
3031
print("Ensure pyzmq is installed: pip install pyzmq")
3132
print("Falling back to shell-based recording...")
32-
subprocess.run(["/opt/bin/video.sh"], check=True)
33+
_run_shell_recorder()
3334
else:
3435
print("Starting shell-based video recording...")
35-
subprocess.run(["/opt/bin/video.sh"], check=True)
36+
_run_shell_recorder()
37+
38+
39+
def _run_shell_recorder():
40+
proc = subprocess.Popen(["/opt/bin/video.sh"])
41+
42+
def forward_signal(signum, frame):
43+
proc.send_signal(signum)
44+
proc.wait()
45+
46+
signal.signal(signal.SIGTERM, forward_signal)
47+
signal.signal(signal.SIGINT, forward_signal)
48+
proc.wait()
3649

3750

3851
if __name__ == "__main__":

Video/video_service.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,9 @@ async def wait_for_node_ready(self) -> None:
326326
then extracts nodeId and externalUri from the response.
327327
328328
Response structure differs by mode:
329-
- Standalone: $.value.nodes[0].id, $.value.nodes[0].externalUri
330-
- Distributed: $.value.node.nodeId, $.value.node.externalUri
329+
- Standalone (hub): $.value.nodes[0].id, $.value.nodes[0].externalUri
330+
- Distributed (node): $.value.node.nodeId, $.value.node.externalUri
331+
- Standalone sidecar on dynamic grid node: falls back to $.value.node path
331332
"""
332333
node_status_url = f"{self.se_server_protocol}://{self.display_container}:{self.se_node_port}/status"
333334
headers = {}
@@ -368,6 +369,12 @@ async def wait_for_node_ready(self) -> None:
368369
node_info = nodes[0]
369370
self.node_id = node_info.get("id")
370371
self.node_external_uri = node_info.get("externalUri")
372+
else:
373+
# Fallback: sidecar connected directly to a node
374+
# (e.g. dynamic grid where /status returns singular "node")
375+
node_info = body.get("value", {}).get("node", {})
376+
self.node_id = node_info.get("nodeId") or node_info.get("id")
377+
self.node_external_uri = node_info.get("externalUri")
371378
else:
372379
node_info = body.get("value", {}).get("node", {})
373380
self.node_id = node_info.get("nodeId")

tests/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
1212

1313
url = "http://127.0.0.1:2375"
1414

15-
video-image = "${NAMESPACE}/video:${VIDEO_TAG}"
15+
video-image = "false"
1616

1717
[node]
1818
detect-drivers = false

tests/config_video_sidecar.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[docker]
2+
configs = [
3+
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
4+
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
5+
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
6+
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
7+
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
8+
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}'
9+
]
10+
11+
host-config-keys = ["Dns", "DnsOptions", "DnsSearch", "ExtraHosts", "Binds"]
12+
13+
url = "http://127.0.0.1:2375"
14+
15+
video-image = "${NAMESPACE}/video:${VIDEO_TAG}"
16+
17+
[node]
18+
detect-drivers = false
19+
enable-managed-downloads = "${SELENIUM_ENABLE_MANAGED_DOWNLOADS}"
20+
override-max-sessions = true
21+
max-sessions = 3
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[docker]
2+
configs = [
3+
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
4+
"${NAMESPACE}/standalone-firefox:${TAG}", '{"browserName": "firefox", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
5+
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
6+
"${NAMESPACE}/standalone-${NODE_CHROME}:${TAG}", '{"browserName": "chrome", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}',
7+
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "stable", "myApp:publish": "external"}',
8+
"${NAMESPACE}/standalone-${NODE_EDGE}:${TAG}", '{"browserName": "MicrosoftEdge", "platformName": "linux", "myApp:version": "beta", "myApp:publish": "internal"}'
9+
]
10+
11+
url = "http://127.0.0.1:2375"
12+
13+
video-image = "${NAMESPACE}/video:${VIDEO_TAG}"
14+
15+
[node]
16+
detect-drivers = false
17+
enable-managed-downloads = "${SELENIUM_ENABLE_MANAGED_DOWNLOADS}"
18+
override-max-sessions = true
19+
max-sessions = 16
20+
session-timeout = 1000
21+
enable-cdp = true
22+
selenium-manager = false
23+
24+
[sessionqueue]
25+
session-request-timeout = "${REQUEST_TIMEOUT}"
26+
27+
[router]
28+
disable-ui = false

0 commit comments

Comments
 (0)