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
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/memory/watchdog/configuration_spec.rb')
-rw-r--r--spec/lib/gitlab/memory/watchdog/configuration_spec.rb47
1 files changed, 32 insertions, 15 deletions
diff --git a/spec/lib/gitlab/memory/watchdog/configuration_spec.rb b/spec/lib/gitlab/memory/watchdog/configuration_spec.rb
index 38a39f6a33a..9242344ead2 100644
--- a/spec/lib/gitlab/memory/watchdog/configuration_spec.rb
+++ b/spec/lib/gitlab/memory/watchdog/configuration_spec.rb
@@ -20,10 +20,14 @@ RSpec.describe Gitlab::Memory::Watchdog::Configuration do
end
end
- describe '#logger' do
- context 'when logger is not set, defaults to stdout logger' do
- it 'defaults to Logger' do
- expect(configuration.logger).to be_an_instance_of(::Gitlab::Logger)
+ describe '#event_reporter' do
+ context 'when event reporter is not set' do
+ before do
+ allow(Gitlab::Metrics).to receive(:counter)
+ end
+
+ it 'defaults to EventReporter' do
+ expect(configuration.event_reporter).to be_an_instance_of(::Gitlab::Memory::Watchdog::EventReporter)
end
end
end
@@ -38,6 +42,8 @@ RSpec.describe Gitlab::Memory::Watchdog::Configuration do
describe '#monitors' do
context 'when monitors are configured to be used' do
+ let(:monitor_name1) { :monitor1 }
+ let(:monitor_name2) { :monitor2 }
let(:payload1) do
{
message: 'monitor_1_text',
@@ -96,7 +102,17 @@ RSpec.describe Gitlab::Memory::Watchdog::Configuration do
expect(payloads).to eq([payload1, payload2])
expect(thresholds).to eq([false, true])
expect(strikes).to eq([false, true])
- expect(monitor_names).to eq([:monitor1, :monitor2])
+ expect(monitor_names).to eq([monitor_name1, monitor_name2])
+ end
+
+ it 'monitors are not empty' do
+ expect(configuration.monitors).not_to be_empty
+ end
+ end
+
+ context 'when monitors are not configured' do
+ it 'monitors are empty' do
+ expect(configuration.monitors).to be_empty
end
end
@@ -119,18 +135,19 @@ RSpec.describe Gitlab::Memory::Watchdog::Configuration do
include_examples 'executes monitors and returns correct results'
end
- end
- context 'when same monitor class is configured twice' do
- before do
- configuration.monitors.push monitor_class_1, max_strikes: 1
- configuration.monitors.push monitor_class_1, max_strikes: 1
- end
+ context 'when monitors are configured with monitor name' do
+ let(:monitor_name1) { :mon_one }
+ let(:monitor_name2) { :mon_two }
- it 'calls same monitor only once' do
- expect do |b|
- configuration.monitors.call_each(&b)
- end.to yield_control.once
+ before do
+ configuration.monitors do |stack|
+ stack.push monitor_class_1, false, { message: 'monitor_1_text' }, max_strikes: 5, monitor_name: :mon_one
+ stack.push monitor_class_2, true, { message: 'monitor_2_text' }, max_strikes: 0, monitor_name: :mon_two
+ end
+ end
+
+ include_examples 'executes monitors and returns correct results'
end
end
end