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

notifications: no long tasks email for certain users #14674

Conversation

pnovotny
Copy link
Contributor

@pnovotny pnovotny commented Apr 8, 2024

Problem Statement

Users with disabled account or disabled email were still receiving notifications about long-running tasks.

Solution

New test that verifies that these users don't receive the notification.

Related Issues

Bugzilla: https://bugzilla.redhat.com/2245056

@pnovotny pnovotny added CherryPick PR needs CherryPick to previous branches AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels Apr 8, 2024
@pnovotny pnovotny self-assigned this Apr 8, 2024
@pnovotny pnovotny requested review from pondrejk, lhellebr and a team April 8, 2024 11:32
@pnovotny
Copy link
Contributor Author

pnovotny commented Apr 8, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_notifications.py -k test_negative_no_notification_for_long_running_tasks

@pnovotny pnovotny marked this pull request as ready for review April 8, 2024 11:59
@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6352
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_notifications.py -k test_negative_no_notification_for_long_running_tasks --external-logging
Test Result : ========== 2 passed, 3 deselected, 30 warnings in 1049.90s (0:17:29) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Apr 8, 2024
'wait_for_no_long_running_task_mail',
)
def test_negative_no_notification_for_long_running_tasks(
admin_user_with_custom_settings, long_running_task, root_mailbox_copy
Copy link
Member

@ogajduse ogajduse Apr 8, 2024

Choose a reason for hiding this comment

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

The code looks rock-solid. One question here, why does this test require the root_mailbox_copy fixture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I actually wanted to ensure that a clean mailbox file is created, but it is already done in fixture wait_for_no_long_running_task_mail via clean_root_mailbox.
But since you mentioned it, I decided to keep it and added few lines to check for the unexpected mail explicitly.
Read more below...

Bugzilla: https://bugzilla.redhat.com/2245056

Verify that users with disabled account or disabled email don't receive
email notifications about long-running tasks.
@pnovotny pnovotny force-pushed the no-long-tasks-email-for-certain-users branch from 21bf130 to 5a94b8b Compare April 8, 2024 15:39
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Apr 8, 2024
Comment on lines +436 to +439
for email in root_mailbox_copy:
assert (
task_id not in email.as_string()
), f'Unexpected notification e-mail with long-running task ID {task_id} found in user mailbox!'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO this gives the test more "believable" look since nothing much else looks to be happening here 😉
And it's also a double safety, because if this assert fails, it means that the unwanted mail somehow slipped through wait_for_no_long_running_task_mail fixture (meaning it's not working as it should).

@pnovotny
Copy link
Contributor Author

pnovotny commented Apr 8, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_notifications.py -k test_negative_no_notification_for_long_running_tasks

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6361
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_notifications.py -k test_negative_no_notification_for_long_running_tasks --external-logging
Test Result : ========== 2 passed, 3 deselected, 31 warnings in 1059.36s (0:17:39) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Apr 8, 2024
@Griffin-Sullivan Griffin-Sullivan merged commit ce6777c into SatelliteQE:master Apr 9, 2024
10 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 9, 2024
notifications: exclude some users from long-running tasks email

Bugzilla: https://bugzilla.redhat.com/2245056

Verify that users with disabled account or disabled email don't receive
email notifications about long-running tasks.

(cherry picked from commit ce6777c)
shweta83 pushed a commit to shweta83/robottelo that referenced this pull request Apr 10, 2024
notifications: exclude some users from long-running tasks email

Bugzilla: https://bugzilla.redhat.com/2245056

Verify that users with disabled account or disabled email don't receive
email notifications about long-running tasks.
@pnovotny pnovotny deleted the no-long-tasks-email-for-certain-users branch April 30, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants