summaryrefslogtreecommitdiff
path: root/spec/lib/prometheus
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-17 03:07:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-17 03:07:45 +0000
commit9763c081708e4c2e08de1f4e9ca9abdef5cffe3c (patch)
treeb27794ba1a039cdc42cdf5d90bcb7b7503437324 /spec/lib/prometheus
parent7480d774dfca97ea905321d52c70fd19496f0084 (diff)
downloadgitlab-ce-9763c081708e4c2e08de1f4e9ca9abdef5cffe3c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/prometheus')
-rw-r--r--spec/lib/prometheus/pid_provider_spec.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/prometheus/pid_provider_spec.rb b/spec/lib/prometheus/pid_provider_spec.rb
index 5a17f25f144..6fdc11b14c4 100644
--- a/spec/lib/prometheus/pid_provider_spec.rb
+++ b/spec/lib/prometheus/pid_provider_spec.rb
@@ -6,13 +6,16 @@ describe Prometheus::PidProvider do
describe '.worker_id' do
subject { described_class.worker_id }
+ let(:sidekiq_module) { Module.new }
+
before do
- allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(false)
+ allow(sidekiq_module).to receive(:server?).and_return(false)
+ stub_const('Sidekiq', sidekiq_module)
end
context 'when running in Sidekiq server mode' do
before do
- allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(true)
+ expect(Sidekiq).to receive(:server?).and_return(true)
end
context 'in a clustered setup' do
@@ -30,7 +33,8 @@ describe Prometheus::PidProvider do
context 'when running in Unicorn mode' do
before do
- allow(Gitlab::Runtime).to receive(:unicorn?).and_return(true)
+ stub_const('Unicorn::Worker', Class.new)
+ hide_const('Puma')
expect(described_class).to receive(:process_name)
.at_least(:once)
@@ -90,7 +94,8 @@ describe Prometheus::PidProvider do
context 'when running in Puma mode' do
before do
- allow(Gitlab::Runtime).to receive(:puma?).and_return(true)
+ stub_const('Puma', Module.new)
+ hide_const('Unicorn::Worker')
expect(described_class).to receive(:process_name)
.at_least(:once)
@@ -111,6 +116,11 @@ describe Prometheus::PidProvider do
end
context 'when running in unknown mode' do
+ before do
+ hide_const('Puma')
+ hide_const('Unicorn::Worker')
+ end
+
it { is_expected.to eq "process_#{Process.pid}" }
end
end