mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
test/integration: use a context with a deadline for streaming
Without such a context, this test would hang without data for 10 minutes, then panic. Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
parent
a843239ec3
commit
ff8fbc2d37
@ -1972,6 +1972,10 @@ func TestTransform(t *testing.T) {
|
|||||||
rv = previousRV
|
rv = previousRV
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), wait.ForeverTestTimeout)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
cancel()
|
||||||
|
})
|
||||||
w, err := client.Get().
|
w, err := client.Get().
|
||||||
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).
|
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).
|
||||||
SetHeader("Accept", tc.accept).
|
SetHeader("Accept", tc.accept).
|
||||||
@ -1981,7 +1985,7 @@ func TestTransform(t *testing.T) {
|
|||||||
FieldSelector: fields.OneTermEqualSelector("metadata.name", obj.GetName()).String(),
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", obj.GetName()).String(),
|
||||||
}, metav1.ParameterCodec).
|
}, metav1.ParameterCodec).
|
||||||
Param("includeObject", string(tc.includeObject)).
|
Param("includeObject", string(tc.includeObject)).
|
||||||
Stream(context.TODO())
|
Stream(ctx)
|
||||||
if (tc.wantErr != nil) != (err != nil) {
|
if (tc.wantErr != nil) != (err != nil) {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user