diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index a70ff7450..5ea9c563f 100644 --- a/test/e2e/annotations/auth.go +++ b/test/e2e/annotations/auth.go @@ -28,9 +28,7 @@ import ( "github.com/parnurzeal/gorequest" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -269,22 +267,15 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() { f.NewHttpbinDeployment() var httpbinIP string - err := wait.PollImmediate(framework.Poll, 5*time.Minute, func() (bool, error) { - e, err := f.KubeClientSet.CoreV1().Endpoints(f.IngressController.Namespace).Get("httpbin", metav1.GetOptions{}) - if errors.IsNotFound(err) { - return false, nil - } - if err != nil { - return false, err - } - if len(e.Subsets) < 1 || len(e.Subsets[0].Addresses) < 1 { - return false, nil - } - httpbinIP = e.Subsets[0].Addresses[0].IP - return true, nil - }) + + err := framework.WaitForEndpoints(f.KubeClientSet, framework.DefaultTimeout, "httpbin", f.IngressController.Namespace) Expect(err).NotTo(HaveOccurred()) + e, err := f.KubeClientSet.CoreV1().Endpoints(f.IngressController.Namespace).Get("httpbin", metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred()) + + httpbinIP = e.Subsets[0].Addresses[0].IP + annotations := map[string]string{ "nginx.ingress.kubernetes.io/auth-url": fmt.Sprintf("http://%s/basic-auth/user/password", httpbinIP), "nginx.ingress.kubernetes.io/auth-signin": "http://$host/auth/start", diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index f44932207..d395cbb8b 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -123,6 +123,6 @@ func (f *Framework) NewDeployment(name, image string, port int32, replicas int32 s := f.EnsureService(service) Expect(s).NotTo(BeNil(), "expected a service but none returned") - err = WaitForEndpoints(f.KubeClientSet, defaultTimeout, name, f.IngressController.Namespace) + err = WaitForEndpoints(f.KubeClientSet, DefaultTimeout, name, f.IngressController.Namespace) Expect(err).NotTo(HaveOccurred(), "failed to wait for endpoints to become ready") } diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 7ca0eee56..ae0a6ec5b 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -112,7 +112,7 @@ func (f *Framework) BeforeEach() { err = f.NewIngressController(f.IngressController.Namespace) Expect(err).NotTo(HaveOccurred()) - err = WaitForPodsReady(f.KubeClientSet, defaultTimeout, 1, f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.IngressController.Namespace, metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) Expect(err).NotTo(HaveOccurred()) @@ -342,7 +342,7 @@ func UpdateDeployment(kubeClientSet kubernetes.Interface, namespace string, name } } - err = WaitForPodsReady(kubeClientSet, defaultTimeout, replicas, namespace, metav1.ListOptions{ + err = WaitForPodsReady(kubeClientSet, DefaultTimeout, replicas, namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(deployment.Spec.Template.ObjectMeta.Labels)).String(), }) if err != nil { diff --git a/test/e2e/framework/grpc_fortune_teller.go b/test/e2e/framework/grpc_fortune_teller.go index d2075e017..e6b28ad06 100644 --- a/test/e2e/framework/grpc_fortune_teller.go +++ b/test/e2e/framework/grpc_fortune_teller.go @@ -17,8 +17,6 @@ limitations under the License. package framework import ( - "time" - . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -79,7 +77,7 @@ func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32 Expect(err).NotTo(HaveOccurred()) Expect(d).NotTo(BeNil(), "expected a fortune-teller deployment") - err = WaitForPodsReady(f.KubeClientSet, 5*time.Minute, int(replicas), f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, int(replicas), f.IngressController.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), }) Expect(err).NotTo(HaveOccurred(), "failed to wait for to become ready") diff --git a/test/e2e/framework/influxdb.go b/test/e2e/framework/influxdb.go index 0ad895e72..d34df549b 100644 --- a/test/e2e/framework/influxdb.go +++ b/test/e2e/framework/influxdb.go @@ -17,8 +17,6 @@ limitations under the License. package framework import ( - "time" - . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" @@ -142,7 +140,7 @@ func (f *Framework) NewInfluxDBDeployment() { Expect(d).NotTo(BeNil(), "unexpected error creating deployement for influxdb") - err = WaitForPodsReady(f.KubeClientSet, 5*time.Minute, 1, f.IngressController.Namespace, metav1.ListOptions{ + err = WaitForPodsReady(f.KubeClientSet, DefaultTimeout, 1, f.IngressController.Namespace, metav1.ListOptions{ LabelSelector: fields.SelectorFromSet(fields.Set(d.Spec.Template.ObjectMeta.Labels)).String(), }) Expect(err).NotTo(HaveOccurred(), "failed to wait for influxdb to become ready") diff --git a/test/e2e/framework/ssl.go b/test/e2e/framework/ssl.go index 803f5f034..cdfad461b 100644 --- a/test/e2e/framework/ssl.go +++ b/test/e2e/framework/ssl.go @@ -143,7 +143,7 @@ func CreateIngressMASecret(client kubernetes.Interface, host string, secretName, // WaitForTLS waits until the TLS handshake with a given server completes successfully. func WaitForTLS(url string, tlsConfig *tls.Config) { - err := wait.Poll(Poll, 30*time.Second, matchTLSServerName(url, tlsConfig)) + err := wait.Poll(Poll, DefaultTimeout, matchTLSServerName(url, tlsConfig)) Expect(err).NotTo(HaveOccurred(), "timeout waiting for TLS configuration in URL %s", url) } diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index f6272fc4c..986729f55 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -39,8 +39,8 @@ const ( // Poll how often to poll for conditions Poll = 2 * time.Second - // Default time to wait for operations to complete - defaultTimeout = 30 * time.Second + // DefaultTimeout time to wait for operations to complete + DefaultTimeout = 5 * time.Minute ) func nowStamp() string { @@ -109,7 +109,7 @@ func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error } // Be robust about making the namespace creation call. var got *v1.Namespace - err := wait.PollImmediate(Poll, defaultTimeout, func() (bool, error) { + err := wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) { var err error got, err = c.CoreV1().Namespaces().Create(ns) if err != nil { @@ -140,7 +140,7 @@ func ExpectNoError(err error, explain ...interface{}) { // WaitForKubeNamespaceNotExist waits until a namespaces is not present in the cluster func WaitForKubeNamespaceNotExist(c kubernetes.Interface, namespace string) error { - return wait.PollImmediate(Poll, time.Minute*5, namespaceNotExist(c, namespace)) + return wait.PollImmediate(Poll, DefaultTimeout, namespaceNotExist(c, namespace)) } func namespaceNotExist(c kubernetes.Interface, namespace string) wait.ConditionFunc { @@ -158,7 +158,7 @@ func namespaceNotExist(c kubernetes.Interface, namespace string) wait.ConditionF // WaitForNoPodsInNamespace waits until there are no pods running in a namespace func WaitForNoPodsInNamespace(c kubernetes.Interface, namespace string) error { - return wait.PollImmediate(Poll, time.Minute*5, noPodsInNamespace(c, namespace)) + return wait.PollImmediate(Poll, DefaultTimeout, noPodsInNamespace(c, namespace)) } func noPodsInNamespace(c kubernetes.Interface, namespace string) wait.ConditionFunc { @@ -184,16 +184,16 @@ func WaitForPodRunningInNamespace(c kubernetes.Interface, pod *v1.Pod) error { if pod.Status.Phase == v1.PodRunning { return nil } - return waitTimeoutForPodRunningInNamespace(c, pod.Name, pod.Namespace, defaultTimeout) + return waitTimeoutForPodRunningInNamespace(c, pod.Name, pod.Namespace, DefaultTimeout) } func waitTimeoutForPodRunningInNamespace(c kubernetes.Interface, podName, namespace string, timeout time.Duration) error { - return wait.PollImmediate(Poll, defaultTimeout, podRunning(c, podName, namespace)) + return wait.PollImmediate(Poll, DefaultTimeout, podRunning(c, podName, namespace)) } // WaitForSecretInNamespace waits a default amount of time for the specified secret is present in a particular namespace func WaitForSecretInNamespace(c kubernetes.Interface, namespace, name string) error { - return wait.PollImmediate(1*time.Second, time.Minute*2, secretInNamespace(c, namespace, name)) + return wait.PollImmediate(Poll, DefaultTimeout, secretInNamespace(c, namespace, name)) } func secretInNamespace(c kubernetes.Interface, namespace, name string) wait.ConditionFunc { @@ -215,7 +215,7 @@ func secretInNamespace(c kubernetes.Interface, namespace, name string) wait.Cond // WaitForFileInFS waits a default amount of time for the specified file is present in the filesystem func WaitForFileInFS(file string, fs file.Filesystem) error { - return wait.PollImmediate(1*time.Second, time.Minute*2, fileInFS(file, fs)) + return wait.PollImmediate(Poll, DefaultTimeout, fileInFS(file, fs)) } func fileInFS(file string, fs file.Filesystem) wait.ConditionFunc { @@ -239,7 +239,7 @@ func fileInFS(file string, fs file.Filesystem) wait.ConditionFunc { // WaitForNoIngressInNamespace waits until there is no ingress object in a particular namespace func WaitForNoIngressInNamespace(c kubernetes.Interface, namespace, name string) error { - return wait.PollImmediate(1*time.Second, time.Minute*2, noIngressInNamespace(c, namespace, name)) + return wait.PollImmediate(Poll, DefaultTimeout, noIngressInNamespace(c, namespace, name)) } func noIngressInNamespace(c kubernetes.Interface, namespace, name string) wait.ConditionFunc { @@ -261,7 +261,7 @@ func noIngressInNamespace(c kubernetes.Interface, namespace, name string) wait.C // WaitForIngressInNamespace waits until a particular ingress object exists namespace func WaitForIngressInNamespace(c kubernetes.Interface, namespace, name string) error { - return wait.PollImmediate(1*time.Second, time.Minute*2, ingressInNamespace(c, namespace, name)) + return wait.PollImmediate(Poll, DefaultTimeout, ingressInNamespace(c, namespace, name)) } func ingressInNamespace(c kubernetes.Interface, namespace, name string) wait.ConditionFunc { diff --git a/test/e2e/status/update.go b/test/e2e/status/update.go index 728dbf2fa..062c3cb7e 100644 --- a/test/e2e/status/update.go +++ b/test/e2e/status/update.go @@ -109,7 +109,7 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() { } }() - err = wait.Poll(10*time.Second, time.Minute*3, func() (done bool, err error) { + err = wait.Poll(10*time.Second, framework.DefaultTimeout, func() (done bool, err error) { ing, err = f.KubeClientSet.Extensions().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) if err != nil { return false, err