summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/metrics
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 15:10:04 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 15:10:04 +0000
commitf3b1e07903a7f509b11ad7cf188fac46d98f77f6 (patch)
treea6fa5e65d83d94334387952f1f526ed438604408 /spec/lib/gitlab/metrics
parentba174c982f40d71a87fd511b091753807174f7e7 (diff)
downloadgitlab-ce-f3b1e07903a7f509b11ad7cf188fac46d98f77f6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/metrics')
-rw-r--r--spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
index 1fc6fdcf622..6ee8acbf6fd 100644
--- a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
+++ b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
@@ -36,6 +36,74 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
Timecop.scale(3600) { subject.call(env) }
end
+
+ context 'request is a health check endpoint' do
+ it 'increments health endpoint counter' do
+ env['PATH_INFO'] = '/-/liveness'
+
+ expect(described_class).to receive_message_chain(:http_health_requests_total, :increment).with(method: 'get')
+
+ subject.call(env)
+ end
+
+ context 'with trailing slash' do
+ before do
+ env['PATH_INFO'] = '/-/liveness/'
+ end
+
+ it 'increments health endpoint counter' do
+ expect(described_class).to receive_message_chain(:http_health_requests_total, :increment).with(method: 'get')
+
+ subject.call(env)
+ end
+ end
+
+ context 'with percent encoded values' do
+ before do
+ env['PATH_INFO'] = '/-/%6D%65%74%72%69%63%73' # /-/metrics
+ end
+
+ it 'increments health endpoint counter' do
+ expect(described_class).to receive_message_chain(:http_health_requests_total, :increment).with(method: 'get')
+
+ subject.call(env)
+ end
+ end
+ end
+
+ context 'request is not a health check endpoint' do
+ it 'does not increment health endpoint counter' do
+ env['PATH_INFO'] = '/-/ordinary-requests'
+
+ expect(described_class).not_to receive(:http_health_requests_total)
+
+ subject.call(env)
+ end
+
+ context 'path info is a root path' do
+ before do
+ env['PATH_INFO'] = '/-/'
+ end
+
+ it 'does not increment health endpoint counter' do
+ expect(described_class).not_to receive(:http_health_requests_total)
+
+ subject.call(env)
+ end
+ end
+
+ context 'path info is a subpath' do
+ before do
+ env['PATH_INFO'] = '/-/health/subpath'
+ end
+
+ it 'does not increment health endpoint counter' do
+ expect(described_class).not_to receive(:http_health_requests_total)
+
+ subject.call(env)
+ end
+ end
+ end
end
context '@app.call throws exception' do