Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorder and improve clone test to match docs #16683

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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