Commit e1c583f8 authored by Steve Azzopardi's avatar Steve Azzopardi

User namespace shared runner quota

We are checking project specific quota not at a namespace level so when a
group has a quota the limit was not being considered.
parent be24f5d5
...@@ -8,11 +8,11 @@ module EE ...@@ -8,11 +8,11 @@ module EE
expose :runners do expose :runners do
expose :quota, if: -> (*) { project.shared_runners_minutes_limit_enabled? } do expose :quota, if: -> (*) { project.shared_runners_minutes_limit_enabled? } do
expose :used do |runner| expose :used do |runner|
project.shared_runners_minutes.to_i project.shared_runners_limit_namespace.shared_runners_minutes.to_i
end end
expose :limit do |runner| expose :limit do |runner|
project.actual_shared_runners_minutes_limit.to_i project.shared_runners_limit_namespace.actual_shared_runners_minutes_limit.to_i
end end
end end
end end
......
...@@ -41,6 +41,28 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -41,6 +41,28 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end end
end end
context 'with shared runner quota exceeded' do
let(:group) { create(:group, :with_used_build_minutes_limit) }
let(:project) { create(:project, :repository, namespace: group, shared_runners_enabled: true) }
let(:runner) { create(:ci_runner, :instance, description: 'Shared runner') }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline, runner: runner) }
before do
project.add_developer(user)
sign_in(user)
get_show(id: job.id, format: :json)
end
it 'exposes quota information' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details', dir: 'ee')
expect(json_response['runners']['quota']['used']).to eq 1000
expect(json_response['runners']['quota']['limit']).to eq 500
end
end
context 'when shared runner has no quota' do context 'when shared runner has no quota' do
let(:project) { create(:project, :private, shared_runners_enabled: true) } let(:project) { create(:project, :private, shared_runners_enabled: true) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment