Skip to content

Commit cb00267

Browse files
authored
chore: remove flaking requestidmiddleware test (#2660)
1 parent 014691e commit cb00267

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

pkg/middleware/requestid/requestid_test.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import (
44
"context"
55
"errors"
66
"io"
7-
"sync"
87
"testing"
9-
"time"
108

119
"github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testpb"
1210
"github.com/stretchr/testify/require"
@@ -338,50 +336,3 @@ func (s *requestIDCustomGeneratorTestSuite) TestCustomGenerator() {
338336
require.NotEmpty(s.T(), requestIDs)
339337
require.Contains(s.T(), requestIDs[0], s.customIDPrefix, "Custom generator should be used")
340338
}
341-
342-
// Test suite for timeout handling
343-
type requestIDTimeoutTestSuite struct {
344-
*testpb.InterceptorTestSuite
345-
}
346-
347-
func TestRequestIDMiddlewareTimeout(t *testing.T) {
348-
s := &requestIDTimeoutTestSuite{
349-
InterceptorTestSuite: &testpb.InterceptorTestSuite{
350-
TestService: &testServer{},
351-
ServerOpts: []grpc.ServerOption{
352-
grpc.ChainUnaryInterceptor(
353-
UnaryServerInterceptor(GenerateIfMissing(true)),
354-
),
355-
},
356-
ClientOpts: []grpc.DialOption{},
357-
},
358-
}
359-
suite.Run(t, s)
360-
}
361-
362-
// If a stream receives a context that is already cancelled,
363-
// the middleware will not be invoked at all. Therefore, we try to induce
364-
// what happens when the context errors *while the middleware is running*.
365-
// However, right now, this test is only useful when ran by hand and inspecting logs manually,
366-
// because we don't have a way of asserting what logs were emmitted by the middleware.
367-
func (s *requestIDTimeoutTestSuite) TestContextTimeout() {
368-
var wg sync.WaitGroup
369-
for i := 0; i < 10_000; i++ {
370-
wg.Add(1)
371-
wg.Go(func() {
372-
defer wg.Done()
373-
374-
// context will be cancelled in the middle of the middleware (if we are lucky)
375-
ctx, cancel := context.WithTimeout(s.T().Context(), 1*time.Millisecond)
376-
defer cancel()
377-
378-
var trailer metadata.MD
379-
_, err := s.Client.PingEmpty(ctx, &testpb.PingEmptyRequest{}, grpc.Trailer(&trailer))
380-
381-
// The RPC should fail due to context cancellation, but middleware should handle it gracefully
382-
require.Error(s.T(), err)
383-
})
384-
}
385-
386-
wg.Wait()
387-
}

0 commit comments

Comments
 (0)