From 02bd75764c15a1f02957363d8434b5e6de76a4d6 Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Mon, 11 Jun 2018 14:43:23 -0700 Subject: [PATCH] Issue 63622 - Flaky e2e/aggr test. Investigated issue 63622. The test usually passes. When it does it seems to take almost 30 seconds for the sample-apiserver to start returning 2xx rather than 4xx to flunder requests. On the failing tests I looked at it was taking almost 45 seconds for the sample-apiserver to become healthy. I bumped the wait/timeout in the test for this case to 60 seconds. I also added a log statement to make it easier to track how long it was taking for the sample-apiserver to come up. Once we have a bit more history I will log a bug for the long start up time. Fixed go format error. --- test/e2e/apimachinery/aggregator.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/e2e/apimachinery/aggregator.go b/test/e2e/apimachinery/aggregator.go index 30e6cb22b52..9b08fcbdc1b 100644 --- a/test/e2e/apimachinery/aggregator.go +++ b/test/e2e/apimachinery/aggregator.go @@ -324,7 +324,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) { currentPods *v1.PodList ) - err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) { + err = pollTimed(100*time.Millisecond, 60*time.Second, func() (bool, error) { currentAPIService, _ = aggrclient.ApiregistrationV1beta1().APIServices().Get("v1alpha1.wardle.k8s.io", metav1.GetOptions{}) currentPods, _ = client.CoreV1().Pods(namespace).List(metav1.ListOptions{}) @@ -346,7 +346,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) { return false, err } return true, nil - }) + }, "Waited %s for the sample-apiserver to be ready to handle requests.") if err != nil { currentAPIServiceJSON, _ := json.Marshal(currentAPIService) framework.Logf("current APIService: %s", string(currentAPIServiceJSON)) @@ -460,6 +460,17 @@ func TestSampleAPIServer(f *framework.Framework, image string) { cleanTest(client, aggrclient, namespace) } +// pollTimed will call Poll but time how long Poll actually took. +// It will then framework.logf the msg with the duration of the Poll. +// It is assumed that msg will contain one %s for the elapsed time. +func pollTimed(interval, timeout time.Duration, condition wait.ConditionFunc, msg string) error { + defer func(start time.Time, msg string) { + elapsed := time.Since(start) + framework.Logf(msg, elapsed) + }(time.Now(), msg) + return wait.Poll(interval, timeout, condition) +} + func validateErrorWithDebugInfo(f *framework.Framework, err error, pods *v1.PodList, msg string, fields ...interface{}) { if err != nil { namespace := f.Namespace.Name