diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-13 16:38:08 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-13 16:38:08 +0100 |
commit | c65e96061bf2dae9f79ffbbf4b291cb12bf47d90 (patch) | |
tree | de563ab8b9c5433984ec3c9f77c60515abd70ff1 /spec/services/ci | |
parent | 19ef4083f373dd5fdc6b4c59325a4cb14179e699 (diff) | |
download | gitlab-ce-c65e96061bf2dae9f79ffbbf4b291cb12bf47d90.tar.gz |
Implement new pipeline retry service
The new service takes stages order into account.
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/retry_pipeline_service_spec.rb | 51 |
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:) |