diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb index 9c63c1d8c..128eb05b2 100644 --- a/spec/support/elasticsearch_helpers.rb +++ b/spec/support/elasticsearch_helpers.rb @@ -10,6 +10,7 @@ module ElasticsearchHelpers end def clear_elasticsearch_data(search_class) + search_class.refresh_index Search::Client.delete_by_query( index: search_class::INDEX_ALIAS, body: { query: { match_all: {} } }, ) diff --git a/spec/workers/metrics/record_data_counts_worker_spec.rb b/spec/workers/metrics/record_data_counts_worker_spec.rb index a5c25fcb7..c124dffb1 100644 --- a/spec/workers/metrics/record_data_counts_worker_spec.rb +++ b/spec/workers/metrics/record_data_counts_worker_spec.rb @@ -45,7 +45,7 @@ RSpec.describe Metrics::RecordDataCountsWorker, type: :worker do expect( DatadogStatsClient, - ).to have_received(:gauge).with("elasticsearch.document_count", 0, tags: Array).at_least(1) + ).to have_received(:gauge).with("elasticsearch.document_count", Integer, tags: Array).at_least(1) end end end