Improve automatic post cleanup worker performances (#24785)

This commit is contained in:
Claire 2023-05-03 10:31:40 +02:00 committed by Tarrien
parent 70c48aa25a
commit 415d94a166

View File

@ -70,7 +70,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
end
end
describe '#get_budget' do
describe '#compute_budget' do
context 'on a single thread' do
let(:process_set_stub) { [ { 'concurrency' => 1, 'queues' => ['push', 'default'] } ] }
@ -112,6 +112,19 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
it 'eventually deletes every deletable toot' do
expect { subject.perform; subject.perform; subject.perform; subject.perform }.to change { Status.count }.by(-20)
end
context 'when given a big budget' do
let(:process_set_stub) { [{ 'concurrency' => 400, 'queues' => %w(push default) }] }
before do
stub_const 'Scheduler::AccountsStatusesCleanupScheduler::MAX_BUDGET', 400
end
it 'correctly handles looping in a single run' do
expect(subject.compute_budget).to eq(400)
expect { subject.perform }.to change { Status.count }.by(-30)
end
end
end
end
end