Skip to content

Commit

Permalink
feat: backoff-wait 1 min for the datastreams to be present
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jul 1, 2020
1 parent a789661 commit c8c484c
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions e2e/_suites/ingest-manager/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,55 @@ func (fts *FleetTestSuite) theAgentIsListedInFleetAsOnline() error {
func (fts *FleetTestSuite) systemPackageDashboardsAreListedInFleet() error {
log.Debug("Checking system Package dashboards in Fleet")

dataStreams, err := getDataStreams()
dataStreamsCount := 0
maxTimeout := 1 * time.Minute
retryCount := 1

exp := e2e.GetExponentialBackOff(maxTimeout)

countDataStreamsFn := func() error {
dataStreams, err := getDataStreams()
if err != nil {
log.WithFields(log.Fields{
"retry": retryCount,
"elapsedTime": exp.GetElapsedTime(),
}).Warn(err.Error())

retryCount++

return err
}

count := len(dataStreams.Children())
if count == 0 {
err = fmt.Errorf("There are no datastreams yet")

log.WithFields(log.Fields{
"retry": retryCount,
"dataStreams": count,
"elapsedTime": exp.GetElapsedTime(),
}).Warn(err.Error())

retryCount++

return err
}

log.WithFields(log.Fields{
"elapsedTime": exp.GetElapsedTime(),
"datastreams": count,
"retries": retryCount,
}).Info("Datastreams are present")
dataStreamsCount = count
return nil
}

err := backoff.Retry(countDataStreamsFn, exp)
if err != nil {
return err
}

if len(dataStreams.Children()) == 0 {
if dataStreamsCount == 0 {
err = fmt.Errorf("There are no datastreams. We expected to have more than one")
log.Error(err.Error())
return err
Expand Down

0 comments on commit c8c484c

Please sign in to comment.