diff --git a/e2e/_suites/metricbeat/metricbeat_test.go b/e2e/_suites/metricbeat/metricbeat_test.go index 8454831b51..172efbdff1 100644 --- a/e2e/_suites/metricbeat/metricbeat_test.go +++ b/e2e/_suites/metricbeat/metricbeat_test.go @@ -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() diff --git a/e2e/elasticsearch.go b/e2e/elasticsearch.go index d3791251db..4acd31dfa6 100644 --- a/e2e/elasticsearch.go +++ b/e2e/elasticsearch.go @@ -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) } } diff --git a/e2e/utils.go b/e2e/utils.go index 80bb2cb691..fcfacbc9ca 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -13,7 +13,6 @@ import ( "net/http" "os" "path" - "strconv" "strings" "time" @@ -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 }