-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve class instantiation and resource deployment.
- Loading branch information
Showing
10 changed files
with
79 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,29 @@ | ||
import pytest | ||
import importlib | ||
from lib import console_lib | ||
import json | ||
import os | ||
from test_suite.suite_runner import SuiteRunner | ||
|
||
|
||
@pytest.mark.run_on(['all']) | ||
def test_cloudx_components(host): | ||
cloudx_components_test_suites = { | ||
'awscli2': 'test_suite.package.test_awscli2', | ||
'opentelemetry-collector': 'test_suite.package.otel_package.test_otel' | ||
} | ||
def test_cloudx_components_aws(): | ||
cloudx_components_test_suites = [ | ||
"test_suite/package/test_awscli2.py", | ||
"test_suite/package/otel_package/test_otel.py", | ||
] | ||
|
||
failures_count = 0 | ||
# For this test, we asssume one instance has been deployed at a time. | ||
with open(os.environ['CIV_INSTANCES_JSON'], 'r') as f: | ||
inst = json.load(f) | ||
|
||
for component, module_name in cloudx_components_test_suites.items(): | ||
try: | ||
module = importlib.import_module(module_name) | ||
test_classes = [cls for cls in vars(module).values() if isinstance(cls, type) and issubclass(cls, object)] | ||
suite_runner = SuiteRunner(cloud_provider='aws', | ||
instances=inst, | ||
ssh_config=os.environ['CIV_SSH_CONFIG_FILE'], | ||
parallel=False, | ||
debug=True) | ||
|
||
for test_class in test_classes: | ||
console_lib.print_debug(f'TEST CLASS: {test_class.__name__}') | ||
status = suite_runner.run_tests(test_suite_paths=cloudx_components_test_suites, | ||
output_filepath=os.environ['CIV_OUTPUT_FILE']) | ||
|
||
if hasattr(test_class, "__pytest_mark__"): | ||
# Run the test methods | ||
for attr in dir(test_class): | ||
if attr.startswith("test_"): | ||
test_func = getattr(test_class, attr) | ||
try: | ||
test_func(host) | ||
print(f'{component}::{attr} PASS') | ||
except AssertionError as e: | ||
print(f'{component}::{attr} FAIL - {e}') | ||
failures_count += 1 | ||
return_code = status >> 8 | ||
|
||
except ModuleNotFoundError: | ||
print(f'{component} SKIPPED (Module not found)') | ||
failures_count += 1 | ||
|
||
assert failures_count == 0, 'One or more components failed. Please check the logs.' | ||
assert return_code == 0, "One or more components failed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters