Skip to content
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
3 changes: 2 additions & 1 deletion ENV_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
| SE_NODE_BROWSER_NAME | | | |
| SE_NODE_CONTAINER_NAME | | | |
| SE_NODE_HOST | | | |
| SE_NODE_MAX_CONCURRENCY | | When node is handled both browser and relay, SE_NODE_MAX_CONCURRENCY is used to configure max concurrency based on sum of them | |
| SE_NODE_RELAY_BROWSER_NAME | | | |
| SE_NODE_RELAY_MAX_SESSIONS | | | |
| SE_NODE_RELAY_PLATFORM_NAME | | | |
Expand All @@ -142,3 +141,5 @@
| SE_SESSIONS_MAP_EXTERNAL_JDBC_USER | | | |
| SE_SESSIONS_MAP_EXTERNAL_PORT | | | |
| SE_SESSIONS_MAP_EXTERNAL_SCHEME | | | |
| SE_NODE_RELAY_STEREOTYPE | | Capabilities in JSON string to overwrite the default Node relay stereotype | |
| SE_NODE_RELAY_STEREOTYPE_EXTRA | | Extra capabilities in JSON string that wants to merge to the default Node relay stereotype | |
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ set_containerd_image_store:
docker info -f '{{ .DriverStatus }}'

format_shell_scripts:
sudo apt-get update -qq ; \
sudo apt-get install -yq shfmt ; \
sudo apt-get update -qq || true ; \
sudo apt-get install -yq shfmt || true ; \
shfmt -l -w -d $${PWD}/*.sh $${PWD}/**/*.sh $$PWD/**.sh $$PWD/**/generate_** $$PWD/**/wrap_* ; \
git diff --stat --exit-code ; \
EXIT_CODE=$$? ; \
Expand Down
3 changes: 1 addition & 2 deletions NodeBase/generate_config
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ echo "session-timeout = ${SE_NODE_SESSION_TIMEOUT}" >>"$FILENAME"
echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >>"$FILENAME"
echo "detect-drivers = false" >>"$FILENAME"
echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_SESSION_COUNT}" >>"$FILENAME"
# When node is handled both browser and relay, SE_NODE_MAX_CONCURRENCY is used to configure max concurrency based on sum of them
echo "max-sessions = ${SE_NODE_MAX_CONCURRENCY:-${SE_NODE_MAX_SESSIONS}}
echo "max-sessions = ${SE_NODE_MAX_SESSIONS}
" >>"$FILENAME"

if [ -f /opt/selenium/browser_name ]; then
Expand Down
19 changes: 15 additions & 4 deletions NodeBase/generate_relay_config
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ if [[ -n "${SE_NODE_RELAY_URL}" ]]; then
if [[ -n "${SE_NODE_RELAY_PROTOCOL_VERSION}" ]]; then
echo "protocol-version = \"${SE_NODE_RELAY_PROTOCOL_VERSION}\"" >>"$FILENAME"
fi
echo "configs = [
\"${SE_NODE_RELAY_MAX_SESSIONS}\", \"{\\\"browserName\\\": \\\"${SE_NODE_RELAY_BROWSER_NAME}\\\", \\\"platformName\\\": \\\"${SE_NODE_RELAY_PLATFORM_NAME}\\\", \\\"appium:platformVersion\\\": \\\"${SE_NODE_RELAY_PLATFORM_VERSION}\\\"}\"
]
" >>"$FILENAME"
if [[ -z "${SE_NODE_RELAY_STEREOTYPE}" ]]; then
SE_NODE_RELAY_STEREOTYPE="{\"browserName\": \"${SE_NODE_RELAY_BROWSER_NAME}\", \"platformName\": \"${SE_NODE_RELAY_PLATFORM_NAME}\", \"appium:platformVersion\": \"${SE_NODE_RELAY_PLATFORM_VERSION}\"}"
else
SE_NODE_RELAY_STEREOTYPE="${SE_NODE_RELAY_STEREOTYPE}"
fi
if [[ -n "${SE_NODE_RELAY_STEREOTYPE_EXTRA}" ]]; then
echo "Merging SE_NODE_RELAY_STEREOTYPE_EXTRA=${SE_NODE_RELAY_STEREOTYPE_EXTRA} to main relay stereotype"
SE_NODE_RELAY_STEREOTYPE="$(python3 /opt/bin/json_merge.py "${SE_NODE_RELAY_STEREOTYPE}" "${SE_NODE_RELAY_STEREOTYPE_EXTRA}")"
if [[ $? -ne 0 ]]; then
echo "Failed to merge SE_NODE_RELAY_STEREOTYPE_EXTRA. Please check the format of the JSON string. Keep using main relay stereotype."
else
echo "Merged relay stereotype: ${SE_NODE_RELAY_STEREOTYPE}"
fi
fi
echo "configs = ['${SE_NODE_RELAY_MAX_SESSIONS}', '${SE_NODE_RELAY_STEREOTYPE}']" >>"$FILENAME"
fi
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ The following is an en example of configuration relay commands.
If you want to relay commands only, `selenium/node-base` is suitable and lightweight for this purpose.
In case you want to configure node with both browsers and relay commands, respective node images can be used.
To use environment variables for generate relay configs, set `SE_NODE_RELAY_URL` and other variables as below
To use environment variables for generate relay configs, set `SE_NODE_RELAY_URL` and other variables as below. Those will be used to generate the default relay config in TOML format looks like below.
```toml
[relay]
Expand All @@ -1190,6 +1190,10 @@ protocol-version = "${SE_NODE_RELAY_PROTOCOL_VERSION}"
configs = [ '${SE_NODE_RELAY_MAX_SESSIONS}', '{"browserName": "${SE_NODE_RELAY_BROWSER_NAME}", "platformName": "${SE_NODE_RELAY_PLATFORM_NAME}", "appium:platformVersion": "${SE_NODE_RELAY_PLATFORM_VERSION}"}' ]
```
Instead of input value for each environment variable to construct the default relay stereotype, you can use the `SE_NODE_RELAY_STEREOTYPE` environment variable to overwrite the default relay stereotype with your custom stereotype.
In another case, if you want to retain the default relay stereotype and append additional capabilities, you can use the `SE_NODE_RELAY_STEREOTYPE_EXTRA` environment variable to set your capabilities. Those will be merged to the default relay stereotype.
To run a sample test with the relayed node, you can clone the project and try below command:
```bash
Expand Down
11 changes: 7 additions & 4 deletions scripts/generate_list_env_vars/description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,6 @@
- name: SE_NODE_HOST
description: ''
cli: ''
- name: SE_NODE_MAX_CONCURRENCY
description: When node is handled both browser and relay, SE_NODE_MAX_CONCURRENCY
is used to configure max concurrency based on sum of them
cli: ''
- name: SE_NODE_RELAY_BROWSER_NAME
description: ''
cli: ''
Expand Down Expand Up @@ -431,3 +427,10 @@
- name: SE_SESSIONS_MAP_EXTERNAL_SCHEME
description: ''
cli: ''
- name: SE_NODE_RELAY_STEREOTYPE
description: Capabilities in JSON string to overwrite the default Node relay stereotype
cli: ''
- name: SE_NODE_RELAY_STEREOTYPE_EXTRA
description: Extra capabilities in JSON string that wants to merge to the default
Node relay stereotype
cli: ''
6 changes: 4 additions & 2 deletions scripts/generate_list_env_vars/value.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@
default: '30'
- name: SE_NODE_HOST
default: ''
- name: SE_NODE_MAX_CONCURRENCY
default: ''
- name: SE_NODE_MAX_SESSIONS
default: '1'
- name: SE_NODE_OVERRIDE_MAX_SESSIONS
Expand All @@ -124,6 +122,10 @@
default: ''
- name: SE_NODE_RELAY_STATUS_ENDPOINT
default: ''
- name: SE_NODE_RELAY_STEREOTYPE
default: ''
- name: SE_NODE_RELAY_STEREOTYPE_EXTRA
default: ''
- name: SE_NODE_RELAY_URL
default: ''
- name: SE_NODE_SESSION_TIMEOUT
Expand Down
1 change: 1 addition & 0 deletions tests/docker-compose-v3-test-node-relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
- SE_NODE_RELAY_PLATFORM_NAME=Android
- SE_NODE_RELAY_PLATFORM_VERSION=${ANDROID_PLATFORM_API}
- SE_NODE_RELAY_BROWSER_NAME=chrome
- SE_NODE_RELAY_STEREOTYPE_EXTRA={"myApp:version":"beta","myApp:publish":"public"}
- SE_NODE_RELAY_WEB_VNC=ws://emulator:6080/websockify

emulator:
Expand Down
2 changes: 1 addition & 1 deletion tests/relay_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ max-sessions = 1
url = "http://standalone:4444/wd/hub"
status-endpoint = "/status"
configs = [
'1', '{"browserName":"${BROWSER_NAME}","platformName":"linux"}'
'3', '{"browserName":"${BROWSER_NAME}","platformName":"linux"}'
]
Loading