From ff8fbc2d37ee4cd53117142426005836907fcb6a Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Thu, 3 Mar 2022 09:30:10 -0800 Subject: [PATCH] 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 --- test/integration/apiserver/apiserver_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/integration/apiserver/apiserver_test.go b/test/integration/apiserver/apiserver_test.go index 8caa43e9efe..7d7ad600569 100644 --- a/test/integration/apiserver/apiserver_test.go +++ b/test/integration/apiserver/apiserver_test.go @@ -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) }