From ac9261eff1603877a6528716180ef75351b704a3 Mon Sep 17 00:00:00 2001 From: narrieta Date: Mon, 17 Apr 2023 12:19:40 -0700 Subject: [PATCH 1/5] Use cloud when validating test location --- tests_e2e/orchestrator/lib/agent_test_loader.py | 13 +++++++++---- .../orchestrator/lib/agent_test_suite_combinator.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_loader.py b/tests_e2e/orchestrator/lib/agent_test_loader.py index f1a2dfc9d..743fabcbe 100644 --- a/tests_e2e/orchestrator/lib/agent_test_loader.py +++ b/tests_e2e/orchestrator/lib/agent_test_loader.py @@ -60,11 +60,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. @@ -78,6 +81,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() @@ -111,7 +115,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 image.locations[self.__cloud]): raise Exception(f"Test suite {suite.name} must be executed in {suite.location}, but <{image.urn}> is not available in that location") @staticmethod @@ -131,7 +136,7 @@ def _load_test_suites(test_suites: str) -> List[TestSuiteInfo]: # # If test_suites is not YML, then it should be a comma-separated list of description files # - description_files: List[Path] = [AgentTestLoader._SOURCE_CODE_ROOT/"test_suites"/f"{t.strip()}.yml" for t in test_suites.split(',')] + description_files: List[Path] = [AgentTestLoader._SOURCE_CODE_ROOT / "test_suites" / f"{t.strip()}.yml" for t in test_suites.split(',')] return [AgentTestLoader._load_test_suite(f) for f in description_files] @staticmethod @@ -213,7 +218,7 @@ def _load_images() -> Dict[str, List[VmImageInfo]]: See the comments in image.yml for a description of the structure of each item. """ - image_descriptions = AgentTestLoader._load_file(AgentTestLoader._SOURCE_CODE_ROOT/"test_suites"/"images.yml") + image_descriptions = AgentTestLoader._load_file(AgentTestLoader._SOURCE_CODE_ROOT / "test_suites" / "images.yml") if "images" not in image_descriptions: raise Exception("images.yml is missing the 'images' item") diff --git a/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py b/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py index 423e54290..6bf28bb95 100644 --- a/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py +++ b/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py @@ -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 From 5cd740bd5975c37df680e1254173cd461adb3c3d Mon Sep 17 00:00:00 2001 From: narrieta Date: Mon, 17 Apr 2023 12:21:52 -0700 Subject: [PATCH 2/5] fix formatting --- tests_e2e/orchestrator/lib/agent_test_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_loader.py b/tests_e2e/orchestrator/lib/agent_test_loader.py index 743fabcbe..445213cec 100644 --- a/tests_e2e/orchestrator/lib/agent_test_loader.py +++ b/tests_e2e/orchestrator/lib/agent_test_loader.py @@ -218,7 +218,7 @@ def _load_images() -> Dict[str, List[VmImageInfo]]: See the comments in image.yml for a description of the structure of each item. """ - image_descriptions = AgentTestLoader._load_file(AgentTestLoader._SOURCE_CODE_ROOT / "test_suites" / "images.yml") + image_descriptions = AgentTestLoader._load_file(AgentTestLoader._SOURCE_CODE_ROOT/"test_suites"/"images.yml") if "images" not in image_descriptions: raise Exception("images.yml is missing the 'images' item") From bc13e83e40ed0ed1761db4ae1d288a825d24d61f Mon Sep 17 00:00:00 2001 From: narrieta Date: Mon, 17 Apr 2023 12:28:27 -0700 Subject: [PATCH 3/5] fix formatting --- tests_e2e/orchestrator/lib/agent_test_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_loader.py b/tests_e2e/orchestrator/lib/agent_test_loader.py index 445213cec..aa1b9597d 100644 --- a/tests_e2e/orchestrator/lib/agent_test_loader.py +++ b/tests_e2e/orchestrator/lib/agent_test_loader.py @@ -136,7 +136,7 @@ def _load_test_suites(test_suites: str) -> List[TestSuiteInfo]: # # If test_suites is not YML, then it should be a comma-separated list of description files # - description_files: List[Path] = [AgentTestLoader._SOURCE_CODE_ROOT / "test_suites" / f"{t.strip()}.yml" for t in test_suites.split(',')] + description_files: List[Path] = [AgentTestLoader._SOURCE_CODE_ROOT/"test_suites"/f"{t.strip()}.yml" for t in test_suites.split(',')] return [AgentTestLoader._load_test_suite(f) for f in description_files] @staticmethod From 622068fcf40edf82d506a0e092e28e1bb82ad538 Mon Sep 17 00:00:00 2001 From: narrieta Date: Mon, 17 Apr 2023 12:37:22 -0700 Subject: [PATCH 4/5] variable --- tests_e2e/orchestrator/lib/agent_test_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_loader.py b/tests_e2e/orchestrator/lib/agent_test_loader.py index aa1b9597d..a7e82c0c8 100644 --- a/tests_e2e/orchestrator/lib/agent_test_loader.py +++ b/tests_e2e/orchestrator/lib/agent_test_loader.py @@ -116,7 +116,7 @@ def _validate(self): # If the image has a location restriction, validate that it is available on the location the suite must run on if image.locations: locations = image.locations.get(self.__cloud) - if locations is not None and not any(suite.location in l for l in image.locations[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 From 03ec61c14fc1fc7f328be59acf10bbdb1b8ef29b Mon Sep 17 00:00:00 2001 From: narrieta Date: Mon, 17 Apr 2023 12:45:46 -0700 Subject: [PATCH 5/5] parameter --- tests_e2e/orchestrator/lib/agent_test_suite_combinator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py b/tests_e2e/orchestrator/lib/agent_test_suite_combinator.py index 6bf28bb95..282625cb7 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]] = [ {