Commit 265605b4 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'lm-fix-ssjn' into 'master'

Fix stage_dependent_jobs

See merge request gitlab-org/gitlab!67337
parents 456f28e5 ddeda755
......@@ -38,7 +38,7 @@ module Ci
end
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
def needs_dependent_jobs(processable)
......
......@@ -8,37 +8,41 @@ RSpec.describe Ci::AfterRequeueJobService do
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!(: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) }
it 'marks subsequent skipped jobs as processable' do
expect(test1.reload).to be_success
expect(test2.reload).to be_skipped
expect(test3.reload).to be_skipped
expect(deploy.reload).to be_skipped
execute_service
expect(test1.reload).to be_success
expect(test2.reload).to be_created
expect(test3.reload).to be_created
expect(deploy.reload).to be_created
end
context 'when there is a job need from the same stage' do
let!(:test3) do
let!(:test4) do
create(:ci_build,
:skipped,
:dependent,
pipeline: pipeline,
stage_idx: 0,
scheduling_type: :dag)
end
before do
create(:ci_build_need, build: test3, name: 'build')
scheduling_type: :dag,
needed: build)
end
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
context 'with ci_same_stage_job_needs FF disabled' do
......@@ -47,7 +51,7 @@ RSpec.describe Ci::AfterRequeueJobService do
end
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
......
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