2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
RSpec.describe API::SidekiqMetrics, :aggregate_failures, feature_category: :shared do
|
2016-06-22 15:30:34 +05:30
|
|
|
let(:admin) { create(:user, :admin) }
|
|
|
|
|
|
|
|
describe 'GET sidekiq/*' do
|
2023-06-20 00:43:36 +05:30
|
|
|
%w[/sidekiq/queue_metrics /sidekiq/process_metrics /sidekiq/job_stats
|
|
|
|
/sidekiq/compound_metrics].each do |path|
|
|
|
|
it_behaves_like 'GET request permissions for admin mode' do
|
|
|
|
let(:path) { path }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
it 'defines the `queue_metrics` endpoint' do
|
2023-06-20 00:43:36 +05:30
|
|
|
get api('/sidekiq/queue_metrics', admin, admin_mode: true)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(json_response).to match a_hash_including(
|
|
|
|
'queues' => a_hash_including(
|
|
|
|
'default' => {
|
|
|
|
'backlog' => be_a(Integer),
|
|
|
|
'latency' => be_a(Integer)
|
|
|
|
},
|
|
|
|
'mailers' => {
|
|
|
|
'backlog' => be_a(Integer),
|
|
|
|
'latency' => be_a(Integer)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'defines the `process_metrics` endpoint' do
|
2023-06-20 00:43:36 +05:30
|
|
|
get api('/sidekiq/process_metrics', admin, admin_mode: true)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2016-06-22 15:30:34 +05:30
|
|
|
expect(json_response['processes']).to be_an Array
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'defines the `job_stats` endpoint' do
|
2023-06-20 00:43:36 +05:30
|
|
|
get api('/sidekiq/job_stats', admin, admin_mode: true)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2016-06-22 15:30:34 +05:30
|
|
|
expect(json_response).to be_a Hash
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(json_response['jobs']).to be_a Hash
|
|
|
|
expect(json_response['jobs'].keys)
|
|
|
|
.to contain_exactly(*%w[processed failed enqueued dead])
|
|
|
|
expect(json_response['jobs'].values).to all(be_an(Integer))
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'defines the `compound_metrics` endpoint' do
|
2023-06-20 00:43:36 +05:30
|
|
|
get api('/sidekiq/compound_metrics', admin, admin_mode: true)
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2016-06-22 15:30:34 +05:30
|
|
|
expect(json_response).to be_a Hash
|
|
|
|
expect(json_response['queues']).to be_a Hash
|
|
|
|
expect(json_response['processes']).to be_an Array
|
|
|
|
expect(json_response['jobs']).to be_a Hash
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|