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

[6.15.z] Add preconversion check and Remove Data telemetry option from convert2rhel tests #15579

Closed
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
74 changes: 70 additions & 4 deletions tests/foreman/api/test_convert2rhel.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ def version(request):

@pytest.mark.e2e
@pytest.mark.parametrize('version', ['oracle7', 'oracle8'], indirect=True)
def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, version):
def test_convert2rhel_oracle_with_pre_conversion_template_check(
module_target_sat, oracle, activation_key_rhel, version
):
"""Convert Oracle linux to RHEL

:id: 7fd393f0-551a-4de0-acdd-7f026b485f79
Expand All @@ -265,6 +267,8 @@ def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, ver
and subscription status

:parametrized: yes

Verifies: SAT-24654
"""
major = version.split('.')[0]
assert oracle.execute('yum -y update').status == 0
Expand All @@ -278,6 +282,29 @@ def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, ver
host_content = module_target_sat.api.Host(id=oracle.hostname).read_json()
assert host_content['operatingsystem_name'] == f"OracleLinux {version}"

# Pre-conversion template job
template_id = (
module_target_sat.api.JobTemplate()
.search(query={'search': 'name="Convert2RHEL analyze"'})[0]
.id
)
job = module_target_sat.api.JobInvocation().run(
synchronous=False,
data={
'job_template_id': template_id,
'targeting_type': 'static_query',
'search_query': f'name = {oracle.hostname}',
},
)

# wait for job to complete
module_target_sat.wait_for_tasks(
f'resource_type = JobInvocation and resource_id = {job["id"]}',
poll_timeout=5500,
search_rate=20,
)
result = module_target_sat.api.JobInvocation(id=job['id']).read()
assert result.succeeded == 1
# execute job 'Convert 2 RHEL' on host
template_id = (
module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id
Expand All @@ -289,7 +316,6 @@ def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, ver
'inputs': {
'Activation Key': activation_key_rhel.id,
'Restart': 'yes',
'Data telemetry': 'yes',
},
'targeting_type': 'static_query',
'search_query': f'name = {oracle.hostname}',
Expand All @@ -311,11 +337,19 @@ def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, ver
or host_content['operatingsystem_name'].startswith(f'RHEL {version}')
)
assert host_content['subscription_status'] == 0
# Wait for the host to be rebooted and SSH daemon to be started.
oracle.wait_for_connection()

# Verify convert2rhel facts are generated, and verify fact conversions.success is true
assert oracle.execute('test -f /etc/rhsm/facts/convert2rhel.facts').status == 0
assert host_content['facts']['conversions::success'] == 'true'


@pytest.mark.e2e
@pytest.mark.parametrize('version', ['centos7', 'centos8'], indirect=True)
def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, version):
def test_convert2rhel_centos_with_pre_conversion_template_check(
module_target_sat, centos, activation_key_rhel, version
):
"""Convert CentOS linux to RHEL

:id: 6f698440-7d85-4deb-8dd9-363ea9003b92
Expand All @@ -329,10 +363,36 @@ def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, ver
and subscription status

:parametrized: yes

Verifies: SAT-24654
"""
host_content = module_target_sat.api.Host(id=centos.hostname).read_json()
major = version.split('.')[0]
assert host_content['operatingsystem_name'] == f'CentOS {major}'

# Pre-conversion template job
template_id = (
module_target_sat.api.JobTemplate()
.search(query={'search': 'name="Convert2RHEL analyze"'})[0]
.id
)
job = module_target_sat.api.JobInvocation().run(
synchronous=False,
data={
'job_template_id': template_id,
'targeting_type': 'static_query',
'search_query': f'name = {centos.hostname}',
},
)
# wait for job to complete
module_target_sat.wait_for_tasks(
f'resource_type = JobInvocation and resource_id = {job["id"]}',
poll_timeout=5500,
search_rate=20,
)
result = module_target_sat.api.JobInvocation(id=job['id']).read()
assert result.succeeded == 1

# execute job 'Convert 2 RHEL' on host
template_id = (
module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id
Expand All @@ -344,7 +404,6 @@ def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, ver
'inputs': {
'Activation Key': activation_key_rhel.id,
'Restart': 'yes',
'Data telemetry': 'yes',
},
'targeting_type': 'static_query',
'search_query': f'name = {centos.hostname}',
Expand All @@ -368,3 +427,10 @@ def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, ver
or host_content['operatingsystem_name'].startswith(f'RHEL {version}')
)
assert host_content['subscription_status'] == 0

# Wait for the host to be rebooted and SSH daemon to be started.
centos.wait_for_connection()

# Verify convert2rhel facts are generated, and verify fact conversions.success is true
assert centos.execute('test -f /etc/rhsm/facts/convert2rhel.facts').status == 0
assert host_content['facts']['conversions::success'] == 'true'