beats
beats copied to clipboard
x-pack/filebeat/input/{cel,httpjson}: fix flaky test
Proposed commit message
Do not use uncontrolled randomisation in tests where it is not necessary. The retry tests in the httpjson and cel packages were using a randomised 5xx HTTP status code to trigger the retry behaviour of the the go-retryablehttp package. This had the unfortunate consequence of causing 2% of test runs to fail.
The reason for this is given in the go-retryablehttp documentation[1]:
Mainly, if an error is returned by the client (connection errors, etc.), or if a 500-range response code is received (except 501), then a retry is invoked after a wait period.
Since the package is already tested, and is documented to accept all 5xx status codes except 501 to cause a retry, just use 500.
[1]https://pkg.go.dev/github.com/hashicorp/[email protected]#section-readme
Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] 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
- [x] I have added an entry in
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.
Disruptive User Impact
Author's Checklist
- [ ]
How to test this PR locally
Related issues
- For #40503
Use cases
Screenshots
Logs
backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.
Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)