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

x-pack/filebeat/input/{cel,httpjson}: fix flaky test #41358

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented Oct 22, 2024

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/go-retryablehttp@v0.7.7#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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 added Filebeat Filebeat backport-7.17 Automated backport to the 7.17 branch with mergify bugfix Team:Security-Service Integrations Security Service Integrations Team labels Oct 22, 2024
@efd6 efd6 self-assigned this Oct 22, 2024
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Oct 22, 2024
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 1% 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/go-retryablehttp@v0.7.7#section-readme
Copy link
Contributor

mergify bot commented Oct 22, 2024

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.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Oct 22, 2024
@efd6 efd6 force-pushed the 40503-cel_httpjson branch from f75ce67 to c46b21d Compare October 22, 2024 03:51
@efd6 efd6 marked this pull request as ready for review October 22, 2024 05:34
@efd6 efd6 requested a review from a team as a code owner October 22, 2024 05:34
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@efd6 efd6 merged commit 794b832 into elastic:main Oct 23, 2024
20 of 22 checks passed
mergify bot pushed a commit that referenced this pull request Oct 23, 2024
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 has 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/go-retryablehttp@v0.7.7#section-readme

(cherry picked from commit 794b832)

# Conflicts:
#	x-pack/filebeat/input/cel/input_test.go
#	x-pack/filebeat/input/httpjson/input_test.go
mergify bot pushed a commit that referenced this pull request Oct 23, 2024
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 has 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/go-retryablehttp@v0.7.7#section-readme

(cherry picked from commit 794b832)
efd6 added a commit that referenced this pull request Oct 24, 2024
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 has 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/go-retryablehttp@v0.7.7#section-readme

(cherry picked from commit 794b832)

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
efd6 added a commit that referenced this pull request Oct 24, 2024
…ky test (#41405)

* x-pack/filebeat/input/{cel,httpjson}: fix flaky test (#41358)

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 has 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/go-retryablehttp@v0.7.7#section-readme

(cherry picked from commit 794b832)

# Conflicts:
#	x-pack/filebeat/input/cel/input_test.go
#	x-pack/filebeat/input/httpjson/input_test.go

remove:
* redundant changelog entries
* cel tests
* conflicts in httpjson tests

---------

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.17 Automated backport to the 7.17 branch with mergify backport-8.x Automated backport to the 8.x branch with mergify bugfix Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants