From c4f78ef11dfc849bced052e57cfb1f97aa0cf08a Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Wed, 30 Sep 2020 11:24:51 -0300 Subject: [PATCH] Improve e2e speed execution time --- test/e2e/framework/deployment.go | 5 +++-- test/e2e/framework/framework.go | 24 +++++------------------- test/e2e/framework/k8s.go | 6 +++--- test/e2e/kind.yaml | 5 +++++ 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/test/e2e/framework/deployment.go b/test/e2e/framework/deployment.go index 5836f49fd..69bf60728 100644 --- a/test/e2e/framework/deployment.go +++ b/test/e2e/framework/deployment.go @@ -280,10 +280,11 @@ func (f *Framework) NewGRPCBinDeployment() { func newDeployment(name, namespace, image string, port int32, replicas int32, command []string, volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment { probe := &corev1.Probe{ - InitialDelaySeconds: 1, + InitialDelaySeconds: 2, PeriodSeconds: 1, SuccessThreshold: 1, - TimeoutSeconds: 1, + TimeoutSeconds: 2, + FailureThreshold: 6, Handler: corev1.Handler{ HTTPGet: &corev1.HTTPGetAction{ Port: intstr.FromString("http"), diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 3c1c35849..a2d8107f5 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -25,9 +25,6 @@ import ( "github.com/gavv/httpexpect/v2" "github.com/onsi/ginkgo" "github.com/pkg/errors" - dto "github.com/prometheus/client_model/go" - "github.com/prometheus/common/expfmt" - "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -364,21 +361,22 @@ func (f *Framework) UpdateNginxConfigMapData(key string, value string) { } func (f *Framework) waitForReload(fn func()) { - reloadCount := getReloadCount(f.pod, f.Namespace, f.KubeClientSet) + initialReloadCount := getReloadCount(f.pod, f.Namespace, f.KubeClientSet) fn() count := 0 - err := wait.Poll(2*time.Second, DefaultTimeout, func() (bool, error) { + err := wait.Poll(1*time.Second, DefaultTimeout, func() (bool, error) { + reloads := getReloadCount(f.pod, f.Namespace, f.KubeClientSet) // most of the cases reload the ingress controller // in cases where the value is not modified we could wait forever - if count > 3 { + if count > 5 && reloads == initialReloadCount { return true, nil } count++ - return (getReloadCount(f.pod, f.Namespace, f.KubeClientSet) > reloadCount), nil + return (reloads > initialReloadCount), nil }) assert.Nil(ginkgo.GinkgoT(), err, "while waiting for ingress controller reload") } @@ -397,18 +395,6 @@ func getReloadCount(pod *corev1.Pod, namespace string, client kubernetes.Interfa return reloadCount } -func extractReloadCount(mf *dto.MetricFamily) (float64, error) { - vec, err := expfmt.ExtractSamples(&expfmt.DecodeOptions{ - Timestamp: model.Now(), - }, mf) - - if err != nil { - return 0, err - } - - return float64(vec[0].Value), nil -} - // DeleteNGINXPod deletes the currently running pod. It waits for the replacement pod to be up. // Grace period to wait for pod shutdown is in seconds. func (f *Framework) DeleteNGINXPod(grace int64) { diff --git a/test/e2e/framework/k8s.go b/test/e2e/framework/k8s.go index f46fa96b8..ad7f4a3bd 100644 --- a/test/e2e/framework/k8s.go +++ b/test/e2e/framework/k8s.go @@ -129,7 +129,7 @@ func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Depl // waitForPodsReady waits for a given amount of time until a group of Pods is running in the given namespace. func waitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration, expectedReplicas int, namespace string, opts metav1.ListOptions) error { - return wait.Poll(Poll, timeout, func() (bool, error) { + return wait.PollImmediate(1*time.Second, timeout, func() (bool, error) { pl, err := kubeClientSet.CoreV1().Pods(namespace).List(context.TODO(), opts) if err != nil { return false, nil @@ -172,7 +172,7 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, return nil } - return wait.Poll(Poll, timeout, func() (bool, error) { + return wait.PollImmediate(Poll, timeout, func() (bool, error) { endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(context.TODO(), name, metav1.GetOptions{}) if k8sErrors.IsNotFound(err) { return false, nil @@ -220,7 +220,7 @@ func podRunningReady(p *core.Pod) (bool, error) { // getIngressNGINXPod returns the ingress controller running pod func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Pod, error) { var pod *core.Pod - err := wait.PollImmediate(Poll, DefaultTimeout, func() (bool, error) { + err := wait.Poll(1*time.Second, DefaultTimeout, func() (bool, error) { l, err := kubeClientSet.CoreV1().Pods(ns).List(context.TODO(), metav1.ListOptions{ LabelSelector: "app.kubernetes.io/name=ingress-nginx", }) diff --git a/test/e2e/kind.yaml b/test/e2e/kind.yaml index ffb5dd22b..6fddba4e2 100644 --- a/test/e2e/kind.yaml +++ b/test/e2e/kind.yaml @@ -9,3 +9,8 @@ kubeadmConfigPatches: kind: ClusterConfiguration metadata: name: config + controllerManager: + extraArgs: + namespace-sync-period: 10s + concurrent-deployment-syncs: "30" + deployment-controller-sync-period: 10s