Skip to content

Commit

Permalink
Use rsync to copy /var/lib/pulp after satellite-clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffin-Sullivan committed Dec 19, 2023
1 parent 885e263 commit f2381d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
13 changes: 12 additions & 1 deletion pytest_fixtures/component/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -101,6 +102,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
Expand Down
34 changes: 22 additions & 12 deletions tests/foreman/destructive/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = 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
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f2381d4

Please sign in to comment.