From 9dc93a4519d9d5d7be48ff274127136236a3adb3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Apr 2021 23:50:22 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-11-stable-ee --- .../api/ci/runner/jobs_request_post_spec.rb | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'spec/requests/api/ci/runner/jobs_request_post_spec.rb') 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 aced094e219..cf0d8a632f1 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -143,7 +143,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do context 'when there is a pending job' do let(:expected_job_info) do - { 'name' => job.name, + { 'id' => job.id, + 'name' => job.name, 'stage' => job.stage, 'project_id' => job.project.id, 'project_name' => job.project.name } @@ -490,6 +491,36 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do { 'id' => job.id, 'name' => job.name, 'token' => job.token }, { 'id' => job2.id, 'name' => job2.name, 'token' => job2.token }) end + + describe 'preloading job_artifacts_archive' do + context 'when the feature flag is disabled' do + before do + stub_feature_flags(preload_associations_jobs_request_api_endpoint: false) + end + + it 'queries the ci_job_artifacts table multiple times' 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) + end + end + + context 'when the feature flag is enabled' do + before do + stub_feature_flags(preload_associations_jobs_request_api_endpoint: true) + end + + it 'queries the ci_job_artifacts table once only' do + expect { request_job }.not_to exceed_all_query_limit(1).for_model(::Ci::JobArtifact) + end + + it 'queries the ci_builds table five times' do + expect { request_job }.not_to exceed_all_query_limit(5).for_model(::Ci::Build) + end + end + end end context 'when pipeline have jobs with artifacts' do -- cgit v1.2.1