diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-17 03:09:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-17 03:09:32 +0300 |
commit | 1b1bd461da768b31adb730f42060b7d6adf548c5 (patch) | |
tree | f0150b942ee4e9f5798418aad6da669de6ace00b /spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb | |
parent | 2c34e41161b78fddbdff9a858086e95558e06ba0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb')
-rw-r--r-- | spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb b/spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb new file mode 100644 index 00000000000..44031175497 --- /dev/null +++ b/spec/migrations/20230214154101_fix_partition_ids_on_ci_sources_pipelines_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe FixPartitionIdsOnCiSourcesPipelines, migration: :gitlab_ci, feature_category: :continuous_integration do + let(:sources_pipelines) { table(:ci_sources_pipelines, database: :ci) } + + before do + sources_pipelines.insert_all!([ + { partition_id: 100, source_partition_id: 100 }, + { partition_id: 100, source_partition_id: 101 }, + { partition_id: 101, source_partition_id: 100 }, + { partition_id: 101, source_partition_id: 101 } + ]) + end + + describe '#up' do + context 'when on sass' do + before do + allow(Gitlab).to receive(:com?).and_return(true) + end + + it 'fixes partition_id and source_partition_id' do + expect { migrate! }.not_to raise_error + + expect(sources_pipelines.where(partition_id: 100).count).to eq(4) + expect(sources_pipelines.where(partition_id: 101).count).to eq(0) + expect(sources_pipelines.where(source_partition_id: 100).count).to eq(4) + expect(sources_pipelines.where(source_partition_id: 101).count).to eq(0) + end + end + + context 'when on self managed' do + it 'does not change partition_id or source_partition_id' do + expect { migrate! }.not_to raise_error + + expect(sources_pipelines.where(partition_id: 100).count).to eq(2) + expect(sources_pipelines.where(partition_id: 100).count).to eq(2) + expect(sources_pipelines.where(source_partition_id: 101).count).to eq(2) + expect(sources_pipelines.where(source_partition_id: 101).count).to eq(2) + end + end + end +end |