diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-11-07 15:02:18 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-11-07 15:02:18 +0000 |
commit | f323d6148b7b71609cbd32ab9db4724fc108729d (patch) | |
tree | 28762cadb685f35a7a4b70bbf243a3023e999262 /spec/services | |
parent | 5dc0577b84b9d41b1e2a6e781dfeaa400e8e2c10 (diff) | |
parent | 0c59fdaab69e93e2f00fdf70f2a31bb095e3d8d0 (diff) | |
download | gitlab-ce-f323d6148b7b71609cbd32ab9db4724fc108729d.tar.gz |
Merge branch 'max_retries_when' into 'master'
Allow to configure when to retry builds
Closes gitlab-runner#3515
See merge request gitlab-org/gitlab-ce!21758
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/services/ci/process_pipeline_service_spec.rb | 4 |
2 files changed, 27 insertions, 9 deletions
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 054b7b1561c..5c87ed5c3c6 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -435,16 +435,34 @@ describe Ci::CreatePipelineService do end context 'when builds with auto-retries are configured' do - before do - config = YAML.dump(rspec: { script: 'rspec', retry: 2 }) - stub_ci_pipeline_yaml_file(config) + context 'as an integer' do + before do + config = YAML.dump(rspec: { script: 'rspec', retry: 2 }) + stub_ci_pipeline_yaml_file(config) + end + + it 'correctly creates builds with auto-retry value configured' do + pipeline = execute_service + + expect(pipeline).to be_persisted + expect(pipeline.builds.find_by(name: 'rspec').retries_max).to eq 2 + expect(pipeline.builds.find_by(name: 'rspec').retry_when).to eq ['always'] + end end - it 'correctly creates builds with auto-retry value configured' do - pipeline = execute_service + context 'as hash' do + before do + config = YAML.dump(rspec: { script: 'rspec', retry: { max: 2, when: 'runner_system_failure' } }) + stub_ci_pipeline_yaml_file(config) + end - expect(pipeline).to be_persisted - expect(pipeline.builds.find_by(name: 'rspec').retries_max).to eq 2 + it 'correctly creates builds with auto-retry value configured' do + pipeline = execute_service + + expect(pipeline).to be_persisted + expect(pipeline.builds.find_by(name: 'rspec').retries_max).to eq 2 + expect(pipeline.builds.find_by(name: 'rspec').retry_when).to eq ['runner_system_failure'] + end end end diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index 8c7258c42ad..538992b621e 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -671,9 +671,9 @@ describe Ci::ProcessPipelineService, '#execute' do context 'when builds with auto-retries are configured' do before do - create_build('build:1', stage_idx: 0, user: user, options: { retry: 2 }) + create_build('build:1', stage_idx: 0, user: user, options: { retry: { max: 2 } }) create_build('test:1', stage_idx: 1, user: user, when: :on_failure) - create_build('test:2', stage_idx: 1, user: user, options: { retry: 1 }) + create_build('test:2', stage_idx: 1, user: user, options: { retry: { max: 1 } }) end it 'automatically retries builds in a valid order' do |