From e3fdd93be1af7e3fea8139c95041fea57ab351df Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Sat, 17 Feb 2024 10:12:56 -0500 Subject: [PATCH] debug --- test/e2e-tests.sh | 3 +-- test/e2e/defective_revision_test.go | 31 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index 815cd9b0ef65..1417d37dc3d4 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -36,7 +36,7 @@ header "Running tests" failed=0 # Run tests serially in the mesh and https scenarios. -GO_TEST_FLAGS="-v -run TestDefect" +GO_TEST_FLAGS="-run TestDefect" E2E_TEST_FLAGS="${TEST_OPTIONS}" if [ -z "${E2E_TEST_FLAGS}" ]; then @@ -63,7 +63,6 @@ if (( SHORT )); then GO_TEST_FLAGS+=" -short" fi - go_test_e2e -timeout=30m \ ${GO_TEST_FLAGS} \ ./test/conformance/api/... \ diff --git a/test/e2e/defective_revision_test.go b/test/e2e/defective_revision_test.go index c8e4e8757a1f..7bd9cc2ff2f1 100644 --- a/test/e2e/defective_revision_test.go +++ b/test/e2e/defective_revision_test.go @@ -22,6 +22,7 @@ package e2e import ( "context" "errors" + "fmt" "net/http" "testing" "time" @@ -39,8 +40,16 @@ import ( revisionnames "knative.dev/serving/pkg/reconciler/revision/resources/names" ) -func TestDefectiveRevisionScalesDown(t *testing.T) { +func TestDefectiveRevision(t *testing.T) { t.Parallel() + for i := 0; i < 10; i++ { + t.Run(fmt.Sprintf("%v", i), func(t *testing.T) { + runtest(t) + }) + } +} + +func runtest(t *testing.T) { clients := Setup(t) // This one uses the default namespace `test.ServingFlags.TestNamespace` resources := test.ResourceNames{ @@ -142,7 +151,7 @@ func TestDefectiveRevisionScalesDown(t *testing.T) { clients.KubeClient, rev1DeploymentName, func(d *appsv1.Deployment) (bool, error) { - // Fail if there's an error making the request + // Fail fast if there's an error making the request select { case requestErr = <-errs: return false, requestErr @@ -156,13 +165,14 @@ func TestDefectiveRevisionScalesDown(t *testing.T) { ) if requestErr != nil { - t.Fatal("triggering request to revision failed: ", err) + t.Fatal("triggering request to revision failed: ", requestErr) } if err != nil { t.Fatal("failed to wait for deployment to scale up: ", err) } + // trigger a rollout of a new revision if _, err = v1test.UpdateService(t, clients, resources, serviceFunc); err != nil { t.Fatal("failed to update service: ", err) } @@ -171,9 +181,20 @@ func TestDefectiveRevisionScalesDown(t *testing.T) { t.Fatal("failed to rollout new revision", err) } + // wait for the request to be complete prior to asserting scale to zero +outer: + for { + select { + case _, ok := <-errs: + if !ok { + break outer + } + case <-time.After(30 * time.Second): + t.Fatalf("request didn't complete") + } + } + if err = WaitForScaleToZero(t, rev1DeploymentName, clients); err != nil { t.Fatal("first revision failed to scale down") } - - t.Fatal("it shouldn't fail here") }