Commit a68c51a0 authored by Yevgeny Pats's avatar Yevgeny Pats Committed by Mayra Cabrera

Add usage_data for coverage_fuzzing

Add index migration for coverage_fuzzing telemetry
parent 3e6d49c0
---
title: Add usage ping for coverage_fuzzing
merge_request: 36960
author:
type: added
# frozen_string_literal: true
class UpdateIndexForCoverageFuzzingTelemetry < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
OLD_INDEX_NAME = 'index_security_ci_builds_on_name_and_id'
NEW_INDEX_NAME = 'index_security_ci_builds_on_name_and_id_parser_features'
OLD_CLAUSE = "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text,
('dast'::character varying)::text,
('dependency_scanning'::character varying)::text,
('license_management'::character varying)::text,
('sast'::character varying)::text,
('secret_detection'::character varying)::text,
('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text)"
NEW_CLAUSE = "((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text,
('dast'::character varying)::text,
('dependency_scanning'::character varying)::text,
('license_management'::character varying)::text,
('sast'::character varying)::text,
('secret_detection'::character varying)::text,
('coverage_fuzzing'::character varying)::text,
('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text)"
def up
add_concurrent_index :ci_builds, [:name, :id], name: NEW_INDEX_NAME, where: NEW_CLAUSE
remove_concurrent_index_by_name :ci_builds, OLD_INDEX_NAME
end
def down
add_concurrent_index :ci_builds, [:name, :id], name: OLD_INDEX_NAME, where: OLD_CLAUSE
remove_concurrent_index_by_name :ci_builds, NEW_INDEX_NAME
end
end
9a395ab591542ec49fc17c22747d9bbf085fd5f61ae71f49493dfe34f0389059
\ No newline at end of file
...@@ -20634,7 +20634,7 @@ CREATE UNIQUE INDEX index_scim_oauth_access_tokens_on_group_id_and_token_encrypt ...@@ -20634,7 +20634,7 @@ CREATE UNIQUE INDEX index_scim_oauth_access_tokens_on_group_id_and_token_encrypt
CREATE INDEX index_secure_ci_builds_on_user_id_created_at ON public.ci_builds USING btree (user_id, created_at) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text]))); CREATE INDEX index_secure_ci_builds_on_user_id_created_at ON public.ci_builds USING btree (user_id, created_at) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text])));
CREATE INDEX index_security_ci_builds_on_name_and_id ON public.ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text)); CREATE INDEX index_security_ci_builds_on_name_and_id_parser_features ON public.ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text));
CREATE INDEX index_self_managed_prometheus_alert_events_on_environment_id ON public.self_managed_prometheus_alert_events USING btree (environment_id); CREATE INDEX index_self_managed_prometheus_alert_events_on_environment_id ON public.self_managed_prometheus_alert_events USING btree (environment_id);
......
...@@ -26,6 +26,9 @@ module EE ...@@ -26,6 +26,9 @@ module EE
}, },
secret_detection: { secret_detection: {
name: :secret_detection_jobs name: :secret_detection_jobs
},
coverage_fuzzing: {
name: :coverage_fuzzing_jobs
} }
}.freeze }.freeze
...@@ -303,7 +306,7 @@ module EE ...@@ -303,7 +306,7 @@ module EE
end end
# Currently too complicated and to get reliable counts for these stats: # Currently too complicated and to get reliable counts for these stats:
# container_scanning_jobs, dast_jobs, dependency_scanning_jobs, license_management_jobs, sast_jobs, secret_detection_jobs # container_scanning_jobs, dast_jobs, dependency_scanning_jobs, license_management_jobs, sast_jobs, secret_detection_jobs, coverage_fuzzing_jobs
# Once https://gitlab.com/gitlab-org/gitlab/merge_requests/17568 is merged, this might be doable # Once https://gitlab.com/gitlab-org/gitlab/merge_requests/17568 is merged, this might be doable
override :usage_activity_by_stage_secure override :usage_activity_by_stage_secure
def usage_activity_by_stage_secure(time_period) def usage_activity_by_stage_secure(time_period)
......
...@@ -27,6 +27,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -27,6 +27,7 @@ RSpec.describe Gitlab::UsageData do
create(:ee_ci_build, name: 'license_scanning', pipeline: pipeline) create(:ee_ci_build, name: 'license_scanning', pipeline: pipeline)
create(:ci_build, name: 'sast', pipeline: pipeline) create(:ci_build, name: 'sast', pipeline: pipeline)
create(:ci_build, name: 'secret_detection', pipeline: pipeline) create(:ci_build, name: 'secret_detection', pipeline: pipeline)
create(:ci_build, name: 'coverage_fuzzing', pipeline: pipeline)
create(:prometheus_alert, project: projects[0]) create(:prometheus_alert, project: projects[0])
create(:prometheus_alert, project: projects[0]) create(:prometheus_alert, project: projects[0])
...@@ -86,6 +87,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -86,6 +87,7 @@ RSpec.describe Gitlab::UsageData do
expect(count_data.keys).to include(*%i( expect(count_data.keys).to include(*%i(
confidential_epics confidential_epics
container_scanning_jobs container_scanning_jobs
coverage_fuzzing_jobs
dast_jobs dast_jobs
dependency_list_usages_total dependency_list_usages_total
dependency_scanning_jobs dependency_scanning_jobs
...@@ -150,6 +152,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -150,6 +152,7 @@ RSpec.describe Gitlab::UsageData do
expect(count_data[:license_management_jobs]).to eq(2) expect(count_data[:license_management_jobs]).to eq(2)
expect(count_data[:sast_jobs]).to eq(1) expect(count_data[:sast_jobs]).to eq(1)
expect(count_data[:secret_detection_jobs]).to eq(1) expect(count_data[:secret_detection_jobs]).to eq(1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1)
end end
it 'correctly shows failure for combined license management' do it 'correctly shows failure for combined license management' do
...@@ -501,6 +504,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -501,6 +504,7 @@ RSpec.describe Gitlab::UsageData do
before do before do
for_defined_days_back do for_defined_days_back do
create(:ci_build, name: 'container_scanning', user: user) create(:ci_build, name: 'container_scanning', user: user)
create(:ci_build, name: 'coverage_fuzzing', user: user)
create(:ci_build, name: 'dast', user: user) create(:ci_build, name: 'dast', user: user)
create(:ci_build, name: 'dependency_scanning', user: user) create(:ci_build, name: 'dependency_scanning', user: user)
create(:ci_build, name: 'license_management', user: user) create(:ci_build, name: 'license_management', user: user)
...@@ -513,6 +517,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -513,6 +517,7 @@ RSpec.describe Gitlab::UsageData do
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq( expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3, user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1, user_container_scanning_jobs: 1,
user_coverage_fuzzing_jobs: 1,
user_dast_jobs: 1, user_dast_jobs: 1,
user_dependency_scanning_jobs: 1, user_dependency_scanning_jobs: 1,
user_license_management_jobs: 1, user_license_management_jobs: 1,
...@@ -581,6 +586,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -581,6 +586,7 @@ RSpec.describe Gitlab::UsageData do
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq( expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3, user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1, user_container_scanning_jobs: 1,
user_coverage_fuzzing_jobs: 1,
user_dast_jobs: 3, user_dast_jobs: 3,
user_dependency_scanning_jobs: 1, user_dependency_scanning_jobs: 1,
user_license_management_jobs: 1, user_license_management_jobs: 1,
...@@ -604,6 +610,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -604,6 +610,7 @@ RSpec.describe Gitlab::UsageData do
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq( expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3, user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: 1, user_container_scanning_jobs: 1,
user_coverage_fuzzing_jobs: 1,
user_dast_jobs: 1, user_dast_jobs: 1,
user_dependency_scanning_jobs: 1, user_dependency_scanning_jobs: 1,
user_license_management_jobs: 2, user_license_management_jobs: 2,
...@@ -626,6 +633,7 @@ RSpec.describe Gitlab::UsageData do ...@@ -626,6 +633,7 @@ RSpec.describe Gitlab::UsageData do
expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq( expect(described_class.usage_activity_by_stage_secure(described_class.last_28_days_time_period)).to eq(
user_preferences_group_overview_security_dashboard: 3, user_preferences_group_overview_security_dashboard: 3,
user_container_scanning_jobs: -1, user_container_scanning_jobs: -1,
user_coverage_fuzzing_jobs: -1,
user_dast_jobs: -1, user_dast_jobs: -1,
user_dependency_scanning_jobs: -1, user_dependency_scanning_jobs: -1,
user_license_management_jobs: -1, user_license_management_jobs: -1,
......
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