diff --git a/charts/selenium-grid/Chart.yaml b/charts/selenium-grid/Chart.yaml index 78d2222d2..156e3ae85 100644 --- a/charts/selenium-grid/Chart.yaml +++ b/charts/selenium-grid/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: selenium-grid description: A Helm chart for creating a Selenium Grid Server in Kubernetes type: application -version: 0.28.2 +version: 0.28.3 appVersion: 4.18.1-20240224 icon: https://github.com/SeleniumHQ/docker-selenium/raw/trunk/logo.png dependencies: diff --git a/charts/selenium-grid/templates/_nameHelpers.tpl b/charts/selenium-grid/templates/_nameHelpers.tpl index cc68e2460..e5370aeed 100644 --- a/charts/selenium-grid/templates/_nameHelpers.tpl +++ b/charts/selenium-grid/templates/_nameHelpers.tpl @@ -60,7 +60,7 @@ Selenium Hub fullname Event bus fullname */}} {{- define "seleniumGrid.eventBus.fullname" -}} -{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-event-bus" $)) .Values.components.eventBus.nameOverride) $ | trunc 63 | trimSuffix "-" | trimPrefix "selenium-" -}} +{{- tpl (default (include "seleniumGrid.component.name" (list "selenium-event-bus" $)) .Values.components.eventBus.nameOverride) $ | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* diff --git a/tests/charts/bootstrap.sh b/tests/charts/bootstrap.sh index c401e9501..6b63bb320 100755 --- a/tests/charts/bootstrap.sh +++ b/tests/charts/bootstrap.sh @@ -13,13 +13,15 @@ python -m pip install pyyaml==6.0.1 \ cd .. -helm template dummy --values tests/charts/templates/render/dummy.yaml \ +RELEASE_NAME="selenium" + +helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy.yaml \ --set-file 'nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ --set-file 'recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ --set-file 'uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ charts/selenium-grid > ./tests/tests/dummy_template_manifests.yaml -python tests/charts/templates/test.py "./tests/tests/dummy_template_manifests.yaml" dummy +python tests/charts/templates/test.py "./tests/tests/dummy_template_manifests.yaml" ${RELEASE_NAME} if [ $? -ne 0 ]; then echo "Failed to validate the chart" exit 1 @@ -28,13 +30,15 @@ fi helm dependency update tests/charts/umbrella-charts helm dependency build tests/charts/umbrella-charts -helm template dummy --values tests/charts/templates/render/dummy_solution.yaml \ +RELEASE_NAME="test" + +helm template ${RELEASE_NAME} --values tests/charts/templates/render/dummy_solution.yaml \ --set-file 'selenium-grid.nodeConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ --set-file 'selenium-grid.recorderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ --set-file 'selenium-grid.uploaderConfigMap.extraScripts.setFromCommand\.sh=tests/charts/templates/render/dummy_external.sh' \ tests/charts/umbrella-charts > ./tests/tests/dummy_solution_template_manifests.yaml -python tests/charts/templates/test.py "./tests/tests/dummy_solution_template_manifests.yaml" dummy +python tests/charts/templates/test.py "./tests/tests/dummy_solution_template_manifests.yaml" ${RELEASE_NAME} if [ $? -ne 0 ]; then echo "Failed to validate the umbrella chart" exit 1 @@ -43,5 +47,3 @@ fi if [ "${CI:-false}" = "false" ]; then deactivate fi - -exit $ret_code diff --git a/tests/charts/templates/test.py b/tests/charts/templates/test.py index e856dac7b..08a913f92 100644 --- a/tests/charts/templates/test.py +++ b/tests/charts/templates/test.py @@ -17,14 +17,14 @@ def load_template(yaml_file): class ChartTemplateTests(unittest.TestCase): def test_set_affinity(self): - resources_name = ['{0}-selenium-chrome-node'.format(RELEASE_NAME), - '{0}-selenium-distributor'.format(RELEASE_NAME), - '{0}-selenium-edge-node'.format(RELEASE_NAME), - '{0}-selenium-firefox-node'.format(RELEASE_NAME), - '{0}-selenium-event-bus'.format(RELEASE_NAME), - '{0}-selenium-router'.format(RELEASE_NAME), - '{0}-selenium-session-map'.format(RELEASE_NAME), - '{0}-selenium-session-queue'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-chrome-node'.format(RELEASE_NAME), + '{0}selenium-distributor'.format(RELEASE_NAME), + '{0}selenium-edge-node'.format(RELEASE_NAME), + '{0}selenium-firefox-node'.format(RELEASE_NAME), + '{0}selenium-event-bus'.format(RELEASE_NAME), + '{0}selenium-router'.format(RELEASE_NAME), + '{0}selenium-session-map'.format(RELEASE_NAME), + '{0}selenium-session-queue'.format(RELEASE_NAME)] count = 0 logger.info(f"Assert affinity is set in global and nodes") for doc in LIST_OF_DOCUMENTS: @@ -35,7 +35,7 @@ def test_set_affinity(self): self.assertEqual(count, len(resources_name), "Not all resources have affinity set") def test_ingress_nginx_annotations(self): - resources_name = ['{0}-selenium-ingress'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-ingress'.format(RELEASE_NAME)] count = 0 for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'Ingress': @@ -52,7 +52,7 @@ def test_ingress_nginx_annotations(self): self.assertEqual(count, len(resources_name), "No ingress resources found") def test_sub_path_append_to_node_grid_url(self): - resources_name = ['{0}-selenium-node-config'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-node-config'.format(RELEASE_NAME)] count = 0 for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap': @@ -62,7 +62,7 @@ def test_sub_path_append_to_node_grid_url(self): self.assertEqual(count, len(resources_name), "No node config resources found") def test_sub_path_set_to_grid_env_var(self): - resources_name = ['{0}-selenium-router'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-router'.format(RELEASE_NAME)] is_present = False for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment': @@ -74,7 +74,7 @@ def test_sub_path_set_to_grid_env_var(self): self.assertTrue(is_present, "ENV variable SE_SUB_PATH is not populated") def test_disable_ui_set_to_grid_env_var(self): - resources_name = ['{0}-selenium-router'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-router'.format(RELEASE_NAME)] is_present = False for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'Deployment': @@ -86,18 +86,18 @@ def test_disable_ui_set_to_grid_env_var(self): self.assertTrue(is_present, "ENV variable SE_DISABLE_UI is not populated") def test_log_level_set_to_logging_config_map(self): - resources_name = ['{0}-selenium-chrome-node'.format(RELEASE_NAME), - '{0}-selenium-distributor'.format(RELEASE_NAME), - '{0}-selenium-edge-node'.format(RELEASE_NAME), - '{0}-selenium-firefox-node'.format(RELEASE_NAME), - '{0}-selenium-event-bus'.format(RELEASE_NAME), - '{0}-selenium-router'.format(RELEASE_NAME), - '{0}-selenium-session-map'.format(RELEASE_NAME), - '{0}-selenium-session-queue'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-chrome-node'.format(RELEASE_NAME), + '{0}selenium-distributor'.format(RELEASE_NAME), + '{0}selenium-edge-node'.format(RELEASE_NAME), + '{0}selenium-firefox-node'.format(RELEASE_NAME), + '{0}selenium-event-bus'.format(RELEASE_NAME), + '{0}selenium-router'.format(RELEASE_NAME), + '{0}selenium-session-map'.format(RELEASE_NAME), + '{0}selenium-session-queue'.format(RELEASE_NAME)] logger.info(f"Assert log level value is set to logging ConfigMap") count_config = 0 for doc in LIST_OF_DOCUMENTS: - if doc['metadata']['name'] == '{0}-selenium-logging-config'.format(RELEASE_NAME) and doc['kind'] == 'ConfigMap': + if doc['metadata']['name'] == '{0}selenium-logging-config'.format(RELEASE_NAME) and doc['kind'] == 'ConfigMap': self.assertTrue(doc['data']['SE_LOG_LEVEL'] == 'FINE') count_config += 1 self.assertEqual(count_config, 1, "No logging ConfigMap found") @@ -109,16 +109,16 @@ def test_log_level_set_to_logging_config_map(self): list_env_from = doc['spec']['template']['spec']['containers'][0]['envFrom'] for env in list_env_from: if env.get('configMapRef') is not None: - if env['configMapRef']['name'] == '{0}-selenium-logging-config'.format(RELEASE_NAME): + if env['configMapRef']['name'] == '{0}selenium-logging-config'.format(RELEASE_NAME): is_present = True self.assertTrue(is_present, "envFrom doesn't contain logging ConfigMap") count += 1 self.assertEqual(count, len(resources_name), "Logging ConfigMap is not present in expected resources") def test_node_port_set_when_service_type_is_node_port(self): - single_node_port = {'{0}-selenium-distributor'.format(RELEASE_NAME): 30553, - '{0}-selenium-router'.format(RELEASE_NAME): 30444, - '{0}-selenium-session-queue'.format(RELEASE_NAME): 30559} + single_node_port = {'{0}selenium-distributor'.format(RELEASE_NAME): 30553, + '{0}selenium-router'.format(RELEASE_NAME): 30444, + '{0}selenium-session-queue'.format(RELEASE_NAME): 30559} count = 0 logger.info(f"Assert NodePort is set to components service") for doc in LIST_OF_DOCUMENTS: @@ -130,13 +130,14 @@ def test_node_port_set_when_service_type_is_node_port(self): def test_all_metadata_name_is_prefixed_with_release_name(self): logger.info(f"Assert all metadata name is prefixed with RELEASE NAME") + prefix = "selenium-" if RELEASE_NAME == "" else RELEASE_NAME for doc in LIST_OF_DOCUMENTS: logger.info(f"Assert metadata name: {doc['metadata']['name']}") self.assertTrue(doc['metadata']['name'].startswith(RELEASE_NAME), f"Metadata name {doc['metadata']['name']} is not prefixed with RELEASE NAME: {RELEASE_NAME}") def test_extra_script_import_to_node_configmap(self): - resources_name = ['{0}-selenium-node-config'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-node-config'.format(RELEASE_NAME)] count = 0 for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap': @@ -149,7 +150,7 @@ def test_extra_script_import_to_node_configmap(self): self.assertEqual(count, len(resources_name), "No node config resources found") def test_extra_script_import_to_uploader_configmap(self): - resources_name = ['{0}-selenium-uploader-config'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-uploader-config'.format(RELEASE_NAME)] count = 0 for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap': @@ -160,7 +161,7 @@ def test_extra_script_import_to_uploader_configmap(self): self.assertEqual(count, len(resources_name), "No uploader config resources found") def test_extra_script_import_to_recorder_configmap(self): - resources_name = ['{0}-selenium-recorder-config'.format(RELEASE_NAME)] + resources_name = ['{0}selenium-recorder-config'.format(RELEASE_NAME)] count = 0 for doc in LIST_OF_DOCUMENTS: if doc['metadata']['name'] in resources_name and doc['kind'] == 'ConfigMap': @@ -175,6 +176,10 @@ def test_extra_script_import_to_recorder_configmap(self): try: FILE_NAME = sys.argv[1] RELEASE_NAME = sys.argv[2] + if RELEASE_NAME == "selenium": + RELEASE_NAME = "" + else: + RELEASE_NAME = RELEASE_NAME + "-" LIST_OF_DOCUMENTS = load_template(FILE_NAME) suite = unittest.TestLoader().loadTestsFromTestCase(ChartTemplateTests) test_runner = unittest.TextTestRunner(verbosity=3) diff --git a/tests/charts/umbrella-charts/Chart.yaml b/tests/charts/umbrella-charts/Chart.yaml index 7f655364c..364127cd2 100644 --- a/tests/charts/umbrella-charts/Chart.yaml +++ b/tests/charts/umbrella-charts/Chart.yaml @@ -6,5 +6,5 @@ version: 0.0.1 appVersion: "1.0.0" dependencies: - name: selenium-grid - version: 0.28.2 + version: 0.28.3 repository: file://../../../charts/selenium-grid