Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-27 06:08:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-27 06:08:46 +0300
commit75208e7c925434b876e038603f81165f93ce43c5 (patch)
tree7f7816ddf7ce4c5344994df0a8406ea94990a9a0 /spec
parent760a58cc78d5646d957bf10d8e86d940d423dfbe (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/db/schema_spec.rb1
-rw-r--r--spec/models/batched_git_ref_updates/deletion_spec.rb125
-rw-r--r--spec/models/ci/persistent_ref_spec.rb28
-rw-r--r--spec/models/ci/pipeline_spec.rb46
-rw-r--r--spec/models/merge_request_spec.rb31
-rw-r--r--spec/services/batched_git_ref_updates/cleanup_scheduler_service_spec.rb55
-rw-r--r--spec/services/batched_git_ref_updates/project_cleanup_service_spec.rb98
-rw-r--r--spec/services/git/base_hooks_service_spec.rb12
-rw-r--r--spec/services/merge_requests/cleanup_refs_service_spec.rb1
-rw-r--r--spec/services/merge_requests/merge_to_ref_service_spec.rb23
-rw-r--r--spec/workers/batched_git_ref_updates/cleanup_scheduler_worker_spec.rb31
-rw-r--r--spec/workers/batched_git_ref_updates/project_cleanup_worker_spec.rb33
-rw-r--r--spec/workers/clusters/agents/notify_git_push_worker_spec.rb12
13 files changed, 418 insertions, 78 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index bb50c7cf69d..2dfea0c7924 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -89,6 +89,7 @@ RSpec.describe 'Database schema', feature_category: :database do
oauth_access_tokens: %w[resource_owner_id application_id],
oauth_applications: %w[owner_id],
p_ci_builds: %w[project_id runner_id user_id erased_by_id trigger_request_id partition_id],
+ p_batched_git_ref_updates_deletions: %w[project_id partition_id],
product_analytics_events_experimental: %w[event_id txn_id user_id],
project_build_artifacts_size_refreshes: %w[last_job_artifact_id],
project_data_transfers: %w[project_id namespace_id],
diff --git a/spec/models/batched_git_ref_updates/deletion_spec.rb b/spec/models/batched_git_ref_updates/deletion_spec.rb
new file mode 100644
index 00000000000..1679e8977b3
--- /dev/null
+++ b/spec/models/batched_git_ref_updates/deletion_spec.rb
@@ -0,0 +1,125 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BatchedGitRefUpdates::Deletion, feature_category: :gitaly do
+ describe '.mark_records_processed' do
+ let_it_be(:deletion_1) { described_class.create!(project_id: 5, ref: 'refs/test/1') }
+ let_it_be(:deletion_2) { described_class.create!(project_id: 1, ref: 'refs/test/2') }
+ let_it_be(:deletion_3) { described_class.create!(project_id: 3, ref: 'refs/test/3') }
+ let_it_be(:deletion_4) { described_class.create!(project_id: 1, ref: 'refs/test/4') }
+ let_it_be(:deletion_5) { described_class.create!(project_id: 4, ref: 'refs/test/5', status: :processed) }
+
+ it 'updates all records' do
+ expect(described_class.status_pending.count).to eq(4)
+ expect(described_class.status_processed.count).to eq(1)
+
+ deletions = described_class.for_project(1).select_ref_and_identity
+ described_class.mark_records_processed(deletions)
+
+ deletions.each do |deletion|
+ expect(deletion.reload.status).to eq("processed")
+ end
+
+ expect(described_class.status_pending.count).to eq(2)
+ expect(described_class.status_processed.count).to eq(3)
+ end
+ end
+
+ describe 'sliding_list partitioning' do
+ let(:partition_manager) { Gitlab::Database::Partitioning::PartitionManager.new(described_class) }
+
+ describe 'next_partition_if callback' do
+ let(:active_partition) { described_class.partitioning_strategy.active_partition }
+
+ subject(:value) { described_class.partitioning_strategy.next_partition_if.call(active_partition) }
+
+ context 'when the partition is empty' do
+ it { is_expected.to eq(false) }
+ end
+
+ context 'when the partition has records' do
+ before do
+ described_class.create!(project_id: 1, ref: 'refs/test/1', status: :processed)
+ described_class.create!(project_id: 2, ref: 'refs/test/2', status: :pending)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+
+ context 'when the first record of the partition is older than PARTITION_DURATION' do
+ before do
+ described_class.create!(
+ project_id: 1,
+ ref: 'refs/test/1',
+ created_at: (described_class::PARTITION_DURATION + 1.day).ago)
+
+ described_class.create!(project_id: 2, ref: 'refs/test/2')
+ end
+
+ it { is_expected.to eq(true) }
+ end
+ end
+
+ describe 'detach_partition_if callback' do
+ let(:active_partition) { described_class.partitioning_strategy.active_partition }
+
+ subject(:value) { described_class.partitioning_strategy.detach_partition_if.call(active_partition) }
+
+ context 'when the partition contains unprocessed records' do
+ before do
+ described_class.create!(project_id: 1, ref: 'refs/test/1')
+ described_class.create!(project_id: 2, ref: 'refs/test/2', status: :processed)
+ end
+
+ it { is_expected.to eq(false) }
+ end
+
+ context 'when the partition contains only processed records' do
+ before do
+ described_class.create!(project_id: 1, ref: 'refs/test/1', status: :processed)
+ described_class.create!(project_id: 2, ref: 'refs/test/2', status: :processed)
+ end
+
+ it { is_expected.to eq(true) }
+ end
+ end
+
+ describe 'the behavior of the strategy' do
+ it 'moves records to new partitions as time passes', :freeze_time do
+ # We start with partition 1
+ expect(described_class.partitioning_strategy.current_partitions.map(&:value)).to eq([1])
+
+ # it's not a day old yet so no new partitions are created
+ partition_manager.sync_partitions
+
+ expect(described_class.partitioning_strategy.current_partitions.map(&:value)).to eq([1])
+
+ # add one record so the next partition will be created
+ described_class.create!(project_id: 1, ref: 'refs/test/1')
+
+ # after traveling forward a day
+ travel(described_class::PARTITION_DURATION + 1.second)
+
+ # a new partition is created
+ partition_manager.sync_partitions
+
+ expect(described_class.partitioning_strategy.current_partitions.map(&:value)).to contain_exactly(1, 2)
+
+ # and we can insert to the new partition
+ described_class.create!(project_id: 2, ref: 'refs/test/2')
+
+ # after processing old records
+ described_class.mark_records_processed(described_class.for_partition(1).select_ref_and_identity)
+
+ partition_manager.sync_partitions
+
+ # the old one is removed
+ expect(described_class.partitioning_strategy.current_partitions.map(&:value)).to eq([2])
+
+ # and we only have the newly created partition left.
+ expect(described_class.count).to eq(1)
+ end
+ end
+ end
+end
diff --git a/spec/models/ci/persistent_ref_spec.rb b/spec/models/ci/persistent_ref_spec.rb
index ecaa8f59ecf..ed4ea02d8ba 100644
--- a/spec/models/ci/persistent_ref_spec.rb
+++ b/spec/models/ci/persistent_ref_spec.rb
@@ -3,26 +3,40 @@
require 'spec_helper'
RSpec.describe Ci::PersistentRef do
- it 'cleans up persistent refs after pipeline finished', :sidekiq_inline do
+ it 'cleans up persistent refs async after pipeline finished' do
pipeline = create(:ci_pipeline, :running)
- expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async).with(pipeline.id)
-
- pipeline.succeed!
+ expect { pipeline.succeed! }
+ .to change { ::BatchedGitRefUpdates::Deletion.count }
+ .by(1)
end
- context 'when pipeline_cleanup_ref_worker_async is disabled' do
+ context 'when pipeline_delete_gitaly_refs_in_batches is disabled' do
before do
- stub_feature_flags(pipeline_cleanup_ref_worker_async: false)
+ stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false)
end
it 'cleans up persistent refs after pipeline finished' do
pipeline = create(:ci_pipeline, :running)
- expect(pipeline.persistent_ref).to receive(:delete).once
+ expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async).with(pipeline.id)
pipeline.succeed!
end
+
+ context 'when pipeline_cleanup_ref_worker_async is disabled' do
+ before do
+ stub_feature_flags(pipeline_cleanup_ref_worker_async: false)
+ end
+
+ it 'cleans up persistent refs after pipeline finished' do
+ pipeline = create(:ci_pipeline, :running)
+
+ expect(pipeline.persistent_ref).to receive(:delete).once
+
+ pipeline.succeed!
+ end
+ end
end
describe '#exist?' do
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index ae3725a0b08..1e3ce8bc656 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -1328,33 +1328,47 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep, feature_category:
%w[succeed! drop! cancel! skip! block! delay!].each do |action|
context "when the pipeline received #{action} event" do
- it 'deletes a persistent ref asynchronously', :sidekiq_inline do
- expect(pipeline.persistent_ref).not_to receive(:delete_refs)
-
- expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async)
- .with(pipeline.id).and_call_original
-
- expect_next_instance_of(Ci::PersistentRef) do |persistent_ref|
- expect(persistent_ref).to receive(:delete_refs)
- .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}").once
- end
+ it 'deletes a persistent ref asynchronously' do
+ expect(pipeline.persistent_ref).to receive(:async_delete)
+ expect(pipeline.persistent_ref).not_to receive(:delete)
pipeline.public_send(action)
end
- context 'when pipeline_cleanup_ref_worker_async is disabled' do
+ context 'when pipeline_delete_gitaly_refs_in_batches is disabled' do
before do
- stub_feature_flags(pipeline_cleanup_ref_worker_async: false)
+ stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false)
end
- it 'deletes a persistent ref synchronously' do
- expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id)
+ it 'deletes a persistent ref asynchronously via ::Ci::PipelineCleanupRefWorker', :sidekiq_inline do
+ expect(pipeline.persistent_ref).not_to receive(:delete_refs)
- expect(pipeline.persistent_ref).to receive(:delete_refs).once
- .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}")
+ expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async)
+ .with(pipeline.id).and_call_original
+
+ expect_next_instance_of(Ci::PersistentRef) do |persistent_ref|
+ expect(persistent_ref).to receive(:delete_refs)
+ .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}").once
+ end
pipeline.public_send(action)
end
+
+ context 'when pipeline_cleanup_ref_worker_async is disabled' do
+ before do
+ stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false)
+ stub_feature_flags(pipeline_cleanup_ref_worker_async: false)
+ end
+
+ it 'deletes a persistent ref synchronously' do
+ expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id)
+
+ expect(pipeline.persistent_ref).to receive(:delete_refs).once
+ .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}")
+
+ pipeline.public_send(action)
+ end
+ end
end
end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index bf71d289105..1dfd14c0993 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -5124,24 +5124,39 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev
let(:merge_request) { build(:merge_request, source_project: create(:project, :repository)) }
- it 'does schedule MergeRequests::CleanupRefWorker' do
- expect(MergeRequests::CleanupRefWorker).to receive(:perform_async).with(merge_request.id, 'train')
+ it 'deletes refs asynchronously' do
+ expect(merge_request.target_project.repository)
+ .to receive(:async_delete_refs)
+ .with(merge_request.train_ref_path)
subject
end
- context 'when merge_request_cleanup_ref_worker_async is disabled' do
+ context 'when merge_request_delete_gitaly_refs_in_batches is disabled' do
before do
- stub_feature_flags(merge_request_cleanup_ref_worker_async: false)
+ stub_feature_flags(merge_request_delete_gitaly_refs_in_batches: false)
end
- it 'deletes all refs from the target project' do
- expect(merge_request.target_project.repository)
- .to receive(:delete_refs)
- .with(merge_request.train_ref_path)
+ it 'does schedule MergeRequests::CleanupRefWorker' do
+ expect(MergeRequests::CleanupRefWorker).to receive(:perform_async).with(merge_request.id, 'train')
subject
end
+
+ context 'when merge_request_cleanup_ref_worker_async is disabled' do
+ before do
+ stub_feature_flags(merge_request_delete_gitaly_refs_in_batches: false)
+ stub_feature_flags(merge_request_cleanup_ref_worker_async: false)
+ end
+
+ it 'deletes all refs from the target project' do
+ expect(merge_request.target_project.repository)
+ .to receive(:delete_refs)
+ .with(merge_request.train_ref_path)
+
+ subject
+ end
+ end
end
end
diff --git a/spec/services/batched_git_ref_updates/cleanup_scheduler_service_spec.rb b/spec/services/batched_git_ref_updates/cleanup_scheduler_service_spec.rb
new file mode 100644
index 00000000000..50081a5e9e7
--- /dev/null
+++ b/spec/services/batched_git_ref_updates/cleanup_scheduler_service_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BatchedGitRefUpdates::CleanupSchedulerService, feature_category: :gitaly do
+ let(:service) { described_class.new }
+
+ describe '#execute' do
+ before do
+ BatchedGitRefUpdates::Deletion.create!(project_id: 123, ref: 'ref1')
+ BatchedGitRefUpdates::Deletion.create!(project_id: 123, ref: 'ref2')
+ BatchedGitRefUpdates::Deletion.create!(project_id: 456, ref: 'ref3')
+ BatchedGitRefUpdates::Deletion.create!(project_id: 789, ref: 'ref4', status: :processed)
+ end
+
+ it 'schedules ProjectCleanupWorker for each project in pending BatchedGitRefUpdates::Deletion' do
+ project_ids = []
+ expect(BatchedGitRefUpdates::ProjectCleanupWorker)
+ .to receive(:bulk_perform_async_with_contexts) do |deletions, arguments_proc:, context_proc:| # rubocop:disable Lint/UnusedBlockArgument
+ project_ids += deletions.map(&arguments_proc)
+ end
+
+ service.execute
+
+ expect(project_ids).to contain_exactly(123, 456)
+ end
+
+ it 'returns stats' do
+ stats = service.execute
+
+ expect(stats).to eq({
+ total_projects: 2
+ })
+ end
+
+ it 'acquires a lock to avoid running duplicate instances' do
+ expect(service).to receive(:in_lock) # Mock and don't yield
+ .with(described_class.name, retries: 0, ttl: described_class::LOCK_TIMEOUT)
+ expect(BatchedGitRefUpdates::ProjectCleanupWorker).not_to receive(:bulk_perform_async_with_contexts)
+
+ service.execute
+ end
+
+ it 'limits to MAX_PROJECTS before it stops' do
+ stub_const("#{described_class}::BATCH_SIZE", 1)
+ stub_const("#{described_class}::MAX_PROJECTS", 1)
+
+ stats = service.execute
+
+ expect(stats).to eq({
+ total_projects: 1
+ })
+ end
+ end
+end
diff --git a/spec/services/batched_git_ref_updates/project_cleanup_service_spec.rb b/spec/services/batched_git_ref_updates/project_cleanup_service_spec.rb
new file mode 100644
index 00000000000..dcdfdfade3c
--- /dev/null
+++ b/spec/services/batched_git_ref_updates/project_cleanup_service_spec.rb
@@ -0,0 +1,98 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BatchedGitRefUpdates::ProjectCleanupService, feature_category: :gitaly do
+ let(:service) { described_class.new(project1.id) }
+ let_it_be(:project1) { create(:project, :repository) }
+ let_it_be(:project2) { create(:project, :repository) }
+ let!(:project1_ref1) do
+ BatchedGitRefUpdates::Deletion.create!(project_id: project1.id, ref: 'refs/test/project1-ref1')
+ end
+
+ let!(:project1_ref2) do
+ BatchedGitRefUpdates::Deletion.create!(project_id: project1.id, ref: 'refs/test/project1-ref2')
+ end
+
+ let!(:project1_ref3) do
+ BatchedGitRefUpdates::Deletion.create!(project_id: project1.id, ref: 'refs/test/already-processed',
+ status: :processed)
+ end
+
+ let!(:project2_ref1) do
+ BatchedGitRefUpdates::Deletion.create!(project_id: project2.id, ref: 'refs/test/project2-ref1')
+ end
+
+ describe '#execute' do
+ before do
+ project1.repository.create_ref('HEAD', 'refs/test/ref-to-not-be-deleted')
+ project1.repository.create_ref('HEAD', project1_ref1.ref)
+ project1.repository.create_ref('HEAD', project1_ref2.ref)
+ project1.repository.create_ref('HEAD', 'refs/test/already-processed')
+ project2.repository.create_ref('HEAD', project2_ref1.ref)
+ end
+
+ it 'deletes the named refs in batches for the given project only' do
+ expect(test_refs(project1)).to include(
+ 'refs/test/ref-to-not-be-deleted',
+ 'refs/test/already-processed',
+ 'refs/test/project1-ref1',
+ 'refs/test/project1-ref1',
+ 'refs/test/project1-ref2')
+
+ service.execute
+
+ expect(test_refs(project1)).to include(
+ 'refs/test/already-processed',
+ 'refs/test/ref-to-not-be-deleted')
+
+ expect(test_refs(project1)).not_to include(
+ 'refs/test/project1-ref1',
+ 'refs/test/project1-ref2')
+
+ expect(test_refs(project2)).to include('refs/test/project2-ref1')
+ end
+
+ it 'marks the processed BatchedGitRefUpdates::Deletion as processed' do
+ service.execute
+
+ expect(BatchedGitRefUpdates::Deletion.status_pending.map(&:ref)).to contain_exactly('refs/test/project2-ref1')
+ expect(BatchedGitRefUpdates::Deletion.status_processed.map(&:ref)).to contain_exactly(
+ 'refs/test/project1-ref1',
+ 'refs/test/project1-ref2',
+ 'refs/test/already-processed')
+ end
+
+ it 'returns stats' do
+ result = service.execute
+
+ expect(result[:total_deletes]).to eq(2)
+ end
+
+ it 'acquires a lock for the given project_id to avoid running duplicate instances' do
+ expect(service).to receive(:in_lock) # Mock and don't yield
+ .with("#{described_class}/#{project1.id}", retries: 0, ttl: described_class::LOCK_TIMEOUT)
+
+ expect { service.execute }.not_to change { BatchedGitRefUpdates::Deletion.status_pending.count }
+ end
+
+ it 'does nothing when the project does not exist' do
+ result = described_class.new(non_existing_record_id).execute
+
+ expect(result[:total_deletes]).to eq(0)
+ end
+
+ it 'stops after it reaches limit of deleted refs' do
+ stub_const("#{described_class}::QUERY_BATCH_SIZE", 1)
+ stub_const("#{described_class}::MAX_DELETES", 1)
+
+ result = service.execute
+
+ expect(result[:total_deletes]).to eq(1)
+ end
+
+ def test_refs(project)
+ project.repository.list_refs(['refs/test/']).map(&:name)
+ end
+ end
+end
diff --git a/spec/services/git/base_hooks_service_spec.rb b/spec/services/git/base_hooks_service_spec.rb
index 60883db0cd5..e083c8d7316 100644
--- a/spec/services/git/base_hooks_service_spec.rb
+++ b/spec/services/git/base_hooks_service_spec.rb
@@ -363,17 +363,5 @@ RSpec.describe Git::BaseHooksService, feature_category: :source_code_management
subject.execute
end
end
-
- context 'when :notify_kas_on_git_push feature flag is disabled' do
- before do
- stub_feature_flags(notify_kas_on_git_push: false)
- end
-
- it do
- expect(Clusters::Agents::NotifyGitPushWorker).not_to receive(:perform_async)
-
- subject.execute
- end
- end
end
end
diff --git a/spec/services/merge_requests/cleanup_refs_service_spec.rb b/spec/services/merge_requests/cleanup_refs_service_spec.rb
index efb6265e3d8..c818c60ad5f 100644
--- a/spec/services/merge_requests/cleanup_refs_service_spec.rb
+++ b/spec/services/merge_requests/cleanup_refs_service_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe MergeRequests::CleanupRefsService, feature_category: :code_review
describe '#execute' do
before do
+ stub_feature_flags(merge_request_delete_gitaly_refs_in_batches: false)
stub_feature_flags(merge_request_cleanup_ref_worker_async: false)
# Need to re-enable this as it's being stubbed in spec_helper for
diff --git a/spec/services/merge_requests/merge_to_ref_service_spec.rb b/spec/services/merge_requests/merge_to_ref_service_spec.rb
index 4e951f1bc85..5105a275fba 100644
--- a/spec/services/merge_requests/merge_to_ref_service_spec.rb
+++ b/spec/services/merge_requests/merge_to_ref_service_spec.rb
@@ -36,29 +36,6 @@ RSpec.describe MergeRequests::MergeToRefService, feature_category: :code_review_
expect(repository.ref_exists?(target_ref)).to be(true)
expect(ref_head.id).to eq(result[:commit_id])
end
-
- context 'cache_merge_to_ref_calls parameter', :use_clean_rails_memory_store_caching do
- before do
- # warm the cache
- #
- service.execute(merge_request, true)
- end
-
- context 'when true' do
- it 'caches the response', :request_store do
- expect { 3.times { service.execute(merge_request, true) } }
- .not_to change(Gitlab::GitalyClient, :get_request_count)
- end
- end
-
- context 'when false' do
- it 'does not cache the response', :request_store do
- expect(Gitlab::GitalyClient).to receive(:call).at_least(3).times.and_call_original
-
- 3.times { service.execute(merge_request, false) }
- end
- end
- end
end
shared_examples_for 'successfully evaluates pre-condition checks' do
diff --git a/spec/workers/batched_git_ref_updates/cleanup_scheduler_worker_spec.rb b/spec/workers/batched_git_ref_updates/cleanup_scheduler_worker_spec.rb
new file mode 100644
index 00000000000..a52043993b7
--- /dev/null
+++ b/spec/workers/batched_git_ref_updates/cleanup_scheduler_worker_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BatchedGitRefUpdates::CleanupSchedulerWorker, feature_category: :gitaly do
+ let(:stats) { { total_projects: 456 } }
+ let(:service) { instance_double(BatchedGitRefUpdates::CleanupSchedulerService, execute: stats) }
+ let(:worker) { described_class.new }
+
+ describe '#perform' do
+ before do
+ allow(BatchedGitRefUpdates::CleanupSchedulerService).to receive(:new).and_return(service)
+ end
+
+ it 'delegates to CleanupSchedulerService' do
+ expect(service).to receive(:execute)
+
+ worker.perform
+ end
+
+ it 'logs stats' do
+ worker.perform
+
+ expect(worker.logging_extras).to eq({
+ "extra.batched_git_ref_updates_cleanup_scheduler_worker.stats" => { total_projects: 456 }
+ })
+ end
+ end
+
+ it_behaves_like 'an idempotent worker'
+end
diff --git a/spec/workers/batched_git_ref_updates/project_cleanup_worker_spec.rb b/spec/workers/batched_git_ref_updates/project_cleanup_worker_spec.rb
new file mode 100644
index 00000000000..5442b9dd051
--- /dev/null
+++ b/spec/workers/batched_git_ref_updates/project_cleanup_worker_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe BatchedGitRefUpdates::ProjectCleanupWorker, feature_category: :gitaly do
+ let(:stats) { { total_deletes: 456 } }
+ let(:service) { instance_double(BatchedGitRefUpdates::ProjectCleanupService, execute: stats) }
+ let(:worker) { described_class.new }
+
+ describe '#perform' do
+ before do
+ allow(BatchedGitRefUpdates::ProjectCleanupService).to receive(:new).with(123).and_return(service)
+ end
+
+ it 'delegates to ProjectCleanupService' do
+ expect(service).to receive(:execute)
+
+ worker.perform(123)
+ end
+
+ it 'logs stats' do
+ worker.perform(123)
+
+ expect(worker.logging_extras).to eq({
+ "extra.batched_git_ref_updates_project_cleanup_worker.stats" => { total_deletes: 456 }
+ })
+ end
+ end
+
+ it_behaves_like 'an idempotent worker' do
+ let(:job_args) { [123] }
+ end
+end
diff --git a/spec/workers/clusters/agents/notify_git_push_worker_spec.rb b/spec/workers/clusters/agents/notify_git_push_worker_spec.rb
index 561a66b86e9..c6ef8dc3338 100644
--- a/spec/workers/clusters/agents/notify_git_push_worker_spec.rb
+++ b/spec/workers/clusters/agents/notify_git_push_worker_spec.rb
@@ -25,17 +25,5 @@ RSpec.describe Clusters::Agents::NotifyGitPushWorker, feature_category: :deploym
expect { subject }.not_to raise_error
end
end
-
- context 'when the :notify_kas_on_git_push feature flag is disabled' do
- before do
- stub_feature_flags(notify_kas_on_git_push: false)
- end
-
- it 'does not notify KAS' do
- expect(Gitlab::Kas::Client).not_to receive(:new)
-
- subject
- end
- end
end
end