-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
AAP-39559 Wait for all event processing to finish, add fallback task #15798
Merged
pb82
merged 2 commits into
ansible:feature_indirect-host-counting
from
AlanCoding:indirect_host_periodic
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import copy | ||
|
||
import pytest | ||
|
||
from awx.main.tasks.host_indirect import get_hashable_form | ||
|
||
|
||
class TestHashableForm: | ||
@pytest.mark.parametrize( | ||
'data', | ||
[ | ||
{'a': 'b'}, | ||
['a', 'b'], | ||
('a', 'b'), | ||
{'a': {'b': 'c'}}, | ||
{'a': ['b', 'c']}, | ||
{'a': ('b', 'c')}, | ||
['a', ['b', 'c']], | ||
['a', ('b', 'c')], | ||
['a', {'b': 'c'}], | ||
], | ||
) | ||
def test_compare_equal_data(self, data): | ||
other_data = copy.deepcopy(data) | ||
# A tuple of scalars may be cached so ids could legitimately be the same | ||
if data != ('a', 'b'): | ||
assert id(data) != id(other_data) # sanity | ||
assert id(get_hashable_form(data)) != id(get_hashable_form(data)) | ||
|
||
assert get_hashable_form(data) == get_hashable_form(data) | ||
assert hash(get_hashable_form(data)) == hash(get_hashable_form(data)) | ||
|
||
assert get_hashable_form(data) in {get_hashable_form(data): 1} # test lookup hit | ||
|
||
@pytest.mark.parametrize( | ||
'data, other_data', | ||
[ | ||
[{'a': 'b'}, {'a': 'c'}], | ||
[{'a': 'b'}, {'a': 'b', 'c': 'd'}], | ||
[['a', 'b'], ['a', 'c']], | ||
[('a', 'b'), ('a', 'c')], | ||
[{'a': {'b': 'c'}}, {'a': {'b': 'd'}}], | ||
[{'a': ['b', 'c']}, {'a': ['b', 'd']}], | ||
[{'a': ('b', 'c')}, {'a': ('b', 'd')}], | ||
[['a', ['b', 'c']], ['a', ['b', 'd']]], | ||
[['a', ('b', 'c')], ['a', ('b', 'd')]], | ||
[['a', {'b': 'c'}], ['a', {'b': 'd'}]], | ||
], | ||
) | ||
def test_compar_different_data(self, data, other_data): | ||
assert data != other_data # sanity, otherwise why test this? | ||
assert get_hashable_form(data) != get_hashable_form(other_data) | ||
assert hash(get_hashable_form(data)) != hash(get_hashable_form(other_data)) | ||
|
||
assert get_hashable_form(other_data) not in {get_hashable_form(data): 1} # test lookup miss | ||
assert get_hashable_form(data) not in {get_hashable_form(other_data): 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this runs the first time, it could lead to a large number of processing jobs (all jobs completed in the last three days). Are we ok with that? Most of them will probably end quickly because there are no queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that seems like a good argument for having a limit to the start of the window which I did here. Otherwise that was more of a gut feeling.
But I still sense something to be worried about. This will get scheduled for a lot of jobs that don't need the processing done. The periodic task will run and schedule a job for each unprocessed job. Each should be a no-op with a single write, but that could still be a lot of jobs. Worse, it could temporarily overwhelm the dispatcher, because it can't delay tasks (ideal might be to scramble them with random delays).
I have a thought for this, and I'll work on putting something up. With a different angle, it'll get more intuitive.