Commit 6b2eb865 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'performance/gb/improve-pipeline-creation-service' into 'master'

Improve pipeline creation service performance

Closes #37987

See merge request gitlab-org/gitlab-ce!18582
parents 928e45e7 d3ea3940
---
title: Improve performance of a service responsible for creating a pipeline
merge_request: 18582
author:
type: performance
...@@ -14,14 +14,10 @@ module Gitlab ...@@ -14,14 +14,10 @@ module Gitlab
@command.seeds_block&.call(pipeline) @command.seeds_block&.call(pipeline)
## ##
# Populate pipeline with all stages and builds from pipeline seeds. # Populate pipeline with all stages, and stages with builds.
# #
pipeline.stage_seeds.each do |stage| pipeline.stage_seeds.each do |stage|
pipeline.stages << stage.to_resource pipeline.stages << stage.to_resource
stage.seeds.each do |build|
pipeline.builds << build.to_resource
end
end end
if pipeline.stages.none? if pipeline.stages.none?
......
...@@ -35,11 +35,6 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do ...@@ -35,11 +35,6 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
it 'populates pipeline with stages' do it 'populates pipeline with stages' do
expect(pipeline.stages).to be_one expect(pipeline.stages).to be_one
expect(pipeline.stages.first).not_to be_persisted expect(pipeline.stages.first).not_to be_persisted
end
it 'populates pipeline with builds' do
expect(pipeline.builds).to be_one
expect(pipeline.builds.first).not_to be_persisted
expect(pipeline.stages.first.builds).to be_one expect(pipeline.stages.first.builds).to be_one
expect(pipeline.stages.first.builds.first).not_to be_persisted expect(pipeline.stages.first.builds.first).not_to be_persisted
end end
...@@ -151,8 +146,8 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do ...@@ -151,8 +146,8 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
step.perform! step.perform!
expect(pipeline.stages.size).to eq 1 expect(pipeline.stages.size).to eq 1
expect(pipeline.builds.size).to eq 1 expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.builds.first.name).to eq 'rspec' expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end end
end end
end end
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