Commit e1d2685e authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'mwaw/clean_quarantine_secure_product_type_metrics_feature_flag' into 'master'

Enable quarantined service ping metrics

See merge request gitlab-org/gitlab!73348
parents c0c00782 7197509e
---
name: allow_quarantined_security_products_usage_metrics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71722
rollout_issue_url:
milestone: '14.4'
type: ops
group: group::product intelligence
default_enabled: false
......@@ -144,11 +144,7 @@ module EE
def security_products_usage
results = SECURE_PRODUCT_TYPES.each_with_object({}) do |(secure_type, attribs), response|
response[attribs[:name]] = if ::Feature.enabled?(:allow_quarantined_security_products_usage_metrics, type: :ops, default_enabled: :yaml)
count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord
else
::Gitlab::Database::BatchCounter::FALLBACK
end
response[attribs[:name]] = count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord
end
# handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
......
......@@ -128,50 +128,17 @@ RSpec.describe Gitlab::UsageData do
expect(count_data[:epic_issues]).to eq(2)
end
context 'with allow_quarantined_security_products_usage_metrics turned on' do
it 'gathers security products usage data' do
expect(count_data[:container_scanning_jobs]).to eq(1)
expect(count_data[:dast_jobs]).to eq(1)
expect(count_data[:dependency_scanning_jobs]).to eq(1)
expect(count_data[:license_management_jobs]).to eq(2)
expect(count_data[:sast_jobs]).to eq(1)
expect(count_data[:secret_detection_jobs]).to eq(1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1)
end
it 'counts metrics data' do
expect(described_class).to receive(:count).exactly(10).times
described_class.security_products_usage
end
end
context 'with allow_quarantined_security_products_usage_metrics turned off' do
before do
stub_feature_flags(allow_quarantined_security_products_usage_metrics: false)
end
it 'avoid counting metrics' do
expect(described_class).not_to receive(:count)
described_class.security_products_usage
end
it 'returns fallback value for quarantined security products usage data' do
expect(count_data[:container_scanning_jobs]).to eq(-1)
expect(count_data[:dast_jobs]).to eq(-1)
expect(count_data[:dependency_scanning_jobs]).to eq(-1)
expect(count_data[:license_management_jobs]).to eq(-1)
expect(count_data[:sast_jobs]).to eq(-1)
expect(count_data[:secret_detection_jobs]).to eq(-1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(-1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1)
end
it 'gathers security products usage data' do
expect(count_data[:container_scanning_jobs]).to eq(1)
expect(count_data[:dast_jobs]).to eq(1)
expect(count_data[:dependency_scanning_jobs]).to eq(1)
expect(count_data[:license_management_jobs]).to eq(2)
expect(count_data[:sast_jobs]).to eq(1)
expect(count_data[:secret_detection_jobs]).to eq(1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1)
end
it 'gathers group overview preferences usage data', :aggregate_failures do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment