blob: 063dddd8c46ae62b7530af021099d17d1a8e5599 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'sidekiq' do
describe 'enable_reliable_fetch?' do
subject { enable_reliable_fetch? }
context 'when gitlab_sidekiq_reliable_fetcher is enabled' do
before do
stub_feature_flags(gitlab_sidekiq_reliable_fetcher: true)
end
it { is_expected.to be_truthy }
end
context 'when gitlab_sidekiq_reliable_fetcher is disabled' do
before do
stub_feature_flags(gitlab_sidekiq_reliable_fetcher: false)
end
it { is_expected.to be_falsey }
end
end
describe 'enable_semi_reliable_fetch_mode?' do
subject { enable_semi_reliable_fetch_mode? }
context 'when gitlab_sidekiq_enable_semi_reliable_fetcher is enabled' do
before do
stub_feature_flags(gitlab_sidekiq_enable_semi_reliable_fetcher: true)
end
it { is_expected.to be_truthy }
end
context 'when gitlab_sidekiq_enable_semi_reliable_fetcher is disabled' do
before do
stub_feature_flags(gitlab_sidekiq_enable_semi_reliable_fetcher: false)
end
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
|