diff --git a/.rubocop_todo/layout/argument_alignment.yml b/.rubocop_todo/layout/argument_alignment.yml index cab3185a3779373015c7b48b6f06d078dcd1b098..3a0de7eb0b7bed9654917732cd177ab4ee364d19 100644 --- a/.rubocop_todo/layout/argument_alignment.yml +++ b/.rubocop_todo/layout/argument_alignment.yml @@ -1466,22 +1466,7 @@ Layout/ArgumentAlignment: - 'spec/lib/gitlab/cross_project_access/class_methods_spec.rb' - 'spec/lib/gitlab/cross_project_access_spec.rb' - 'spec/lib/gitlab/data_builder/push_spec.rb' - - 'spec/lib/gitlab/database/background_migration/batched_migration_spec.rb' - - 'spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb' - - 'spec/lib/gitlab/database/background_migration/prometheus_metrics_spec.rb' - - 'spec/lib/gitlab/database/bulk_update_spec.rb' - - 'spec/lib/gitlab/database/loose_foreign_keys_spec.rb' - 'spec/lib/gitlab/database/migration_helpers_spec.rb' - - 'spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb' - - 'spec/lib/gitlab/database/migrations/instrumentation_spec.rb' - - 'spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb' - - 'spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb' - - 'spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb' - - 'spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb' - - 'spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb' - - 'spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb' - - 'spec/lib/gitlab/database/postgres_constraint_spec.rb' - - 'spec/lib/gitlab/database/tables_truncate_spec.rb' - 'spec/lib/gitlab/dependency_linker/parser/gemfile_spec.rb' - 'spec/lib/gitlab/diff/file_collection/compare_spec.rb' - 'spec/lib/gitlab/diff/file_collection/merge_request_diff_batch_spec.rb' diff --git a/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb b/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb index 213dee0d19d432905f2892cf6237367cba54dbde..f70b38377d85a20b5be22190ac26c389e013909c 100644 --- a/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb +++ b/spec/lib/gitlab/database/background_migration/batched_migration_spec.rb @@ -422,11 +422,12 @@ describe '#create_batched_job!' do let(:batched_migration) do - create(:batched_background_migration, - batch_size: 999, - sub_batch_size: 99, - pause_ms: 250 - ) + create( + :batched_background_migration, + batch_size: 999, + sub_batch_size: 99, + pause_ms: 250 + ) end it 'creates a batched_job with the correct batch configuration' do diff --git a/spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb b/spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb index 8d74d16f4e5c62f92042c3d2aaa22baadaf22719..bbcb65109ce218f165fc4b3238a6f0d26b4d48e6 100644 --- a/spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb +++ b/spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb @@ -32,17 +32,17 @@ end it 'runs the migration job' do - expect(job_class).to receive(:new) - .with(start_id: 1, - end_id: 10, - batch_table: 'events', - batch_column: 'id', - sub_batch_size: 1, - pause_ms: pause_ms, - job_arguments: active_migration.job_arguments, - connection: connection, - sub_batch_exception: sub_batch_exception) - .and_return(job_instance) + expect(job_class).to receive(:new).with( + start_id: 1, + end_id: 10, + batch_table: 'events', + batch_column: 'id', + sub_batch_size: 1, + pause_ms: pause_ms, + job_arguments: active_migration.job_arguments, + connection: connection, + sub_batch_exception: sub_batch_exception + ).and_return(job_instance) expect(job_instance).to receive(:perform).with(no_args) diff --git a/spec/lib/gitlab/database/background_migration/prometheus_metrics_spec.rb b/spec/lib/gitlab/database/background_migration/prometheus_metrics_spec.rb index 1f256de35ec95051faf5d3ffa8d1b271bd75c18c..8f380a8229cb63eb85162aa3d2a3747c9655b679 100644 --- a/spec/lib/gitlab/database/background_migration/prometheus_metrics_spec.rb +++ b/spec/lib/gitlab/database/background_migration/prometheus_metrics_spec.rb @@ -5,11 +5,14 @@ RSpec.describe Gitlab::Database::BackgroundMigration::PrometheusMetrics, :prometheus do describe '#track' do let(:job_record) do - build(:batched_background_migration_job, :succeeded, - started_at: Time.current - 2.minutes, - finished_at: Time.current - 1.minute, - updated_at: Time.current, - metrics: { 'timings' => { 'update_all' => [0.05, 0.2, 0.4, 0.9, 4] } }) + build( + :batched_background_migration_job, + :succeeded, + started_at: Time.current - 2.minutes, + finished_at: Time.current - 1.minute, + updated_at: Time.current, + metrics: { 'timings' => { 'update_all' => [0.05, 0.2, 0.4, 0.9, 4] } } + ) end let(:labels) { job_record.batched_migration.prometheus_labels } diff --git a/spec/lib/gitlab/database/bulk_update_spec.rb b/spec/lib/gitlab/database/bulk_update_spec.rb index fa519cffd6bfffc4790780aad1f071cc14bd8a76..2f0859dba743d8856f4121157fa788ca2466b4d0 100644 --- a/spec/lib/gitlab/database/bulk_update_spec.rb +++ b/spec/lib/gitlab/database/bulk_update_spec.rb @@ -92,7 +92,7 @@ end context 'validates prepared_statements support', :reestablished_active_record_base, - :suppress_gitlab_schemas_validate_connection do + :suppress_gitlab_schemas_validate_connection do using RSpec::Parameterized::TableSyntax where(:prepared_statements) do diff --git a/spec/lib/gitlab/database/loose_foreign_keys_spec.rb b/spec/lib/gitlab/database/loose_foreign_keys_spec.rb index 552df64096a21d9c200015b984d199d1454f87e2..1824a50cb283325d0201ed3209d2a964ee6757dc 100644 --- a/spec/lib/gitlab/database/loose_foreign_keys_spec.rb +++ b/spec/lib/gitlab/database/loose_foreign_keys_spec.rb @@ -8,14 +8,14 @@ it 'all definitions have assigned a known gitlab_schema and on_delete' do is_expected.to all(have_attributes( - options: a_hash_including( - column: be_a(String), - gitlab_schema: be_in(Gitlab::Database.schemas_to_base_models.symbolize_keys.keys), - on_delete: be_in([:async_delete, :async_nullify]) - ), - from_table: be_a(String), - to_table: be_a(String) - )) + options: a_hash_including( + column: be_a(String), + gitlab_schema: be_in(Gitlab::Database.schemas_to_base_models.symbolize_keys.keys), + on_delete: be_in([:async_delete, :async_nullify]) + ), + from_table: be_a(String), + to_table: be_a(String) + )) end context 'ensure keys are sorted' do diff --git a/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb b/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb index 476b5f3a784e3ff6b4a3a5e1cab7e551002793cb..4d7c51a3fbf38b71bc7b4922aa31f8c34d9762bb 100644 --- a/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb +++ b/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb @@ -13,9 +13,11 @@ describe '#check_constraint_name' do it 'returns a valid constraint name' do - name = model.check_constraint_name(:this_is_a_very_long_table_name, - :with_a_very_long_column_name, - :with_a_very_long_type) + name = model.check_constraint_name( + :this_is_a_very_long_table_name, + :with_a_very_long_column_name, + :with_a_very_long_type + ) expect(name).to be_an_instance_of(String) expect(name).to start_with('check_') @@ -404,9 +406,7 @@ describe '#add_text_limit' do context 'when it is called with the default options' do it 'calls add_check_constraint with an infered constraint name and validate: true' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'max_length') + constraint_name = model.check_constraint_name(:test_table, :name, 'max_length') check = "char_length(name) <= 255" expect(model).to receive(:check_constraint_name).and_call_original @@ -440,9 +440,7 @@ describe '#validate_text_limit' do context 'when constraint_name is not provided' do it 'calls validate_check_constraint with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'max_length') + constraint_name = model.check_constraint_name(:test_table, :name, 'max_length') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:validate_check_constraint) @@ -468,9 +466,7 @@ describe '#remove_text_limit' do context 'when constraint_name is not provided' do it 'calls remove_check_constraint with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'max_length') + constraint_name = model.check_constraint_name(:test_table, :name, 'max_length') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:remove_check_constraint) @@ -496,9 +492,7 @@ describe '#check_text_limit_exists?' do context 'when constraint_name is not provided' do it 'calls check_constraint_exists? with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'max_length') + constraint_name = model.check_constraint_name(:test_table, :name, 'max_length') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:check_constraint_exists?) @@ -524,9 +518,7 @@ describe '#add_not_null_constraint' do context 'when it is called with the default options' do it 'calls add_check_constraint with an infered constraint name and validate: true' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'not_null') + constraint_name = model.check_constraint_name(:test_table, :name, 'not_null') check = "name IS NOT NULL" expect(model).to receive(:column_is_nullable?).and_return(true) @@ -571,9 +563,7 @@ describe '#validate_not_null_constraint' do context 'when constraint_name is not provided' do it 'calls validate_check_constraint with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'not_null') + constraint_name = model.check_constraint_name(:test_table, :name, 'not_null') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:validate_check_constraint) @@ -599,9 +589,7 @@ describe '#remove_not_null_constraint' do context 'when constraint_name is not provided' do it 'calls remove_check_constraint with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'not_null') + constraint_name = model.check_constraint_name(:test_table, :name, 'not_null') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:remove_check_constraint) @@ -627,9 +615,7 @@ describe '#check_not_null_constraint_exists?' do context 'when constraint_name is not provided' do it 'calls check_constraint_exists? with an infered constraint name' do - constraint_name = model.check_constraint_name(:test_table, - :name, - 'not_null') + constraint_name = model.check_constraint_name(:test_table, :name, 'not_null') expect(model).to receive(:check_constraint_name).and_call_original expect(model).to receive(:check_constraint_exists?) diff --git a/spec/lib/gitlab/database/migrations/instrumentation_spec.rb b/spec/lib/gitlab/database/migrations/instrumentation_spec.rb index a12e0909dc2f418a1357814a26966e18d106f363..81368dde94da23435ded9e4fe57b9d89e5cf4a93 100644 --- a/spec/lib/gitlab/database/migrations/instrumentation_spec.rb +++ b/spec/lib/gitlab/database/migrations/instrumentation_spec.rb @@ -75,8 +75,12 @@ def load_observation(result_dir, migration_name) context 'on successful execution' do subject do - instrumentation.observe(version: migration_version, name: migration_name, - connection: connection, meta: migration_meta) {} + instrumentation.observe( + version: migration_version, + name: migration_name, + connection: connection, + meta: migration_meta + ) {} end it 'records a valid observation', :aggregate_failures do @@ -98,8 +102,12 @@ def load_observation(result_dir, migration_name) with_them do subject(:observe) do - instrumentation.observe(version: migration_version, name: migration_name, - connection: connection, meta: migration_meta) { raise exception, error_message } + instrumentation.observe( + version: migration_version, + name: migration_name, + connection: connection, + meta: migration_meta + ) { raise exception, error_message } end context 'retrieving observations' do diff --git a/spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb b/spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb index 31a194ae8837df1651f2e5f9327c1dd59b95f52d..660c4347ffa49c3dc20a146901d8f09604a57dc2 100644 --- a/spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb +++ b/spec/lib/gitlab/database/migrations/test_batched_background_runner_spec.rb @@ -80,8 +80,11 @@ def queue_migration( end subject(:sample_migration) do - described_class.new(result_dir: result_dir, connection: connection, - from_id: from_id).run_jobs(for_duration: 1.minute) + described_class.new( + result_dir: result_dir, + connection: connection, + from_id: from_id + ).run_jobs(for_duration: 1.minute) end it 'runs sampled jobs from the batched background migration' do @@ -125,12 +128,19 @@ def queue_migration( calls << args end - queue_migration(migration_name, table_name, :id, - job_interval: 5.minutes, - batch_size: 100) + queue_migration( + migration_name, + table_name, + :id, + job_interval: 5.minutes, + batch_size: 100 + ) - described_class.new(result_dir: result_dir, connection: connection, - from_id: from_id).run_jobs(for_duration: 3.minutes) + described_class.new( + result_dir: result_dir, + connection: connection, + from_id: from_id + ).run_jobs(for_duration: 3.minutes) expect(calls).not_to be_empty end @@ -142,13 +152,19 @@ def queue_migration( calls << args end - queue_migration(migration_name, table_name, :id, - job_interval: 5.minutes, - batch_size: num_rows_in_table * 2, - sub_batch_size: num_rows_in_table * 2) + queue_migration( + migration_name, + table_name, :id, + job_interval: 5.minutes, + batch_size: num_rows_in_table * 2, + sub_batch_size: num_rows_in_table * 2 + ) - described_class.new(result_dir: result_dir, connection: connection, - from_id: from_id).run_jobs(for_duration: 3.minutes) + described_class.new( + result_dir: result_dir, + connection: connection, + from_id: from_id + ).run_jobs(for_duration: 3.minutes) expect(calls.size).to eq(1) end @@ -161,13 +177,20 @@ def queue_migration( calls << args end - queue_migration(migration_name, table_name, :id, - job_interval: 5.minutes, - batch_size: num_rows_in_table * 2, - sub_batch_size: num_rows_in_table * 2) - - described_class.new(result_dir: result_dir, connection: connection, - from_id: from_id).run_jobs(for_duration: 3.minutes) + queue_migration( + migration_name, + table_name, + :id, + job_interval: 5.minutes, + batch_size: num_rows_in_table * 2, + sub_batch_size: num_rows_in_table * 2 + ) + + described_class.new( + result_dir: result_dir, + connection: connection, + from_id: from_id + ).run_jobs(for_duration: 3.minutes) expect(calls.count).to eq(0) end @@ -181,26 +204,41 @@ def queue_migration( it 'runs all pending jobs based on the last migration id' do old_migration = define_background_migration(migration_name) - queue_migration(migration_name, table_name, :id, - job_interval: 5.minutes, - batch_size: 100) + queue_migration( + migration_name, + table_name, + :id, + job_interval: 5.minutes, + batch_size: 100 + ) last_id new_migration = define_background_migration('NewMigration') { travel 1.second } - queue_migration('NewMigration', table_name, :id, - job_interval: 5.minutes, - batch_size: 10, - sub_batch_size: 5) + queue_migration( + 'NewMigration', + table_name, + :id, + job_interval: 5.minutes, + batch_size: 10, + sub_batch_size: 5 + ) other_new_migration = define_background_migration('NewMigration2') { travel 2.seconds } - queue_migration('NewMigration2', table_name, :id, - job_interval: 5.minutes, - batch_size: 10, - sub_batch_size: 5) + queue_migration( + 'NewMigration2', + table_name, + :id, + job_interval: 5.minutes, + batch_size: 10, + sub_batch_size: 5 + ) expect_migration_runs(new_migration => 3, other_new_migration => 2, old_migration => 0) do - described_class.new(result_dir: result_dir, connection: connection, - from_id: last_id).run_jobs(for_duration: 5.seconds) + described_class.new( + result_dir: result_dir, + connection: connection, + from_id: last_id + ).run_jobs(for_duration: 5.seconds) end end end diff --git a/spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb b/spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb index 04940028aeefde1a2ae79c22528866d3fbe965df..eb78d836be086497040165ed245bc9b72c72dbb3 100644 --- a/spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb +++ b/spec/lib/gitlab/database/partitioning/detached_partition_dropper_spec.rb @@ -57,17 +57,19 @@ def create_partition(name:, from:, to:, attached:, drop_after:, table: :_test_pa SQL end - Postgresql::DetachedPartition.create!(table_name: name, - drop_after: drop_after) + Postgresql::DetachedPartition.create!(table_name: name, drop_after: drop_after) end describe '#perform' do context 'when the partition should not be dropped yet' do it 'does not drop the partition' do - create_partition(name: :_test_partition, - from: 2.months.ago, to: 1.month.ago, - attached: false, - drop_after: 1.day.from_now) + create_partition( + name: :_test_partition, + from: 2.months.ago, + to: 1.month.ago, + attached: false, + drop_after: 1.day.from_now + ) dropper.perform @@ -77,11 +79,13 @@ def create_partition(name:, from:, to:, attached:, drop_after:, table: :_test_pa context 'with a partition to drop' do before do - create_partition(name: :_test_partition, - from: 2.months.ago, - to: 1.month.ago.beginning_of_month, - attached: false, - drop_after: 1.second.ago) + create_partition( + name: :_test_partition, + from: 2.months.ago, + to: 1.month.ago.beginning_of_month, + attached: false, + drop_after: 1.second.ago + ) end it 'drops the partition' do @@ -159,11 +163,13 @@ def create_partition(name:, from:, to:, attached:, drop_after:, table: :_test_pa context 'when the partition to drop is still attached to its table' do before do - create_partition(name: :_test_partition, - from: 2.months.ago, - to: 1.month.ago.beginning_of_month, - attached: true, - drop_after: 1.second.ago) + create_partition( + name: :_test_partition, + from: 2.months.ago, + to: 1.month.ago.beginning_of_month, + attached: true, + drop_after: 1.second.ago + ) end it 'does not drop the partition, but does remove the DetachedPartition entry' do @@ -192,17 +198,21 @@ def create_partition(name:, from:, to:, attached:, drop_after:, table: :_test_pa context 'with multiple partitions to drop' do before do - create_partition(name: :_test_partition_1, - from: 3.months.ago, - to: 2.months.ago, - attached: false, - drop_after: 1.second.ago) - - create_partition(name: :_test_partition_2, - from: 2.months.ago, - to: 1.month.ago, - attached: false, - drop_after: 1.second.ago) + create_partition( + name: :_test_partition_1, + from: 3.months.ago, + to: 2.months.ago, + attached: false, + drop_after: 1.second.ago + ) + + create_partition( + name: :_test_partition_2, + from: 2.months.ago, + to: 1.month.ago, + attached: false, + drop_after: 1.second.ago + ) end it 'drops both partitions' do diff --git a/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb b/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb index 3afa338fdf7ea00de534b653cd9eaee00c2bf731..8b18e5b6d081533bf01b177dcf2d6d027f3d971f 100644 --- a/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb +++ b/spec/lib/gitlab/database/partitioning/monthly_strategy_spec.rb @@ -235,8 +235,12 @@ subject { described_class.new(model, partitioning_key, retain_for: 3.months).extra_partitions } it 'prunes the unbounded partition ending 2020-05-01' do - min_value_to_may = Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', - partition_name: '_test_partitioned_test_000000') + min_value_to_may = Gitlab::Database::Partitioning::TimePartition.new( + model.table_name, + nil, + '2020-05-01', + partition_name: '_test_partitioned_test_000000' + ) expect(subject).to contain_exactly(min_value_to_may) end @@ -247,8 +251,18 @@ it 'prunes the unbounded partition and the partition for May-June' do expect(subject).to contain_exactly( - Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000'), - Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: '_test_partitioned_test_202005') + Gitlab::Database::Partitioning::TimePartition.new( + model.table_name, + nil, + '2020-05-01', + partition_name: '_test_partitioned_test_000000' + ), + Gitlab::Database::Partitioning::TimePartition.new( + model.table_name, + '2020-05-01', + '2020-06-01', + partition_name: '_test_partitioned_test_202005' + ) ) end @@ -257,8 +271,18 @@ it 'prunes empty partitions' do expect(subject).to contain_exactly( - Gitlab::Database::Partitioning::TimePartition.new(model.table_name, nil, '2020-05-01', partition_name: '_test_partitioned_test_000000'), - Gitlab::Database::Partitioning::TimePartition.new(model.table_name, '2020-05-01', '2020-06-01', partition_name: '_test_partitioned_test_202005') + Gitlab::Database::Partitioning::TimePartition.new( + model.table_name, + nil, + '2020-05-01', + partition_name: '_test_partitioned_test_000000' + ), + Gitlab::Database::Partitioning::TimePartition.new( + model.table_name, + '2020-05-01', + '2020-06-01', + partition_name: '_test_partitioned_test_202005' + ) ) end diff --git a/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb b/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb index ac4d345271e3c13acfb8a7198a5b986922426df5..9ca0a1b6e573ff3c31d268b372de4102f09dc301 100644 --- a/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb +++ b/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb @@ -15,9 +15,12 @@ let(:detach_partition_if) { double('detach_partition_if') } subject(:strategy) do - described_class.new(model, :partition, - next_partition_if: next_partition_if, - detach_partition_if: detach_partition_if) + described_class.new( + model, + :partition, + next_partition_if: next_partition_if, + detach_partition_if: detach_partition_if + ) end before do @@ -213,9 +216,9 @@ include PartitionedTable partitioned_by :partition, - strategy: :sliding_list, - next_partition_if: proc { false }, - detach_partition_if: proc { false } + strategy: :sliding_list, + next_partition_if: proc { false }, + detach_partition_if: proc { false } end end.to raise_error(/ignored_columns/) end @@ -228,9 +231,9 @@ self.ignored_columns = [:partition] partitioned_by :partition, - strategy: :sliding_list, - next_partition_if: proc { false }, - detach_partition_if: proc { false } + strategy: :sliding_list, + next_partition_if: proc { false }, + detach_partition_if: proc { false } end end.not_to raise_error end @@ -255,9 +258,9 @@ def self.detach_partition_if_wrapper(...) detach_partition?(...) end partitioned_by :partition, - strategy: :sliding_list, - next_partition_if: method(:next_partition_if_wrapper), - detach_partition_if: method(:detach_partition_if_wrapper) + strategy: :sliding_list, + next_partition_if: method(:next_partition_if_wrapper), + detach_partition_if: method(:detach_partition_if_wrapper) def self.next_partition?(current_partition); end diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb index a81c8a5a49c174d704176e6a0730d2926bb228f7..aa64488530612f50161bba1a8bed3bf838b37a94 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/index_helpers_spec.rb @@ -99,8 +99,11 @@ def expect_add_concurrent_index_and_call_original(table, column, index) expect(migration).to receive(:add_index) .with(table_name, column_name, { name: index_name, where: 'x > 0', unique: true }) - migration.add_concurrent_partitioned_index(table_name, column_name, - { name: index_name, where: 'x > 0', unique: true }) + migration.add_concurrent_partitioned_index( + table_name, + column_name, + { name: index_name, where: 'x > 0', unique: true } + ) end end diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb index 6a9470443178a9fbb90286c98f10471633d38a4a..182b69603846638b4b2140f0ad5d77763b9c224c 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb @@ -51,13 +51,15 @@ end it 'delegates to a method on List::ConvertTable' do - expect_next_instance_of(Gitlab::Database::Partitioning::List::ConvertTable, - migration_context: migration, - table_name: source_table, - parent_table_name: partitioned_table, - partitioning_column: partition_column, - zero_partition_value: min_date, - **extra_options) do |converter| + expect_next_instance_of( + Gitlab::Database::Partitioning::List::ConvertTable, + migration_context: migration, + table_name: source_table, + parent_table_name: partitioned_table, + partitioning_column: partition_column, + zero_partition_value: min_date, + **extra_options + ) do |converter| expect(converter).to receive(expected_method) end @@ -70,11 +72,13 @@ let(:lock_tables) { [source_table] } let(:expected_method) { :partition } let(:migrate) do - migration.convert_table_to_first_list_partition(table_name: source_table, - partitioning_column: partition_column, - parent_table_name: partitioned_table, - initial_partitioning_value: min_date, - lock_tables: lock_tables) + migration.convert_table_to_first_list_partition( + table_name: source_table, + partitioning_column: partition_column, + parent_table_name: partitioned_table, + initial_partitioning_value: min_date, + lock_tables: lock_tables + ) end end end @@ -83,10 +87,12 @@ it_behaves_like 'delegates to ConvertTable' do let(:expected_method) { :revert_partitioning } let(:migrate) do - migration.revert_converting_table_to_first_list_partition(table_name: source_table, - partitioning_column: partition_column, - parent_table_name: partitioned_table, - initial_partitioning_value: min_date) + migration.revert_converting_table_to_first_list_partition( + table_name: source_table, + partitioning_column: partition_column, + parent_table_name: partitioned_table, + initial_partitioning_value: min_date + ) end end end @@ -95,11 +101,13 @@ it_behaves_like 'delegates to ConvertTable' do let(:expected_method) { :prepare_for_partitioning } let(:migrate) do - migration.prepare_constraint_for_list_partitioning(table_name: source_table, - partitioning_column: partition_column, - parent_table_name: partitioned_table, - initial_partitioning_value: min_date, - async: false) + migration.prepare_constraint_for_list_partitioning( + table_name: source_table, + partitioning_column: partition_column, + parent_table_name: partitioned_table, + initial_partitioning_value: min_date, + async: false + ) end end end @@ -108,10 +116,12 @@ it_behaves_like 'delegates to ConvertTable' do let(:expected_method) { :revert_preparation_for_partitioning } let(:migrate) do - migration.revert_preparing_constraint_for_list_partitioning(table_name: source_table, - partitioning_column: partition_column, - parent_table_name: partitioned_table, - initial_partitioning_value: min_date) + migration.revert_preparing_constraint_for_list_partitioning( + table_name: source_table, + partitioning_column: partition_column, + parent_table_name: partitioned_table, + initial_partitioning_value: min_date + ) end end end diff --git a/spec/lib/gitlab/database/postgres_constraint_spec.rb b/spec/lib/gitlab/database/postgres_constraint_spec.rb index 75084a691150f91e189879cf24156c4fb4a2e97e..140180540e0f223a8c70f98614be7c247574bdac 100644 --- a/spec/lib/gitlab/database/postgres_constraint_spec.rb +++ b/spec/lib/gitlab/database/postgres_constraint_spec.rb @@ -51,9 +51,11 @@ subject(:check_constraints) { described_class.check_constraints.by_table_identifier(table_identifier) } it 'finds check constraints for the table' do - expect(check_constraints.map(&:name)).to contain_exactly(check_constraint_a_positive, - check_constraint_a_gt_b, - invalid_constraint_a) + expect(check_constraints.map(&:name)).to contain_exactly( + check_constraint_a_positive, + check_constraint_a_gt_b, + invalid_constraint_a + ) end it 'includes columns for the check constraints', :aggregate_failures do @@ -108,8 +110,12 @@ describe '#including_column' do it 'only matches constraints on the given column' do constraints_on_a = described_class.by_table_identifier(table_identifier).including_column('a').map(&:name) - expect(constraints_on_a).to contain_exactly(check_constraint_a_positive, check_constraint_a_gt_b, - unique_constraint_a, invalid_constraint_a) + expect(constraints_on_a).to contain_exactly( + check_constraint_a_positive, + check_constraint_a_gt_b, + unique_constraint_a, + invalid_constraint_a + ) end end diff --git a/spec/lib/gitlab/database/tables_truncate_spec.rb b/spec/lib/gitlab/database/tables_truncate_spec.rb index e41c7d34378c4b37623dc3bdf97a026144b1f7c2..350e36ff1f13edd496b471db854c09bc1e98f71b 100644 --- a/spec/lib/gitlab/database/tables_truncate_spec.rb +++ b/spec/lib/gitlab/database/tables_truncate_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::Database::TablesTruncate, :reestablished_active_record_base, - :suppress_gitlab_schemas_validate_connection, feature_category: :cell do + :suppress_gitlab_schemas_validate_connection, feature_category: :cell do include MigrationsHelpers let(:min_batch_size) { 1 }