Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conflict config.toml in browser containers when node-docker volumes is shared #2345

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ NAME := $(or $(NAME),$(NAME),selenium)
CURRENT_DATE := $(shell date '+%Y%m%d')
BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE))
BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.23.0)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.23.0)
BINDING_VERSION := $(or $(BINDING_VERSION),$(BINDING_VERSION),4.23.0)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.23.1)
BINDING_VERSION := $(or $(BINDING_VERSION),$(BINDING_VERSION),4.23.1)
BASE_RELEASE_NIGHTLY := $(or $(BASE_RELEASE_NIGHTLY),$(BASE_RELEASE_NIGHTLY),nightly)
BASE_VERSION_NIGHTLY := $(or $(BASE_VERSION_NIGHTLY),$(BASE_VERSION_NIGHTLY),4.24.0-SNAPSHOT)
VERSION := $(or $(VERSION),$(VERSION),4.23.0)
VERSION := $(or $(VERSION),$(VERSION),4.23.1)
TAG_VERSION := $(VERSION)-$(BUILD_DATE)
CHART_VERSION_NIGHTLY := $(or $(CHART_VERSION_NIGHTLY),$(CHART_VERSION_NIGHTLY),1.0.0-nightly)
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
Expand Down Expand Up @@ -67,10 +67,12 @@ build: all

ci: build test

base:
gen_certs:
rm -rf ./Base/configs/node && mkdir -p ./Base/configs/node && cp -r ./charts/selenium-grid/configs/node ./Base/configs
rm -rf ./Base/certs && cp -r ./charts/selenium-grid/certs ./Base
./Base/certs/gen-cert-helper.sh -d ./Base/certs

base: gen_certs
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) .

base_nightly:
Expand Down
3 changes: 2 additions & 1 deletion NodeDocker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ USER ${SEL_UID}
EXPOSE 4444

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

COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/

COPY selenium-grid-docker.conf /etc/supervisor/conf.d/

ENV SE_OTEL_SERVICE_NAME="selenium-node-docker"
2 changes: 1 addition & 1 deletion NodeDocker/start-selenium-grid-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
--bind-host ${SE_BIND_HOST} \
--detect-drivers false \
--config /opt/selenium/config.toml \
--config /opt/selenium/${SE_NODE_DOCKER_CONFIG_FILENAME:-"config.toml"} \
${SE_GRID_URL} ${SE_OPTS}
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Talk to us at https://www.selenium.dev/support/
* [Video recording and uploading](#video-recording-and-uploading)
* [Dynamic Grid](#dynamic-grid)
* [Configuration example](#configuration-example)
* [Share volumes config of Dynamic Grid container to node browser containers](#share-volumes-config-of-dynamic-grid-container-to-node-browser-containers)
* [Execution with Hub & Node roles](#execution-with-hub--node-roles)
* [Execution with Standalone roles](#execution-with-standalone-roles)
* [Using Dynamic Grid in different machines/VMs](#using-dynamic-grid-in-different-machinesvms)
Expand Down Expand Up @@ -745,6 +746,36 @@ With the optional config key `host-config-keys` under section [docker] in a conf

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.

### Share volumes config of Dynamic Grid container to node browser containers

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

```toml
[docker]
host-config-keys = ["Binds"]
```

Volumes config in docker compose file

```dockerfile
services:
node-docker:
image: selenium/node-docker:latest
volumes:
- ./assets:/opt/selenium/assets
- ./config.toml:/opt/selenium/docker.toml
- ./downloads:/home/seluser/Downloads
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
```

`/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.

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.

Refer to example [docker-compose-v3-test-node-docker.yaml](./tests/docker-compose-v3-test-node-docker.yaml)

### Execution with Hub & Node roles

This can be expanded to a full Grid deployment, all components deployed individually. The overall
Expand Down
2 changes: 2 additions & 0 deletions tests/SeleniumTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def setUp(self):
options.set_capability('appium:adbExecTimeout', 120000)
options.set_capability('appium:uiautomator2ServerInstallTimeout', 120000)
options.set_capability('appium:appWaitDuration', 120000)
options.set_capability('appium:suppressKillServer', True)
options.set_capability('appium:allowDelayAdb', False)
else:
options.set_capability('platformName', 'Linux')
start_time = time.time()
Expand Down
3 changes: 2 additions & 1 deletion tests/docker-compose-v3-test-node-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: ${NAMESPACE}/node-docker:${TAG}
volumes:
- ./videos:/opt/selenium/assets
- ./videos/config.toml:/opt/selenium/config.toml
- ./videos/config.toml:/opt/selenium/docker.toml
- /var/run/docker.sock:/var/run/docker.sock
- ./videos/Downloads:/home/seluser/Downloads
dns:
Expand All @@ -16,6 +16,7 @@ services:
depends_on:
- selenium-hub
environment:
- SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
Expand Down
Loading