Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cloud when validating test location #2806

Merged
merged 6 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests_e2e/orchestrator/lib/agent_test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests_e2e/orchestrator/lib/agent_test_suite_combinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = [
{
Expand All @@ -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
Expand Down