Skip to content

Commit

Permalink
Substitute RHSM skip variable & bump leapp-framework rq
Browse files Browse the repository at this point in the history
The development variable LEAPP_DEVEL_SKIP_RHSM is being deprecated and
replaced with LEAPP_NO_RHSM, which is going to be officially supported.
At the framework level, setting LEAPP_DEVEL_SKIP_RHSM to 1 also sets
LEAPP_NO_RHSM to 1. This is intentional not to break existing tests and
scripts. Therefore, it makes sense to only check for the latter one in
tests.

Bump leapp-framework requirement to 1.2 regarding the change
in the leapp.
  • Loading branch information
drehak authored and pirat89 committed Apr 16, 2020
1 parent b949185 commit 15b0800
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packaging/leapp-repository.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Requires: leapp-repository-dependencies = 5

# IMPORTANT: this is capability provided by the leapp framework rpm.
# Check that 'version' this instead of the real framework rpm version.
Requires: leapp-framework >= 1.1, leapp-framework < 2
Requires: leapp-framework >= 1.2, leapp-framework < 2
Requires: python2-leapp

# That's temporary to ensure the obsoleted subpackage is not installed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

def test_sku_report_skipped(monkeypatch, current_actor_context):
with monkeypatch.context() as context:
context.setenv('LEAPP_DEVEL_SKIP_RHSM', '1')
context.setenv('LEAPP_NO_RHSM', '1')
current_actor_context.feed(RHSMInfo(attached_skus=[]))
current_actor_context.run()
assert not list(current_actor_context.consume(Report))


def test_sku_report_has_skus(monkeypatch, current_actor_context):
with monkeypatch.context() as context:
context.setenv('LEAPP_DEVEL_SKIP_RHSM', '0')
context.setenv('LEAPP_NO_RHSM', '0')
current_actor_context.feed(RHSMInfo(attached_skus=['testing-sku']))
current_actor_context.run()
assert not list(current_actor_context.consume(Report))


def test_sku_report_has_no_skus(monkeypatch, current_actor_context):
with monkeypatch.context() as context:
context.setenv('LEAPP_DEVEL_SKIP_RHSM', '0')
context.setenv('LEAPP_NO_RHSM', '0')
current_actor_context.feed(RHSMInfo(attached_skus=[]))
current_actor_context.run()
reports = list(current_actor_context.consume(Report))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def set_rhsm_release():
"""Set the RHSM release to the target RHEL 8 minor version."""
if rhsm.skip_rhsm():
api.current_logger().debug('Skipping setting the RHSM release due to the use of LEAPP_DEVEL_SKIP_RHSM.')
api.current_logger().debug('Skipping setting the RHSM release due to --no-rhsm or environment variables.')
return

if config.get_product_type('target') != 'ga':
Expand All @@ -29,8 +29,8 @@ def enable_rhsm_repos():
the known repositories.
"""
if rhsm.skip_rhsm():
api.current_logger().debug('Skipping enabling repositories through subscription-manager due to the use of'
' LEAPP_DEVEL_SKIP_RHSM.')
api.current_logger().debug('Skipping enabling repositories through subscription-manager due to --no-rhsm'
' or environment variables.')
return
try:
run(get_submgr_cmd(get_repos_to_enable()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_setrelease_submgr_throwing_error(monkeypatch):
@pytest.mark.parametrize('product', ['beta', 'htb'])
def test_setrelease_skip_rhsm(monkeypatch, product):
commands_called, _ = not_isolated_actions()
monkeypatch.setenv('LEAPP_DEVEL_SKIP_RHSM', '1')
monkeypatch.setenv('LEAPP_NO_RHSM', '1')
monkeypatch.setattr(config, 'get_product_type', lambda dummy: product)
# To make this work we need to re-apply the decorator, so it respects the environment variable
monkeypatch.setattr(rhsm, 'set_release', rhsm.with_rhsm(rhsm.set_release))
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_running_submgr_fail(monkeypatch):


def test_enable_repos_skip_rhsm(monkeypatch):
monkeypatch.setenv('LEAPP_DEVEL_SKIP_RHSM', '1')
monkeypatch.setenv('LEAPP_NO_RHSM', '1')
monkeypatch.setattr(library, 'run', run_mocked())
monkeypatch.setattr(api, 'current_logger', logger_mocked())
library.enable_rhsm_repos()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_consume_data(monkeypatch, raised, pkg_msgs, rhsm_info, xfs, storage):
mocked_consume = MockedConsume(pkg_msgs, rhsm_info, xfs, storage)
monkeypatch.setattr(api, 'consume', mocked_consume)
monkeypatch.setattr(api, 'current_logger', mocked_logger())
monkeypatch.setenv('LEAPP_DEVEL_SKIP_RHSM', '0')
monkeypatch.setenv('LEAPP_NO_RHSM', '0')
if not xfs:
xfs = models.XFSPresence()
if not raised:
Expand Down
2 changes: 1 addition & 1 deletion repos/system_upgrade/el7toel8/libraries/rhsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _handle_rhsm_exceptions(hint=None):

def skip_rhsm():
"""Check whether we should skip RHSM related code."""
return os.getenv('LEAPP_DEVEL_SKIP_RHSM', '0') == '1'
return os.getenv('LEAPP_NO_RHSM', '0') == '1'


def with_rhsm(f):
Expand Down

0 comments on commit 15b0800

Please sign in to comment.