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

Added logic for RHEL AWS Stratosphere images. #340

Merged
merged 1 commit into from
Sep 27, 2024
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
12 changes: 12 additions & 0 deletions lib/aws_lib.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions test_suite/cloud/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
narmaku marked this conversation as resolved.
Show resolved Hide resolved
def test_yum_group_install(self, host):
if test_lib.is_rhel_atomic_host(host):
pytest.skip('Not applicable to Atomic host AMIs')
Expand Down
9 changes: 8 additions & 1 deletion test_suite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -158,6 +158,13 @@ def rhel_atomic_only(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):
values_to_find = [host.backend.hostname]
Expand Down
5 changes: 4 additions & 1 deletion test_suite/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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
Expand Down Expand Up @@ -483,6 +483,7 @@ def test_no_fail_service(self, host):
@pytest.mark.pub
@pytest.mark.run_on(['rhel'])
@pytest.mark.exclude_on(['<rhel8.3'])
@pytest.mark.usefixtures('rhel_aws_marketplace_only')
class TestsSubscriptionManager:
def test_subscription_manager_auto(self, host, instance_data):
"""
Expand Down Expand Up @@ -640,6 +641,7 @@ def test_cloud_cfg_netdev_rhel9(self, host):

@pytest.mark.pub
@pytest.mark.order(3)
@pytest.mark.usefixtures('rhel_aws_marketplace_only')
class TestsYum:
# TODO: confirm if this test needs to be deprecated
@pytest.mark.run_on(['rhel', 'fedora'])
Expand Down Expand Up @@ -920,6 +922,7 @@ class TestsRhelEls:
A set of test cases that should only run if RHEL minor release is the last one and will enter into ELS mode.
For example, for RHEL-8, the last minor release is RHEL-8.10, and there won't be any further minor releases for major version 8.
"""

def test_rhui_pkg_is_not_e4s(self, host):
"""
Make sure the RHUI package is not "e4s".
Expand Down
Loading