diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-07 15:09:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-07 15:09:35 +0300 |
commit | 2abeca2d92cfe3bc18441b63ca0c54af086b206e (patch) | |
tree | 72f02f9c0470b897f31c45a6b7ccce6fe57955b0 /spec/lib/api/ci/helpers/runner_spec.rb | |
parent | f4a9d976cf03888fbfd81ab9813720f4e8ec8056 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/api/ci/helpers/runner_spec.rb')
-rw-r--r-- | spec/lib/api/ci/helpers/runner_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/api/ci/helpers/runner_spec.rb b/spec/lib/api/ci/helpers/runner_spec.rb index 37277e7dcbd..6801d16d13e 100644 --- a/spec/lib/api/ci/helpers/runner_spec.rb +++ b/spec/lib/api/ci/helpers/runner_spec.rb @@ -66,4 +66,30 @@ RSpec.describe API::Ci::Helpers::Runner do expect(helper.current_runner).to eq(runner) end end + + describe '#track_runner_authentication', :prometheus do + subject { helper.track_runner_authentication } + + let(:runner) { create(:ci_runner, token: 'foo') } + + it 'increments gitlab_ci_runner_authentication_success_total' do + allow(helper).to receive(:params).and_return(token: runner.token) + + success_counter = ::Gitlab::Ci::Runner::Metrics.runner_authentication_success_counter + failure_counter = ::Gitlab::Ci::Runner::Metrics.runner_authentication_failure_counter + expect { subject }.to change { success_counter.get(runner_type: 'instance_type') }.by(1) + .and not_change { success_counter.get(runner_type: 'project_type') } + .and not_change { failure_counter.get } + end + + it 'increments gitlab_ci_runner_authentication_failure_total' do + allow(helper).to receive(:params).and_return(token: 'invalid') + + success_counter = ::Gitlab::Ci::Runner::Metrics.runner_authentication_success_counter + failure_counter = ::Gitlab::Ci::Runner::Metrics.runner_authentication_failure_counter + expect { subject }.to change { failure_counter.get }.by(1) + .and not_change { success_counter.get(runner_type: 'instance_type') } + .and not_change { success_counter.get(runner_type: 'project_type') } + end + end end |