summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/runner/metrics_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 15:40:28 +0000
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/lib/gitlab/ci/runner/metrics_spec.rb
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
downloadgitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/lib/gitlab/ci/runner/metrics_spec.rb')
-rw-r--r--spec/lib/gitlab/ci/runner/metrics_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/runner/metrics_spec.rb b/spec/lib/gitlab/ci/runner/metrics_spec.rb
new file mode 100644
index 00000000000..3c459271092
--- /dev/null
+++ b/spec/lib/gitlab/ci/runner/metrics_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Ci::Runner::Metrics, :prometheus do
+ subject { described_class.new }
+
+ describe '#increment_runner_authentication_success_counter' do
+ it 'increments count for same type' do
+ expect { subject.increment_runner_authentication_success_counter(runner_type: 'instance_type') }
+ .to change { described_class.runner_authentication_success_counter.get(runner_type: 'instance_type') }.by(1)
+ end
+
+ it 'does not increment count for different type' do
+ expect { subject.increment_runner_authentication_success_counter(runner_type: 'group_type') }
+ .to not_change { described_class.runner_authentication_success_counter.get(runner_type: 'project_type') }
+ end
+
+ it 'does not increment failure count' do
+ expect { subject.increment_runner_authentication_success_counter(runner_type: 'project_type') }
+ .to not_change { described_class.runner_authentication_failure_counter.get }
+ end
+
+ it 'throws ArgumentError for invalid runner type' do
+ expect { subject.increment_runner_authentication_success_counter(runner_type: 'unknown_type') }
+ .to raise_error(ArgumentError, 'unknown runner type: unknown_type')
+ end
+ end
+
+ describe '#increment_runner_authentication_failure_counter' do
+ it 'increments count' do
+ expect { subject.increment_runner_authentication_failure_counter }
+ .to change { described_class.runner_authentication_failure_counter.get }.by(1)
+ end
+
+ it 'does not increment success count' do
+ expect { subject.increment_runner_authentication_failure_counter }
+ .to not_change { described_class.runner_authentication_success_counter.get(runner_type: 'instance_type') }
+ end
+ end
+end