summaryrefslogtreecommitdiff
path: root/spec/support/helpers/usage_data_helpers.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/support/helpers/usage_data_helpers.rb
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
downloadgitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/support/helpers/usage_data_helpers.rb')
-rw-r--r--spec/support/helpers/usage_data_helpers.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/support/helpers/usage_data_helpers.rb b/spec/support/helpers/usage_data_helpers.rb
index df79049123d..d05676a649e 100644
--- a/spec/support/helpers/usage_data_helpers.rb
+++ b/spec/support/helpers/usage_data_helpers.rb
@@ -174,6 +174,22 @@ module UsageDataHelpers
allow(Gitlab::Prometheus::Internal).to receive(:prometheus_enabled?).and_return(false)
end
+ def stub_prometheus_queries
+ stub_request(:get, %r{^https?://::1:9090/-/ready})
+ .to_return(
+ status: 200,
+ body: [{}].to_json,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+
+ stub_request(:get, %r{^https?://::1:9090/api/v1/query\?query=.*})
+ .to_return(
+ status: 200,
+ body: [{}].to_json,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+ end
+
def clear_memoized_values(values)
values.each { |v| described_class.clear_memoization(v) }
end
@@ -242,4 +258,12 @@ module UsageDataHelpers
end
end
end
+
+ def load_sample_metric_definition(filename: 'sample_metric.yml')
+ load_metric_yaml(fixture_file("lib/generators/gitlab/usage_metric_definition_generator/#{filename}"))
+ end
+
+ def load_metric_yaml(data)
+ ::Gitlab::Config::Loader::Yaml.new(data).load_raw!
+ end
end