BigW Consortium Gitlab

Commit 63da9172 by Z.J. van de Weg

Improve pipeline size for query limit test

The pipeline was quite meagre in both stages and the number of groups. This has been improved. Performance is not yet optimal, but to limit this from sliding further this slippery slope, a hard limit has been set.
parent 20987f4f
......@@ -38,7 +38,7 @@ describe Projects::PipelinesController do
end
describe 'GET show JSON' do
let!(:pipeline) { create(:ci_pipeline_with_one_job, project: project) }
let(:pipeline) { create(:ci_pipeline_with_one_job, project: project) }
it 'returns the pipeline' do
get_pipeline_json
......@@ -49,20 +49,48 @@ describe Projects::PipelinesController do
expect(json_response['details']).to have_key 'stages'
end
context 'when the pipeline has multiple jobs' do
context 'when the pipeline has multiple stages and groups' do
before do
RequestStore.begin!
create_build('build', 0, 'build')
create_build('test', 1, 'rspec 0')
create_build('deploy', 2, 'production')
create_build('post deploy', 3, 'pages 0')
end
after do
RequestStore.end!
RequestStore.clear!
end
let(:project) { create(:project) }
let(:pipeline) do
create(:ci_empty_pipeline, project: project, user: user, sha: project.commit.id)
end
it 'does not perform N + 1 queries' do
control_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
create(:ci_build, pipeline: pipeline)
create_build('test', 1, 'rspec 1')
create_build('test', 1, 'spinach 0')
create_build('test', 1, 'spinach 1')
create_build('test', 1, 'audit')
create_build('post deploy', 3, 'pages 1')
create_build('post deploy', 3, 'pages 2')
# The plus 2 is needed to group and sort
expect { get_pipeline_json }.not_to exceed_query_limit(control_count + 2)
new_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
expect(new_count).to be_within(12).of(control_count)
end
end
def get_pipeline_json
get :show, namespace_id: project.namespace, project_id: project, id: pipeline, format: :json
end
def create_build(stage, stage_idx, name)
create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name)
end
end
describe 'GET stages.json' do
......
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