Improve e2e speed execution time

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-09-30 11:24:51 -03:00
parent 9dbfc11f01
commit c4f78ef11d
4 changed files with 16 additions and 24 deletions

View file

@ -280,10 +280,11 @@ func (f *Framework) NewGRPCBinDeployment() {
func newDeployment(name, namespace, image string, port int32, replicas int32, command []string, func newDeployment(name, namespace, image string, port int32, replicas int32, command []string,
volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment { volumeMounts []corev1.VolumeMount, volumes []corev1.Volume) *appsv1.Deployment {
probe := &corev1.Probe{ probe := &corev1.Probe{
InitialDelaySeconds: 1, InitialDelaySeconds: 2,
PeriodSeconds: 1, PeriodSeconds: 1,
SuccessThreshold: 1, SuccessThreshold: 1,
TimeoutSeconds: 1, TimeoutSeconds: 2,
FailureThreshold: 6,
Handler: corev1.Handler{ Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{ HTTPGet: &corev1.HTTPGetAction{
Port: intstr.FromString("http"), Port: intstr.FromString("http"),

View file

@ -25,9 +25,6 @@ import (
"github.com/gavv/httpexpect/v2" "github.com/gavv/httpexpect/v2"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
"github.com/pkg/errors" "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" "github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/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()) { func (f *Framework) waitForReload(fn func()) {
reloadCount := getReloadCount(f.pod, f.Namespace, f.KubeClientSet) initialReloadCount := getReloadCount(f.pod, f.Namespace, f.KubeClientSet)
fn() fn()
count := 0 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 // most of the cases reload the ingress controller
// in cases where the value is not modified we could wait forever // in cases where the value is not modified we could wait forever
if count > 3 { if count > 5 && reloads == initialReloadCount {
return true, nil return true, nil
} }
count++ 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") 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 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. // 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. // Grace period to wait for pod shutdown is in seconds.
func (f *Framework) DeleteNGINXPod(grace int64) { func (f *Framework) DeleteNGINXPod(grace int64) {

View file

@ -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. // 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 { 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) pl, err := kubeClientSet.CoreV1().Pods(namespace).List(context.TODO(), opts)
if err != nil { if err != nil {
return false, nil return false, nil
@ -172,7 +172,7 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration,
return nil 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{}) endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(context.TODO(), name, metav1.GetOptions{})
if k8sErrors.IsNotFound(err) { if k8sErrors.IsNotFound(err) {
return false, nil return false, nil
@ -220,7 +220,7 @@ func podRunningReady(p *core.Pod) (bool, error) {
// getIngressNGINXPod returns the ingress controller running pod // getIngressNGINXPod returns the ingress controller running pod
func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Pod, error) { func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Pod, error) {
var pod *core.Pod 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{ l, err := kubeClientSet.CoreV1().Pods(ns).List(context.TODO(), metav1.ListOptions{
LabelSelector: "app.kubernetes.io/name=ingress-nginx", LabelSelector: "app.kubernetes.io/name=ingress-nginx",
}) })

View file

@ -9,3 +9,8 @@ kubeadmConfigPatches:
kind: ClusterConfiguration kind: ClusterConfiguration
metadata: metadata:
name: config name: config
controllerManager:
extraArgs:
namespace-sync-period: 10s
concurrent-deployment-syncs: "30"
deployment-controller-sync-period: 10s