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

Add test case for automatic content counts update toggling #15371

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from 2 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
120 changes: 120 additions & 0 deletions tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ def default_non_admin_user(target_sat, default_org, default_location):
user.delete()


@pytest.fixture(scope="module")
vsedmik marked this conversation as resolved.
Show resolved Hide resolved
def module_autosync_setting(request, module_target_sat, module_capsule_configured):
"""Set capsule autosync setting"""
setting_entity = module_target_sat.api.Setting().search(
query={'search': 'name=foreman_proxy_content_auto_sync'}
)[0]
original_autosync = setting_entity.value
setting_entity.value = request.param
setting_entity.update({'value'})
yield
setting_entity.value = original_autosync
setting_entity.update({'value'})


@pytest.mark.run_in_one_thread
class TestCapsuleContentManagement:
"""Content Management related tests, which exercise katello with pulp
Expand Down Expand Up @@ -1651,6 +1665,112 @@ def test_positive_content_counts_blank_update(
counts is None or len(counts['content_view_versions']) == 0
), f"No content counts expected, but got:\n{counts['content_view_versions']}."

@pytest.mark.skip_if_open('SAT-25542')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be turned to :BlockedBy or :Verifies tag?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:BlockedBy:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:Verifies: is primarily used to map a feature to test(s). :BlockedBy: for skipping a test because of some bugs.

Copy link
Contributor Author

@vsedmik vsedmik Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turned into :BlockedBy:.

@pytest.mark.parametrize('module_autosync_setting', [True], indirect=True)
@pytest.mark.parametrize(
'setting_update', ['automatic_content_count_updates=False'], indirect=True
)
def test_automatic_content_counts_update_toggle(
self,
target_sat,
module_capsule_configured,
module_autosync_setting,
setting_update,
function_org,
function_product,
function_lce,
):
"""Verify the automatic content counts update can be turned off and on again.

:id: aa8d50e3-c04c-4e0f-a1c2-544767331973

:setup:
1. Satellite with registered external Capsule.
2. foreman_proxy_content_auto_sync setting is turned on.
3. automatic_content_count_updates setting is turned off.

:steps:
1. Sync some content to the Capsule, capsule is synced automatically.
2. Verify no content counts update task was spawned after capsule sync completed.
3. Invoke manual capsule sync and verify no update task was spawned again.
4. Turn the automatic_content_count_updates on, invoke manual capsule sync again
and verify the update task was spawned this time.

:expectedresults:
1. Capsule content counts update task respects the setting.

:CaseImportance: Medium

:BZ: 2284027
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:BZ: 2284027
:BZ: 2284027
:Verifies: SAT-25503

Can we add Verifies field too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jameerpathan111 I think we should not since it's not a feature? (It's a BZ coverage only)
As you say here #15371 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's usage is not limited to feature coverage I'd say. If it's covering a BZ scenario then it counts under Verifies too and we shouldn't use :BZ: anymore anyway. @JacobCallahan correct me if I'm wrong.


:customerscenario: true
"""
# Sync some content to the Capsule, capsule is synced automatically.
repo = target_sat.api.Repository(
product=function_product, url=settings.repos.yum_1.url
).create()
module_capsule_configured.nailgun_capsule.content_add_lifecycle_environment(
data={'environment_id': function_lce.id}
)
capsule_lces = module_capsule_configured.nailgun_capsule.content_lifecycle_environments()
assert len(capsule_lces['results'])
assert function_lce.id in [lce['id'] for lce in capsule_lces['results']]

cv = target_sat.api.ContentView(organization=function_org, repository=[repo]).create()
repo.sync()
cv.publish()
cv = cv.read()

cvv = cv.version[-1].read()
timestamp = datetime.utcnow()
cvv.promote(data={'environment_ids': function_lce.id})

module_capsule_configured.wait_for_sync(start_time=timestamp)

# Verify no content counts update task was spawned after capsule sync completed.
with pytest.raises(AssertionError) as err:
target_sat.wait_for_tasks(
search_query=(
'label = Actions::Katello::CapsuleContent::UpdateContentCounts'
f' and started_at >= "{timestamp}"'
),
search_rate=5,
max_tries=12,
)
assert 'No task was found' in str(err)

# Invoke manual capsule sync and verify no update task again.
sync_status = module_capsule_configured.nailgun_capsule.content_sync()
assert sync_status['result'] == 'success'

with pytest.raises(AssertionError) as err:
target_sat.wait_for_tasks(
search_query=(
'label = Actions::Katello::CapsuleContent::UpdateContentCounts'
f' and started_at >= "{timestamp}"'
),
search_rate=5,
max_tries=12,
)
assert 'No task was found' in str(err)

# Turn the automatic_content_count_updates on, invoke manual capsule sync again
# and verify the update task was spawned this time.
setting_update.value = True
setting_update = setting_update.update({'value'})

sync_status = module_capsule_configured.nailgun_capsule.content_sync()
assert sync_status['result'] == 'success'

target_sat.wait_for_tasks(
vijaysawant marked this conversation as resolved.
Show resolved Hide resolved
search_query=(
'label = Actions::Katello::CapsuleContent::UpdateContentCounts'
f' and started_at >= "{timestamp}"'
),
search_rate=5,
max_tries=12,
)

def test_positive_read_with_non_admin_user(
self,
target_sat,
Expand Down