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

Commit

Permalink
chore: initialise timeout factor on its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed May 4, 2021
1 parent f258414 commit eb30ca2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion e2e/_suites/fleet/ingest_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions e2e/_suites/kubernetes-autodiscover/autodiscover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ const defaultBeatVersion = "8.0.0-SNAPSHOT"
var defaultEventsWaitTimeout = 60 * time.Second
var defaultDeployWaitTimeout = 60 * time.Second

func init() {
// initialise timeout factor
common.TimeoutFactor = shell.GetEnvInteger("TIMEOUT_FACTOR", common.TimeoutFactor)

defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(common.TimeoutFactor)
defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(common.TimeoutFactor)
}

type podsManager struct {
kubectl kubernetes.Control
ctx context.Context
Expand Down Expand Up @@ -472,6 +464,9 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
// init logger
config.Init()

defaultEventsWaitTimeout = defaultEventsWaitTimeout * time.Duration(common.TimeoutFactor)
defaultDeployWaitTimeout = defaultDeployWaitTimeout * time.Duration(common.TimeoutFactor)

err := cluster.Initialize(suiteContext, "testdata/kind.yml")
if err != nil {
log.WithError(err).Fatal("Failed to initialize cluster")
Expand Down
5 changes: 5 additions & 0 deletions internal/common/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit eb30ca2

Please sign in to comment.