-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Flaky test TestGetRoundTripperTLSConfig #4732
Comments
Hey, I would like to work on this issue. |
Hey @yurishkuro, I am unable to replicate this issue. When I'm running |
Flaky tests are difficult to reproduce reliably. Sometimes you can run it multiple times with |
I ran the make test -n command multiple times, but can't replicate the issue 😢 How can I fix this issue. |
I'm a little confused about the test error. The assertion is: assert.Equal(t, "Bearer foo", r.Header.Get("Authorization")) But the test fails with:
I expected the assertion error to contain something like @yurishkuro do you have the link to the error run or was it something you encountered from a local run of the test? |
@albertteoh it wasn't local, it was from CI. I suspect that the stars are somehow substituted by GitHub runner. If you change the string to
|
Yeah, that's a good idea. I'll put that in. I'm wondering if As such, I wonder if it's worthwhile changing the test to have a boolean variable outside and setting this to So something like: var gotExpectedRequest bool
server := httptest.NewServer(
http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Authorization") == "Bearer foo" {
gotExpectedRequest = true
}
},
),
)
...
assert.True(t, gotExpectedRequest) |
I believe each test server runs on a random port, so crossover should not happen. I agree that it's better to have the handler store the data somewhere and then assert on that data in the main test. Example: https://github.com/jaegertracing/jaeger/pull/4342/files#diff-fb005680ccab1461b654fe14dcb0a53eb862af4f9bfc15b279731e287083b5daR285 - this one is a bit more complicated because basic auth is encoded and I didn't want to compare values in the encoded form (not informative if assertion fails). Note that you should use synchronized storage var, otherwise your test may cause race condition detector to flag it. |
## Which problem is this PR solving? - Resolves #4732 ## Description of the changes - Introduces an atomic boolean outside of the HTTP test handler and only set to `true` if the expected request is received. - This should prevent cases where unrelated processes are hitting the same test URL. ## How was this change tested? - Ran `make test` to pass. - Ran `go test -tags=memory_storage_integration -count 10 ./...` and confirmed `metricsstore` tests are passing. - Note that a number of unrelated tests were failing with the `-count 10` flag set, **not as a result of the changes from this PR**, namely: ``` --- FAIL: TestFactory (0.00s) --- FAIL: TestFactory/#00 (0.00s) panic: Reuse of exported var name: test_1694287567920905000_counter_x [recovered] panic: Reuse of exported var name: test_1694287567920905000_counter_x ``` and ``` --- FAIL: TestPublishOpts (0.00s) builder_test.go:308: Error Trace: /Users/albertteoh/go/src/github.com/albertteoh/jaeger/cmd/agent/app/builder_test.go:308 Error: Received unexpected error: cannot create processors: cannot create Thrift Processor: cannot create UDP Server: cannot create UDPServerTransport: listen udp :5775: bind: address already in use Test: TestPublishOpts ``` ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Albert Teoh <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Albert Teoh <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
jaeger/plugin/metrics/prometheus/metricsstore/reader_test.go
Line 543 in 2ac6aac
The text was updated successfully, but these errors were encountered: