Skip to content

Commit

Permalink
improve and reorder clone test to match docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rmynar committed Oct 16, 2024
1 parent f17bd17 commit 9a8b2aa
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions tests/foreman/destructive/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

from fauxfactory import gen_string
import pytest

from robottelo import constants
Expand Down Expand Up @@ -49,7 +50,7 @@ def test_positive_clone_backup(
:parametrized: yes
:Verifies: SAT-10789, SAT-15437, SAT-13950
:Verifies: SAT-10789, SAT-15437, SAT-13950, SAT-27907
:customerscenario: true
"""
Expand All @@ -58,6 +59,15 @@ def test_positive_clone_backup(

pulp_artifact_len = len(target_sat.execute('ls /var/lib/pulp/media/artifact').stdout)

# occupy source user IDs by random users on target server (so clone has to change ownership and permissions)
sat_src_users = ["foreman", "pulp"]
sat_src_users_ids = []
for user in sat_src_users:
id = target_sat.execute(f'id -u {user}').stdout.strip()
if id:
sat_src_users_ids.append(id)
sat_ready_rhel.execute(f"useradd {gen_string('alpha')} -u {id}")

# SATELLITE PART - SOURCE SERVER
# Enabling and starting services
assert target_sat.cli.Service.enable().status == 0
Expand All @@ -83,6 +93,17 @@ def test_positive_clone_backup(
assert target_sat.cli.Service.stop().status == 0
assert target_sat.cli.Service.disable().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/pulp/'
).status
== 0
)

# RHEL PART - TARGET SERVER
assert sat_ready_rhel.execute('ls /backup/config_files.tar.gz').status == 0
# Registering to cdn
Expand Down Expand Up @@ -114,22 +135,17 @@ def test_positive_clone_backup(
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
)

# verify if owherships of pulp directory was changed (owner's user id has changed)
assert (
sat_ready_rhel.execute('stat -c "%u" /var/lib/pulp/').stdout.strip()
not in sat_src_users_ids
)


def test_positive_list_tasks(target_sat):
"""Test that satellite-clone --list-tasks command doesn't fail.
Expand Down

0 comments on commit 9a8b2aa

Please sign in to comment.