Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-08 18:12:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-08 18:12:29 +0300
commitf8c7f38d02ebf964cbf40d9445f0f9f843710701 (patch)
tree755d5c384a0f64ffc8aad26f4628844697499522 /spec/tasks
parent8fea353b907d1fd571f5450a757cafee73cfbfd0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/usage_data_rake_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/usage_data_rake_spec.rb b/spec/tasks/gitlab/usage_data_rake_spec.rb
index 207a9884090..f54d06f406f 100644
--- a/spec/tasks/gitlab/usage_data_rake_spec.rb
+++ b/spec/tasks/gitlab/usage_data_rake_spec.rb
@@ -3,6 +3,7 @@
require 'rake_helper'
RSpec.describe 'gitlab:usage data take tasks', :silence_stdout do
+ include StubRequests
include UsageDataHelpers
let(:metrics_file) { Rails.root.join('tmp', 'test', 'sql_metrics_queries.json') }
@@ -44,4 +45,39 @@ RSpec.describe 'gitlab:usage data take tasks', :silence_stdout do
expect(Pathname.new(metrics_file)).to exist
end
end
+
+ describe 'generate_and_send' do
+ let(:service_ping_payload_url) do
+ File.join(ServicePing::SubmitService::STAGING_BASE_URL, ServicePing::SubmitService::USAGE_DATA_PATH)
+ end
+
+ let(:service_ping_metadata_url) do
+ File.join(ServicePing::SubmitService::STAGING_BASE_URL, ServicePing::SubmitService::METADATA_PATH)
+ end
+
+ let(:payload) { { recorded_at: Time.current } }
+
+ before do
+ allow_next_instance_of(ServicePing::BuildPayload) do |service|
+ allow(service).to receive(:execute).and_return(payload)
+ end
+ stub_response(body: payload.merge(conv_index: { usage_data_id: 123 }))
+ stub_response(body: nil, url: service_ping_metadata_url, status: 201)
+ end
+
+ it 'generates and sends Service Ping payload' do
+ expect { run_rake_task('gitlab:usage_data:generate_and_send') }.to output(/.*201.*/).to_stdout
+ end
+
+ private
+
+ def stub_response(url: service_ping_payload_url, body:, status: 201)
+ stub_full_request(url, method: :post)
+ .to_return(
+ headers: { 'Content-Type' => 'application/json' },
+ body: body.to_json,
+ status: status
+ )
+ end
+ end
end