-
Notifications
You must be signed in to change notification settings - Fork 351
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
predicates/traffic: fix flaky TrafficSegment tests #2423
Conversation
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) { |
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.
Where is the N?
Maybe better to call it do
?
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.
N is hardcoded, see below.
The name highlights that it does multiple requests
👍 |
1 similar comment
👍 |
|
||
t.Logf("Response codes: %v", codes) | ||
|
||
assert.InDelta(t, N*0.5, codes[200], delta) |
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.
Why moving to a function?
Test failure could be reproduced via:
Based on the biggest difference seen for 1000 test requests:
the delta should be 38/500=0.076
To reduce flakiness: