Skip to content

Commit

Permalink
chore: increase timeout for Ceph (elastic#618)
Browse files Browse the repository at this point in the history
* chore: simplify sleep parameter, using a Duration

* chore: wait longer for Ceph service
  • Loading branch information
mdelapenya committed Jan 19, 2021
1 parent c97785f commit 18fafdb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
10 changes: 8 additions & 2 deletions e2e/_suites/metricbeat/metricbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,14 @@ func (mts *MetricbeatTestSuite) installedUsingConfiguration(configuration string
// runMetricbeatService runs a metricbeat service entity for a service to monitor it
func (mts *MetricbeatTestSuite) runMetricbeatService() error {
// this is needed because, in general, the target service (apache, mysql, redis) does not have a healthcheck
waitForService := time.Duration(timeoutFactor) * 10
e2e.Sleep(fmt.Sprintf("%d", waitForService))
waitForService := time.Duration(timeoutFactor) * 10 * time.Second
if mts.ServiceName == "ceph" {
// see https://github.com/elastic/beats/blob/ef6274d0d1e36308a333cbed69846a1bd63528ae/metricbeat/module/ceph/mgr_osd_tree/mgr_osd_tree_integration_test.go#L35
// Ceph service needs more time to start up
waitForService = waitForService * 4
}

e2e.Sleep(waitForService)

serviceManager := services.NewServiceManager()

Expand Down
2 changes: 1 addition & 1 deletion e2e/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func RetrySearch(indexName string, esQuery map[string]interface{}, maxAttempts i
"retryAttempts": maxAttempts,
"retryTimeout": retryTimeout,
}).Tracef("Waiting %d seconds for the index to be ready", retryTimeout)
time.Sleep(time.Duration(retryTimeout) * time.Second)
Sleep(time.Duration(retryTimeout) * time.Second)
}
}

Expand Down
17 changes: 5 additions & 12 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/http"
"os"
"path"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -444,20 +443,14 @@ func RandomString(length int) string {
return randomStringWithCharset(length, charset)
}

// Sleep sleeps a number of seconds, including logs
func Sleep(seconds string) error {
// Sleep sleeps a duration, including logs
func Sleep(duration time.Duration) error {
fields := log.Fields{
"seconds": seconds,
"duration": duration,
}

s, err := strconv.Atoi(seconds)
if err != nil {
log.WithFields(fields).Errorf("Cannot convert %s to seconds", seconds)
return err
}

log.WithFields(fields).Tracef("Waiting %s seconds", seconds)
time.Sleep(time.Duration(s) * time.Second)
log.WithFields(fields).Tracef("Waiting %v", duration)
time.Sleep(duration)

return nil
}
Expand Down

0 comments on commit 18fafdb

Please sign in to comment.