2019-04-11 12:17:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-24 10:25:44 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-06-30 09:08:07 +00:00
|
|
|
RSpec.describe ServicePing::SubmitService do
|
2019-04-21 10:03:26 +00:00
|
|
|
include StubRequests
|
2020-06-03 12:08:21 +00:00
|
|
|
include UsageDataHelpers
|
2019-04-21 10:03:26 +00:00
|
|
|
|
2021-03-25 21:09:13 +00:00
|
|
|
let(:usage_data_id) { 31643 }
|
2020-01-22 12:08:40 +00:00
|
|
|
let(:score_params) do
|
|
|
|
{
|
|
|
|
score: {
|
|
|
|
leader_issues: 10.2,
|
|
|
|
instance_issues: 3.2,
|
|
|
|
percentage_issues: 31.37,
|
|
|
|
|
|
|
|
leader_notes: 25.3,
|
|
|
|
instance_notes: 23.2,
|
|
|
|
|
|
|
|
leader_milestones: 16.2,
|
|
|
|
instance_milestones: 5.5,
|
|
|
|
|
|
|
|
leader_boards: 5.2,
|
|
|
|
instance_boards: 3.2,
|
|
|
|
|
|
|
|
leader_merge_requests: 5.2,
|
|
|
|
instance_merge_requests: 3.2,
|
|
|
|
|
|
|
|
leader_ci_pipelines: 25.1,
|
|
|
|
instance_ci_pipelines: 21.3,
|
|
|
|
|
|
|
|
leader_environments: 3.3,
|
|
|
|
instance_environments: 2.2,
|
|
|
|
|
|
|
|
leader_deployments: 41.3,
|
|
|
|
instance_deployments: 15.2,
|
|
|
|
|
|
|
|
leader_projects_prometheus_active: 0.31,
|
|
|
|
instance_projects_prometheus_active: 0.30,
|
|
|
|
|
|
|
|
leader_service_desk_issues: 15.8,
|
|
|
|
instance_service_desk_issues: 15.1,
|
|
|
|
|
2021-03-25 21:09:13 +00:00
|
|
|
usage_data_id: usage_data_id,
|
|
|
|
|
2020-01-22 12:08:40 +00:00
|
|
|
non_existing_column: 'value'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:with_dev_ops_score_params) { { dev_ops_score: score_params[:score] } }
|
|
|
|
let(:with_conv_index_params) { { conv_index: score_params[:score] } }
|
2021-10-14 12:09:39 +00:00
|
|
|
let(:with_usage_data_id_params) { { conv_index: { usage_data_id: usage_data_id } } }
|
2022-04-20 15:10:23 +00:00
|
|
|
let(:service_ping_payload_url) { File.join(described_class::STAGING_BASE_URL, described_class::USAGE_DATA_PATH) }
|
|
|
|
let(:service_ping_errors_url) { File.join(described_class::STAGING_BASE_URL, described_class::ERROR_PATH) }
|
|
|
|
let(:service_ping_metadata_url) { File.join(described_class::STAGING_BASE_URL, described_class::METADATA_PATH) }
|
2020-01-22 12:08:40 +00:00
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
shared_examples 'does not run' do
|
|
|
|
it do
|
|
|
|
expect(Gitlab::HTTP).not_to receive(:post)
|
2022-02-07 12:12:27 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).not_to receive(:for)
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
shared_examples 'does not send a blank usage ping payload' do
|
|
|
|
it do
|
2022-04-20 15:10:23 +00:00
|
|
|
expect(Gitlab::HTTP).not_to receive(:post).with(service_ping_payload_url, any_args)
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
expect { subject.execute }.to raise_error(described_class::SubmissionError) do |error|
|
|
|
|
expect(error.message).to include('Usage data is blank')
|
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-31 15:10:41 +00:00
|
|
|
shared_examples 'saves DevOps report data from the response' do
|
2020-01-22 12:08:40 +00:00
|
|
|
it do
|
|
|
|
expect { subject.execute }
|
2020-09-10 18:08:54 +00:00
|
|
|
.to change { DevOpsReport::Metric.count }
|
2020-01-22 12:08:40 +00:00
|
|
|
.by(1)
|
|
|
|
|
2020-09-10 18:08:54 +00:00
|
|
|
expect(DevOpsReport::Metric.last.leader_issues).to eq 10.2
|
|
|
|
expect(DevOpsReport::Metric.last.instance_issues).to eq 3.2
|
|
|
|
expect(DevOpsReport::Metric.last.percentage_issues).to eq 31.37
|
2020-01-22 12:08:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
context 'when usage ping is disabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(usage_ping_enabled: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not run'
|
|
|
|
end
|
|
|
|
|
2021-06-11 03:10:14 +00:00
|
|
|
context 'when usage ping is disabled from GitLab config file' do
|
|
|
|
before do
|
|
|
|
stub_config_setting(usage_ping_enabled: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not run'
|
|
|
|
end
|
|
|
|
|
2021-07-13 15:08:38 +00:00
|
|
|
context 'when product_intelligence_enabled is false' do
|
|
|
|
before do
|
2021-07-23 09:08:49 +00:00
|
|
|
allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(false)
|
2021-07-13 15:08:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not run'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when product_intelligence_enabled is true' do
|
|
|
|
before do
|
|
|
|
stub_usage_data_connections
|
2021-12-20 03:12:58 +00:00
|
|
|
stub_database_flavor_check
|
2021-07-13 15:08:38 +00:00
|
|
|
|
2021-07-23 09:08:49 +00:00
|
|
|
allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(true)
|
2021-07-13 15:08:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'generates service ping' do
|
|
|
|
stub_response(body: with_dev_ops_score_params)
|
2022-04-20 15:10:23 +00:00
|
|
|
stub_response(body: nil, url: service_ping_metadata_url, status: 201)
|
2021-07-13 15:08:38 +00:00
|
|
|
|
2022-02-08 15:12:33 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values).and_call_original
|
2021-07-13 15:08:38 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-24 10:25:44 +00:00
|
|
|
context 'when usage ping is enabled' do
|
|
|
|
before do
|
2020-06-03 12:08:21 +00:00
|
|
|
stub_usage_data_connections
|
2021-12-20 03:12:58 +00:00
|
|
|
stub_database_flavor_check
|
2017-05-24 10:25:44 +00:00
|
|
|
stub_application_setting(usage_ping_enabled: true)
|
2022-04-20 15:10:23 +00:00
|
|
|
stub_response(body: nil, url: service_ping_errors_url, status: 201)
|
|
|
|
stub_response(body: nil, url: service_ping_metadata_url, status: 201)
|
2017-05-24 10:25:44 +00:00
|
|
|
end
|
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
context 'and user requires usage stats consent' do
|
|
|
|
before do
|
2022-05-14 00:08:57 +00:00
|
|
|
allow(User).to receive(:single_user)
|
|
|
|
.and_return(instance_double(User, :user, requires_usage_stats_consent?: true))
|
2020-08-05 03:10:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not run'
|
|
|
|
end
|
|
|
|
|
2017-05-24 10:25:44 +00:00
|
|
|
it 'sends a POST request' do
|
2022-04-20 15:10:23 +00:00
|
|
|
stub_response(body: nil, url: service_ping_metadata_url, status: 201)
|
2021-03-25 21:09:13 +00:00
|
|
|
response = stub_response(body: with_dev_ops_score_params)
|
2017-05-24 10:25:44 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
expect(response).to have_been_requested
|
|
|
|
end
|
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
it 'forces a refresh of usage data statistics before submitting' do
|
2021-03-25 21:09:13 +00:00
|
|
|
stub_response(body: with_dev_ops_score_params)
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2022-02-08 15:12:33 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values).and_call_original
|
2017-05-24 10:25:44 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
|
2020-01-22 12:08:40 +00:00
|
|
|
context 'when conv_index data is passed' do
|
|
|
|
before do
|
2020-08-05 03:10:58 +00:00
|
|
|
stub_response(body: with_conv_index_params)
|
2020-01-22 12:08:40 +00:00
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2020-08-31 15:10:41 +00:00
|
|
|
it_behaves_like 'saves DevOps report data from the response'
|
2021-03-25 21:09:13 +00:00
|
|
|
|
|
|
|
it 'saves usage_data_id to version_usage_data_id_value' do
|
|
|
|
recorded_at = Time.current
|
|
|
|
usage_data = { uuid: 'uuid', recorded_at: recorded_at }
|
2021-10-14 12:09:39 +00:00
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values)
|
|
|
|
.and_return(usage_data)
|
2021-10-14 12:09:39 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
raw_usage_data = RawUsageData.find_by(recorded_at: recorded_at)
|
|
|
|
|
|
|
|
expect(raw_usage_data.version_usage_data_id_value).to eq(31643)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when only usage_data_id is passed in response' do
|
|
|
|
before do
|
|
|
|
stub_response(body: with_usage_data_id_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not save DevOps report data' do
|
|
|
|
expect { subject.execute }.not_to change { DevOpsReport::Metric.count }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves usage_data_id to version_usage_data_id_value' do
|
|
|
|
recorded_at = Time.current
|
|
|
|
usage_data = { uuid: 'uuid', recorded_at: recorded_at }
|
2021-03-25 21:09:13 +00:00
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values)
|
|
|
|
.and_return(usage_data)
|
2021-03-25 21:09:13 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
raw_usage_data = RawUsageData.find_by(recorded_at: recorded_at)
|
|
|
|
|
|
|
|
expect(raw_usage_data.version_usage_data_id_value).to eq(31643)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when version app usage_data_id is invalid' do
|
|
|
|
let(:usage_data_id) { -1000 }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_response(body: with_conv_index_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'raises an exception' do
|
|
|
|
expect { subject.execute }.to raise_error(described_class::SubmissionError) do |error|
|
|
|
|
expect(error.message).to include('Invalid usage_data_id in response: -1000')
|
|
|
|
end
|
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
end
|
|
|
|
|
2020-08-31 15:10:41 +00:00
|
|
|
context 'when DevOps report data is passed' do
|
2020-01-22 12:08:40 +00:00
|
|
|
before do
|
2020-08-05 03:10:58 +00:00
|
|
|
stub_response(body: with_dev_ops_score_params)
|
2020-01-22 12:08:40 +00:00
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
|
2020-08-31 15:10:41 +00:00
|
|
|
it_behaves_like 'saves DevOps report data from the response'
|
2020-01-22 12:08:40 +00:00
|
|
|
end
|
2020-08-05 03:10:58 +00:00
|
|
|
|
2020-12-15 09:10:00 +00:00
|
|
|
context 'with saving raw_usage_data' do
|
2020-08-17 21:09:56 +00:00
|
|
|
before do
|
|
|
|
stub_response(body: with_dev_ops_score_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a raw_usage_data record' do
|
|
|
|
expect { subject.execute }.to change(RawUsageData, :count).by(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves the correct payload' do
|
|
|
|
recorded_at = Time.current
|
|
|
|
usage_data = { uuid: 'uuid', recorded_at: recorded_at }
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values)
|
|
|
|
.and_return(usage_data)
|
2020-08-17 21:09:56 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
raw_usage_data = RawUsageData.find_by(recorded_at: recorded_at)
|
|
|
|
|
|
|
|
expect(raw_usage_data.recorded_at).to be_like_time(recorded_at)
|
|
|
|
expect(raw_usage_data.payload.to_json).to eq(usage_data.to_json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-05 03:10:58 +00:00
|
|
|
context 'and usage ping response has unsuccessful status' do
|
|
|
|
before do
|
|
|
|
stub_response(body: nil, status: 504)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'raises an exception' do
|
|
|
|
expect { subject.execute }.to raise_error(described_class::SubmissionError) do |error|
|
|
|
|
expect(error.message).to include('Unsuccessful response code: 504')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and usage data is empty string' do
|
|
|
|
before do
|
2022-02-08 15:12:33 +00:00
|
|
|
allow(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values).and_return({})
|
2020-08-05 03:10:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not send a blank usage ping payload'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and usage data is nil' do
|
|
|
|
before do
|
2022-05-14 00:08:57 +00:00
|
|
|
allow(ServicePing::BuildPayload).to receive(:execute).and_return(nil)
|
2022-02-08 15:12:33 +00:00
|
|
|
allow(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values).and_return(nil)
|
2020-08-05 03:10:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'does not send a blank usage ping payload'
|
|
|
|
end
|
2021-07-14 15:09:57 +00:00
|
|
|
|
|
|
|
context 'if payload service fails' do
|
|
|
|
before do
|
|
|
|
stub_response(body: with_dev_ops_score_params)
|
2022-04-20 15:10:23 +00:00
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
allow(ServicePing::BuildPayload).to receive_message_chain(:new, :execute)
|
2022-01-25 18:11:55 +00:00
|
|
|
.and_raise(described_class::SubmissionError, 'SubmissionError')
|
2021-07-14 15:09:57 +00:00
|
|
|
end
|
|
|
|
|
2022-02-07 12:12:27 +00:00
|
|
|
it 'calls Gitlab::Usage::ServicePingReport .for method' do
|
2021-07-14 15:09:57 +00:00
|
|
|
usage_data = build_usage_data
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values)
|
|
|
|
.and_return(usage_data)
|
2021-07-14 15:09:57 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
2022-01-25 18:11:55 +00:00
|
|
|
|
|
|
|
it 'submits error' do
|
2022-04-20 15:10:23 +00:00
|
|
|
expect(Gitlab::HTTP).to receive(:post).with(URI.join(service_ping_payload_url), any_args)
|
|
|
|
.and_call_original
|
|
|
|
expect(Gitlab::HTTP).to receive(:post).with(URI.join(service_ping_errors_url), any_args)
|
2022-01-25 18:11:55 +00:00
|
|
|
.and_call_original
|
2022-04-20 15:10:23 +00:00
|
|
|
expect(Gitlab::HTTP).to receive(:post).with(URI.join(service_ping_metadata_url), any_args)
|
2022-01-25 18:11:55 +00:00
|
|
|
.and_call_original
|
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
2021-07-14 15:09:57 +00:00
|
|
|
end
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
context 'calls BuildPayload first' do
|
2021-07-14 15:09:57 +00:00
|
|
|
before do
|
|
|
|
stub_response(body: with_dev_ops_score_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns usage data' do
|
|
|
|
usage_data = build_usage_data
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect_next_instance_of(ServicePing::BuildPayload) do |service|
|
2021-07-14 15:09:57 +00:00
|
|
|
expect(service).to receive(:execute).and_return(usage_data)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'if version app response fails' do
|
|
|
|
before do
|
|
|
|
stub_response(body: with_dev_ops_score_params, status: 404)
|
|
|
|
|
|
|
|
usage_data = build_usage_data
|
2022-05-14 00:08:57 +00:00
|
|
|
allow_next_instance_of(ServicePing::BuildPayload) do |service|
|
2021-07-14 15:09:57 +00:00
|
|
|
allow(service).to receive(:execute).and_return(usage_data)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-07 12:12:27 +00:00
|
|
|
it 'calls Gitlab::Usage::ServicePingReport .for method' do
|
2021-07-14 15:09:57 +00:00
|
|
|
usage_data = build_usage_data
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(Gitlab::Usage::ServicePingReport).to receive(:for).with(output: :all_metrics_values)
|
|
|
|
.and_return(usage_data)
|
2021-07-14 15:09:57 +00:00
|
|
|
|
|
|
|
# SubmissionError is raised as a result of 404 in response from HTTP Request
|
|
|
|
expect { subject.execute }.to raise_error(described_class::SubmissionError)
|
|
|
|
end
|
|
|
|
end
|
2021-11-22 18:10:55 +00:00
|
|
|
|
|
|
|
context 'when skip_db_write passed to service' do
|
|
|
|
let(:subject) { ServicePing::SubmitService.new(skip_db_write: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_response(body: with_dev_ops_score_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not save RawUsageData' do
|
|
|
|
expect { subject.execute }
|
|
|
|
.not_to change { RawUsageData.count }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not call DevOpsReport service' do
|
2022-05-14 00:08:57 +00:00
|
|
|
expect(ServicePing::DevopsReport).not_to receive(:new)
|
2021-11-22 18:10:55 +00:00
|
|
|
|
|
|
|
subject.execute
|
|
|
|
end
|
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
end
|
|
|
|
|
2022-04-20 15:10:23 +00:00
|
|
|
context 'metadata reporting' do
|
|
|
|
before do
|
|
|
|
stub_usage_data_connections
|
|
|
|
stub_database_flavor_check
|
|
|
|
stub_application_setting(usage_ping_enabled: true)
|
|
|
|
stub_response(body: with_conv_index_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with feature flag measure_service_ping_metric_collection turned on' do
|
|
|
|
let(:metric_double) { instance_double(Gitlab::Usage::ServicePing::LegacyMetricTimingDecorator, duration: 123) }
|
|
|
|
let(:payload) do
|
|
|
|
{
|
|
|
|
metric_a: metric_double,
|
|
|
|
metric_group: {
|
|
|
|
metric_b: metric_double
|
|
|
|
},
|
|
|
|
metric_without_timing: "value",
|
|
|
|
recorded_at: Time.current
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:metadata_payload) do
|
|
|
|
{
|
|
|
|
metadata: {
|
|
|
|
metrics: [
|
|
|
|
{ name: 'metric_a', time_elapsed: 123 },
|
|
|
|
{ name: 'metric_group.metric_b', time_elapsed: 123 }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2021-09-14 12:10:35 +00:00
|
|
|
|
|
|
|
before do
|
2022-04-20 15:10:23 +00:00
|
|
|
stub_feature_flags(measure_service_ping_metric_collection: true)
|
|
|
|
|
2022-05-14 00:08:57 +00:00
|
|
|
allow_next_instance_of(ServicePing::BuildPayload) do |service|
|
2022-04-20 15:10:23 +00:00
|
|
|
allow(service).to receive(:execute).and_return(payload)
|
|
|
|
end
|
2021-09-14 12:10:35 +00:00
|
|
|
end
|
|
|
|
|
2022-04-20 15:10:23 +00:00
|
|
|
it 'submits metadata' do
|
|
|
|
response = stub_full_request(service_ping_metadata_url, method: :post)
|
|
|
|
.with(body: metadata_payload)
|
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
expect(response).to have_been_requested
|
2021-09-14 12:10:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-20 15:10:23 +00:00
|
|
|
context 'with feature flag measure_service_ping_metric_collection turned off' do
|
2021-09-14 12:10:35 +00:00
|
|
|
before do
|
2022-04-20 15:10:23 +00:00
|
|
|
stub_feature_flags(measure_service_ping_metric_collection: false)
|
2021-09-14 12:10:35 +00:00
|
|
|
end
|
|
|
|
|
2022-04-20 15:10:23 +00:00
|
|
|
it 'does NOT submit metadata' do
|
|
|
|
response = stub_full_request(service_ping_metadata_url, method: :post)
|
|
|
|
|
|
|
|
subject.execute
|
|
|
|
|
|
|
|
expect(response).not_to have_been_requested
|
2021-09-14 12:10:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-20 15:10:23 +00:00
|
|
|
def stub_response(url: service_ping_payload_url, body:, status: 201)
|
2021-09-14 12:10:35 +00:00
|
|
|
stub_full_request(url, method: :post)
|
2017-06-21 13:48:12 +00:00
|
|
|
.to_return(
|
2017-05-24 10:25:44 +00:00
|
|
|
headers: { 'Content-Type' => 'application/json' },
|
2020-08-05 03:10:58 +00:00
|
|
|
body: body.to_json,
|
|
|
|
status: status
|
2017-05-24 10:25:44 +00:00
|
|
|
)
|
|
|
|
end
|
2021-07-14 15:09:57 +00:00
|
|
|
|
|
|
|
def build_usage_data
|
|
|
|
{ uuid: 'uuid', recorded_at: Time.current }
|
|
|
|
end
|
2017-05-24 10:25:44 +00:00
|
|
|
end
|