Skip to content

Commit

Permalink
[6.13.z] Fix capsule download policy update (#13249)
Browse files Browse the repository at this point in the history
Fix capsule download policy update (#13240)

(cherry picked from commit 9d7c7bd)

Co-authored-by: vsedmik <[email protected]>
  • Loading branch information
Satellite-QE and vsedmik authored Dec 4, 2023
1 parent 6a384cf commit 2e095a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
6 changes: 6 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,12 @@ def capsule_setup(self, sat_host=None, capsule_cert_opts=None, **installer_kwarg
f'A core service is not running at capsule host\n{result.stdout}'
)

def update_download_policy(self, policy):
"""Updates capsule's download policy to desired value"""
proxy = self.nailgun_smart_proxy.read()
proxy.download_policy = policy
proxy.update(['download_policy'])

def set_rex_script_mode_provider(self, mode='ssh'):
"""Set provider for remote execution script mode. One of: ssh(default),
pull-mqtt, ssh-async"""
Expand Down
18 changes: 4 additions & 14 deletions tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ class TestCapsuleContentManagement:
interactions and use capsule.
"""

def update_capsule_download_policy(
self, module_capsule_configured, download_policy, module_target_sat
):
"""Updates capsule's download policy to desired value"""
proxy = module_target_sat.api.SmartProxy(
id=module_capsule_configured.nailgun_capsule.id
).read()
proxy.download_policy = download_policy
proxy.update(['download_policy'])

@pytest.mark.tier3
@pytest.mark.skip_if_not_set('capsule', 'clients', 'fake_manifest')
def test_positive_insights_puppet_package_availability(self, module_capsule_configured):
Expand Down Expand Up @@ -593,7 +583,7 @@ def test_positive_on_demand_sync(
assert function_lce.id in [capsule_lce['id'] for capsule_lce in result['results']]

# Update capsule's download policy to on_demand
self.update_capsule_download_policy(module_capsule_configured, 'on_demand')
module_capsule_configured.update_download_policy('on_demand')

# Create a content view with the repository
cv = target_sat.api.ContentView(organization=function_org, repository=[repo]).create()
Expand Down Expand Up @@ -667,7 +657,7 @@ def test_positive_update_with_immediate_sync(
url=repo_url,
).create()
# Update capsule's download policy to on_demand to match repository's policy
self.update_capsule_download_policy(module_capsule_configured, 'on_demand')
module_capsule_configured.update_download_policy('on_demand')
# Associate the lifecycle environment with the capsule
module_capsule_configured.nailgun_capsule.content_add_lifecycle_environment(
data={'environment_id': function_lce.id}
Expand Down Expand Up @@ -704,7 +694,7 @@ def test_positive_update_with_immediate_sync(
assert repo.download_policy == 'immediate'

# Update capsule's download policy as well
self.update_capsule_download_policy(module_capsule_configured, 'immediate')
module_capsule_configured.update_download_policy('immediate')

# Sync repository once again
repo.sync()
Expand Down Expand Up @@ -805,7 +795,7 @@ def test_positive_sync_kickstart_repo(
assert lce.id in [capsule_lce['id'] for capsule_lce in result['results']]

# Update capsule's download policy to on_demand
self.update_capsule_download_policy(module_capsule_configured, 'on_demand')
module_capsule_configured.update_download_policy('on_demand')

# Create a content view with the repository
cv = target_sat.api.ContentView(
Expand Down

0 comments on commit 2e095a9

Please sign in to comment.