summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage_data_metrics_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/usage_data_metrics_spec.rb')
-rw-r--r--spec/lib/gitlab/usage_data_metrics_spec.rb44
1 files changed, 38 insertions, 6 deletions
diff --git a/spec/lib/gitlab/usage_data_metrics_spec.rb b/spec/lib/gitlab/usage_data_metrics_spec.rb
index 18acd767c6d..e0063194f9b 100644
--- a/spec/lib/gitlab/usage_data_metrics_spec.rb
+++ b/spec/lib/gitlab/usage_data_metrics_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Gitlab::UsageDataMetrics do
allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false)
end
- context 'whith instrumentation_class' do
+ context 'with instrumentation_class' do
it 'includes top level keys' do
expect(subject).to include(:uuid)
expect(subject).to include(:hostname)
@@ -26,11 +26,6 @@ RSpec.describe Gitlab::UsageDataMetrics do
expect(subject[:counts]).to include(:boards)
end
- it 'includes i_quickactions_approve monthly and weekly key' do
- expect(subject[:redis_hll_counters][:quickactions]).to include(:i_quickactions_approve_monthly)
- expect(subject[:redis_hll_counters][:quickactions]).to include(:i_quickactions_approve_weekly)
- end
-
it 'includes counts keys' do
expect(subject[:counts]).to include(:issues)
end
@@ -42,6 +37,43 @@ RSpec.describe Gitlab::UsageDataMetrics do
it 'includes usage_activity_by_stage_monthly keys' do
expect(subject[:usage_activity_by_stage_monthly][:plan]).to include(:issues)
end
+
+ it 'includes settings keys' do
+ expect(subject[:settings]).to include(:collected_data_categories)
+ end
+
+ describe 'Redis_HLL_counters' do
+ let(:metric_files_key_paths) do
+ Gitlab::Usage::MetricDefinition
+ .definitions
+ .select { |k, v| v.attributes[:data_source] == 'redis_hll' && v.key_path.starts_with?('redis_hll_counters') }
+ .keys
+ .sort
+ end
+
+ # Recursively traverse nested Hash of a generated Service Ping to return an Array of key paths
+ # in the dotted format used in metric definition YAML files, e.g.: 'count.category.metric_name'
+ def parse_service_ping_keys(object, key_path = [])
+ if object.is_a?(Hash)
+ object.each_with_object([]) do |(key, value), result|
+ result.append parse_service_ping_keys(value, key_path + [key])
+ end
+ else
+ key_path.join('.')
+ end
+ end
+
+ let(:service_ping_key_paths) do
+ parse_service_ping_keys(subject)
+ .flatten
+ .select { |k| k.starts_with?('redis_hll_counters') }
+ .sort
+ end
+
+ it 'is included in the Service Ping hash structure' do
+ expect(metric_files_key_paths).to match_array(service_ping_key_paths)
+ end
+ end
end
end
end