@@ -153,15 +153,21 @@ func (s) TestRetryChainedInterceptor(t *testing.T) {
153
153
handler := func (ctx context.Context , req any ) (any , error ) {
154
154
return nil , nil
155
155
}
156
- ii (context .Background (), nil , nil , handler )
156
+
157
+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
158
+ defer cancel ()
159
+
160
+ ii (ctx , nil , nil , handler )
157
161
if ! cmp .Equal (records , []int {1 , 2 , 3 , 2 , 3 }) {
158
162
t .Fatalf ("retry failed on chained interceptors: %v" , records )
159
163
}
160
164
}
161
165
162
166
func (s ) TestStreamContext (t * testing.T ) {
163
167
expectedStream := & transport.Stream {}
164
- ctx := NewContextWithServerTransportStream (context .Background (), expectedStream )
168
+ ctx , cancel := context .WithTimeout (NewContextWithServerTransportStream (context .Background (), expectedStream ), defaultTestTimeout )
169
+ defer cancel ()
170
+
165
171
s := ServerTransportStreamFromContext (ctx )
166
172
stream , ok := s .(* transport.Stream )
167
173
if ! ok || expectedStream != stream {
@@ -186,7 +192,10 @@ func BenchmarkChainUnaryInterceptor(b *testing.B) {
186
192
b .ReportAllocs ()
187
193
b .ResetTimer ()
188
194
for i := 0 ; i < b .N ; i ++ {
189
- if _ , err := s .opts .unaryInt (context .Background (), nil , nil ,
195
+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
196
+ defer cancel ()
197
+
198
+ if _ , err := s .opts .unaryInt (ctx , nil , nil ,
190
199
func (ctx context.Context , req any ) (any , error ) {
191
200
return nil , nil
192
201
},
0 commit comments