Add guard test for Service Ping generated queries for Snowflake
requested to merge 347545-spike-add-test-for-service-ping-generated-queries-for-snowflake into master
What does this MR do and why?
This MR tests the Gitlab::Usage::ServicePingReport
to guard against any changes to the queries.
This means that every time a metric is added or changed, the fixture file must be regenerated to acknowledge the changes to the SQL queries, which allows for tighter control and review.
How to set up and validate locally
- Make a change in a database metric that changes the underlying SQL query, for example:
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 951ec5ea5c3..62e3fe818a3 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -129,7 +129,7 @@ def system_usage_data
packages: count(::Packages::Package),
pages_domains: count(PagesDomain),
pool_repositories: count(PoolRepository),
- projects: count(Project),
+ projects: count(Project.limit(1)),
projects_creating_incidents: distinct_count(Issue.incident, :project_id),
projects_imported_from_github: count(Project.where(import_type: 'github')),
projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),
- The spec should fail unless the fixture file is regenerated to acknowledge the changes
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #347545 (closed)
Edited by Carlo Catimbang