From f7800a7247235525f000df54b2b1248230c7b621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Tue, 4 May 2021 15:47:58 +0200 Subject: [PATCH] chore: initialise timeout factor next to the declaration (#1118) * chore: initialise timeout factor on its own package * chore: reuse timeout factor from common (cherry picked from commit 15a2a3d73e5f5e98ab8d09e74f9c8466d7b0f24f) # Conflicts: # e2e/_suites/kubernetes-autodiscover/autodiscover_test.go --- e2e/_suites/fleet/ingest_manager_test.go | 1 - e2e/_suites/helm/helm_charts_test.go | 7 +------ .../autodiscover_test.go | 19 +++++++++++++++++++ internal/common/retry.go | 5 +++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/e2e/_suites/fleet/ingest_manager_test.go b/e2e/_suites/fleet/ingest_manager_test.go index 44c748d234..967f2d2116 100644 --- a/e2e/_suites/fleet/ingest_manager_test.go +++ b/e2e/_suites/fleet/ingest_manager_test.go @@ -48,7 +48,6 @@ func setUpSuite() { } common.AgentVersionBase = v - common.TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", common.TimeoutFactor) common.AgentVersion = shell.GetEnv("BEAT_VERSION", common.AgentVersionBase) // check if version is an alias diff --git a/e2e/_suites/helm/helm_charts_test.go b/e2e/_suites/helm/helm_charts_test.go index 180d583fad..2b983cdb52 100644 --- a/e2e/_suites/helm/helm_charts_test.go +++ b/e2e/_suites/helm/helm_charts_test.go @@ -37,10 +37,6 @@ var elasticAPMActive = false var helmManager helm.Manager -// timeoutFactor a multiplier for the max timeout when doing backoff retries. -// It can be overriden by TIMEOUT_FACTOR env var -var timeoutFactor = 2 - //nolint:unused var kubectlClient kubectl.Kubectl @@ -80,7 +76,6 @@ func setupSuite() { helmVersion = shell.GetEnv("HELM_VERSION", helmVersion) helmChartVersion = shell.GetEnv("HELM_CHART_VERSION", helmChartVersion) kubernetesVersion = shell.GetEnv("KUBERNETES_VERSION", kubernetesVersion) - timeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", timeoutFactor) stackVersion = shell.GetEnv("STACK_VERSION", stackVersion) v, err := utils.GetElasticArtifactVersion(stackVersion) @@ -187,7 +182,7 @@ func (ts *HelmChartTestSuite) aResourceWillExposePods(resourceType string) error return err } - maxTimeout := time.Duration(timeoutFactor) * time.Minute + maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute exp := common.GetExponentialBackOff(maxTimeout) retryCount := 1 diff --git a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go index 6984d07cf1..e5e74fc53e 100644 --- a/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go +++ b/e2e/_suites/kubernetes-autodiscover/autodiscover_test.go @@ -22,9 +22,18 @@ import ( "github.com/elastic/e2e-testing/internal/utils" ) +<<<<<<< HEAD const defaultBeatVersion = "7.13.0-SNAPSHOT" const defaultEventsWaitTimeout = 120 * time.Second const defaultDeployWaitTimeout = 120 * time.Second +======= +var beatVersions = map[string]string{} + +const defaultBeatVersion = "8.0.0-SNAPSHOT" + +var defaultEventsWaitTimeout = 60 * time.Second +var defaultDeployWaitTimeout = 60 * time.Second +>>>>>>> 15a2a3d7... chore: initialise timeout factor next to the declaration (#1118) type podsManager struct { kubectl kubernetesControl @@ -387,7 +396,17 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) { log.DeferExitHandler(cancel) ctx.BeforeSuite(func() { +<<<<<<< HEAD err := cluster.initialize(suiteContext) +======= + // init logger + config.Init() + + defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(common.TimeoutFactor) + defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(common.TimeoutFactor) + + err := cluster.Initialize(suiteContext, "testdata/kind.yml") +>>>>>>> 15a2a3d7... chore: initialise timeout factor next to the declaration (#1118) if err != nil { log.WithError(err).Fatal("Failed to initialize cluster") } diff --git a/internal/common/retry.go b/internal/common/retry.go index fa38cb95a1..2c221bd61f 100644 --- a/internal/common/retry.go +++ b/internal/common/retry.go @@ -8,12 +8,17 @@ import ( "time" backoff "github.com/cenkalti/backoff/v4" + "github.com/elastic/e2e-testing/internal/shell" ) // TimeoutFactor a multiplier for the max timeout when doing backoff retries. // It can be overriden by TIMEOUT_FACTOR env var var TimeoutFactor = 3 +func init() { + TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", TimeoutFactor) +} + // GetExponentialBackOff returns a preconfigured exponential backoff instance func GetExponentialBackOff(elapsedTime time.Duration) *backoff.ExponentialBackOff { var (