diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-19 12:08:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-19 12:08:55 +0300 |
commit | 021a832cb8e90a0305452381ccf4ce15dc5e0ebd (patch) | |
tree | 16f746f3a684b5757a2dfc010e7e6730a6b1a6cf /spec | |
parent | af685f7e44d974c8b2035be1895fa4c0f6fb0c5f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 43 insertions, 20 deletions
diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_deployments_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_deployments_metric_spec.rb new file mode 100644 index 00000000000..538be7bbdc4 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/count_deployments_metric_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountDeploymentsMetric, feature_category: :service_ping do + using RSpec::Parameterized::TableSyntax + + before(:all) do + env = create(:environment) + [3, 60].each do |n| + deployment_options = { created_at: n.days.ago, project: env.project, environment: env } + create(:deployment, :failed, deployment_options) + create(:deployment, :success, deployment_options) + create(:deployment, :success, deployment_options) + end + end + + where(:type, :time_frame, :expected_value) do + :all | 'all' | 6 + :all | '28d' | 3 + :success | 'all' | 4 + :success | '28d' | 2 + :failed | 'all' | 2 + :failed | '28d' | 1 + end + + with_them do + expected_value = params[:expected_value] # rubocop: disable Lint/UselessAssignment + time_frame = params[:time_frame] + type = params[:type] + + it_behaves_like 'a correct instrumented metric value', { time_frame: time_frame, options: { type: type } } + end +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 ced9ec7f221..42855271e22 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 @@ -12,7 +12,8 @@ RSpec.describe Gitlab::UsageDataCounters::KubernetesAgentCounter do let(:events) do { 'gitops_sync' => 1, - 'k8s_api_proxy_request' => 2 + 'k8s_api_proxy_request' => 2, + 'flux_git_push_notifications_total' => 3 } end @@ -23,7 +24,10 @@ RSpec.describe Gitlab::UsageDataCounters::KubernetesAgentCounter do described_class.increment_event_counts(events) described_class.increment_event_counts(events) - expect(described_class.totals).to eq(kubernetes_agent_gitops_sync: 3, kubernetes_agent_k8s_api_proxy_request: 6) + expect(described_class.totals).to eq( + kubernetes_agent_gitops_sync: 3, + kubernetes_agent_k8s_api_proxy_request: 6, + kubernetes_agent_flux_git_push_notifications_total: 9) end context 'with empty events' do diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 1014daf693b..9df869f8801 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -568,9 +568,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic expect(count_data[:kubernetes_agents]).to eq(2) expect(count_data[:kubernetes_agents_with_token]).to eq(1) - expect(count_data[:deployments]).to eq(4) - expect(count_data[:successful_deployments]).to eq(2) - expect(count_data[:failed_deployments]).to eq(2) expect(count_data[:feature_flags]).to eq(1) expect(count_data[:projects_creating_incidents]).to eq(2) @@ -623,16 +620,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic let_it_be(:project) { create(:project, created_at: 3.days.ago) } before do - env = create(:environment) create(:package, project: project, created_at: 3.days.ago) create(:package, created_at: 2.months.ago, project: project) - [3, 31].each do |n| - deployment_options = { created_at: n.days.ago, project: env.project, environment: env } - create(:deployment, :failed, deployment_options) - create(:deployment, :success, deployment_options) - end - for_defined_days_back do create(:product_analytics_event, project: project, se_category: 'epics', se_action: 'promote') end @@ -643,9 +633,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :servic it 'gathers monthly usage counts correctly' do counts_monthly = subject[:counts_monthly] - expect(counts_monthly[:deployments]).to eq(2) - expect(counts_monthly[:successful_deployments]).to eq(1) - expect(counts_monthly[:failed_deployments]).to eq(1) expect(counts_monthly[:projects]).to eq(1) expect(counts_monthly[:packages]).to eq(1) end diff --git a/spec/requests/api/internal/kubernetes_spec.rb b/spec/requests/api/internal/kubernetes_spec.rb index cd2c21fda29..3c76fba4e2c 100644 --- a/spec/requests/api/internal/kubernetes_spec.rb +++ b/spec/requests/api/internal/kubernetes_spec.rb @@ -122,11 +122,12 @@ RSpec.describe API::Internal::Kubernetes, feature_category: :deployment_manageme it 'tracks events and unique events', :aggregate_failures do request_count = 2 - counters = { gitops_sync: 10, k8s_api_proxy_request: 5 } + counters = { gitops_sync: 10, k8s_api_proxy_request: 5, flux_git_push_notifications_total: 42 } unique_counters = { agent_users_using_ci_tunnel: [10, 999, 777, 10] } expected_counters = { kubernetes_agent_gitops_sync: request_count * counters[:gitops_sync], - kubernetes_agent_k8s_api_proxy_request: request_count * counters[:k8s_api_proxy_request] + kubernetes_agent_k8s_api_proxy_request: request_count * counters[:k8s_api_proxy_request], + kubernetes_agent_flux_git_push_notifications_total: request_count * counters[:flux_git_push_notifications_total] } expected_hll_count = unique_counters[:agent_users_using_ci_tunnel].uniq.count diff --git a/spec/support/helpers/usage_data_helpers.rb b/spec/support/helpers/usage_data_helpers.rb index 050a2780af4..73f7a79dd5b 100644 --- a/spec/support/helpers/usage_data_helpers.rb +++ b/spec/support/helpers/usage_data_helpers.rb @@ -12,9 +12,6 @@ module UsageDataHelpers auto_devops_enabled auto_devops_disabled deploy_keys - deployments - successful_deployments - failed_deployments environments clusters clusters_enabled |