diff --git a/tests/charts/bootstrap.sh b/tests/charts/bootstrap.sh index 33721c44b6..6bf2460b38 100755 --- a/tests/charts/bootstrap.sh +++ b/tests/charts/bootstrap.sh @@ -21,7 +21,7 @@ helm template dummy --values tests/charts/templates/render/dummy.yaml \ --set-file 'uploaderConfigMap.secretFiles.config\.conf=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" +python tests/charts/templates/test.py "./tests/tests/dummy_template_manifests.yaml" dummy ret_code=$? if [ "${CI:-false}" = "false" ]; then diff --git a/tests/charts/templates/test.py b/tests/charts/templates/test.py index 1d01965840..18cc05e8ef 100644 --- a/tests/charts/templates/test.py +++ b/tests/charts/templates/test.py @@ -17,8 +17,14 @@ def load_template(yaml_file): class ChartTemplateTests(unittest.TestCase): def test_set_affinity(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'] + 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: @@ -29,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 = ['selenium-ingress'] + 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': @@ -46,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 = ['selenium-node-config'] + 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': @@ -56,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 = ['selenium-router'] + 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': @@ -68,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 = ['selenium-router'] + 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': @@ -80,12 +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 = ['selenium-chrome-node', 'selenium-distributor', 'selenium-edge-node', 'selenium-firefox-node', - 'selenium-event-bus', 'selenium-router', 'selenium-session-map', 'selenium-session-queue'] + 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'] == 'selenium-logging-config' 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") @@ -97,14 +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'] == 'selenium-logging-config': + 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 = {'selenium-distributor': 30553, 'selenium-router': 30444, 'selenium-session-queue': 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: @@ -118,6 +132,7 @@ def test_node_port_set_when_service_type_is_node_port(self): failed = False try: FILE_NAME = sys.argv[1] + RELEASE_NAME = sys.argv[2] LIST_OF_DOCUMENTS = load_template(FILE_NAME) suite = unittest.TestLoader().loadTestsFromTestCase(ChartTemplateTests) test_runner = unittest.TextTestRunner(verbosity=3)