summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-06-10 16:09:40 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-06-10 16:09:40 +0000
commit497acb167078d62c0cec7bc5ff9be1be6cd2fe4a (patch)
tree659d933f1173b00b44200f006eb6dae02fa29f56 /spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb
parentd5e8e1ef1341c65fe9105c38b9532239462ace9d (diff)
downloadgitlab-ce-497acb167078d62c0cec7bc5ff9be1be6cd2fe4a.tar.gz
Add metric for measuring PumaWorkerKiller activity
PumaWorkerKiller is used for periodically checking and killing workers (the biggest one) if overall memory reaches specified limit. This metric allows us to watch number of killed workers.
Diffstat (limited to 'spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb')
-rw-r--r--spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb b/spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb
new file mode 100644
index 00000000000..180520b27e7
--- /dev/null
+++ b/spec/lib/gitlab/cluster/puma_worker_killer_observer_spec.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Cluster::PumaWorkerKillerObserver do
+ let(:counter) { Gitlab::Metrics::NullMetric.instance }
+
+ before do
+ allow(Gitlab::Metrics).to receive(:counter)
+ .with(any_args)
+ .and_return(counter)
+ end
+
+ describe '#callback' do
+ subject { described_class.new }
+
+ it 'increments timeout counter' do
+ worker = double(index: 0)
+
+ expect(counter)
+ .to receive(:increment)
+ .with({ worker: 'worker_0' })
+
+ subject.callback.call(worker)
+ end
+ end
+end