Skip to content

Commit 5d41bf0

Browse files
authored
fix: conflict config.toml in browser containers when node-docker volumes is shared (#2345)
* Update Selenium Grid 4.23.1 Signed-off-by: Viet Nguyen Duc <[email protected]> * fix: conflict config.toml in node-docker when volume bindings shared to browser Signed-off-by: Viet Nguyen Duc <[email protected]> --------- Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent b91d300 commit 5d41bf0

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ NAME := $(or $(NAME),$(NAME),selenium)
22
CURRENT_DATE := $(shell date '+%Y%m%d')
33
BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE))
44
BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.23.0)
5-
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.23.0)
6-
BINDING_VERSION := $(or $(BINDING_VERSION),$(BINDING_VERSION),4.23.0)
5+
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.23.1)
6+
BINDING_VERSION := $(or $(BINDING_VERSION),$(BINDING_VERSION),4.23.1)
77
BASE_RELEASE_NIGHTLY := $(or $(BASE_RELEASE_NIGHTLY),$(BASE_RELEASE_NIGHTLY),nightly)
88
BASE_VERSION_NIGHTLY := $(or $(BASE_VERSION_NIGHTLY),$(BASE_VERSION_NIGHTLY),4.24.0-SNAPSHOT)
9-
VERSION := $(or $(VERSION),$(VERSION),4.23.0)
9+
VERSION := $(or $(VERSION),$(VERSION),4.23.1)
1010
TAG_VERSION := $(VERSION)-$(BUILD_DATE)
1111
CHART_VERSION_NIGHTLY := $(or $(CHART_VERSION_NIGHTLY),$(CHART_VERSION_NIGHTLY),1.0.0-nightly)
1212
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
@@ -67,10 +67,12 @@ build: all
6767

6868
ci: build test
6969

70-
base:
70+
gen_certs:
7171
rm -rf ./Base/configs/node && mkdir -p ./Base/configs/node && cp -r ./charts/selenium-grid/configs/node ./Base/configs
7272
rm -rf ./Base/certs && cp -r ./charts/selenium-grid/certs ./Base
7373
./Base/certs/gen-cert-helper.sh -d ./Base/certs
74+
75+
base: gen_certs
7476
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg AUTHORS=$(AUTHORS) -t $(NAME)/base:$(TAG_VERSION) .
7577

7678
base_nightly:

NodeDocker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ USER ${SEL_UID}
2222
EXPOSE 4444
2323

2424
COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-docker.sh \
25-
config.toml \
2625
start-socat.sh \
2726
/opt/bin/
2827

28+
COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/
29+
2930
COPY selenium-grid-docker.conf /etc/supervisor/conf.d/
3031

3132
ENV SE_OTEL_SERVICE_NAME="selenium-node-docker"

NodeDocker/start-selenium-grid-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
106106
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
107107
--bind-host ${SE_BIND_HOST} \
108108
--detect-drivers false \
109-
--config /opt/selenium/config.toml \
109+
--config /opt/selenium/${SE_NODE_DOCKER_CONFIG_FILENAME:-"config.toml"} \
110110
${SE_GRID_URL} ${SE_OPTS}

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Talk to us at https://www.selenium.dev/support/
4242
* [Video recording and uploading](#video-recording-and-uploading)
4343
* [Dynamic Grid](#dynamic-grid)
4444
* [Configuration example](#configuration-example)
45+
* [Share volumes config of Dynamic Grid container to node browser containers](#share-volumes-config-of-dynamic-grid-container-to-node-browser-containers)
4546
* [Execution with Hub & Node roles](#execution-with-hub--node-roles)
4647
* [Execution with Standalone roles](#execution-with-standalone-roles)
4748
* [Using Dynamic Grid in different machines/VMs](#using-dynamic-grid-in-different-machinesvms)
@@ -745,6 +746,36 @@ With the optional config key `host-config-keys` under section [docker] in a conf
745746

746747
Valid key names for Docker host config can be found in the Docker API [documentation](https://docs.docker.com/engine/api/latest/#tag/Container/operation/ContainerCreate) or via the command `docker inspect` the node-docker container.
747748

749+
### Share volumes config of Dynamic Grid container to node browser containers
750+
751+
In case you want to access download directory in node browser containers (e.g `/home/seluser/Downloads`) via volumes config of Dynamic Grid container, you can add the following config to the `config.toml` file
752+
753+
```toml
754+
[docker]
755+
host-config-keys = ["Binds"]
756+
```
757+
758+
Volumes config in docker compose file
759+
760+
```dockerfile
761+
services:
762+
node-docker:
763+
image: selenium/node-docker:latest
764+
volumes:
765+
- ./assets:/opt/selenium/assets
766+
- ./config.toml:/opt/selenium/docker.toml
767+
- ./downloads:/home/seluser/Downloads
768+
- /var/run/docker.sock:/var/run/docker.sock
769+
environment:
770+
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
771+
```
772+
773+
`/opt/selenium/config.toml` is the default path for the config file in all images. Once volumes config is shared to node browser containers, its `config.toml` could be overwritten by node-docker container config file.
774+
775+
In this case, mount your `config.toml` file to `/opt/selenium/docker.toml` in node-docker container. And set the environment variable `SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml` to specify that config file name for the startup script.
776+
777+
Refer to example [docker-compose-v3-test-node-docker.yaml](./tests/docker-compose-v3-test-node-docker.yaml)
778+
748779
### Execution with Hub & Node roles
749780

750781
This can be expanded to a full Grid deployment, all components deployed individually. The overall

tests/SeleniumTests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def setUp(self):
142142
options.set_capability('appium:adbExecTimeout', 120000)
143143
options.set_capability('appium:uiautomator2ServerInstallTimeout', 120000)
144144
options.set_capability('appium:appWaitDuration', 120000)
145+
options.set_capability('appium:suppressKillServer', True)
146+
options.set_capability('appium:allowDelayAdb', False)
145147
else:
146148
options.set_capability('platformName', 'Linux')
147149
start_time = time.time()

tests/docker-compose-v3-test-node-docker.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
image: ${NAMESPACE}/node-docker:${TAG}
55
volumes:
66
- ./videos:/opt/selenium/assets
7-
- ./videos/config.toml:/opt/selenium/config.toml
7+
- ./videos/config.toml:/opt/selenium/docker.toml
88
- /var/run/docker.sock:/var/run/docker.sock
99
- ./videos/Downloads:/home/seluser/Downloads
1010
dns:
@@ -16,6 +16,7 @@ services:
1616
depends_on:
1717
- selenium-hub
1818
environment:
19+
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
1920
- SE_EVENT_BUS_HOST=selenium-hub
2021
- SE_EVENT_BUS_PUBLISH_PORT=4442
2122
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

0 commit comments

Comments
 (0)