diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/lib/gitlab/usage_data_counters | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/lib/gitlab/usage_data_counters')
4 files changed, 48 insertions, 19 deletions
diff --git a/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb index 82db3d94493..5f66387c82b 100644 --- a/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/editor_unique_counter_spec.rb @@ -28,14 +28,6 @@ RSpec.describe Gitlab::UsageDataCounters::EditorUniqueCounter, :clean_gitlab_red it 'does not track edit actions if author is not present' do expect(track_action(author: nil)).to be_nil end - - context 'when feature flag track_editor_edit_actions is disabled' do - it 'does not track edit actions' do - stub_feature_flags(track_editor_edit_actions: false) - - expect(track_action(author: user1)).to be_nil - end - end end context 'for web IDE edit actions' do diff --git a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb index 9fc28f6c4ec..4efacae0a48 100644 --- a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb @@ -45,6 +45,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s 'quickactions', 'pipeline_authoring', 'epics_usage', + 'epic_boards_usage', 'secure' ) end diff --git a/spec/lib/gitlab/usage_data_counters/kubernetes_agent_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/kubernetes_agent_counter_spec.rb index 8f9a3e0cd9e..e7edb8b9cf1 100644 --- a/spec/lib/gitlab/usage_data_counters/kubernetes_agent_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/kubernetes_agent_counter_spec.rb @@ -3,21 +3,57 @@ require 'spec_helper' RSpec.describe Gitlab::UsageDataCounters::KubernetesAgentCounter do - it_behaves_like 'a redis usage counter', 'Kubernetes Agent', :gitops_sync + described_class::KNOWN_EVENTS.each do |event| + it_behaves_like 'a redis usage counter', 'Kubernetes Agent', event + it_behaves_like 'a redis usage counter with totals', :kubernetes_agent, event => 1 + end + + describe '.increment_event_counts' do + let(:events) do + { + 'gitops_sync' => 1, + 'k8s_api_proxy_request' => 2 + } + end - it_behaves_like 'a redis usage counter with totals', :kubernetes_agent, gitops_sync: 1 + subject { described_class.increment_event_counts(events) } - describe '.increment_gitops_sync' do - it 'increments the gtops_sync counter by the new increment amount' do - described_class.increment_gitops_sync(7) - described_class.increment_gitops_sync(2) - described_class.increment_gitops_sync(0) + it 'increments the specified counters by the new increment amount' do + described_class.increment_event_counts(events) + described_class.increment_event_counts(events) + described_class.increment_event_counts(events) - expect(described_class.totals).to eq(kubernetes_agent_gitops_sync: 9) + expect(described_class.totals).to eq(kubernetes_agent_gitops_sync: 3, kubernetes_agent_k8s_api_proxy_request: 6) end - it 'raises for negative numbers' do - expect { described_class.increment_gitops_sync(-1) }.to raise_error(ArgumentError) + context 'event is unknown' do + let(:events) do + { + 'gitops_sync' => 1, + 'other_event' => 2 + } + end + + it 'raises an ArgumentError' do + expect(described_class).not_to receive(:increment_by) + + expect { subject }.to raise_error(ArgumentError, 'unknown event other_event') + end + end + + context 'increment is negative' do + let(:events) do + { + 'gitops_sync' => -1, + 'k8s_api_proxy_request' => 2 + } + end + + it 'raises an ArgumentError' do + expect(described_class).not_to receive(:increment_by) + + expect { subject }.to raise_error(ArgumentError, 'gitops_sync count must be greater than or equal to zero') + end end end end diff --git a/spec/lib/gitlab/usage_data_counters/package_event_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/package_event_counter_spec.rb index 1be2a83f98f..c484595ee71 100644 --- a/spec/lib/gitlab/usage_data_counters/package_event_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/package_event_counter_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Gitlab::UsageDataCounters::PackageEventCounter, :clean_gitlab_red end it 'includes the right events' do - expect(described_class::KNOWN_EVENTS.size).to eq 48 + expect(described_class::KNOWN_EVENTS.size).to eq 51 end described_class::KNOWN_EVENTS.each do |event| |