Skip to content

Commit

Permalink
feat(chart): Append subPath to ENV variable SE_NODE_GRID_URL (#2053)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Dec 8, 2023
1 parent 93de6e8 commit 3e19181
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ http://{{- if eq .Values.basicAuth.enabled true}}{{ .Values.basicAuth.username}}
{{- end }}
{{- end -}}

{{- define "seleniumGrid.url.subPath" -}}
{{- $subPath := "/" -}}
{{ if $.Values.isolateComponents }}
{{- $subPath = default $subPath $.Values.components.subPath -}}
{{- else -}}
{{- $subPath = default $subPath $.Values.hub.subPath -}}
{{- end -}}
{{ $subPath }}
{{- end -}}

{{/*
Graphql Url of the hub or the router
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ metadata:
{{- end }}
data:
SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}'
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}'
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}{{ include "seleniumGrid.url.subPath" .}}'
3 changes: 3 additions & 0 deletions tests/charts/templates/render/dummy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ ingress:

isolateComponents: true

components:
subPath: *gridAppRoot

chromeNode:
affinity: *affinity

Expand Down
22 changes: 22 additions & 0 deletions tests/charts/templates/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ def test_ingress_nginx_annotations(self):
count += 1
self.assertEqual(count, len(resources_name), "No ingress resources found")

def test_sub_path_append_to_node_grid_url(self):
resources_name = ['selenium-node-config']
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")
self.assertTrue(doc['data']['SE_NODE_GRID_URL'] == 'http://admin:[email protected]:4444/selenium')
count += 1
self.assertEqual(count, len(resources_name), "No node config resources found")

def test_sub_path_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 subPath is set to grid ENV variable")
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")

if __name__ == '__main__':
failed = False
try:
Expand Down

0 comments on commit 3e19181

Please sign in to comment.