Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-13 18:38:08 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-13 18:38:08 +0300
commitc65e96061bf2dae9f79ffbbf4b291cb12bf47d90 (patch)
treede563ab8b9c5433984ec3c9f77c60515abd70ff1 /spec/services/ci/retry_pipeline_service_spec.rb
parent19ef4083f373dd5fdc6b4c59325a4cb14179e699 (diff)
Implement new pipeline retry service
The new service takes stages order into account.
Diffstat (limited to 'spec/services/ci/retry_pipeline_service_spec.rb')
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb51
1 files changed, 50 insertions, 1 deletions
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index 6fc1d884920..aeb3ee228ad 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -21,6 +21,51 @@ describe Ci::RetryPipelineService, '#execute', :services do
expect(build('rspec 2')).to be_pending
expect(build('rspec 3')).to be_pending
+ expect(pipeline.reload).to be_running
+ end
+ end
+
+ context 'when there are failed or canceled builds in the first stage' do
+ before do
+ create_build(name: 'rspec 1', status: :failed, stage_num: 0)
+ create_build(name: 'rspec 2', status: :canceled, stage_num: 0)
+ create_build(name: 'rspec 3', status: :skipped, stage_num: 1)
+ create_build(name: 'deploy 1', status: :skipped, stage_num: 2)
+ end
+
+ it 'retries builds failed builds and marks subsequent for processing' do
+ service.execute
+
+ expect(build('rspec 1')).to be_pending
+ expect(build('rspec 2')).to be_pending
+ expect(build('rspec 3')).to be_created
+ expect(build('deploy 1')).to be_created
+ expect(pipeline.reload).to be_running
+ end
+ end
+
+ context 'when there is failed build present which was run on failure' do
+ before do
+ create_build(name: 'rspec 1', status: :failed, stage_num: 0)
+ create_build(name: 'rspec 2', status: :canceled, stage_num: 0)
+ create_build(name: 'rspec 3', status: :skipped, stage_num: 1)
+ create_build(name: 'report 1', status: :failed, stage_num: 2)
+ end
+
+ it 'retries builds failed builds and marks subsequent for processing' do
+ service.execute
+
+ expect(build('rspec 1')).to be_pending
+ expect(build('rspec 2')).to be_pending
+ expect(build('rspec 3')).to be_created
+ expect(build('report 1')).to be_created
+ expect(pipeline.reload).to be_running
+ end
+
+ it 'creates a new job for report job in this case' do
+ service.execute
+
+ expect(statuses.where(name: 'report 1').count).to eq 2
end
end
end
@@ -32,8 +77,12 @@ describe Ci::RetryPipelineService, '#execute', :services do
end
end
+ def statuses
+ pipeline.reload.statuses
+ end
+
def build(name)
- pipeline.statuses.find_by(name: name)
+ statuses.latest.find_by(name: name)
end
def create_build(name:, status:, stage_num:)