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

predicates/traffic: fix flaky TrafficSegment tests #2423

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

AlexanderYastrebov
Copy link
Member

Test failure could be reproduced via:

go test ./predicates/traffic/ -count=100 -run=TestTrafficSegmentSplit
  • use delta of expected value instead of total number of test requests
  • use predefined number of test requests for all tests

Based on the biggest difference seen for 1000 test requests:

Max difference between 500 and 462 allowed is 25, but difference was 38

the delta should be 38/500=0.076

To reduce flakiness:

  • increase total number of samples to 10'000
  • then increase delta to 6% based on the failed test case output

Test failure could be reproduced via:
```
go test ./predicates/traffic/ -count=100 -run=TestTrafficSegmentSplit
```

* use delta of expected value instead of total number of test requests
* use predefined number of test requests for all tests

Based on the biggest difference seen for 1000 test requests:
```
Max difference between 500 and 462 allowed is 25, but difference was 38
```
the delta should be 38/500=0.076

To reduce flakiness:

* increase total number of samples to 10'000
* then increase delta to 6% based on the failed test case output

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
// doN performs a number of requests and returns the number of responses for each status code and
// a total number of requests performed.
// Results use float64 type to simplify fractional comparisons.
func doN(t *testing.T, client *proxytest.TestClient, request func() *http.Request) (map[int]float64, float64) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the N?
Maybe better to call it do ?

Copy link
Member Author

@AlexanderYastrebov AlexanderYastrebov Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N is hardcoded, see below.
The name highlights that it does multiple requests

@szuecs
Copy link
Member

szuecs commented Jun 23, 2023

👍

1 similar comment
@AlexanderYastrebov
Copy link
Member Author

👍

@AlexanderYastrebov AlexanderYastrebov merged commit 399b08b into master Jun 23, 2023
@AlexanderYastrebov AlexanderYastrebov deleted the predicates/traffic/fix-segment-tests branch June 23, 2023 13:58

t.Logf("Response codes: %v", codes)

assert.InDelta(t, N*0.5, codes[200], delta)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why moving to a function?

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