From 4cda68da0c7e098592b5ece27c750a2fc7f4adf9 Mon Sep 17 00:00:00 2001 From: Vladimir Sedmik Date: Fri, 20 Sep 2024 13:11:13 +0200 Subject: [PATCH] Fix upgrade scenarios tests --- tests/upgrades/test_errata.py | 20 +++++++++++++++----- tests/upgrades/test_repository.py | 10 +++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/upgrades/test_errata.py b/tests/upgrades/test_errata.py index 37a7b0d7680..4b03a7e232b 100644 --- a/tests/upgrades/test_errata.py +++ b/tests/upgrades/test_errata.py @@ -114,7 +114,7 @@ def test_pre_scenario_generate_errata_for_client( 1. Create Product and Custom Yum Repo 2. Create custom tools, rhel repos and sync them 3. Create content view and publish it - 4. Create activation key and add subscription + 4. Create activation key, add subscription if applicable (if the org is SCA-disabled) 5. Register RHEL host to Satellite 6. Generate Errata by installing outdated/older packages 7. Check that errata applicability generated expected errata list for the given client. @@ -148,10 +148,20 @@ def test_pre_scenario_generate_errata_for_client( ak = target_sat.api.ActivationKey( content_view=content_view, organization=function_org, environment=environment ).create() - subscription = target_sat.api.Subscription(organization=function_org).search( - query={'search': f'name={product.name}'} - )[0] - ak.add_subscriptions(data={'subscription_id': subscription.id}) + if not target_sat.is_sca_mode_enabled(function_org.id): + subscription = target_sat.api.Subscription(organization=function_org).search( + query={'search': f'name={product.name}'} + )[0] + ak.add_subscriptions(data={'subscription_id': subscription.id}) + # Override/enable all AK repos (disabled by default since 6.15) + c_labels = [ + i['label'] for i in ak.product_content(data={'content_access_mode_all': '1'})['results'] + ] + ak.content_override( + data={ + 'content_overrides': [{'content_label': label, 'value': '1'} for label in c_labels] + } + ) rhel_contenthost.register(function_org, None, ak.name, target_sat) rhel_contenthost.add_rex_key(satellite=target_sat) rhel_contenthost.install_katello_host_tools() diff --git a/tests/upgrades/test_repository.py b/tests/upgrades/test_repository.py index 1a5d9c88e24..3bb8c810b4d 100644 --- a/tests/upgrades/test_repository.py +++ b/tests/upgrades/test_repository.py @@ -152,8 +152,16 @@ def test_pre_scenario_custom_repo_check(self, target_sat, sat_upgrade_chost, sav query={'search': f'name={product.name}'} )[0] ak.add_subscriptions(data={'subscription_id': subscription.id}) + # Override/enable all AK repos (disabled by default since 6.15) + c_labels = [ + i['label'] for i in ak.product_content(data={'content_access_mode_all': '1'})['results'] + ] + ak.content_override( + data={ + 'content_overrides': [{'content_label': label, 'value': '1'} for label in c_labels] + } + ) sat_upgrade_chost.register(org, None, ak.name, target_sat) - sat_upgrade_chost.execute('subscription-manager repos --enable=*;yum clean all') result = sat_upgrade_chost.execute(f'yum install -y {FAKE_0_CUSTOM_PACKAGE_NAME}') assert result.status == 0