Commit ddeda755 authored by lauraMon's avatar lauraMon

Updates `stage_dependent_jobs` in the AfterRequeueJobService

* This MR reverts to the original way (before same stage job needs) of
processing jobs after requeuing jobs from a stage. When requeuing after a manual job,
if there is a job with needs, we need to make sure that they are requeued even
if they are `scheduling_type_dag`.
* Also adds a spec for this specific case
parent 22530534
...@@ -38,7 +38,7 @@ module Ci ...@@ -38,7 +38,7 @@ module Ci
end end
def stage_dependent_jobs(processable) def stage_dependent_jobs(processable)
skipped_jobs(processable).scheduling_type_stage.after_stage(processable.stage_idx) skipped_jobs(processable).after_stage(processable.stage_idx)
end end
def needs_dependent_jobs(processable) def needs_dependent_jobs(processable)
......
...@@ -8,37 +8,41 @@ RSpec.describe Ci::AfterRequeueJobService do ...@@ -8,37 +8,41 @@ RSpec.describe Ci::AfterRequeueJobService do
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, pipeline: pipeline, stage_idx: 0, name: 'build') }
let!(:test1) { create(:ci_build, :success, pipeline: pipeline, stage_idx: 1) } let!(:test1) { create(:ci_build, :success, pipeline: pipeline, stage_idx: 1) }
let!(:test2) { create(:ci_build, :skipped, pipeline: pipeline, stage_idx: 1) } let!(:test2) { create(:ci_build, :skipped, pipeline: pipeline, stage_idx: 1) }
let!(:build) { create(:ci_build, pipeline: pipeline, stage_idx: 0, name: 'build') } let!(:test3) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 1, needed: build) }
let!(:deploy) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 2, needed: test3) }
subject(:execute_service) { described_class.new(project, user).execute(build) } subject(:execute_service) { described_class.new(project, user).execute(build) }
it 'marks subsequent skipped jobs as processable' do it 'marks subsequent skipped jobs as processable' do
expect(test1.reload).to be_success expect(test1.reload).to be_success
expect(test2.reload).to be_skipped expect(test2.reload).to be_skipped
expect(test3.reload).to be_skipped
expect(deploy.reload).to be_skipped
execute_service execute_service
expect(test1.reload).to be_success expect(test1.reload).to be_success
expect(test2.reload).to be_created expect(test2.reload).to be_created
expect(test3.reload).to be_created
expect(deploy.reload).to be_created
end end
context 'when there is a job need from the same stage' do context 'when there is a job need from the same stage' do
let!(:test3) do let!(:test4) do
create(:ci_build, create(:ci_build,
:skipped, :skipped,
:dependent,
pipeline: pipeline, pipeline: pipeline,
stage_idx: 0, stage_idx: 0,
scheduling_type: :dag) scheduling_type: :dag,
end needed: build)
before do
create(:ci_build_need, build: test3, name: 'build')
end end
it 'marks subsequent skipped jobs as processable' do it 'marks subsequent skipped jobs as processable' do
expect { execute_service }.to change { test3.reload.status }.from('skipped').to('created') expect { execute_service }.to change { test4.reload.status }.from('skipped').to('created')
end end
context 'with ci_same_stage_job_needs FF disabled' do context 'with ci_same_stage_job_needs FF disabled' do
...@@ -47,7 +51,7 @@ RSpec.describe Ci::AfterRequeueJobService do ...@@ -47,7 +51,7 @@ RSpec.describe Ci::AfterRequeueJobService do
end end
it 'does nothing with the build' do it 'does nothing with the build' do
expect { execute_service }.not_to change { test3.reload.status } expect { execute_service }.not_to change { test4.reload.status }
end end
end end
end end
......
config:
stages: [first, second, third]
job_a:
when: manual
stage: first
script:
- echo
job_b:
when: manual
stage: second
script:
- echo
job_c:
needs: ["job_b"]
stage: third
script:
- echo
job_d:
needs: ["job_a"]
stage: third
script:
- echo
init:
expect:
pipeline: skipped
stages:
first: skipped
second: skipped
third: skipped
jobs:
job_a: manual
job_b: manual
job_c: skipped
job_d: skipped
transitions:
- event: play
jobs: [job_b]
expect:
pipeline: pending
stages:
first: skipped
second: pending
third: pending
jobs:
job_a: manual
job_b: pending
job_c: created
job_d: skipped
config:
stages: [first, second, third, fourth]
first_job:
stage: first
script:
- echo
second_job:
stage: second
script:
- echo
when: manual
third_job:
stage: third
needs: ["second_job"]
script:
- echo
fourth_job:
stage: fourth
needs: ["third_job"]
script:
- echo
init:
expect:
pipeline: pending
stages:
first: pending
second: created
third: created
fourth: created
jobs:
first_job: pending
second_job: created
third_job: created
fourth_job: created
transitions:
- event: success
jobs: [first_job]
expect:
pipeline: success
stages:
first: success
second: skipped
third: skipped
fourth: skipped
jobs:
first_job: success
second_job: manual
third_job: skipped
fourth_job: skipped
- event: play
jobs: [second_job]
expect:
pipeline: running
stages:
first: success
second: pending
third: skipped
fourth: skipped
jobs:
first_job: success
second_job: pending
third_job: created
fourth_job: created
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