From d239a9f64462c7af8aa1d4c9e3484ac647054a4c Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 8 Apr 2022 09:15:52 +0200 Subject: [PATCH 30/39] restrict Satellite upgrades to x86_64 --- .../actors/satellite_upgrade_facts/actor.py | 4 ++++ .../unit_test_satellite_upgrade_facts.py | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py index c837b449..8b1f5625 100644 --- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py +++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py @@ -1,6 +1,7 @@ import os from leapp.actors import Actor +from leapp.libraries.common.config import architecture from leapp.libraries.common.rpms import has_package from leapp.libraries.stdlib import run from leapp.models import ( @@ -28,6 +29,9 @@ class SatelliteUpgradeFacts(Actor): tags = (IPUWorkflowTag, FactsPhaseTag) def process(self): + if not architecture.matches_architecture(architecture.ARCH_X86_64): + return + has_foreman = has_package(InstalledRPM, 'foreman') or has_package(InstalledRPM, 'foreman-proxy') if not has_foreman: return diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py index fceda925..0b6f6c1d 100644 --- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py +++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py @@ -1,5 +1,6 @@ import os +from leapp.libraries.common.config import mock_configs from leapp.models import ( DNFWorkaround, InstalledRPM, @@ -28,21 +29,28 @@ POSTGRESQL_RPM = fake_package('rh-postgresql12-postgresql-server') def test_no_satellite_present(current_actor_context): current_actor_context.feed(InstalledRPM(items=[])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) message = current_actor_context.consume(SatelliteFacts) assert not message def test_satellite_present(current_actor_context): current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) message = current_actor_context.consume(SatelliteFacts)[0] assert message.has_foreman +def test_wrong_arch(current_actor_context): + current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) + current_actor_context.run(config_model=mock_configs.CONFIG_S390X) + message = current_actor_context.consume(SatelliteFacts) + assert not message + + def test_satellite_capsule_present(current_actor_context): current_actor_context.feed(InstalledRPM(items=[FOREMAN_PROXY_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) message = current_actor_context.consume(SatelliteFacts)[0] assert message.has_foreman @@ -63,14 +71,14 @@ def test_katello_installer_present(current_actor_context): def test_enables_ruby_module(current_actor_context): current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) message = current_actor_context.consume(RpmTransactionTasks)[0] assert Module(name='ruby', stream='2.7') in message.modules_to_enable def test_enables_pki_modules(current_actor_context): current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, KATELLO_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) message = current_actor_context.consume(RpmTransactionTasks)[0] assert Module(name='pki-core', stream='10.6') in message.modules_to_enable assert Module(name='pki-deps', stream='10.6') in message.modules_to_enable @@ -88,7 +96,7 @@ def test_detects_local_postgresql(monkeypatch, current_actor_context): monkeypatch.setattr("os.stat", mock_stat()) current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, POSTGRESQL_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) rpmmessage = current_actor_context.consume(RpmTransactionTasks)[0] assert Module(name='postgresql', stream='12') in rpmmessage.modules_to_enable @@ -101,7 +109,7 @@ def test_detects_local_postgresql(monkeypatch, current_actor_context): def test_detects_remote_postgresql(current_actor_context): current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM])) - current_actor_context.run() + current_actor_context.run(config_model=mock_configs.CONFIG) rpmmessage = current_actor_context.consume(RpmTransactionTasks)[0] assert Module(name='postgresql', stream='12') not in rpmmessage.modules_to_enable -- 2.35.3