Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 15a2a3d

Browse files
authored
chore: initialise timeout factor next to the declaration (#1118)
* chore: initialise timeout factor on its own package * chore: reuse timeout factor from common
1 parent 6118601 commit 15a2a3d

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

e2e/_suites/fleet/ingest_manager_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func setUpSuite() {
4848
}
4949
common.AgentVersionBase = v
5050

51-
common.TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", common.TimeoutFactor)
5251
common.AgentVersion = shell.GetEnv("BEAT_VERSION", common.AgentVersionBase)
5352

5453
// check if version is an alias

e2e/_suites/helm/helm_charts_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ var elasticAPMActive = false
3737

3838
var helmManager helm.Manager
3939

40-
// timeoutFactor a multiplier for the max timeout when doing backoff retries.
41-
// It can be overriden by TIMEOUT_FACTOR env var
42-
var timeoutFactor = 2
43-
4440
//nolint:unused
4541
var kubectlClient kubectl.Kubectl
4642

@@ -80,7 +76,6 @@ func setupSuite() {
8076
helmVersion = shell.GetEnv("HELM_VERSION", helmVersion)
8177
helmChartVersion = shell.GetEnv("HELM_CHART_VERSION", helmChartVersion)
8278
kubernetesVersion = shell.GetEnv("KUBERNETES_VERSION", kubernetesVersion)
83-
timeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", timeoutFactor)
8479

8580
stackVersion = shell.GetEnv("STACK_VERSION", stackVersion)
8681
v, err := utils.GetElasticArtifactVersion(stackVersion)
@@ -187,7 +182,7 @@ func (ts *HelmChartTestSuite) aResourceWillExposePods(resourceType string) error
187182
return err
188183
}
189184

190-
maxTimeout := time.Duration(timeoutFactor) * time.Minute
185+
maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute
191186

192187
exp := common.GetExponentialBackOff(maxTimeout)
193188
retryCount := 1

e2e/_suites/kubernetes-autodiscover/autodiscover_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ const defaultBeatVersion = "8.0.0-SNAPSHOT"
3737
var defaultEventsWaitTimeout = 60 * time.Second
3838
var defaultDeployWaitTimeout = 60 * time.Second
3939

40-
func init() {
41-
// initialise timeout factor
42-
common.TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", common.TimeoutFactor)
43-
44-
defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(common.TimeoutFactor)
45-
defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(common.TimeoutFactor)
46-
}
47-
4840
type podsManager struct {
4941
kubectl kubernetes.Control
5042
ctx context.Context
@@ -472,6 +464,9 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
472464
// init logger
473465
config.Init()
474466

467+
defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(common.TimeoutFactor)
468+
defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(common.TimeoutFactor)
469+
475470
err := cluster.Initialize(suiteContext, "testdata/kind.yml")
476471
if err != nil {
477472
log.WithError(err).Fatal("Failed to initialize cluster")

internal/common/retry.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ import (
88
"time"
99

1010
backoff "github.com/cenkalti/backoff/v4"
11+
"github.com/elastic/e2e-testing/internal/shell"
1112
)
1213

1314
// TimeoutFactor a multiplier for the max timeout when doing backoff retries.
1415
// It can be overriden by TIMEOUT_FACTOR env var
1516
var TimeoutFactor = 3
1617

18+
func init() {
19+
TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", TimeoutFactor)
20+
}
21+
1722
// GetExponentialBackOff returns a preconfigured exponential backoff instance
1823
func GetExponentialBackOff(elapsedTime time.Duration) *backoff.ExponentialBackOff {
1924
var (

0 commit comments

Comments
 (0)