diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-18 03:07:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-18 03:07:42 +0300 |
commit | c8ccf45aa0aa17413b107f9bbf9d6f160eaa8779 (patch) | |
tree | 77b07d805562786cf9b218e25e0ed18fae396448 /spec/models | |
parent | 360ee1db0bf3bba2fc7aad7f230ec80829561227 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_metadata_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/processable_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/runner_machine_build_spec.rb | 38 | ||||
-rw-r--r-- | spec/models/ci/runner_machine_spec.rb | 4 |
5 files changed, 42 insertions, 5 deletions
diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb index fb50ba89cd3..c3b445cbbe5 100644 --- a/spec/models/ci/build_metadata_spec.rb +++ b/spec/models/ci/build_metadata_spec.rb @@ -22,7 +22,6 @@ RSpec.describe Ci::BuildMetadata do it { is_expected.to belong_to(:build) } it { is_expected.to belong_to(:project) } - it { is_expected.to belong_to(:runner_machine) } describe '#update_timeout_state' do subject { metadata } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 2b3dc97e06d..e7b090630d3 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Ci::Build, feature_category: :continuous_integration, factory_def it { is_expected.to have_many(:pages_deployments).with_foreign_key(:ci_build_id) } it { is_expected.to have_one(:deployment) } - it { is_expected.to have_one(:runner_machine).through(:metadata) } + it { is_expected.to have_one(:runner_machine).through(:runner_machine_build) } it { is_expected.to have_one(:runner_session).with_foreign_key(:build_id) } it { is_expected.to have_one(:trace_metadata).with_foreign_key(:build_id) } it { is_expected.to have_one(:runtime_metadata).with_foreign_key(:build_id) } diff --git a/spec/models/ci/processable_spec.rb b/spec/models/ci/processable_spec.rb index db22d8f3a6c..cf2c176816d 100644 --- a/spec/models/ci/processable_spec.rb +++ b/spec/models/ci/processable_spec.rb @@ -83,7 +83,7 @@ RSpec.describe Ci::Processable, feature_category: :continuous_integration do runner_id tag_taggings taggings tags trigger_request_id user_id auto_canceled_by_id retried failure_reason sourced_pipelines sourced_pipeline artifacts_file_store artifacts_metadata_store - metadata runner_machine_id runner_machine runner_session trace_chunks upstream_pipeline_id + metadata runner_machine_build runner_machine runner_session trace_chunks upstream_pipeline_id artifacts_file artifacts_metadata artifacts_size commands resource resource_group_id processed security_scans author pipeline_id report_results pending_state pages_deployments diff --git a/spec/models/ci/runner_machine_build_spec.rb b/spec/models/ci/runner_machine_build_spec.rb new file mode 100644 index 00000000000..cf62731a551 --- /dev/null +++ b/spec/models/ci/runner_machine_build_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::RunnerMachineBuild, model: true, feature_category: :runner_fleet do + it { is_expected.to belong_to(:build) } + it { is_expected.to belong_to(:runner_machine) } + + describe 'partitioning' do + context 'with build' do + let(:build) { FactoryBot.build(:ci_build, partition_id: ci_testing_partition_id) } + let(:runner_machine_build) { FactoryBot.build(:ci_runner_machine_build, build: build) } + + it 'sets partition_id to the current partition value' do + expect { runner_machine_build.valid? }.to change { runner_machine_build.partition_id } + .to(ci_testing_partition_id) + end + + context 'when it is already set' do + let(:runner_machine_build) { FactoryBot.build(:ci_runner_machine_build, partition_id: 125) } + + it 'does not change the partition_id value' do + expect { runner_machine_build.valid? }.not_to change { runner_machine_build.partition_id } + end + end + end + + context 'without build' do + let(:runner_machine_build) { FactoryBot.build(:ci_runner_machine_build, build: nil) } + + it { is_expected.to validate_presence_of(:partition_id) } + + it 'does not change the partition_id value' do + expect { runner_machine_build.valid? }.not_to change { runner_machine_build.partition_id } + end + end + end +end diff --git a/spec/models/ci/runner_machine_spec.rb b/spec/models/ci/runner_machine_spec.rb index d0979d8a485..a0569829125 100644 --- a/spec/models/ci/runner_machine_spec.rb +++ b/spec/models/ci/runner_machine_spec.rb @@ -7,8 +7,8 @@ RSpec.describe Ci::RunnerMachine, feature_category: :runner_fleet, type: :model it { is_expected.to belong_to(:runner) } it { is_expected.to belong_to(:runner_version).with_foreign_key(:version) } - it { is_expected.to have_many(:build_metadata) } - it { is_expected.to have_many(:builds).through(:build_metadata) } + it { is_expected.to have_many(:runner_machine_builds) } + it { is_expected.to have_many(:builds).through(:runner_machine_builds) } describe 'validation' do it { is_expected.to validate_presence_of(:runner) } |