diff --git a/lib/aws_lib.py b/lib/aws_lib.py new file mode 100644 index 00000000..10e581e6 --- /dev/null +++ b/lib/aws_lib.py @@ -0,0 +1,12 @@ +import json + + +def get_aws_instance_identity_from_web(host): + instance_document_url = 'http://169.254.169.254/latest/dynamic/instance-identity/document' + return json.loads(host.check_output(f'curl -s {instance_document_url}')) + + +def is_rhel_aws_stratosphere(host): + instance_data = get_aws_instance_identity_from_web(host) + + return instance_data['billingProducts'] is None diff --git a/test_suite/cloud/test_aws.py b/test_suite/cloud/test_aws.py index 38476457..c277a0d9 100644 --- a/test_suite/cloud/test_aws.py +++ b/test_suite/cloud/test_aws.py @@ -4,13 +4,12 @@ import pytest from packaging import version -from lib import test_lib +from lib import test_lib, aws_lib @pytest.fixture def instance_data_aws_web(host): - instance_document_url = 'http://169.254.169.254/latest/dynamic/instance-identity/document' - return json.loads(host.check_output(f'curl -s {instance_document_url}')) + return aws_lib.get_aws_instance_identity_from_web(host) @pytest.fixture @@ -553,6 +552,7 @@ def test_dracut_conf_xen(self, host): @pytest.mark.pub @pytest.mark.run_on(['rhel']) + @pytest.mark.usefixtures('rhel_aws_marketplace_only') def test_yum_group_install(self, host): if test_lib.is_rhel_atomic_host(host): pytest.skip('Not applicable to Atomic host AMIs') diff --git a/test_suite/conftest.py b/test_suite/conftest.py index e3eda68a..5d9f7eee 100644 --- a/test_suite/conftest.py +++ b/test_suite/conftest.py @@ -11,7 +11,7 @@ from requests.packages.urllib3.util.retry import Retry from test_suite.generic import helpers -from lib import test_lib +from lib import test_lib, aws_lib def __get_host_info(host): @@ -157,6 +157,11 @@ def rhel_atomic_only(host): if not test_lib.is_rhel_atomic_host(host): pytest.skip('Image is not atomic RHEL') +@pytest.fixture +def rhel_aws_marketplace_only(host, instance_data): + # Check if the image is AWS Stratosphere. If so, skip the test. + if instance_data['cloud'] == 'aws' and aws_lib.is_rhel_aws_stratosphere(host): + pytest.skip('Not applicable to RHEL AWS Stratosphere images.') @pytest.fixture(scope='function', autouse=True) def instance_data(host): diff --git a/test_suite/generic/test_generic.py b/test_suite/generic/test_generic.py index 2bf579b6..d285eab6 100644 --- a/test_suite/generic/test_generic.py +++ b/test_suite/generic/test_generic.py @@ -27,6 +27,7 @@ def check_kdump_fix_condition(host): 'while ram size is smaller than 4Gib') + @pytest.mark.order(1) class TestsGeneric: @pytest.mark.run_on(['all']) @@ -35,7 +36,7 @@ def test_no_avc_denials(self, host, instance_data): Check there is no avc denials (selinux). """ if (host.system_info.distribution == 'rhel' and float(host.system_info.release) == 9.4) \ - or (host.system_info.distribution == 'centos' and host.system_info.release == "9"): + or (host.system_info.distribution == 'centos' and host.system_info.release == "9"): pytest.skip('RHEL-24346: Skipping on RHEL-9.4 due to a known issue with NetworkManager.') # CLOUDX-320: This "if" is pending to be removed @@ -490,6 +491,7 @@ def test_no_fail_service(self, host): @pytest.mark.pub @pytest.mark.run_on(['rhel']) @pytest.mark.exclude_on(['