Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
r0x0d committed May 15, 2024
1 parent c630878 commit 650007a
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
26 changes: 26 additions & 0 deletions plans/tier0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,29 @@ description+: |
# Exclude the rhel_subman check, we don't use RHSM for the conversion
exclude:
- checks-after-conversion/rhel_subman

/offline_system_analysis:
adjust+:
# Disabled due to known issue: https://issues.redhat.com/browse/RHELC-1040
# Enable once this gets fixed
- enabled: false
when: distro == oracle-7
environment+:
CONVERT2RHEL_OUTDATED_PACKAGE_CHECK_SKIP: 1
when: distro == oracle-8
because: |
The subman is installed from CentOS repo, resulting in outdated python3-ethtool
package which is then interfering with the test, inhibiting the conversion.
prepare+:
- name: Install subscription manager
how: ansible
playbook: tests/ansible_collections/roles/install-submgr/main.yml
- name: Allow access to Satellite only
how: shell
script: pytest --setup-show -svv tests/integration/*/destructive/offline-system-conversion/prepare_system.py
discover+:
test+<:
- offline-system-conversion/offline_system_analysis
# Exclude the rhel_subman check, we don't use RHSM for the conversion
exclude:
- checks-after-conversion/rhel_subman
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ markers =
test_satellite_conversion
test_pre_registered_conversion
test_offline_system_conversion
test_offline_system_analysis
test_failures_and_skips_in_report
test_successful_report
test_convert_successful_report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ tag+:

/offline_system_conversion:
test: pytest -m test_offline_system_conversion

/offline_system_analysis:
test: pytest -m test_offline_system_analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import pytest

from conftest import TEST_VARS


def collect_enabled_repositories(shell):
"""
Collect the enabled repositories through a subscription-manager call.
This function will return a list of repositories enabled.
"""
raw_output = shell("subscription-manager repos --list-enabled").output
assert raw_output

enabled_repositories = []
for line in raw_output.splitlines():
if line.startswith("Repo ID:"):
# Get the repo_id as in that split it will be the last thing in the
# array.
repo_id = line.split("Repo ID:")[-1]
enabled_repositories.append(repo_id)

return enabled_repositories


@pytest.mark.test_offline_system_analysis
def test_offline_system_analysis(convert2rhel):
"""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
"""

enabled_repositories_prior_analysis = collect_enabled_repositories()

Check failure

Code scanning / CodeQL

Wrong number of arguments in a call Error test

Call to
function collect_enabled_repositories
with too few arguments; should be no fewer than 1.

with convert2rhel(
"analysis -y -k {} -o {} --debug".format(
TEST_VARS["SATELLITE_KEY"],
TEST_VARS["SATELLITE_ORG"],
)
) as c2r:
c2r.expect("Rollback: Enabling RHSM repositories")
assert c2r.exitstatus == 0

enabled_repositories_after_analysis = collect_enabled_repositories()
assert enabled_repositories_prior_analysis == enabled_repositories_after_analysis

0 comments on commit 650007a

Please sign in to comment.