Skip to content
代码片段 群组 项目
未验证 提交 42d54619 编辑于 作者: Niko Belokolodov's avatar Niko Belokolodov 提交者: GitLab
浏览文件

Add a Dangerbot rule to suggest adding specs for Redis/HLL metrics migration

上级 3d3bfa5c
No related branches found
No related tags found
无相关合并请求
......@@ -11,3 +11,5 @@ analytics_instrumentation.check_usage_data_insertions!
analytics_instrumentation.check_deprecated_data_sources!
analytics_instrumentation.check_removed_metric_fields!
analytics_instrumentation.warn_about_migrated_redis_keys_specs!
......@@ -443,4 +443,38 @@
end
end
end
describe '#warn_about_migrated_redis_keys_specs!' do
let(:redis_hll_file) { 'lib/gitlab/usage_data_counters/hll_redis_key_overrides.yml' }
let(:total_counter_file) { 'lib/gitlab/usage_data_counters/total_counter_redis_key_overrides.yml' }
subject(:check_redis_keys_files_overrides) { analytics_instrumentation.warn_about_migrated_redis_keys_specs! }
before do
allow(fake_helper).to receive(:changed_lines).with(redis_hll_file).and_return([file_diff_hll])
allow(fake_helper).to receive(:changed_lines).with(total_counter_file).and_return([file_diff_total])
end
context 'when new keys added to overrides files' do
let(:file_diff_hll) { "+user_viewed_cluster_configuration-user: user_viewed_cluster_configuration" }
let(:file_diff_total) { "+user_viewed_cluster_configuration-user: USER_VIEWED_CLUSTER_CONFIGURATION" }
it 'adds suggestion to add specs' do
expect(analytics_instrumentation).to receive(:warn)
check_redis_keys_files_overrides
end
end
context 'when no new keys added to overrides files' do
let(:file_diff_hll) { "-user_viewed_cluster_configuration-user: user_viewed_cluster_configuration" }
let(:file_diff_total) { "-user_viewed_cluster_configuration-user: USER_VIEWED_CLUSTER_CONFIGURATION" }
it 'adds suggestion to add specs' do
expect(analytics_instrumentation).not_to receive(:warn)
check_redis_keys_files_overrides
end
end
end
end
......@@ -97,12 +97,22 @@ def check_removed_metric_fields!
end
end
def modified_config_files
helper.modified_files.select { |f| f.include?('config/metrics') && f.end_with?('yml') }
def warn_about_migrated_redis_keys_specs!
override_files_changes = ["lib/gitlab/usage_data_counters/hll_redis_key_overrides.yml",
"lib/gitlab/usage_data_counters/total_counter_redis_key_overrides.yml"].map do |filename|
helper.changed_lines(filename).filter { |line| line.start_with?("+") }
end
return if override_files_changes.flatten.none?
warn "Redis keys overrides were added. Please consider cover keys merging with specs. See the [related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/475191) for details"
end
private
def modified_config_files
helper.modified_files.select { |f| f.include?('config/metrics') && f.end_with?('yml') }
end
def comment_removed_metric(filename, has_removed_url, has_removed_milestone)
mr_has_milestone = !helper.mr_milestone.nil?
milestone = mr_has_milestone ? helper.mr_milestone['title'] : '[PLEASE SET MILESTONE]'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册