Skip to content

Commit

Permalink
feat(chart): Add config to control disabling Grid UI (#2083)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Jan 9, 2024
1 parent ac2897e commit 7accd3f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Hub/start-selenium-grid-hub.sh
Expand Up @@ -56,6 +56,11 @@ if [ ! -z "$SE_REGISTRATION_SECRET" ]; then
SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}"
fi

if [ ! -z "$SE_DISABLE_UI" ]; then
echo "Appending Selenium options: --disable-ui ${SE_DISABLE_UI}"
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
fi

EXTRA_LIBS=""

if [ ! -z "$SE_ENABLE_TRACING" ]; then
Expand Down
5 changes: 5 additions & 0 deletions Router/start-selenium-grid-router.sh
Expand Up @@ -88,6 +88,11 @@ if [ ! -z "$SE_REGISTRATION_SECRET" ]; then
SE_OPTS="$SE_OPTS --registration-secret ${SE_REGISTRATION_SECRET}"
fi

if [ ! -z "$SE_DISABLE_UI" ]; then
echo "Appending Selenium options: --disable-ui ${SE_DISABLE_UI}"
SE_OPTS="$SE_OPTS --disable-ui ${SE_DISABLE_UI}"
fi

EXTRA_LIBS=""

if [ ! -z "$SE_ENABLE_TRACING" ]; then
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/README.md
Expand Up @@ -648,6 +648,7 @@ You can configure the Selenium Hub with these values:
| `hub.imagePullSecret` | `""` | Image pull secret (see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry) |
| `hub.annotations` | `{}` | Custom annotations for Selenium Hub pod |
| `hub.labels` | `{}` | Custom labels for Selenium Hub pod |
| `hub.disableUI` | `false` | Disable the Grid UI |
| `hub.publishPort` | `4442` | Port where events are published |
| `hub.publishNodePort` | `31442` | NodePort where events are published |
| `hub.subscribePort` | `4443` | Port where to subscribe for events |
Expand Down Expand Up @@ -764,6 +765,7 @@ If you implement selenium-grid with separate components (`isolateComponents: tru
| `components.sessionQueue.affinity` | `{}` | Affinity for Session Queue pods |
| `components.sessionQueue.priorityClassName` | `""` | Priority class name for Session Queue pods |
| `components.subPath` | `/` | Custom sub path for all components |
| `components.disableUI` | `false` | Disable the Grid UI |
| `components.extraEnvironmentVariables` | `nil` | Custom environment variables for all components |
| `components.extraEnvFrom` | `nil` | Custom environment variables taken from `configMap` or `secret` for all components |

Expand Down
4 changes: 4 additions & 0 deletions charts/selenium-grid/templates/hub-deployment.yaml
Expand Up @@ -95,6 +95,10 @@ spec:
- name: SE_SUB_PATH
value: {{ . | quote }}
{{- end }}
{{- if .Values.hub.disableUI }}
- name: SE_DISABLE_UI
value: {{ .Values.hub.disableUI | quote }}
{{- end }}
{{- with .Values.hub.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/selenium-grid/templates/router-deployment.yaml
Expand Up @@ -49,6 +49,10 @@ spec:
- name: SE_SUB_PATH
value: {{ . | quote }}
{{- end }}
{{- if .Values.components.disableUI }}
- name: SE_DISABLE_UI
value: {{ .Values.components.disableUI | quote }}
{{- end }}
{{- with .Values.components.extraEnvironmentVariables }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/selenium-grid/values.yaml
Expand Up @@ -336,6 +336,8 @@ components:

# Custom sub path for all components
subPath: ""
# Disable the Grid UI
disableUI: false

# Custom environment variables for all components
extraEnvironmentVariables:
Expand Down Expand Up @@ -370,6 +372,8 @@ hub:
annotations: {}
# Custom labels for Selenium Hub pods
labels: {}
# Disable the Grid UI
disableUI: false
# Port where events are published
publishPort: 4442
publishNodePort: 31442
Expand Down
1 change: 1 addition & 0 deletions tests/charts/templates/render/dummy.yaml
Expand Up @@ -58,6 +58,7 @@ isolateComponents: true

components:
subPath: *gridAppRoot
disableUI: true
router:
serviceType: NodePort
distributor:
Expand Down
16 changes: 14 additions & 2 deletions tests/charts/templates/test.py
Expand Up @@ -50,7 +50,7 @@ def test_sub_path_append_to_node_grid_url(self):
count = 0
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap':
logger.info(f"Assert subPath is appended to node grid url")
logger.info(f"Assert subPath is appended to Node env SE_NODE_GRID_URL")
self.assertTrue(doc['data']['SE_NODE_GRID_URL'] == 'https://sysadmin:strongPassword@10.10.10.10:8443/selenium')
count += 1
self.assertEqual(count, len(resources_name), "No node config resources found")
Expand All @@ -60,13 +60,25 @@ def test_sub_path_set_to_grid_env_var(self):
is_present = False
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment':
logger.info(f"Assert subPath is set to grid ENV variable")
logger.info(f"Assert subPath is set to Router env SE_SUB_PATH")
list_env = doc['spec']['template']['spec']['containers'][0]['env']
for env in list_env:
if env['name'] == 'SE_SUB_PATH' and env['value'] == '/selenium':
is_present = True
self.assertTrue(is_present, "ENV variable SE_SUB_PATH is not populated")

def test_disable_ui_set_to_grid_env_var(self):
resources_name = ['selenium-router']
is_present = False
for doc in LIST_OF_DOCUMENTS:
if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment':
logger.info(f"Assert option disable UI is set to Router env SE_DISABLE_UI")
list_env = doc['spec']['template']['spec']['containers'][0]['env']
for env in list_env:
if env['name'] == 'SE_DISABLE_UI' and env['value'] == 'true':
is_present = True
self.assertTrue(is_present, "ENV variable SE_DISABLE_UI is not populated")

def test_log_level_set_to_logging_config_map(self):
resources_name = ['selenium-chrome-node', 'selenium-distributor', 'selenium-edge-node', 'selenium-firefox-node',
'selenium-event-bus', 'selenium-router', 'selenium-session-map', 'selenium-session-queue']
Expand Down

0 comments on commit 7accd3f

Please sign in to comment.