summaryrefslogtreecommitdiff
path: root/spec/initializers/sidekiq_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/initializers/sidekiq_spec.rb')
-rw-r--r--spec/initializers/sidekiq_spec.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/initializers/sidekiq_spec.rb b/spec/initializers/sidekiq_spec.rb
index e34f59c3427..063dddd8c46 100644
--- a/spec/initializers/sidekiq_spec.rb
+++ b/spec/initializers/sidekiq_spec.rb
@@ -42,4 +42,61 @@ RSpec.describe 'sidekiq' do
it { is_expected.to be_falsey }
end
end
+
+ describe 'load_cron_jobs!' do
+ subject { load_cron_jobs! }
+
+ let(:cron_for_service_ping) { '4 7 * * 4' }
+
+ let(:cron_jobs_settings) do
+ {
+ 'gitlab_service_ping_worker' => {
+ 'cron' => nil,
+ 'job_class' => 'GitlabServicePingWorker'
+ },
+ 'import_export_project_cleanup_worker' => {
+ 'cron' => '0 * * * *',
+ 'job_class' => 'ImportExportProjectCleanupWorker'
+ },
+ "invalid_worker" => {
+ 'cron' => '0 * * * *'
+ }
+ }
+ end
+
+ let(:cron_jobs_hash) do
+ {
+ 'gitlab_service_ping_worker' => {
+ 'cron' => cron_for_service_ping,
+ 'class' => 'GitlabServicePingWorker'
+ },
+ 'import_export_project_cleanup_worker' => {
+ 'cron' => '0 * * * *',
+ 'class' => 'ImportExportProjectCleanupWorker'
+ }
+ }
+ end
+
+ around do |example|
+ original_settings = Gitlab.config['cron_jobs']
+ Gitlab.config['cron_jobs'] = cron_jobs_settings
+
+ example.run
+
+ Gitlab.config['cron_jobs'] = original_settings
+ end
+
+ it 'loads the cron jobs into sidekiq-cron' do
+ allow(Settings).to receive(:cron_for_service_ping).and_return(cron_for_service_ping)
+
+ expect(Sidekiq::Cron::Job).to receive(:load_from_hash!).with(cron_jobs_hash)
+
+ if Gitlab.ee?
+ expect(Gitlab::Mirror).to receive(:configure_cron_job!)
+ expect(Gitlab::Geo).to receive(:configure_cron_jobs!)
+ end
+
+ subject
+ end
+ end
end