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

[Backport 1.3] Add signal/wait model for TestAuditlogImpl (#1758) #1796

Closed
wants to merge 1 commit into from

Conversation

peternied
Copy link
Member

Description

  • Add signal/wait model for TestAuditlogImpl

I have been tracking test failures with testRestMethod very often
showing failures. My theory is that the execution environment can
impact the order of operations sometimes causing the audit log not to
contain messages before it is checked.

Adding a new method doThenWaitForMessages(...) this ensures the
log queue is fresh, the triggering action completes, and the expected
number of messages were recieved. There is a second long time window
that allows for the messages to be flushed, this is likely more than
enough - if the messages are recieved the count down latch immediately
continues execution so the tests will not wait if they are ready to
proceed.

While this new method is much more reliable not all tests were
encountering such issues, so I've keep the original convention. This
can be migrated in one-offs or all at once if we see more troublesome
behavoir. The previous methods/fields are depreciated to push future
tests to follow the new pattern.

Modifications to the rest helper not to throw exceptions were needed to
keep the Runnable declaration clean and small.

Signed-off-by: Peter Nied [email protected]
(cherry picked from commit e213e9c)

Issues Resolved

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

* Add signal/wait model for TestAuditlogImpl

I have been tracking test failures with testRestMethod very often
showing failures.  My theory is that the execution environment can
impact the order of operations sometimes causing the audit log not to
contain messages before it is checked.

Adding a new method `doThenWaitForMessages(...)` this ensures the
log queue is fresh, the triggering action completes, and the expected
number of messages were recieved.  There is a second long time window
that allows for the messages to be flushed, this is likely more than
enough - if the messages are recieved the count down latch immediately
continues execution so the tests will not wait if they are ready to
proceed.

While this new method is much more reliable not all tests were
encountering such issues, so I've keep the original convention.  This
can be migrated in one-offs or all at once if we see more troublesome
behavoir.  The previous methods/fields are depreciated to push future
tests to follow the new pattern.

Modifications to the rest helper not to throw exceptions were needed to
keep the Runnable declaration clean and small.

Signed-off-by: Peter Nied <[email protected]>
(cherry picked from commit e213e9c)
@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2022

Codecov Report

Merging #1796 (3db10a1) into 1.3 (3a873f8) will decrease coverage by 0.02%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                1.3    #1796      +/-   ##
============================================
- Coverage     64.64%   64.62%   -0.03%     
+ Complexity     3222     3220       -2     
============================================
  Files           247      247              
  Lines         17363    17363              
  Branches       3086     3086              
============================================
- Hits          11225    11221       -4     
- Misses         4590     4594       +4     
  Partials       1548     1548              
Impacted Files Coverage Δ
...ecurity/configuration/ConfigurationRepository.java 73.07% <0.00%> (-2.20%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a873f8...3db10a1. Read the comment docs.

@peternied
Copy link
Member Author

@opensearch-project/security I've backported this PR to 1.3 as we will likely have many more patch releases and this will ensure our tests are more reliable. Lets discuss if anyone has concerns.

@peternied peternied self-assigned this Apr 27, 2022
@davidlago
Copy link

I see "Files changed: 0". Did these changes already merge into 1.3 via another PR?

@peternied
Copy link
Member Author

@davidlago You are right, you know what I give up on this change. I'll live with flakier tests here for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants