From 24eb21e6cf36da896ae6a410fad8947c129b39b0 Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Mon, 25 Sep 2017 14:17:43 -0700 Subject: [PATCH] Use PollImmediate and shorter interval in integration test --- test/e2e/framework/deployment_util.go | 2 +- test/e2e/framework/rs_util.go | 2 +- test/integration/deployment/deployment_test.go | 3 +-- test/integration/deployment/util.go | 8 ++++---- test/utils/deployment.go | 4 ++-- test/utils/replicaset.go | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/e2e/framework/deployment_util.go b/test/e2e/framework/deployment_util.go index 5146f8d3178..80c19dcbfd3 100644 --- a/test/e2e/framework/deployment_util.go +++ b/test/e2e/framework/deployment_util.go @@ -36,7 +36,7 @@ import ( ) func UpdateDeploymentWithRetries(c clientset.Interface, namespace, name string, applyUpdate testutils.UpdateDeploymentFunc) (*extensions.Deployment, error) { - return testutils.UpdateDeploymentWithRetries(c, namespace, name, applyUpdate, Logf) + return testutils.UpdateDeploymentWithRetries(c, namespace, name, applyUpdate, Logf, Poll, pollShortTimeout) } // Waits for the deployment to clean up old rcs. diff --git a/test/e2e/framework/rs_util.go b/test/e2e/framework/rs_util.go index bd5eecedcd2..a7c6ce57172 100644 --- a/test/e2e/framework/rs_util.go +++ b/test/e2e/framework/rs_util.go @@ -35,7 +35,7 @@ import ( type updateRsFunc func(d *extensions.ReplicaSet) func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate testutils.UpdateReplicaSetFunc) (*extensions.ReplicaSet, error) { - return testutils.UpdateReplicaSetWithRetries(c, namespace, name, applyUpdate, Logf) + return testutils.UpdateReplicaSetWithRetries(c, namespace, name, applyUpdate, Logf, Poll, pollShortTimeout) } // CheckNewRSAnnotations check if the new RS's annotation is as expected diff --git a/test/integration/deployment/deployment_test.go b/test/integration/deployment/deployment_test.go index 025ab734dee..0695754f38e 100644 --- a/test/integration/deployment/deployment_test.go +++ b/test/integration/deployment/deployment_test.go @@ -20,7 +20,6 @@ import ( "reflect" "strings" "testing" - "time" "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" @@ -367,7 +366,7 @@ func TestDeploymentHashCollision(t *testing.T) { } // Expect deployment collision counter to increment - if err := wait.PollImmediate(time.Second, time.Minute, func() (bool, error) { + if err := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) { d, err := c.ExtensionsV1beta1().Deployments(ns.Name).Get(tester.deployment.Name, metav1.GetOptions{}) if err != nil { return false, nil diff --git a/test/integration/deployment/util.go b/test/integration/deployment/util.go index 9cd60f2cc2e..77547a7454c 100644 --- a/test/integration/deployment/util.go +++ b/test/integration/deployment/util.go @@ -38,7 +38,7 @@ import ( ) const ( - pollInterval = 1 * time.Second + pollInterval = 100 * time.Millisecond pollTimeout = 60 * time.Second fakeImageName = "fake-name" @@ -168,7 +168,7 @@ func (d *deploymentTester) markAllPodsReady() { d.t.Fatalf("failed to parse Deployment selector: %v", err) } var readyPods int32 - err = wait.Poll(100*time.Millisecond, pollTimeout, func() (bool, error) { + err = wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) { readyPods = 0 pods, err := d.c.Core().Pods(ns).List(metav1.ListOptions{LabelSelector: selector.String()}) if err != nil { @@ -217,7 +217,7 @@ func (d *deploymentTester) waitForDeploymentStatusValidAndMarkPodsReady() error } func (d *deploymentTester) updateDeployment(applyUpdate testutil.UpdateDeploymentFunc) (*v1beta1.Deployment, error) { - return testutil.UpdateDeploymentWithRetries(d.c, d.deployment.Namespace, d.deployment.Name, applyUpdate, d.t.Logf) + return testutil.UpdateDeploymentWithRetries(d.c, d.deployment.Namespace, d.deployment.Name, applyUpdate, d.t.Logf, pollInterval, pollTimeout) } func (d *deploymentTester) waitForObservedDeployment(desiredGeneration int64) error { @@ -258,5 +258,5 @@ func (d *deploymentTester) expectNewReplicaSet() (*v1beta1.ReplicaSet, error) { } func (d *deploymentTester) updateReplicaSet(name string, applyUpdate testutil.UpdateReplicaSetFunc) (*v1beta1.ReplicaSet, error) { - return testutil.UpdateReplicaSetWithRetries(d.c, d.deployment.Namespace, name, applyUpdate, d.t.Logf) + return testutil.UpdateReplicaSetWithRetries(d.c, d.deployment.Namespace, name, applyUpdate, d.t.Logf, pollInterval, pollTimeout) } diff --git a/test/utils/deployment.go b/test/utils/deployment.go index 9d0ff50d49b..a531e769508 100644 --- a/test/utils/deployment.go +++ b/test/utils/deployment.go @@ -216,10 +216,10 @@ func containsImage(containers []v1.Container, imageName string) bool { type UpdateDeploymentFunc func(d *extensions.Deployment) -func UpdateDeploymentWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateDeploymentFunc, logf LogfFn) (*extensions.Deployment, error) { +func UpdateDeploymentWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateDeploymentFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.Deployment, error) { var deployment *extensions.Deployment var updateErr error - pollErr := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { + pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) { var err error if deployment, err = c.Extensions().Deployments(namespace).Get(name, metav1.GetOptions{}); err != nil { return false, err diff --git a/test/utils/replicaset.go b/test/utils/replicaset.go index 0721a3d3c93..9a4b6d05b90 100644 --- a/test/utils/replicaset.go +++ b/test/utils/replicaset.go @@ -28,10 +28,10 @@ import ( type UpdateReplicaSetFunc func(d *extensions.ReplicaSet) -func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn) (*extensions.ReplicaSet, error) { +func UpdateReplicaSetWithRetries(c clientset.Interface, namespace, name string, applyUpdate UpdateReplicaSetFunc, logf LogfFn, pollInterval, pollTimeout time.Duration) (*extensions.ReplicaSet, error) { var rs *extensions.ReplicaSet var updateErr error - pollErr := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { + pollErr := wait.PollImmediate(pollInterval, pollTimeout, func() (bool, error) { var err error if rs, err = c.Extensions().ReplicaSets(namespace).Get(name, metav1.GetOptions{}); err != nil { return false, err