Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit 76707fe

Browse files
authored
Merge pull request #10345 from jaryn/fix_rh_updates
[RFR] Fix test_rh_updates
2 parents 5e65926 + 18daef5 commit 76707fe

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

cfme/tests/configure/test_register_appliance.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,25 @@ def pytest_generate_tests(metafunc):
7373

7474
@pytest.fixture(scope="function")
7575
def appliance_preupdate(temp_appliance_preconfig_funcscope):
76-
"""Requests appliance from sprout and configures rpms for crud update
76+
"""Requests appliance from sprout and configures repos for crud update.
7777
78-
To create the required repo (fresh-new (clean) CFME appliance required).
78+
This function is using rpmrebuild to build a CFME with high version number to
79+
force the update.
7980
80-
register and attach the system to RHN
81+
In the past, the rpmrebuild tool was used. The downside is that it is
82+
quite ancient tool, not in any common repo and it may be necessary to build
83+
it from SRPM if some deps are not met.
84+
85+
Note that it would certainly be posible to just take the SRPM of CFME
86+
and rebuild them using rpmbuild instead of using the rpmrebuild.
87+
88+
To create the required repo with rpmrebuild:
89+
90+
# # A fresh-new (clean) CFME appliance required.
91+
#
92+
# # Register and attach the system to RHN
93+
#
94+
# # Define values to be used.
8195
# SERVER=...redhat.com
8296
# CFME_STREAM=5.10
8397
#
@@ -110,17 +124,26 @@ def appliance_preupdate(temp_appliance_preconfig_funcscope):
110124
pytest.skip('Failed looking up rpmrebuild in cfme_data.basic_info')
111125

112126
def run(c):
113-
assert appliance.ssh_client.run_command(c).success
127+
cmd = appliance.ssh_client.run_command(c)
128+
assert cmd.success
129+
130+
rhsm_url = cfme_data['redhat_updates']['registration']['rhsm']['url']
131+
rhsm_username = conf.credentials['rhsm']['username']
132+
rhsm_password = conf.credentials['rhsm']['password']
114133

134+
run(f'subscription-manager register '
135+
f'--server {rhsm_url} --password {rhsm_password} --username {rhsm_username}')
136+
run(f'subscription-manager attach')
115137
run(f'curl -o /etc/yum.repos.d/rpmrebuild.repo {url}')
116138
run('yum install rpmrebuild createrepo -y')
117139
run('mkdir /myrepo')
118140
run('rpmrebuild --release=99 cfme-appliance')
119141
run('cp /root/rpmbuild/RPMS/x86_64/cfme-appliance-* /myrepo/')
120142
run('createrepo /myrepo/')
121143
run('echo '
122-
'"[local-repo]\nname=Internal repository\nbaseurl=file:///myrepo/\nenabled=1\ngpgcheck=0"'
144+
'"[local-repo]\nname=Local repository\nbaseurl=file:///myrepo/\nenabled=1\ngpgcheck=0"'
123145
' > /etc/yum.repos.d/local.repo')
146+
run(f'subscription-manager clean')
124147
yield appliance
125148

126149

0 commit comments

Comments
 (0)