From 6e6f4c946ac4e0658bd8443bec99283ede4a958b Mon Sep 17 00:00:00 2001 From: NiniOak Date: Wed, 20 Mar 2024 15:07:17 -0700 Subject: [PATCH] improve reliability of acceptance tests --- acceptance/framework/helpers/helpers.go | 8 ++++++-- acceptance/tests/api-gateway/api_gateway_test.go | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/acceptance/framework/helpers/helpers.go b/acceptance/framework/helpers/helpers.go index 3c41957f9e..e665eb3a34 100644 --- a/acceptance/framework/helpers/helpers.go +++ b/acceptance/framework/helpers/helpers.go @@ -223,9 +223,13 @@ func RunCommand(t testutil.TestingTB, options *k8s.KubectlOptions, command Comma select { case res := <-resultCh: - return res.output, res.err + if res.err != nil { + resErr := fmt.Errorf("error: %v\nOutput: %s", res.err, res.output) + return "", resErr + } + return res.output, nil // Sometimes this func runs for too long handle timeout if needed. - case <-time.After(320 * time.Second): + case <-time.After(400 * time.Second): GetCRDRemoveFinalizers(t, options) logger.Logf(t, "RunCommand timed out") return "", nil diff --git a/acceptance/tests/api-gateway/api_gateway_test.go b/acceptance/tests/api-gateway/api_gateway_test.go index bbbaa569d4..13cf517382 100644 --- a/acceptance/tests/api-gateway/api_gateway_test.go +++ b/acceptance/tests/api-gateway/api_gateway_test.go @@ -107,11 +107,14 @@ func TestAPIGateway_Basic(t *testing.T) { logger.Log(t, "creating static-client pod") k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.NoCleanup, cfg.DebugDirectory, "../fixtures/bases/static-client") + k8s.RunKubectl(t, ctx.KubectlOptions(t), "wait", "--for=condition=available", "--timeout=5m", fmt.Sprintf("deploy/%s", "static-server")) + logger.Log(t, "patching route to target http server") k8s.RunKubectl(t, ctx.KubectlOptions(t), "patch", "httproute", "http-route", "-p", `{"spec":{"rules":[{"backendRefs":[{"name":"static-server","port":80}]}]}}`, "--type=merge") logger.Log(t, "creating target tcp server") k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.NoCleanup, cfg.DebugDirectory, "../fixtures/bases/static-server-tcp") + k8s.RunKubectl(t, ctx.KubectlOptions(t), "wait", "--for=condition=available", "--timeout=5m", fmt.Sprintf("deploy/%s", "static-server-tcp")) logger.Log(t, "creating tcp-route") k8s.RunKubectl(t, ctx.KubectlOptions(t), "apply", "-f", "../fixtures/cases/api-gateways/tcproute/route.yaml")