-
Notifications
You must be signed in to change notification settings - Fork 144
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
Fix flaky test Test_runDispatcher/gateway_actions_passed #5405
Fix flaky test Test_runDispatcher/gateway_actions_passed #5405
Conversation
A short context timeout makes some tests flaky, but making it longer across the board would unnecessarily make test runs longer. Let's make it customizable per test case.
The flakiness is a result of a 100 miliseconds not always being enough time to dispatch the action in the test environment. The correct way to fix this issue is to run the assertions in an `assert.Eventually` with a longer timeout. Unfortunately, a deficiency in the `testify` testing framework makes it impossible to put the `AssertExpectations` methods in an `assert.Eventually` or `assert.EventuallyWithT` function: stretchr/testify#1414. The workaround is to increase the context timeout for the `gateway actions passed` test case. I'm increasing it from 100ms to 200ms.
Test_runDispatcher/gateway_actions_passed
Test_runDispatcher/gateway_actions_passed
This pull request does not have a backport label. Could you fix it @andrzej-stencel? 🙏
NOTE: |
Quality Gate passedIssues Measures |
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
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.
Looks good.
There is discussion on the issue in the description that links to another issue, which links to stretchr/testify#1395; could the approach from this pr be used to make the |
@michel-laterman I don't know what approach you mean, can you elaborate? Let me merge this pull request for now, but I'd be happy to continue the conversation to hopefully find a better solution. |
* refctor: make context timeout adjustable per test case A short context timeout makes some tests flaky, but making it longer across the board would unnecessarily make test runs longer. Let's make it customizable per test case. * Fix flaky test `Test_runDispatcher/gateway_actions_passed` The flakiness is a result of a 100 miliseconds not always being enough time to dispatch the action in the test environment. The correct way to fix this issue is to run the assertions in an `assert.Eventually` with a longer timeout. Unfortunately, a deficiency in the `testify` testing framework makes it impossible to put the `AssertExpectations` methods in an `assert.Eventually` or `assert.EventuallyWithT` function: stretchr/testify#1414. The workaround is to increase the context timeout for the `gateway actions passed` test case. I'm increasing it from 100ms to 200ms. (cherry picked from commit 0efab75)
* refctor: make context timeout adjustable per test case A short context timeout makes some tests flaky, but making it longer across the board would unnecessarily make test runs longer. Let's make it customizable per test case. * Fix flaky test `Test_runDispatcher/gateway_actions_passed` The flakiness is a result of a 100 miliseconds not always being enough time to dispatch the action in the test environment. The correct way to fix this issue is to run the assertions in an `assert.Eventually` with a longer timeout. Unfortunately, a deficiency in the `testify` testing framework makes it impossible to put the `AssertExpectations` methods in an `assert.Eventually` or `assert.EventuallyWithT` function: stretchr/testify#1414. The workaround is to increase the context timeout for the `gateway actions passed` test case. I'm increasing it from 100ms to 200ms. (cherry picked from commit 0efab75) Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
What does this PR do?
Fixes flaky test
Test_runDispatcher/gateway_actions_passed
by increasing the timeout from 100ms to 200ms.The flakiness is a result of a 100 miliseconds not always being enough time to dispatch the action in the test environment.
The correct way to fix this issue is to run the assertions in an
assert.Eventually
with a longer timeout. Unfortunately, a deficiency in thetestify
testing framework makes it impossible to put theAssertExpectations
methods in anassert.Eventually
orassert.EventuallyWithT
function: stretchr/testify#1414.The workaround is to increase the context timeout for the
gateway actions passed
test case. I'm increasing it from 100ms to 200ms.Why is it important?
Flaky tests are evil!
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature works[ ] I have added an entry in./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testHow to test this PR locally
$ go test -v ./internal/pkg/agent/application/ -run Test_runDispatcher
Related issues