diff --git a/config/configuration_manager.py b/config/configuration_manager.py index 587beeb..767d11b 100644 --- a/config/configuration_manager.py +++ b/config/configuration_manager.py @@ -6,6 +6,7 @@ from config.lab.objects.lab_config import LabConfig from config.logger.objects.logger_config import LoggerConfig from config.rest_api.objects.rest_api_config import RestAPIConfig from config.web.objects.web_config import WebConfig +from framework.resources.resource_finder import get_stx_resource_path class ConfigurationManagerClass: @@ -39,31 +40,31 @@ class ConfigurationManagerClass: lab_config_file = config_file_locations.get_lab_config_file() if not lab_config_file: - lab_config_file = 'config/lab/files/default.json5' + lab_config_file = get_stx_resource_path('config/lab/files/default.json5') k8s_config_file = config_file_locations.get_k8s_config_file() if not k8s_config_file: - k8s_config_file = 'config/k8s/files/default.json5' + k8s_config_file = get_stx_resource_path('config/k8s/files/default.json5') logger_config_file = config_file_locations.get_logger_config_file() if not logger_config_file: - logger_config_file = 'config/logger/files/default.json5' + logger_config_file = get_stx_resource_path('config/logger/files/default.json5') docker_config_file = config_file_locations.get_docker_config_file() if not docker_config_file: - docker_config_file = 'config/docker/files/default.json5' + docker_config_file = get_stx_resource_path('config/docker/files/default.json5') web_config_file = config_file_locations.get_web_config_file() if not web_config_file: - web_config_file = 'config/web/files/default.json5' + web_config_file = get_stx_resource_path('config/web/files/default.json5') database_config_file = config_file_locations.get_database_config_file() if not database_config_file: - database_config_file = 'config/database/files/default.json5' + database_config_file = get_stx_resource_path('config/database/files/default.json5') rest_api_config_file = config_file_locations.get_rest_api_config_file() if not rest_api_config_file: - rest_api_config_file = 'config/rest_api/files/default.json5' + rest_api_config_file = get_stx_resource_path('config/rest_api/files/default.json5') if not self.loaded: try: diff --git a/config/lab/objects/lab_config.py b/config/lab/objects/lab_config.py index ee1936e..e566c3c 100644 --- a/config/lab/objects/lab_config.py +++ b/config/lab/objects/lab_config.py @@ -4,6 +4,7 @@ import json5 from config.host.objects.host_configuration import HostConfiguration from config.lab.objects.credentials import Credentials from config.lab.objects.node import Node +from framework.resources.resource_finder import get_stx_resource_path class LabConfig: @@ -27,7 +28,8 @@ class LabConfig: self.bm_password = lab_dict['bm_password'] self.use_jump_server = lab_dict['use_jump_server'] if 'jump_server_config' in lab_dict: - self.jump_server_config = HostConfiguration(lab_dict['jump_server_config']) + jump_host_config_location = get_stx_resource_path(lab_dict['jump_server_config']) + self.jump_server_config = HostConfiguration(jump_host_config_location) self.ssh_port: int = 22 if 'ssh_port' in lab_dict: @@ -58,7 +60,8 @@ class LabConfig: # if subclouds are listed in the config get the list with the subcloud's names. if 'subclouds' in lab_dict: for subcloud in lab_dict['subclouds']: - self.subclouds.append(LabConfig(lab_dict['subclouds'][subcloud])) + subcloud_config_location = get_stx_resource_path((lab_dict['subclouds'][subcloud])) + self.subclouds.append(LabConfig(subcloud_config_location)) if 'nodes' in lab_dict: for node in lab_dict['nodes']: diff --git a/framework/resources/resource_finder.py b/framework/resources/resource_finder.py new file mode 100644 index 0000000..73cb731 --- /dev/null +++ b/framework/resources/resource_finder.py @@ -0,0 +1,27 @@ +# This utility file contains functions to help the code find the path to resource files +# when starlingx gets used as a submodule, or from outside code. +from pathlib import Path + + +def get_stx_resource_path(relative_path: str) -> str: + """ + This function will get the full path to the resource from the relative_path provided. + This will allow projects that use StarlingX as a submodule to still find resource files using the relative path. + + Args: + relative_path: The relative path to the resource. + + Returns: The full path to the resource + + Example: + >>> get_resource_path("framework/resources/resource_finder.py") + will return /home/user/repo/starlingx/framework/resources/resource_finder.py + """ + + path_of_this_file = Path(__file__) + root_folder_of_stx = path_of_this_file.parent.parent.parent + path_to_resource = f"{str(root_folder_of_stx)}/{relative_path}" + + return path_to_resource + + diff --git a/testcases/cloud_platform/sanity/test_sanity.py b/testcases/cloud_platform/sanity/test_sanity.py index 01b7536..f06713a 100644 --- a/testcases/cloud_platform/sanity/test_sanity.py +++ b/testcases/cloud_platform/sanity/test_sanity.py @@ -3,6 +3,7 @@ import time import pytest from config.configuration_manager import ConfigurationManager from framework.logging.automation_logger import get_logger +from framework.resources.resource_finder import get_stx_resource_path from framework.ssh.secure_transfer_file.secure_transfer_file import SecureTransferFile from framework.ssh.secure_transfer_file.secure_transfer_file_enum import TransferDirection from framework.ssh.secure_transfer_file.secure_transfer_file_input_object import SecureTransferFileInputObject @@ -320,9 +321,9 @@ def deploy_pods(request, ssh_connection: SSHConnection): KubectlDeletePodsKeywords(ssh_connection).cleanup_pod('client-pod1') KubectlDeletePodsKeywords(ssh_connection).cleanup_pod('client-pod2') - file_keywords.upload_file('resources/cloud_platform/sanity/pods/client-pod1.yaml', '/home/sysadmin/client-pod1.yaml') - file_keywords.upload_file('resources/cloud_platform/sanity/pods/client-pod2.yaml', '/home/sysadmin/client-pod2.yaml') - file_keywords.upload_file('resources/cloud_platform/sanity/pods/server_pod.yaml', '/home/sysadmin/server_pod.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/sanity/pods/client-pod1.yaml'), '/home/sysadmin/client-pod1.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/sanity/pods/client-pod2.yaml'), '/home/sysadmin/client-pod2.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/sanity/pods/server_pod.yaml'), '/home/sysadmin/server_pod.yaml') kubectl_create_pods_keyword = KubectlCreatePodsKeywords(ssh_connection) kubectl_create_pods_keyword.create_from_yaml('/home/sysadmin/server_pod.yaml') kubectl_create_pods_keyword.create_from_yaml('/home/sysadmin/client-pod1.yaml') @@ -507,7 +508,7 @@ def test_dc_install_custom_app(): # Defines application name, application file name, source (local) and destination (remote) file paths. app_name = 'hello-kitty' app_file_name = 'hello-kitty-min-k8s-version.tgz' - local_path = f'resources/cloud_platform/containers/{app_file_name}' + local_path = get_stx_resource_path(f'resources/cloud_platform/containers/{app_file_name}') remote_path = f'/home/{ConfigurationManager.get_lab_config().get_admin_credentials().get_user_name()}/{app_file_name}' # Opens an SSH session to active controller. diff --git a/testcases/cloud_platform/sanity/test_sanity_regression.py b/testcases/cloud_platform/sanity/test_sanity_regression.py index 23054a7..cd3117d 100644 --- a/testcases/cloud_platform/sanity/test_sanity_regression.py +++ b/testcases/cloud_platform/sanity/test_sanity_regression.py @@ -2,6 +2,7 @@ import time from config.configuration_manager import ConfigurationManager from framework.logging.automation_logger import get_logger +from framework.resources.resource_finder import get_stx_resource_path from framework.ssh.ssh_connection import SSHConnection from keywords.cloud_platform.helm.helm_keywords import HelmKeywords from keywords.cloud_platform.networking.sriov.get_sriov_config_keywords import GetSriovConfigKeywords @@ -69,7 +70,7 @@ def test_push_docker_image_to_local_registry_simplex(request): local_registry = ConfigurationManager.get_docker_config().get_registry('local_registry') - FileKeywords(ssh_connection).upload_file("resources/images/busybox.tar", "/home/sysadmin/busybox.tar", overwrite=False) + FileKeywords(ssh_connection).upload_file(get_stx_resource_path("resources/images/busybox.tar"), "/home/sysadmin/busybox.tar", overwrite=False) KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) docker_load_image_keywords.load_docker_image_to_host('busybox.tar') @@ -121,7 +122,7 @@ def test_push_docker_image_to_local_registry_standby(request): local_registry = ConfigurationManager.get_docker_config().get_registry('local_registry') - FileKeywords(ssh_connection).upload_file("resources/images/busybox.tar", "/home/sysadmin/busybox.tar", overwrite=False) + FileKeywords(ssh_connection).upload_file(get_stx_resource_path("resources/images/busybox.tar"), "/home/sysadmin/busybox.tar", overwrite=False) KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) docker_load_image_keywords.load_docker_image_to_host('busybox.tar') @@ -251,7 +252,7 @@ def test_upload_charts_via_helm_upload_simplex(): file_keywords.delete_file(f"{helm_chart_location}/{helm_file}") # upload file to lab - file_keywords.upload_file(f"resources/cloud_platform/containers/{helm_file}", f"/home/sysadmin/{helm_file}", overwrite=True) + file_keywords.upload_file(get_stx_resource_path(f"resources/cloud_platform/containers/{helm_file}"), f"/home/sysadmin/{helm_file}", overwrite=True) # run helm-upload command HelmKeywords(ssh_connection).helm_upload('starlingx', f'/home/sysadmin/{helm_file}') @@ -284,7 +285,7 @@ def test_upload_charts_via_helm_upload_standby_controller(request): file_keywords.delete_file(f"{helm_chart_location}/{helm_file}") # upload file to lab - file_keywords.upload_file(f"resources/cloud_platform/containers/{helm_file}", f"/home/sysadmin/{helm_file}", overwrite=True) + file_keywords.upload_file(get_stx_resource_path(f"resources/cloud_platform/containers/{helm_file}"), f"/home/sysadmin/{helm_file}", overwrite=True) # run helm-upload command HelmKeywords(ssh_connection).helm_upload('starlingx', f'/home/sysadmin/{helm_file}') @@ -504,7 +505,7 @@ def deploy_images_to_local_registry(ssh_connection: SSHConnection): local_registry = ConfigurationManager.get_docker_config().get_registry('local_registry') docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) - FileKeywords(ssh_connection).upload_file("resources/images/resource-consumer.tar", "/home/sysadmin/resource-consumer.tar", overwrite=False) + FileKeywords(ssh_connection).upload_file(get_stx_resource_path("resources/images/resource-consumer.tar"), "/home/sysadmin/resource-consumer.tar", overwrite=False) KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') docker_load_image_keywords.load_docker_image_to_host('resource-consumer.tar') docker_load_image_keywords.tag_docker_image_for_registry('gcr.io/kubernetes-e2e-test-images/resource-consumer:1.4', 'resource-consumer', local_registry) @@ -537,7 +538,7 @@ def deploy_pods(request, ssh_connection: SSHConnection): request.addfinalizer(remove_deployments_and_pods) - FileKeywords(ssh_connection).upload_file('resources/cloud_platform/sanity/pods/consumer_app.yaml', '/home/sysadmin/consumer_app.yaml') + FileKeywords(ssh_connection).upload_file(get_stx_resource_path('resources/cloud_platform/sanity/pods/consumer_app.yaml'), '/home/sysadmin/consumer_app.yaml') kubectl_create_pods_keyword = KubectlCreatePodsKeywords(ssh_connection) kubectl_create_pods_keyword.create_from_yaml('/home/sysadmin/consumer_app.yaml') @@ -699,7 +700,7 @@ def test_isolated_2processors_2big_pods_best_effort_simplex(request): KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file("resources/images/pv-test.tar", "/home/sysadmin/pv-test.tar", overwrite=False) + file_keywords.upload_file(get_stx_resource_path("resources/images/pv-test.tar"), "/home/sysadmin/pv-test.tar", overwrite=False) docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) docker_load_image_keywords.load_docker_image_to_host('pv-test.tar') docker_load_image_keywords.tag_docker_image_for_registry('registry.local:9001/pv-test', 'pv-test', local_registry) @@ -709,7 +710,7 @@ def test_isolated_2processors_2big_pods_best_effort_simplex(request): # Create Pod 0 to fill the isolcpus on one processor pod0_name = "test-isolated-2p-2-big-pod-best-effort-ht-aio-pod0" isolcpus_on_processor_0 = host_cpu_output_for_validation.get_number_of_logical_cores(processor_id=0, assigned_function='Application-isolated') - template_file = "resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml" + template_file = get_stx_resource_path("resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml") replacement_dictionary = {"pod_name": pod0_name, "number_of_isolcpus": isolcpus_on_processor_0, "host_name": active_controller_name} pod0_yaml = YamlKeywords(ssh_connection).generate_yaml_file_from_template(template_file, replacement_dictionary, "isolated_cpu_tools.yaml", "/home/sysadmin") KubectlApplyPodsKeywords(ssh_connection).apply_from_yaml(pod0_yaml) @@ -752,7 +753,7 @@ def test_isolated_2processors_2big_pods_best_effort_simplex(request): # Create Pod 1 to fill the isolcpus on the second processor pod1_name = "test-isolated-2p-2-big-pod-best-effort-ht-aio-pod1" isolcpus_on_processor_1 = host_cpu_output_for_validation.get_number_of_logical_cores(processor_id=1, assigned_function='Application-isolated') - template_file = "resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml" + template_file = get_stx_resource_path("resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml") replacement_dictionary = {"pod_name": pod1_name, "number_of_isolcpus": isolcpus_on_processor_1, "host_name": active_controller_name} pod1_yaml = YamlKeywords(ssh_connection).generate_yaml_file_from_template(template_file, replacement_dictionary, "isolated_cpu_tools.yaml", "/home/sysadmin") KubectlApplyPodsKeywords(ssh_connection).apply_from_yaml(pod1_yaml) @@ -959,7 +960,7 @@ def test_isolated_2processors_2big_pods_best_effort_standby_controller(request): KubectlCreateSecretsKeywords(standby_controller_ssh).create_secret_for_registry(local_registry, 'local-secret') file_keywords = FileKeywords(standby_controller_ssh) - file_keywords.upload_file("resources/images/pv-test.tar", "/home/sysadmin/pv-test.tar", overwrite=False) + file_keywords.upload_file(get_stx_resource_path("resources/images/pv-test.tar"), "/home/sysadmin/pv-test.tar", overwrite=False) docker_load_image_keywords = DockerLoadImageKeywords(standby_controller_ssh) docker_load_image_keywords.load_docker_image_to_host('pv-test.tar') docker_load_image_keywords.tag_docker_image_for_registry('registry.local:9001/pv-test', 'pv-test', local_registry) @@ -969,7 +970,7 @@ def test_isolated_2processors_2big_pods_best_effort_standby_controller(request): # Create Pod 0 to fill the isolcpus on one processor pod0_name = "test-isolated-2p-2-big-pod-best-effort-ht-aio-pod0" isolcpus_on_processor_0 = host_cpu_output_for_validation.get_number_of_logical_cores(processor_id=0, assigned_function='Application-isolated') - template_file = "resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml" + template_file = get_stx_resource_path("resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml") replacement_dictionary = {"pod_name": pod0_name, "number_of_isolcpus": isolcpus_on_processor_0, "host_name": standby_controller_name} pod0_yaml = YamlKeywords(standby_controller_ssh).generate_yaml_file_from_template(template_file, replacement_dictionary, "isolated_cpu_tools.yaml", "/home/sysadmin") KubectlApplyPodsKeywords(standby_controller_ssh).apply_from_yaml(pod0_yaml) @@ -1012,7 +1013,7 @@ def test_isolated_2processors_2big_pods_best_effort_standby_controller(request): # Create Pod 1 to fill the isolcpus on the second processor pod1_name = "test-isolated-2p-2-big-pod-best-effort-ht-aio-pod1" isolcpus_on_processor_1 = host_cpu_output_for_validation.get_number_of_logical_cores(processor_id=1, assigned_function='Application-isolated') - template_file = "resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml" + template_file = get_stx_resource_path("resources/cloud_platform/nightly_regression/isolated_cpu_tools.yaml") replacement_dictionary = {"pod_name": pod1_name, "number_of_isolcpus": isolcpus_on_processor_1, "host_name": standby_controller_name} pod1_yaml = YamlKeywords(standby_controller_ssh).generate_yaml_file_from_template(template_file, replacement_dictionary, "isolated_cpu_tools.yaml", "/home/sysadmin") KubectlApplyPodsKeywords(standby_controller_ssh).apply_from_yaml(pod1_yaml) @@ -1449,19 +1450,16 @@ def sriov_deploy_images_to_local_registry(ssh_connection: SSHConnection): """ local_registry = ConfigurationManager.get_docker_config().get_registry('local_registry') - - docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) - file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file("resources/images/pv-test.tar", "/home/sysadmin/pv-test.tar", overwrite=False) + file_keywords.upload_file(get_stx_resource_path("resources/images/pv-test.tar"), "/home/sysadmin/pv-test.tar", overwrite=False) KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') docker_load_image_keywords = DockerLoadImageKeywords(ssh_connection) docker_load_image_keywords.load_docker_image_to_host('pv-test.tar') docker_load_image_keywords.tag_docker_image_for_registry('registry.local:9001/pv-test', 'pv-test', local_registry) docker_load_image_keywords.push_docker_image_to_registry('pv-test', local_registry) - file_keywords.upload_file("resources/images/calico-ctl.tar", "/home/sysadmin/calico-ctl.tar", overwrite=False) + file_keywords.upload_file(get_stx_resource_path("resources/images/calico-ctl.tar"), "/home/sysadmin/calico-ctl.tar", overwrite=False) KubectlCreateSecretsKeywords(ssh_connection).create_secret_for_registry(local_registry, 'local-secret') docker_load_image_keywords.load_docker_image_to_host('calico-ctl.tar') docker_load_image_keywords.tag_docker_image_for_registry('registry.local:9001/calico-ctl', 'calico-ctl', local_registry) @@ -1496,12 +1494,12 @@ def sriov_deploy_pods(request, net_def_yaml: str, calicoctl_pod_yaml: str, ssh_c # copy required files to system file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file('resources/cloud_platform/nightly_regression/calicoctl_sa.yaml', '/home/sysadmin/calicoctl_sa.yaml') - file_keywords.upload_file('resources/cloud_platform/nightly_regression/calicoctl_cr.yaml', '/home/sysadmin/calicoctl_cr.yaml') - file_keywords.upload_file('resources/cloud_platform/nightly_regression/calicoctl_crb.yaml', '/home/sysadmin/calicoctl_crb.yaml') - file_keywords.upload_file('resources/cloud_platform/nightly_regression/calicoctl_pod.yaml', '/home/sysadmin/calicoctl_pod.yaml') - file_keywords.upload_file(f'resources/cloud_platform/nightly_regression/{net_def_yaml}', f'/home/sysadmin/{net_def_yaml}') - file_keywords.upload_file(f'resources/cloud_platform/nightly_regression/{calicoctl_pod_yaml}', f'/home/sysadmin/{calicoctl_pod_yaml}') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/calicoctl_sa.yaml'), '/home/sysadmin/calicoctl_sa.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/calicoctl_cr.yaml'), '/home/sysadmin/calicoctl_cr.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/calicoctl_crb.yaml'), '/home/sysadmin/calicoctl_crb.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/calicoctl_pod.yaml'), '/home/sysadmin/calicoctl_pod.yaml') + file_keywords.upload_file(get_stx_resource_path(f'resources/cloud_platform/nightly_regression/{net_def_yaml}'), f'/home/sysadmin/{net_def_yaml}') + file_keywords.upload_file(get_stx_resource_path(f'resources/cloud_platform/nightly_regression/{calicoctl_pod_yaml}'), f'/home/sysadmin/{calicoctl_pod_yaml}') # apply config files kubectl_apply_pods_keywords = KubectlApplyPodsKeywords(ssh_connection) @@ -1546,7 +1544,7 @@ def sriov_deploy_pods_ipv4(request, ssh_connection: SSHConnection): # copy required files to system file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file('resources/cloud_platform/nightly_regression/netdef_test-sriovdp_ipv4.yaml', '/home/sysadmin/netdef_test-sriovdp_ipv4.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/netdef_test-sriovdp_ipv4.yaml'), '/home/sysadmin/netdef_test-sriovdp_ipv4.yaml') # apply config files kubectl_apply_pods_keywords = KubectlApplyPodsKeywords(ssh_connection) @@ -1564,7 +1562,7 @@ def deploy_daemonset_pod(request, daemonset_pod_yaml: str, ssh_connection: SSHCo Returns: """ - FileKeywords(ssh_connection).upload_file(f'resources/cloud_platform/nightly_regression/{daemonset_pod_yaml}', f'/home/sysadmin/{daemonset_pod_yaml}') + FileKeywords(ssh_connection).upload_file(get_stx_resource_path(f'resources/cloud_platform/nightly_regression/{daemonset_pod_yaml}'), f'/home/sysadmin/{daemonset_pod_yaml}') KubectlApplyPodsKeywords(ssh_connection).apply_from_yaml(f'/home/sysadmin/{daemonset_pod_yaml}') @@ -1602,8 +1600,8 @@ def deploy_sriovdp_netdev_pods_ipv6(request, ssh_connection: SSHConnection): """ file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv6-0.yaml', '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv6-0.yaml') - file_keywords.upload_file('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv6-1.yaml', '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv6-1.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv6-0.yaml'), '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv6-0.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv6-1.yaml'), '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv6-1.yaml') kubectl_apply_pods_keywords = KubectlApplyPodsKeywords(ssh_connection) kubectl_apply_pods_keywords.apply_from_yaml('/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv6-0.yaml') @@ -1651,8 +1649,8 @@ def deploy_sriovdp_netdev_pods_ipv4(request, ssh_connection: SSHConnection): """ file_keywords = FileKeywords(ssh_connection) - file_keywords.upload_file('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv4-0.yaml', '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv4-0.yaml') - file_keywords.upload_file('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv4-1.yaml', '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv4-1.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv4-0.yaml'), '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv4-0.yaml') + file_keywords.upload_file(get_stx_resource_path('resources/cloud_platform/nightly_regression/pod-test-sriovdp-netdev-connectivity-ipv4-1.yaml'), '/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv4-1.yaml') kubectl_apply_pods_keywords = KubectlApplyPodsKeywords(ssh_connection) kubectl_apply_pods_keywords.apply_from_yaml('/home/sysadmin/pod-test-sriovdp-netdev-connectivity-ipv4-0.yaml') diff --git a/unit_tests/config/database/database_config_test.py b/unit_tests/config/database/database_config_test.py index cf451c3..fa66e29 100644 --- a/unit_tests/config/database/database_config_test.py +++ b/unit_tests/config/database/database_config_test.py @@ -1,5 +1,6 @@ from config.configuration_file_locations_manager import ConfigurationFileLocationsManager from config.configuration_manager import ConfigurationManagerClass +from framework.resources.resource_finder import get_stx_resource_path def test_default_database_config(): @@ -26,7 +27,7 @@ def test_custom_database_config(): Tests that we can load a custom database configuration. """ - custom_file = 'unit_tests/config/database/custom_database_config.json5' + custom_file = get_stx_resource_path('unit_tests/config/database/custom_database_config.json5') configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() config_file_locations.set_database_config_file(custom_file) diff --git a/unit_tests/config/lab/dc_template_config_test.py b/unit_tests/config/lab/dc_template_config_test.py index 9fa8210..01f5bea 100644 --- a/unit_tests/config/lab/dc_template_config_test.py +++ b/unit_tests/config/lab/dc_template_config_test.py @@ -1,5 +1,6 @@ from config.configuration_file_locations_manager import ConfigurationFileLocationsManager from config.configuration_manager import ConfigurationManagerClass +from framework.resources.resource_finder import get_stx_resource_path def test_dc_config_loads_successfully(): @@ -10,7 +11,7 @@ def test_dc_config_loads_successfully(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config() is not None, 'dc template config did not load successfully' @@ -23,7 +24,7 @@ def test_dc_config_loads_floating_ip(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_floating_ip() == '10.2.3.125', 'floating ip was incorrect' @@ -36,7 +37,7 @@ def test_dc_config_loads_lab_name(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_name() == 'MyDCLab', 'Lab name was incorrect' @@ -49,7 +50,7 @@ def test_dc_config_loads_lab_type(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_type() == 'Standard', 'lab type was incorrect' @@ -62,7 +63,7 @@ def test_dc_config_loads_admin_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) admin_credentials = configuration_manager.get_lab_config().get_admin_credentials() assert admin_credentials is not None, 'error loading admin credentials' @@ -78,7 +79,7 @@ def test_dc_config_loads_nodes(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) nodes = configuration_manager.get_lab_config().get_nodes() assert len(list(filter(lambda node: node.get_name() == 'controller-0', nodes))) == 1, 'Controller-0 not in nodes' @@ -95,7 +96,7 @@ def test_dc_config_controller_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('controller-0') assert node.get_ip() == '10.2.3.126', 'controller-0 ip is incorrect' @@ -111,7 +112,7 @@ def test_dc_config_controller_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('controller-1') assert node.get_ip() == '10.2.3.127', 'controller-1 ip is incorrect' @@ -127,7 +128,7 @@ def test_dc_config_compute_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('compute-0') assert node.get_ip() == '10.2.3.128', 'compute-0 ip is incorrect' @@ -143,7 +144,7 @@ def test_dc_config_compute_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('compute-1') assert node.get_ip() == '10.2.3.129', 'compute-1 ip is incorrect' @@ -159,7 +160,7 @@ def test_dc_config_ipv4(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().is_ipv6() is False, 'lab is not ipv4' @@ -172,7 +173,7 @@ def test_dc_subclouds_loaded(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subclouds = configuration_manager.get_lab_config().get_subclouds() assert len(list(filter(lambda subcloud: subcloud.get_lab_name() == 'Subcloud1', subclouds))) == 1, 'Subcloud1 not in nodes' @@ -187,7 +188,7 @@ def test_dc_subcloud1_config_loads_floating_ip(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') assert subcloud1.get_floating_ip() == '10.2.3.130', 'floating ip was incorrect' @@ -201,7 +202,7 @@ def test_dc_subcloud1_config_loads_lab_name(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') assert subcloud1.get_lab_name() == 'Subcloud1', 'Sublcloud name was incorrect' @@ -215,7 +216,7 @@ def test_dc_subcloud1_config_loads_lab_type(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') assert subcloud1.get_lab_type() == 'Standard', 'subcloud type was incorrect' @@ -229,7 +230,7 @@ def test_dc_subcloud1_config_loads_admin_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') admin_credentials = subcloud1.get_admin_credentials() @@ -246,7 +247,7 @@ def test_dc_subcloud1_config_loads_nodes(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') nodes = subcloud1.get_nodes() @@ -264,7 +265,7 @@ def test_dc_subcloud1_config_controller_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') node = subcloud1.get_node('controller-0') @@ -281,7 +282,7 @@ def test_dc_subcloud1_config_controller_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') node = subcloud1.get_node('controller-1') @@ -298,7 +299,7 @@ def test_dc_subcloud1_config_compute_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') node = subcloud1.get_node('compute-0') @@ -315,7 +316,7 @@ def test_dc_subcloud1_config_compute_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') node = subcloud1.get_node('compute-1') @@ -332,7 +333,7 @@ def test_dc_subcloud1_config_ipv4(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud1 = configuration_manager.get_lab_config().get_subcloud('Subcloud1') @@ -347,7 +348,7 @@ def test_dc_subcloud2_config_loads_floating_ip(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') assert subcloud2.get_floating_ip() == '10.2.3.135', 'floating ip was incorrect' @@ -361,7 +362,7 @@ def test_dc_subcloud2_config_loads_lab_name(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') assert subcloud2.get_lab_name() == 'Subcloud2', 'Sublcloud name was incorrect' @@ -375,7 +376,7 @@ def test_dc_subcloud2_config_loads_lab_type(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') assert subcloud2.get_lab_type() == 'Simplex', 'subcloud type was incorrect' @@ -389,7 +390,7 @@ def test_dc_subcloud2_config_loads_admin_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') admin_credentials = subcloud2.get_admin_credentials() @@ -406,7 +407,7 @@ def test_dc_subcloud2_config_loads_nodes(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') nodes = subcloud2.get_nodes() @@ -421,7 +422,7 @@ def test_dc_subcloud2_config_controller_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') node = subcloud2.get_node('controller-0') @@ -438,7 +439,7 @@ def test_dc_subcloud2_config_ipv4(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) subcloud2 = configuration_manager.get_lab_config().get_subcloud('Subcloud2') @@ -453,7 +454,7 @@ def test_dc_is_dc_true(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_dc.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_dc.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().is_dc(), 'Lab was not marked as dc' diff --git a/unit_tests/config/lab/simplex_template_config_test.py b/unit_tests/config/lab/simplex_template_config_test.py index 8ff0d52..85f8a1b 100644 --- a/unit_tests/config/lab/simplex_template_config_test.py +++ b/unit_tests/config/lab/simplex_template_config_test.py @@ -1,5 +1,6 @@ from config.configuration_file_locations_manager import ConfigurationFileLocationsManager from config.configuration_manager import ConfigurationManagerClass +from framework.resources.resource_finder import get_stx_resource_path def test_simplex_config_loads_successfully(): @@ -10,7 +11,7 @@ def test_simplex_config_loads_successfully(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config() is not None, 'simplex template config did not load successfully' @@ -23,7 +24,7 @@ def test_simplex_config_loads_floating_ip(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_floating_ip() == '3851:dc57:c69a:3c77:5d53:29a1:f39c:3d9f', 'floating ip was incorrect' @@ -36,7 +37,7 @@ def test_simplex_config_loads_lab_name(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_name() == 'MySimplexLab', 'Lab name was incorrect' @@ -49,7 +50,7 @@ def test_simplex_config_loads_lab_type(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_type() == 'Simplex', 'lab type was incorrect' @@ -62,7 +63,7 @@ def test_simplex_config_loads_admin_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) admin_credentials = configuration_manager.get_lab_config().get_admin_credentials() assert admin_credentials is not None, 'error loading admin credentials' @@ -78,7 +79,7 @@ def test_simplex_config_loads_nodes(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) nodes = configuration_manager.get_lab_config().get_nodes() assert len(list(filter(lambda node: node.get_name() == 'controller-0', nodes))) == 1, 'controller-0 not in nodes' @@ -92,7 +93,7 @@ def test_simplex_config_controller_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('controller-0') assert node.get_ip() == '3851:dc57:c69a:3c77:5d53:29a1:f39c:3d9f', 'controller-0 ip is incorrect' @@ -108,7 +109,7 @@ def test_simplex_config_ipv4(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().is_ipv6(), 'lab is not ipv6' @@ -121,7 +122,7 @@ def test_default_horizon_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_simplex.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_simplex.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_horizon_credentials().get_user_name(), 'admin' assert configuration_manager.get_lab_config().get_horizon_credentials().get_password(), 'fake_password' diff --git a/unit_tests/config/lab/standard_template_config_test.py b/unit_tests/config/lab/standard_template_config_test.py index 1ab9228..d4ed458 100644 --- a/unit_tests/config/lab/standard_template_config_test.py +++ b/unit_tests/config/lab/standard_template_config_test.py @@ -1,5 +1,6 @@ from config.configuration_file_locations_manager import ConfigurationFileLocationsManager from config.configuration_manager import ConfigurationManagerClass +from framework.resources.resource_finder import get_stx_resource_path def test_standard_config_loads_successfully(): @@ -10,7 +11,7 @@ def test_standard_config_loads_successfully(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config() is not None, 'standard template config did not load successfully' @@ -23,7 +24,7 @@ def test_standard_config_loads_floating_ip(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_floating_ip() == '10.2.3.120', 'floating ip was incorrect' @@ -36,7 +37,7 @@ def test_standard_config_loads_lab_name(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_name() == 'MyLab', 'Lab name was incorrect' @@ -49,7 +50,7 @@ def test_standard_config_loads_lab_type(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().get_lab_type() == 'Standard', 'lab type was incorrect' @@ -62,7 +63,7 @@ def test_standard_config_loads_admin_credentials(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) admin_credentials = configuration_manager.get_lab_config().get_admin_credentials() assert admin_credentials is not None, 'error loading admin credentials' @@ -78,7 +79,7 @@ def test_standard_config_loads_nodes(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) nodes = configuration_manager.get_lab_config().get_nodes() assert len(list(filter(lambda node: node.get_name() == 'controller-0', nodes))) == 1, 'controller-0 not in nodes' @@ -95,7 +96,7 @@ def test_standard_config_controller_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('controller-0') assert node.get_ip() == '10.2.3.121', 'controller-0 ip is incorrect' @@ -111,7 +112,7 @@ def test_standard_config_controller_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('controller-1') assert node.get_ip() == '10.2.3.122', 'controller-1 ip is incorrect' @@ -127,7 +128,7 @@ def test_standard_config_compute_0(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('compute-0') assert node.get_ip() == '10.2.3.123', 'compute-0 ip is incorrect' @@ -143,7 +144,7 @@ def test_standard_config_compute_1(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) node = configuration_manager.get_lab_config().get_node('compute-1') assert node.get_ip() == '10.2.3.124', 'compute-1 ip is incorrect' @@ -159,6 +160,6 @@ def test_standard_config_ipv4(): """ configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() - config_file_locations.set_lab_config_file('config/lab/files/template_standard.json5') + config_file_locations.set_lab_config_file(get_stx_resource_path('config/lab/files/template_standard.json5')) configuration_manager.load_configs(config_file_locations) assert configuration_manager.get_lab_config().is_ipv6() is False, 'lab is not ipv4' diff --git a/unit_tests/config/logger/logger_config_test.py b/unit_tests/config/logger/logger_config_test.py index 8c9f5f4..06115a3 100644 --- a/unit_tests/config/logger/logger_config_test.py +++ b/unit_tests/config/logger/logger_config_test.py @@ -3,6 +3,7 @@ import os from config.configuration_file_locations_manager import ConfigurationFileLocationsManager from config.configuration_manager import ConfigurationManagerClass +from framework.resources.resource_finder import get_stx_resource_path def test_default_logger_config(): @@ -34,7 +35,7 @@ def test_invalid_console_log_level_config(): """ try: - custom_file = 'unit_tests/config/logger/invalid_console_log_level_config.json5' + custom_file = get_stx_resource_path('unit_tests/config/logger/invalid_console_log_level_config.json5') configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() config_file_locations.set_logger_config_file(custom_file) @@ -50,7 +51,7 @@ def test_invalid_file_log_level_config(): """ try: - custom_file = 'unit_tests/config/logger/invalid_file_log_level_config.json5' + custom_file = get_stx_resource_path('unit_tests/config/logger/invalid_file_log_level_config.json5') configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() config_file_locations.set_logger_config_file(custom_file) @@ -65,7 +66,7 @@ def test_custom_logger_config(): Tests that we can load a custom logger configuration. """ - custom_file = 'unit_tests/config/logger/custom_logger_config.json5' + custom_file = get_stx_resource_path('unit_tests/config/logger/custom_logger_config.json5') configuration_manager = ConfigurationManagerClass() config_file_locations = ConfigurationFileLocationsManager() config_file_locations.set_logger_config_file(custom_file) diff --git a/unit_tests/framework/resources/resource_finder_test.py b/unit_tests/framework/resources/resource_finder_test.py new file mode 100644 index 0000000..459a4ba --- /dev/null +++ b/unit_tests/framework/resources/resource_finder_test.py @@ -0,0 +1,12 @@ +import os + +from framework.resources import resource_finder + + +def test_resource_finder(): + """ + Verify that the resource_finder can find the full path to the resources appropriately. + """ + + resource_full_path = resource_finder.get_stx_resource_path("framework/resources/resource_finder.py") + assert os.path.isfile(resource_full_path)