Skip to content

Commit 702513f

Browse files
synkdweb-flow
authored andcommitted
Add test for Katello 11637 (#20860)
This PR adds test coverage for Katello/katello#11637, which a bug found in the initial multicv host implementation in which changing the content view in a host's content view environment to a different content view in the same lifecycle environment did not function properly. Requires SatelliteQE/airgun#2321. (cherry picked from commit b63db29)
1 parent 2a57c82 commit 702513f

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

tests/foreman/ui/test_host.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,3 +4189,62 @@ def test_assign_multi_cv_from_host_page(
41894189

41904190
new_cv_env = [env for env in cv_envs if env['lce'] == module_lce.name][0]
41914191
assert new_cv_env['content_view'] == module_cv_repo.name
4192+
4193+
4194+
@pytest.mark.rhel_ver_match(f'{settings.content_host.default_rhel_version}')
4195+
@pytest.mark.no_containers
4196+
def test_assign_different_cv_from_same_env(
4197+
module_target_sat,
4198+
module_org,
4199+
module_lce,
4200+
module_cv_repo,
4201+
rhel_contenthost,
4202+
):
4203+
"""Ensure that a host can be switched to a different content view in the same lifecycle environment
4204+
4205+
:id: 64ac7868-18a6-47cc-9a3d-e014bf3ac320
4206+
4207+
:steps:
4208+
1. Create a content view and an activation key associated with the content view and a new lifecycle environment.
4209+
2. Register a host using the activation key.
4210+
3. Create a second content view associated with the same lifecycle environment as the previous content view.
4211+
4. On the Overview tab of the details page for the host, select the 'Assign content view environments' action from the 'Content view environments' card dropdown.
4212+
5. Use the `Select content view` dropdown to select the content view created in step 3, then click the `Save` button.
4213+
4214+
:expectedresults:
4215+
The host's content view environment is updated to use the content view created in step 3.
4216+
4217+
:verifies: SAT-25846
4218+
"""
4219+
# Create activation key and register host
4220+
ak = module_target_sat.api.ActivationKey(
4221+
organization=module_org.id,
4222+
content_view=module_cv_repo.id,
4223+
environment=module_org.library.id,
4224+
).create()
4225+
result = rhel_contenthost.register(module_org, None, ak.name, module_target_sat)
4226+
assert result.status == 0
4227+
4228+
# Sync a new repo, add it to a new CV, and promote the CV
4229+
repo = module_target_sat.api.Repository(
4230+
product=module_target_sat.api.Product(organization=module_org).create(),
4231+
url=settings.repos.yum_0.url,
4232+
).create()
4233+
repo.sync()
4234+
cv = module_target_sat.api.ContentView(
4235+
organization=module_org.id, name=gen_string('alpha')
4236+
).create()
4237+
cv.repository = [repo]
4238+
cv.update(['repository'])
4239+
cv.publish()
4240+
cv_version = cv.read().version[0]
4241+
cv_version.promote(data={'environment_ids': module_lce.id})
4242+
cv = cv.read()
4243+
4244+
# In a UI session, use the CV environment modal to change the host's CV to the new CV
4245+
with module_target_sat.ui_session() as session:
4246+
session.organization.select(module_org.name)
4247+
session.host_new.switch_associated_cv(rhel_contenthost.hostname, cv.name)
4248+
4249+
cv_env = session.host_new.get_content_view_envs(rhel_contenthost.hostname)[0]
4250+
assert cv_env['content_view'] == cv.name

0 commit comments

Comments
 (0)