From 347b66c64aa3d0df828ee6ca753f99bda9cad956 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:42:09 -0500 Subject: [PATCH] [6.15.z] Use rsync to copy /var/lib/pulp after satellite-clone (#13499) --- pytest_fixtures/component/repository.py | 13 +++++++++- tests/foreman/destructive/test_clone.py | 34 ++++++++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/pytest_fixtures/component/repository.py b/pytest_fixtures/component/repository.py index fd9ba01b88e..6a1c43af100 100644 --- a/pytest_fixtures/component/repository.py +++ b/pytest_fixtures/component/repository.py @@ -4,7 +4,8 @@ from nailgun.entity_mixins import call_entity_method_with_timeout import pytest -from robottelo.constants import DEFAULT_ARCHITECTURE, PRDS, REPOS, REPOSET +from robottelo.config import settings +from robottelo.constants import DEFAULT_ARCHITECTURE, DEFAULT_ORG, PRDS, REPOS, REPOSET @pytest.fixture(scope='module') @@ -102,6 +103,16 @@ def module_repository(os_path, module_product, module_target_sat): return repo +@pytest.fixture +def custom_synced_repo(target_sat): + custom_repo = target_sat.api.Repository( + product=target_sat.api.Product(organization=DEFAULT_ORG).create(), + url=settings.repos.yum_0.url, + ).create() + custom_repo.sync() + return custom_repo + + def _simplify_repos(request, repos): """This is a helper function that transforms repos_collection related fixture parameters into a list that can be passed to robottelo.host_helpers.RepositoryMixins.RepositoryCollection diff --git a/tests/foreman/destructive/test_clone.py b/tests/foreman/destructive/test_clone.py index 60dfc31ca29..f29fd0d22cb 100644 --- a/tests/foreman/destructive/test_clone.py +++ b/tests/foreman/destructive/test_clone.py @@ -29,7 +29,9 @@ @pytest.mark.e2e @pytest.mark.parametrize('backup_type', ['online', 'offline']) @pytest.mark.parametrize('skip_pulp', [False, True], ids=['include_pulp', 'skip_pulp']) -def test_positive_clone_backup(target_sat, sat_ready_rhel, backup_type, skip_pulp): +def test_positive_clone_backup( + target_sat, sat_ready_rhel, backup_type, skip_pulp, custom_synced_repo +): """Make an online/offline backup with/without pulp data of Satellite and clone it (restore it). :id: 5b9182d5-6789-4d2c-bcc3-6641b96ab277 @@ -45,13 +47,15 @@ def test_positive_clone_backup(target_sat, sat_ready_rhel, backup_type, skip_pul :parametrized: yes - :BZ: 2142514 + :BZ: 2142514, 2013776 :customerscenario: true """ rhel_version = sat_ready_rhel._v_major sat_version = 'stream' if target_sat.is_stream else target_sat.version + pulp_artifact_len = len(target_sat.execute('ls /var/lib/pulp/media/artifact').stdout) + # SATELLITE PART - SOURCE SERVER # Enabling and starting services assert target_sat.cli.Service.enable().status == 0 @@ -66,16 +70,6 @@ def test_positive_clone_backup(target_sat, sat_ready_rhel, backup_type, skip_pul assert backup_result.status == 0 sat_backup_dir = backup_result.stdout.strip().split()[-2] - if skip_pulp: - # Copying satellite pulp data to target RHEL - assert sat_ready_rhel.execute('mkdir -p /var/lib/pulp').status == 0 - assert ( - target_sat.execute( - f'''sshpass -p "{SSH_PASS}" scp -o StrictHostKeyChecking=no \ - -r /var/lib/pulp root@{sat_ready_rhel.hostname}:/var/lib/pulp/pulp''' - ).status - == 0 - ) # Copying satellite backup to target RHEL assert ( target_sat.execute( @@ -118,6 +112,22 @@ def test_positive_clone_backup(target_sat, sat_ready_rhel, backup_type, skip_pul cloned_sat = Satellite(sat_ready_rhel.hostname) assert cloned_sat.cli.Health.check().status == 0 + # If --skip-pulp-data make sure you can rsync /var/lib/pulp over per BZ#2013776 + if skip_pulp: + # Copying satellite pulp data to target RHEL + assert ( + target_sat.execute( + f'sshpass -p "{SSH_PASS}" rsync -e "ssh -o StrictHostKeyChecking=no" --archive --partial --progress --compress ' + f'/var/lib/pulp root@{sat_ready_rhel.hostname}:/var/lib/' + ).status + == 0 + ) + + # Make sure all of the pulp data that was on the original Satellite is on the clone + assert ( + len(sat_ready_rhel.execute('ls /var/lib/pulp/media/artifact').stdout) == pulp_artifact_len + ) + @pytest.mark.pit_server def test_positive_list_tasks(target_sat):