diff --git a/tests/scalers/elasticsearch/elasticsearch_test.go b/tests/scalers/elasticsearch/elasticsearch_test.go index a72a2f84c47..bbe55eb00fa 100644 --- a/tests/scalers/elasticsearch/elasticsearch_test.go +++ b/tests/scalers/elasticsearch/elasticsearch_test.go @@ -256,7 +256,21 @@ spec: query: | { "query": { - "match_all": {} + "bool": { + "must": [ + { + "range": { + "@timestamp": { + "gte": "now-1m", + "lte": "now" + } + } + }, + { + "match_all": {} + } + ] + } } } valueLocation: "hits.total.value" @@ -401,6 +415,7 @@ func addElements(t *testing.T, count int) { _, err = ExecuteCommand(fmt.Sprintf("%s -XPOST http://localhost:9200/%s/_doc -d '%s'", kubectlElasticExecCmd, indexName, result)) assert.NoErrorf(t, err, "cannot execute command - %s", err) } + time.Sleep(10 * time.Second) } func getElasticsearchDoc() (interface{}, error) {