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:
Steve Kuznetsov 2022-03-03 09:30:10 -08:00
parent a843239ec3
commit ff8fbc2d37
No known key found for this signature in database
GPG Key ID: 8821C29EC988D9B4

View File

@ -1972,6 +1972,10 @@ func TestTransform(t *testing.T) {
rv = previousRV
}
ctx, cancel := context.WithTimeout(context.Background(), wait.ForeverTestTimeout)
t.Cleanup(func() {
cancel()
})
w, err := client.Get().
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).
SetHeader("Accept", tc.accept).
@ -1981,7 +1985,7 @@ func TestTransform(t *testing.T) {
FieldSelector: fields.OneTermEqualSelector("metadata.name", obj.GetName()).String(),
}, metav1.ParameterCodec).
Param("includeObject", string(tc.includeObject)).
Stream(context.TODO())
Stream(ctx)
if (tc.wantErr != nil) != (err != nil) {
t.Fatalf("unexpected error: %v", err)
}