mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-04 14:08:39 +00:00
rpc: fix flaky otel tests (#35101)
The response can reach the client before the deferred spanEnd fires, so call `httpsrv.Close()` before GetSpans is called.
This commit is contained in:
parent
38667bc64e
commit
e514ede494
1 changed files with 12 additions and 0 deletions
|
|
@ -470,6 +470,10 @@ func TestTracingBatchHTTPEmpty(t *testing.T) {
|
||||||
|
|
||||||
postJSONRPC(t, httpsrv.URL, `[]`)
|
postJSONRPC(t, httpsrv.URL, `[]`)
|
||||||
|
|
||||||
|
// Wait for the in-flight request to finish so the deferred spanEnd fires
|
||||||
|
// before GetSpans is called.
|
||||||
|
httpsrv.Close()
|
||||||
|
|
||||||
if err := tracer.ForceFlush(context.Background()); err != nil {
|
if err := tracer.ForceFlush(context.Background()); err != nil {
|
||||||
t.Fatalf("failed to flush: %v", err)
|
t.Fatalf("failed to flush: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -510,6 +514,10 @@ func TestTracingBatchHTTPTooLarge(t *testing.T) {
|
||||||
]`
|
]`
|
||||||
postJSONRPC(t, httpsrv.URL, body)
|
postJSONRPC(t, httpsrv.URL, body)
|
||||||
|
|
||||||
|
// Wait for the in-flight request to finish so the deferred spanEnd fires
|
||||||
|
// before GetSpans is called.
|
||||||
|
httpsrv.Close()
|
||||||
|
|
||||||
if err := tracer.ForceFlush(context.Background()); err != nil {
|
if err := tracer.ForceFlush(context.Background()); err != nil {
|
||||||
t.Fatalf("failed to flush: %v", err)
|
t.Fatalf("failed to flush: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -553,6 +561,10 @@ func TestTracingHTTPTimeout(t *testing.T) {
|
||||||
// response goes out.
|
// response goes out.
|
||||||
postJSONRPC(t, httpsrv.URL, `{"jsonrpc":"2.0","id":1,"method":"test_block"}`)
|
postJSONRPC(t, httpsrv.URL, `{"jsonrpc":"2.0","id":1,"method":"test_block"}`)
|
||||||
|
|
||||||
|
// Wait for the in-flight request to finish so the deferred spanEnd fires
|
||||||
|
// before GetSpans is called.
|
||||||
|
httpsrv.Close()
|
||||||
|
|
||||||
if err := tracer.ForceFlush(context.Background()); err != nil {
|
if err := tracer.ForceFlush(context.Background()); err != nil {
|
||||||
t.Fatalf("failed to flush: %v", err)
|
t.Fatalf("failed to flush: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue