From 4ba20de52653286f535dd617ba2486fc6809120c Mon Sep 17 00:00:00 2001 From: Norberto Arrieta Date: Thu, 20 Apr 2023 17:18:56 -0700 Subject: [PATCH] Use cloud when validating test location (#2806) * Use cloud when validating test location --------- Co-authored-by: narrieta --- tests_e2e/orchestrator/lib/agent_test_loader.py | 9 +++++++-- .../orchestrator/lib/agent_test_suite_combinator.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_loader.py b/tests_e2e/orchestrator/lib/agent_test_loader.py index 201d39813..193ee9f4d 100644 --- a/tests_e2e/orchestrator/lib/agent_test_loader.py +++ b/tests_e2e/orchestrator/lib/agent_test_loader.py @@ -79,11 +79,14 @@ class AgentTestLoader(object): """ Loads a given set of test suites from the YAML configuration files. """ - def __init__(self, test_suites: str): + def __init__(self, test_suites: str, cloud: str): """ Loads the specified 'test_suites', which are given as a string of comma-separated suite names or a YAML description of a single test_suite. + The 'cloud' parameter indicates the cloud on which the tests will run. It is used to validate any restrictions on the test suite and/or + images location. + When given as a comma-separated list, each item must correspond to the name of the YAML files describing s suite (those files are located under the .../WALinuxAgent/tests_e2e/test_suites directory). For example, if test_suites == "agent_bvt, fast_track" then this method will load files agent_bvt.yml and fast_track.yml. @@ -97,6 +100,7 @@ def __init__(self, test_suites: str): - "bvts/vm_access.py" """ self.__test_suites: List[TestSuiteInfo] = self._load_test_suites(test_suites) + self.__cloud: str = cloud self.__images: Dict[str, List[VmImageInfo]] = self._load_images() self._validate() @@ -130,7 +134,8 @@ def _validate(self): for image in self.images[suite_image]: # If the image has a location restriction, validate that it is available on the location the suite must run on if image.locations: - if not any(suite.location in l for l in image.locations.values()): + locations = image.locations.get(self.__cloud) + if locations is not None and not any(suite.location in l for l in locations): raise Exception(f"Test suite {suite.name} must be executed in {suite.location}, but <{image.urn}> is not available in that location") @staticmethod diff --git a/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py b/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py index 839f39613..efb0e6f21 100644 --- a/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py +++ b/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py @@ -116,7 +116,7 @@ def _next(self) -> Optional[Dict[str, Any]]: } def create_environment_for_existing_vm(self) -> List[Dict[str, Any]]: - loader = AgentTestLoader(self.runbook.test_suites) + loader = AgentTestLoader(self.runbook.test_suites, self.runbook.cloud) environment: List[Dict[str, Any]] = [ { @@ -137,7 +137,7 @@ def create_environment_for_existing_vm(self) -> List[Dict[str, Any]]: return environment def create_environment_list(self) -> List[Dict[str, Any]]: - loader = AgentTestLoader(self.runbook.test_suites) + loader = AgentTestLoader(self.runbook.test_suites, self.runbook.cloud) # # If the runbook provides any of 'image', 'location', or 'vm_size', those values