diff options
Diffstat (limited to 'spec/factories/ci')
-rw-r--r-- | spec/factories/ci/bridge.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 1 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 4 | ||||
-rw-r--r-- | spec/factories/ci/processable.rb | 26 | ||||
-rw-r--r-- | spec/factories/ci/runner_machines.rb | 7 |
5 files changed, 42 insertions, 4 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb index 6cbcabca7ab..49ac74f6f86 100644 --- a/spec/factories/ci/bridge.rb +++ b/spec/factories/ci/bridge.rb @@ -33,6 +33,14 @@ FactoryBot.define do end end + trait :retried do + retried { true } + end + + trait :retryable do + success + end + trait :created do status { 'created' } end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 78398fd7f20..224f460488b 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -7,7 +7,6 @@ FactoryBot.define do created_at { 'Di 29. Okt 09:50:00 CET 2013' } scheduling_type { 'stage' } pending - partition_id { pipeline.partition_id } options do { diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index eef5c593e0f..d68562c0aa5 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -237,7 +237,9 @@ FactoryBot.define do trait :with_job do after(:build) do |pipeline, evaluator| - pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project) + stage = build(:ci_stage, pipeline: pipeline) + + pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project, ci_stage: stage) end end diff --git a/spec/factories/ci/processable.rb b/spec/factories/ci/processable.rb index 76c7376d24a..49e66368f94 100644 --- a/spec/factories/ci/processable.rb +++ b/spec/factories/ci/processable.rb @@ -3,13 +3,37 @@ FactoryBot.define do factory :ci_processable, class: 'Ci::Processable' do name { 'processable' } - stage { 'test' } stage_idx { ci_stage.try(:position) || 0 } ref { 'master' } tag { false } pipeline factory: :ci_pipeline project { pipeline.project } scheduling_type { 'stage' } + partition_id { pipeline.partition_id } + + # This factory was updated to help with the efforts of the removal of `ci_builds.stage`: + # https://gitlab.com/gitlab-org/gitlab/-/issues/364377 + # These additions can be removed once the specs that use the stage attribute have been updated + + transient do + stage { 'test' } + end + + after(:build) do |processable, evaluator| + processable.stage = evaluator.stage + end + + before(:create) do |processable, evaluator| + next if processable.ci_stage + + if ci_stage = processable.pipeline.stages.find_by(name: evaluator.stage) + processable.ci_stage = ci_stage + else + processable.ci_stage = create(:ci_stage, pipeline: processable.pipeline, + project: processable.project || evaluator.project, + name: evaluator.stage, position: evaluator.stage_idx, status: 'created') + end + end trait :waiting_for_resource do status { 'waiting_for_resource' } diff --git a/spec/factories/ci/runner_machines.rb b/spec/factories/ci/runner_machines.rb index 09bf5d0844e..9d601caa634 100644 --- a/spec/factories/ci/runner_machines.rb +++ b/spec/factories/ci/runner_machines.rb @@ -3,6 +3,11 @@ FactoryBot.define do factory :ci_runner_machine, class: 'Ci::RunnerMachine' do runner factory: :ci_runner - machine_xid { "r_#{SecureRandom.hex.slice(0, 10)}" } + system_xid { "r_#{SecureRandom.hex.slice(0, 10)}" } + + trait :stale do + created_at { 1.year.ago } + contacted_at { Ci::RunnerMachine::STALE_TIMEOUT.ago } + end end end |