Commit 09fa65d6 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'mwaw/quarantine_broken_ci_build_jobs_metrics' into 'master'

Quarantine broken security_products_usage metrics

See merge request gitlab-org/gitlab!71722
parents e92fdefd 417a1319
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::static analysis product_group: group::static analysis
product_category: static_application_security_testing product_category: static_application_security_testing
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::static analysis product_group: group::static analysis
product_category: secret_detection product_category: secret_detection
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
---
name: quarantine_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
...@@ -6,7 +6,8 @@ product_stage: secure ...@@ -6,7 +6,8 @@ product_stage: secure
product_group: group::composition analysis product_group: group::composition analysis
product_category: license_compliance product_category: license_compliance
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
data_category: operational data_category: operational
......
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::composition analysis product_group: group::composition analysis
product_category: dependency_scanning product_category: dependency_scanning
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -7,7 +7,8 @@ product_stage: protect ...@@ -7,7 +7,8 @@ product_stage: protect
product_group: group::container security product_group: group::container security
product_category: container_scanning product_category: container_scanning
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -6,7 +6,8 @@ product_stage: secure ...@@ -6,7 +6,8 @@ product_stage: secure
product_group: group::dynamic analysis product_group: group::dynamic analysis
product_category: dynamic_application_security_testing product_category: dynamic_application_security_testing
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
data_category: operational data_category: operational
......
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::dynamic analysis product_group: group::dynamic analysis
product_category: fuzz-testing product_category: fuzz-testing
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::dynamic analysis product_group: group::dynamic analysis
product_category: fuzz-testing product_category: fuzz-testing
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -7,7 +7,8 @@ product_stage: secure ...@@ -7,7 +7,8 @@ product_stage: secure
product_group: group::dynamic analysis product_group: group::dynamic analysis
product_category: fuzz-testing product_category: fuzz-testing
value_type: number value_type: number
status: active status: broken
repair_issue_url: tbd
time_frame: all time_frame: all
data_source: database data_source: database
distribution: distribution:
......
...@@ -143,7 +143,11 @@ module EE ...@@ -143,7 +143,11 @@ module EE
def security_products_usage def security_products_usage
results = SECURE_PRODUCT_TYPES.each_with_object({}) do |(secure_type, attribs), response| results = SECURE_PRODUCT_TYPES.each_with_object({}) do |(secure_type, attribs), response|
response[attribs[:name]] = count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord response[attribs[:name]] = if ::Feature.enabled?(:quarantine_security_products_usage_metrics, type: :ops, default_enabled: :yaml)
::Gitlab::Database::BatchCounter::FALLBACK
else
count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord
end
end end
# handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911 # handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
......
...@@ -128,17 +128,50 @@ RSpec.describe Gitlab::UsageData do ...@@ -128,17 +128,50 @@ RSpec.describe Gitlab::UsageData do
expect(count_data[:epic_issues]).to eq(2) expect(count_data[:epic_issues]).to eq(2)
end end
it 'gathers security products usage data' do context 'with quarantine_security_products_usage_metrics turned on' do
expect(count_data[:container_scanning_jobs]).to eq(1) it 'returns fallback value for quarantined security products usage data' do
expect(count_data[:dast_jobs]).to eq(1) expect(count_data[:container_scanning_jobs]).to eq(-1)
expect(count_data[:dependency_scanning_jobs]).to eq(1) expect(count_data[:dast_jobs]).to eq(-1)
expect(count_data[:license_management_jobs]).to eq(2) expect(count_data[:dependency_scanning_jobs]).to eq(-1)
expect(count_data[:sast_jobs]).to eq(1) expect(count_data[:license_management_jobs]).to eq(-1)
expect(count_data[:secret_detection_jobs]).to eq(1) expect(count_data[:sast_jobs]).to eq(-1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1) expect(count_data[:secret_detection_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_jobs]).to eq(1) expect(count_data[:coverage_fuzzing_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(1) expect(count_data[:api_fuzzing_jobs]).to eq(-1)
expect(count_data[:dast_on_demand_pipelines]).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 'avoid counting metrics' do
expect(described_class).not_to receive(:count)
described_class.security_products_usage
end
end
context 'with quarantine_security_products_usage_metrics turned off' do
before do
stub_feature_flags(quarantine_security_products_usage_metrics: false)
end
it 'counts metrics data' do
expect(described_class).to receive(:count).exactly(10).times
described_class.security_products_usage
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
end end
it 'gathers group overview preferences usage data', :aggregate_failures do 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