From 91f839fb686f42091ade58bd1ce1f01ddbfa3613 Mon Sep 17 00:00:00 2001 From: Victor Agababov Date: Mon, 9 Mar 2020 19:20:47 -0700 Subject: [PATCH 1/3] Some cleanups in the e2e test --- test/e2e/minscale_readiness_test.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/test/e2e/minscale_readiness_test.go b/test/e2e/minscale_readiness_test.go index 0f4487d88c8c..c1af2ead4d63 100644 --- a/test/e2e/minscale_readiness_test.go +++ b/test/e2e/minscale_readiness_test.go @@ -61,11 +61,11 @@ func TestMinScale(t *testing.T) { } revName := latestRevisionName(t, clients, names.Config, "") - serviceName := serverlessServicesName(t, clients, revName) + serviceName := privateServceName(t, clients, revName) // Before becoming ready, observe minScale t.Log("Waiting for revision to scale to minScale before becoming ready") - if err := waitForDesiredScale(t, clients, serviceName, gte(minScale)); err != nil { + if err := waitForDesiredScale(clients, serviceName, gte(minScale)); err != nil { t.Fatalf("The revision %q did not scale >= %d before becoming ready: %v", revName, minScale, err) } @@ -79,7 +79,7 @@ func TestMinScale(t *testing.T) { // Without a route, ignore minScale t.Log("Waiting for revision to scale below minScale after becoming ready") - if err := waitForDesiredScale(t, clients, serviceName, lt(minScale)); err != nil { + if err := waitForDesiredScale(clients, serviceName, lt(minScale)); err != nil { t.Fatalf("The revision %q did not scale < minScale after becoming ready: %v", revName, err) } @@ -99,7 +99,7 @@ func TestMinScale(t *testing.T) { // With a route, observe minScale t.Log("Waiting for revision to scale to minScale after creating route") - if err := waitForDesiredScale(t, clients, serviceName, gte(minScale)); err != nil { + if err := waitForDesiredScale(clients, serviceName, gte(minScale)); err != nil { t.Fatalf("The revision %q did not scale >= %d after creating route: %v", revName, minScale, err) } @@ -109,11 +109,11 @@ func TestMinScale(t *testing.T) { } newRevName := latestRevisionName(t, clients, names.Config, revName) - newServiceName := serverlessServicesName(t, clients, newRevName) + newServiceName := privateServceName(t, clients, newRevName) // After update, observe minScale in new revision t.Log("Waiting for latest revision to scale to minScale after update") - if err := waitForDesiredScale(t, clients, newServiceName, gte(minScale)); err != nil { + if err := waitForDesiredScale(clients, newServiceName, gte(minScale)); err != nil { t.Fatalf("The revision %q did not scale >= %d after creating route: %v", newRevName, minScale, err) } @@ -127,13 +127,13 @@ func TestMinScale(t *testing.T) { // After update, ensure new revision holds minScale t.Log("Hold minScale after update") - if err := ensureDesiredScale(t, clients, newServiceName, gte(minScale)); err != nil { + if err := ensureDesiredScale(clients, newServiceName, gte(minScale)); err != nil { t.Fatalf("The revision %q did not stay at scale >= %d after creating route: %v", newRevName, minScale, err) } // After update, ensure old revision ignores minScale t.Log("Waiting for old revision to scale below minScale after being replaced") - if err := waitForDesiredScale(t, clients, serviceName, lt(minScale)); err != nil { + if err := waitForDesiredScale(clients, serviceName, lt(minScale)); err != nil { t.Fatalf("The revision %q did not scale < minScale after being replaced: %v", revName, err) } } @@ -184,7 +184,7 @@ func latestRevisionName(t *testing.T, clients *test.Clients, configName, oldRevN return config.Status.LatestCreatedRevisionName } -func serverlessServicesName(t *testing.T, clients *test.Clients, revisionName string) string { +func privateServceName(t *testing.T, clients *test.Clients, revisionName string) string { var privateServiceName string if err := wait.PollImmediate(time.Second, 1*time.Minute, func() (bool, error) { @@ -204,7 +204,7 @@ func serverlessServicesName(t *testing.T, clients *test.Clients, revisionName st return privateServiceName } -func waitForDesiredScale(t *testing.T, clients *test.Clients, serviceName string, cond func(int) bool) error { +func waitForDesiredScale(clients *test.Clients, serviceName string, cond func(int) bool) error { endpoints := clients.KubeClient.Kube.CoreV1().Endpoints(test.ServingNamespace) return wait.PollImmediate(250*time.Millisecond, 1*time.Minute, func() (bool, error) { @@ -217,10 +217,10 @@ func waitForDesiredScale(t *testing.T, clients *test.Clients, serviceName string } -func ensureDesiredScale(t *testing.T, clients *test.Clients, serviceName string, cond func(int) bool) error { +func ensureDesiredScale(clients *test.Clients, serviceName string, cond func(int) bool) error { endpoints := clients.KubeClient.Kube.CoreV1().Endpoints(test.ServingNamespace) - err := wait.PollImmediate(250*time.Millisecond, 5*time.Second, func() (bool, error) { + if err := wait.PollImmediate(250*time.Millisecond, 5*time.Second, func() (bool, error) { endpoint, err := endpoints.Get(serviceName, metav1.GetOptions{}) if err != nil { return false, nil @@ -231,9 +231,7 @@ func ensureDesiredScale(t *testing.T, clients *test.Clients, serviceName string, } return false, nil - }) - - if err != wait.ErrWaitTimeout { + }); err != wait.ErrWaitTimeout { return err } From a4bf7402ae5430b2c97e7aff0862a9d16b1dbdc9 Mon Sep 17 00:00:00 2001 From: Victor Agababov Date: Mon, 9 Mar 2020 19:22:45 -0700 Subject: [PATCH 2/3] Some cleanups in the e2e test --- test/e2e/minscale_readiness_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/e2e/minscale_readiness_test.go b/test/e2e/minscale_readiness_test.go index c1af2ead4d63..24b960538afe 100644 --- a/test/e2e/minscale_readiness_test.go +++ b/test/e2e/minscale_readiness_test.go @@ -193,10 +193,7 @@ func privateServceName(t *testing.T, clients *test.Clients, revisionName string) return false, nil } privateServiceName = sks.Status.PrivateServiceName - if privateServiceName == "" { - return false, nil - } - return true, nil + return privateServceName != "", nil }); err != nil { t.Fatalf("Error retrieving sks %q: %v", revisionName, err) } From 758d8c026610f182169011df3935331673324628 Mon Sep 17 00:00:00 2001 From: Victor Agababov Date: Mon, 9 Mar 2020 20:15:54 -0700 Subject: [PATCH 3/3] fix nit --- test/e2e/minscale_readiness_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/minscale_readiness_test.go b/test/e2e/minscale_readiness_test.go index 24b960538afe..34db9d7e1a94 100644 --- a/test/e2e/minscale_readiness_test.go +++ b/test/e2e/minscale_readiness_test.go @@ -61,7 +61,7 @@ func TestMinScale(t *testing.T) { } revName := latestRevisionName(t, clients, names.Config, "") - serviceName := privateServceName(t, clients, revName) + serviceName := privateServiceName(t, clients, revName) // Before becoming ready, observe minScale t.Log("Waiting for revision to scale to minScale before becoming ready") @@ -109,7 +109,7 @@ func TestMinScale(t *testing.T) { } newRevName := latestRevisionName(t, clients, names.Config, revName) - newServiceName := privateServceName(t, clients, newRevName) + newServiceName := privateServiceName(t, clients, newRevName) // After update, observe minScale in new revision t.Log("Waiting for latest revision to scale to minScale after update") @@ -184,7 +184,7 @@ func latestRevisionName(t *testing.T, clients *test.Clients, configName, oldRevN return config.Status.LatestCreatedRevisionName } -func privateServceName(t *testing.T, clients *test.Clients, revisionName string) string { +func privateServiceName(t *testing.T, clients *test.Clients, revisionName string) string { var privateServiceName string if err := wait.PollImmediate(time.Second, 1*time.Minute, func() (bool, error) { @@ -193,7 +193,7 @@ func privateServceName(t *testing.T, clients *test.Clients, revisionName string) return false, nil } privateServiceName = sks.Status.PrivateServiceName - return privateServceName != "", nil + return privateServiceName != "", nil }); err != nil { t.Fatalf("Error retrieving sks %q: %v", revisionName, err) }