diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/requests/api/ci | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/requests/api/ci')
-rw-r--r-- | spec/requests/api/ci/pipelines_spec.rb | 19 | ||||
-rw-r--r-- | spec/requests/api/ci/runner/jobs_request_post_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/ci/runner/runners_post_spec.rb | 30 | ||||
-rw-r--r-- | spec/requests/api/ci/runners_spec.rb | 13 |
4 files changed, 65 insertions, 3 deletions
diff --git a/spec/requests/api/ci/pipelines_spec.rb b/spec/requests/api/ci/pipelines_spec.rb index d0c2b383013..092cd00630e 100644 --- a/spec/requests/api/ci/pipelines_spec.rb +++ b/spec/requests/api/ci/pipelines_spec.rb @@ -362,6 +362,25 @@ RSpec.describe API::Ci::Pipelines do it do expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Array + + expect(json_response).to all match a_hash_including( + 'duration' => be_nil, + 'queued_duration' => (be >= 0.0) + ) + end + end + + context 'when filtering to only running jobs' do + let(:query) { { 'scope' => 'running' } } + + it do + expect(response).to have_gitlab_http_status(:ok) + expect(json_response).to be_an Array + + expect(json_response).to all match a_hash_including( + 'duration' => (be >= 0.0), + 'queued_duration' => (be >= 0.0) + ) end end diff --git a/spec/requests/api/ci/runner/jobs_request_post_spec.rb b/spec/requests/api/ci/runner/jobs_request_post_spec.rb index cf0d8a632f1..63da3340a45 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -378,7 +378,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do { "name" => "release", "script" => - ["release-cli create --name \"Release $CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\" --tag-name \"release-$CI_COMMIT_SHA\" --ref \"$CI_COMMIT_SHA\""], + ["release-cli create --name \"Release $CI_COMMIT_SHA\" --description \"Created using the release-cli $EXTRA_DESCRIPTION\" --tag-name \"release-$CI_COMMIT_SHA\" --ref \"$CI_COMMIT_SHA\" --assets-link \"{\\\"url\\\":\\\"https://example.com/assets/1\\\",\\\"name\\\":\\\"asset1\\\"}\""], "timeout" => 3600, "when" => "on_success", "allow_failure" => false @@ -502,8 +502,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do expect { request_job }.to exceed_all_query_limit(1).for_model(::Ci::JobArtifact) end - it 'queries the ci_builds table more than five times' do - expect { request_job }.to exceed_all_query_limit(5).for_model(::Ci::Build) + it 'queries the ci_builds table more than three times' do + expect { request_job }.to exceed_all_query_limit(3).for_model(::Ci::Build) end end diff --git a/spec/requests/api/ci/runner/runners_post_spec.rb b/spec/requests/api/ci/runner/runners_post_spec.rb index 7984b1d4ca8..b38630183f4 100644 --- a/spec/requests/api/ci/runner/runners_post_spec.rb +++ b/spec/requests/api/ci/runner/runners_post_spec.rb @@ -91,6 +91,21 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do it_behaves_like 'not executing any extra queries for the application context' do let(:subject_proc) { proc { request } } end + + context 'when it exceeds the application limits' do + before do + create(:ci_runner, runner_type: :project_type, projects: [project]) + create(:plan_limits, :default_plan, ci_registered_project_runners: 1) + end + + it 'does not create runner' do + request + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['message']).to include('runner_projects.base' => ['Maximum number of ci registered project runners (1) exceeded']) + expect(project.runners.reload.size).to eq(1) + end + end end context 'when group token is used' do @@ -117,6 +132,21 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do it_behaves_like 'not executing any extra queries for the application context' do let(:subject_proc) { proc { request } } end + + context 'when it exceeds the application limits' do + before do + create(:ci_runner, runner_type: :group_type, groups: [group]) + create(:plan_limits, :default_plan, ci_registered_group_runners: 1) + end + + it 'does not create runner' do + request + + expect(response).to have_gitlab_http_status(:bad_request) + expect(json_response['message']).to include('runner_namespaces.base' => ['Maximum number of ci registered group runners (1) exceeded']) + expect(group.runners.reload.size).to eq(1) + end + end end end diff --git a/spec/requests/api/ci/runners_spec.rb b/spec/requests/api/ci/runners_spec.rb index 670456e5dba..1727bc830fc 100644 --- a/spec/requests/api/ci/runners_spec.rb +++ b/spec/requests/api/ci/runners_spec.rb @@ -999,6 +999,19 @@ RSpec.describe API::Ci::Runners do end.to change { project.runners.count }.by(+1) expect(response).to have_gitlab_http_status(:created) end + + context 'when it exceeds the application limits' do + before do + create(:plan_limits, :default_plan, ci_registered_project_runners: 1) + end + + it 'does not enable specific runner' do + expect do + post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id } + end.not_to change { project.runners.count } + expect(response).to have_gitlab_http_status(:bad_request) + end + end end it 'enables a instance type runner' do |