Skip to content
Snippets Groups Projects
Commit ddd2a256 authored by blackst0ne's avatar blackst0ne
Browse files

Replace 'Sidekiq::Testing.inline!' with 'perform_enqueued_jobs'

`perform_enqueued_jobs` is a Sidekiq method.
Using this method violates the Dependency inversion principle[0].

This commit replaces `perform_enqueued_jobs` with ActiveJob's abstract
method `perform_enqueued_jobs` in specs.

[0]: https://en.wikipedia.org/wiki/Dependency_inversion_principle
parent dc7b4b7b
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 30 additions and 25 deletions
---
title: Replace 'Sidekiq::Testing.inline!' with 'perform_enqueued_jobs'
merge_request: 20768
author: "@blackst0ne"
type: other
require './spec/support/sidekiq'
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
Gitlab::Seeder.quiet do
project_urls = [
'https://gitlab.com/gitlab-org/gitlab-test.git',
Loading
Loading
require './spec/support/sidekiq'
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
Gitlab::Seeder.quiet do
Group.all.each do |group|
User.all.sample(4).each do |user|
Loading
Loading
Loading
Loading
@@ -78,7 +78,7 @@ class Gitlab::Seeder::CycleAnalytics
 
def seed!
Sidekiq::Worker.skipping_transaction_check do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
issues = create_issues
puts '.'
 
Loading
Loading
require './spec/support/sidekiq'
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
Gitlab::Seeder.quiet do
flag = 'SEED_NESTED_GROUPS'
 
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ class Gitlab::Seeder::LabeledIssues
end
 
def seed!
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
group = create_group
 
create_projects(group)
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ describe 'GPG signed commits', :js do
user = create :user, email: 'unrelated.user@example.org'
project.add_maintainer(user)
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
 
Loading
Loading
@@ -21,7 +21,7 @@ describe 'GPG signed commits', :js do
end
 
# user changes his email which makes the gpg key verified
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
user.skip_reconfirmation!
user.update!(email: GpgHelpers::User1.emails.first)
end
Loading
Loading
@@ -48,7 +48,7 @@ describe 'GPG signed commits', :js do
end
 
# user adds the gpg key which makes the signature valid
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
 
Loading
Loading
@@ -66,7 +66,7 @@ describe 'GPG signed commits', :js do
end
 
let(:user_1_key) do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user_1
end
end
Loading
Loading
@@ -79,7 +79,7 @@ describe 'GPG signed commits', :js do
end
 
let(:user_2_key) do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User2.public_key, user: user_2
end
end
Loading
Loading
Loading
Loading
@@ -65,7 +65,7 @@ describe Gitlab::HashedStorage::Migrator do
end
 
it 'migrate project' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
subject.migrate(project)
end
 
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do
end
 
it 'correctly processes services' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(services_table.where(confidential_note_events: nil).count).to eq 4
expect(services_table.where(confidential_note_events: true).count).to eq 1
 
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
end
 
it 'schedules background migrations' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(jobs.where(stage_id: nil).count).to eq 5
 
migrate!
Loading
Loading
Loading
Loading
@@ -34,7 +34,7 @@ describe MigrateStagesStatuses, :sidekiq, :migration do
end
 
it 'correctly migrates stages statuses' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(stages.where(status: nil).count).to eq 3
 
migrate!
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@ describe NormalizeLdapExternUids, :migration, :sidekiq do
end
 
it 'migrates the LDAP identities' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
migrate!
identities.where(id: 1..4).each do |identity|
expect(identity.extern_uid).to eq("uid=foo #{identity.id},ou=people,dc=example,dc=com")
Loading
Loading
@@ -47,7 +47,7 @@ describe NormalizeLdapExternUids, :migration, :sidekiq do
end
 
it 'does not modify non-LDAP identities' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
migrate!
identity = identities.last
expect(identity.extern_uid).to eq(" uid = foo 5, ou = People, dc = example, dc = com ")
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
end
 
it 'schedules background migrations' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(GpgKeySubkey.count).to eq(0)
 
migrate!
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
end
 
it 'schedules background migrations' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL'
 
expect(merge_request_diffs.where(non_empty).count).to eq 3
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
end
 
it 'migrates the data' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL'
 
expect(merge_request_diffs.where(non_empty).count).to eq 3
Loading
Loading
Loading
Loading
@@ -53,7 +53,7 @@ describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :si
end
 
it 'schedules background migrations' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(merge_requests_table.where(latest_merge_request_diff_id: nil).count).to eq 3
 
migrate!
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do
end
 
it 'correctly processes web hooks' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 4
expect(web_hooks_table.where(confidential_note_events: true).count).to eq 1
 
Loading
Loading
Loading
Loading
@@ -179,7 +179,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
 
it 'migrates data to object storage' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
subject
 
build_trace_chunk.reload
Loading
Loading
@@ -201,7 +201,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
 
it 'does not migrate data to object storage' do
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
data_store = build_trace_chunk.data_store
 
subject
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@ describe SpamLog do
spam_log = build(:spam_log)
user = spam_log.user
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
spam_log.remove_user(deleted_by: admin)
end
 
Loading
Loading
Loading
Loading
@@ -102,7 +102,7 @@ describe API::ProjectImport do
it 'correctly overrides params during the import' do
override_params = { 'description' => 'Hello world' }
 
Sidekiq::Testing.inline! do
perform_enqueued_jobs do
post api('/projects/import', user),
path: 'test-import',
file: fixture_file_upload(file),
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment