File: quarantine-check

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (42 lines) | stat: -rwxr-xr-x 1,103 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'json'

missing_issues = []
missing_issue_message = %(\n*** The following quarantined tests are missing issue links:\n\n%s\n)

test_metadata_file = ARGV.shift

unless test_metadata_file
  puts "usage: #{__FILE__} <test_metadata_file>"
  exit 1
end

file = File.read(test_metadata_file)
data_hash = JSON.parse(file)

unless data_hash['examples'].count > 1
  puts "\nRspec output does not contain examples. Check test-metadata.json file.\n"
  exit 1
end

puts "\nAnalyzing quarantined test data...\n"

tests = data_hash['examples']

tests.each do |test|
  next unless test['quarantine']

  missing_issues.push(" ==> #{test['id']} - #{test['full_description']}\n") unless test['quarantine']['issue']
end

if missing_issues.empty?
  puts "\nNo errors found."
else
  puts "\n*** Quarantine format violations detected! ***\n"

  puts missing_issue_message % missing_issues unless missing_issues.empty?
  puts "See https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#quarantining-tests"
  exit 1
end