Skip to content

Commit

Permalink
Enable centos repos before the analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
kokesak committed May 23, 2024
1 parent 9cddbcb commit 4db54d2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def satellite_registration(shell, yum_conf_exclude, request):
Register the system to the Satellite server
By default it acquires the curl command from the satellite_curl_command function
Can be parametrized with requesting a different key from the SAT_REG_FILE(.sat_reg_file):
@pytest.mark.parametrized("satellite_registration", ["DIFFERENT_KEY"], indirect=True)
@pytest.mark.parametrize("satellite_registration", ["DIFFERENT_KEY"], indirect=True)
"""
# Get the curl command for the respective system
# from the conftest function
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest


RHEL_CERTIFICATE_69_PEM = "/usr/share/convert2rhel/rhel-certs/69.pem"


def collect_enabled_repositories(shell):
"""
Collect the enabled repositories through a subscription-manager call.
Expand All @@ -23,14 +26,28 @@ def collect_enabled_repositories(shell):

@pytest.mark.test_enabled_repositories_after_analysis
@pytest.mark.parametrize("satellite_registration", ["RHEL7_AND_CENTOS7_SAT_REG"], indirect=True)
def test_enabled_repositories_after_analysis(shell, convert2rhel, satellite_registration):
@pytest.mark.parametrize("rhel_repo_enabled", [False, True])
def test_enabled_repositories_after_analysis(
shell, convert2rhel, satellite_registration, remove_repositories, rhel_repo_enabled
):
"""Test analysis systems not connected to the Internet but requiring sub-mgr (e.g. managed by Satellite).
This test will perform the following operations:
- Collect the enabled repositories prior to the analysis start
- Run the analysis and assert that we successfully enabled the RHSM repositories
- Collect the enabled repositories after the tool run to compare with the repositories prior to the analysis
"""

# Enable CentOS repos manually because they are disabled by default in our satellite instance
shell("subscription-manager repos --enable='Satellite_Engineering_CentOS_7_Updates_x86_64'")
shell("subscription-manager repos --enable='Satellite_Engineering_CentOS_7_Base_x86_64'")

if rhel_repo_enabled:
# To enable RHEL repos we also need to put the 69.pem certificate to the
# appropriate location
shell(f"cp {RHEL_CERTIFICATE_69_PEM} /etc/pki/product-default/")
shell("subscription-manager repos --enable='rhel-7-server-rpms'")

enabled_repositories_prior_analysis = collect_enabled_repositories(shell)

with convert2rhel("analyze -y --debug") as c2r:
Expand All @@ -46,3 +63,9 @@ def test_enabled_repositories_after_analysis(shell, convert2rhel, satellite_regi
# before the analysis.
for repository in enabled_repositories_after_analysis:
assert repository in enabled_repositories_prior_analysis

if rhel_repo_enabled:
shell("rm -f /etc/pki/product-default/")

# No error reported in the log
assert shell("grep ERROR '/var/log/convert2rhel/convert2rhel-pre-conversion.txt'").returncode == 1

0 comments on commit 4db54d2

Please sign in to comment.