gitlab-qa 6.3.0 → 6.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c99ceb7cdd5d4c53dabf353157bbaf334c7c67febb2afc93620e8bca0fe3774
4
- data.tar.gz: a0d26ee7c892402f37cb9bc0e311f649687878fb088bca8c881ce64a5a0bcd54
3
+ metadata.gz: 12e0b622362bae1054406a72f79f42a29582f9ebca8162a2c3f2d8128c9938f6
4
+ data.tar.gz: fbaa6130f08f1a082cb90e4e1a5c65d7fb253b9f311cbaeb5937b3aa752ce20b
5
5
  SHA512:
6
- metadata.gz: 6984d1bcbfb7939d2b806f9857b6403db776458eba0c89ee719be35f563b4a96076a80ca2cf8bb765e4eccf819e7554343c59b08c702d8d45d4d0c85bcde618c
7
- data.tar.gz: 4c44818ae663d2eece632825d8efd12535312f71a98e7211ab8b431b8dec5d8561d339a1b69e3884797f3324cb049b64164da4be4c0064c329de600cf731d020
6
+ metadata.gz: 9bdd569f223141416086e574911e71fc2350b55b487644ccdc68524cee0da8ee0c5ddaa9c26be1877cc2b218045b736a3212b71a26188f3770ac8355bfd8cf69
7
+ data.tar.gz: e4a83ae9c48728baef2ea881f1abcd50476ce96e59ef1579b788eb6c58812c9aa27a40397caaf7293c71dd5bf1e6614e5607d2d41d438447c3badeafc9cd4595
@@ -98,6 +98,7 @@ module Gitlab
98
98
 
99
99
  module Report
100
100
  autoload :GitlabIssueClient, 'gitlab/qa/report/gitlab_issue_client'
101
+ autoload :BaseTestResults, 'gitlab/qa/report/base_test_results'
101
102
  autoload :JsonTestResults, 'gitlab/qa/report/json_test_results'
102
103
  autoload :JUnitTestResults, 'gitlab/qa/report/junit_test_results'
103
104
  autoload :PrepareStageReports, 'gitlab/qa/report/prepare_stage_reports'
@@ -128,10 +128,10 @@ module Gitlab
128
128
  end
129
129
  end
130
130
 
131
- def wait
131
+ def wait_until_ready
132
132
  return if skip_availability_check
133
133
 
134
- if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
134
+ if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(300)
135
135
  sleep 12 # TODO, handle that better
136
136
  puts ' -> GitLab is available.'
137
137
  else
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Report
6
+ class BaseTestResults
7
+ include Enumerable
8
+
9
+ def initialize(path)
10
+ @results = parse(path)
11
+ @testcases = process
12
+ end
13
+
14
+ def each(&block)
15
+ testcases.each(&block)
16
+ end
17
+
18
+ def write(path)
19
+ raise NotImplementedError
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :results, :testcases
25
+
26
+ def parse(path)
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def process
31
+ raise NotImplementedError
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -5,15 +5,23 @@ require 'json'
5
5
  module Gitlab
6
6
  module QA
7
7
  module Report
8
- class JsonTestResults
9
- include Enumerable
8
+ class JsonTestResults < BaseTestResults
9
+ def write(path)
10
+ json = results.merge('examples' => testcases.map(&:report))
10
11
 
11
- def initialize(file)
12
- @testcases = JSON.parse(File.read(file))['examples'].map { |test| TestResult.from_json(test) }
12
+ File.write(path, JSON.pretty_generate(json))
13
13
  end
14
14
 
15
- def each(&block)
16
- @testcases.each(&block)
15
+ private
16
+
17
+ def parse(path)
18
+ JSON.parse(File.read(path))
19
+ end
20
+
21
+ def process
22
+ results['examples'].map do |test|
23
+ TestResult.from_json(test)
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -5,15 +5,21 @@ require 'nokogiri'
5
5
  module Gitlab
6
6
  module QA
7
7
  module Report
8
- class JUnitTestResults
9
- include Enumerable
8
+ class JUnitTestResults < BaseTestResults
9
+ def write(path)
10
+ # Ignore it for now
11
+ end
12
+
13
+ private
10
14
 
11
- def initialize(file)
12
- @testcases = Nokogiri::XML(File.read(file)).xpath('//testcase').map { |test| TestResult.from_junit(test) }
15
+ def parse(path)
16
+ Nokogiri::XML.parse(File.read(path))
13
17
  end
14
18
 
15
- def each(&block)
16
- @testcases.each(&block)
19
+ def process
20
+ results.xpath('//testcase').map do |test|
21
+ TestResult.from_junit(test)
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -15,15 +15,15 @@ module Gitlab
15
15
  def run!
16
16
  puts "Reporting test results in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
17
17
 
18
- Dir.glob(files).each do |file|
19
- puts "Reporting tests in #{file}"
20
- extension = File.extname(file)
18
+ Dir.glob(files).each do |path|
19
+ puts "Reporting tests in #{path}"
20
+ extension = File.extname(path)
21
21
 
22
22
  case extension
23
23
  when '.json'
24
- test_results = Report::JsonTestResults.new(file)
24
+ test_results = Report::JsonTestResults.new(path)
25
25
  when '.xml'
26
- test_results = Report::JUnitTestResults.new(file)
26
+ test_results = Report::JUnitTestResults.new(path)
27
27
  else
28
28
  raise "Unknown extension #{extension}"
29
29
  end
@@ -31,6 +31,8 @@ module Gitlab
31
31
  test_results.each do |test|
32
32
  report_test(test)
33
33
  end
34
+
35
+ test_results.write(path)
34
36
  end
35
37
  end
36
38
 
@@ -48,6 +50,8 @@ module Gitlab
48
50
  puts "Created new issue: #{issue.web_url}"
49
51
  end
50
52
 
53
+ test.testcase ||= issue.web_url
54
+
51
55
  update_labels(issue, test)
52
56
  note_status(issue, test)
53
57
 
@@ -4,60 +4,114 @@ module Gitlab
4
4
  module QA
5
5
  module Report
6
6
  class TestResult
7
- attr_accessor :name, :file, :skipped, :failures, :testcase
8
-
9
- def self.from_json(test)
10
- new.tap do |test_result|
11
- test_result.name = test['full_description']
12
- test_result.file = test['file_path']
13
- test_result.skipped = test['status'] == 'pending'
14
- test_result.failures = failures_from_json_exceptions(test)
15
- test_result.testcase = test['testcase']
16
- end
7
+ def self.from_json(report)
8
+ JsonTestResult.new(report)
17
9
  end
18
10
 
19
- def self.from_junit(test)
20
- new.tap do |test_result|
21
- test_result.name = test['name']
22
- test_result.file = test['file']
23
- test_result.skipped = test.search('skipped').any?
24
- test_result.failures = failures_from_junit_exceptions(test)
25
- end
11
+ def self.from_junit(report)
12
+ JUnitTestResult.new(report)
26
13
  end
27
14
 
28
- def self.failures_from_json_exceptions(test)
29
- return [] unless test.key?('exceptions')
15
+ attr_accessor :report, :failures
30
16
 
31
- test['exceptions'].map do |exception|
32
- spec_file_first_index = exception['backtrace'].rindex do |line|
33
- line.include?(File.basename(test['file_path']))
34
- end
17
+ def initialize(report)
18
+ self.report = report
19
+ self.failures = failures_from_exceptions
20
+ end
35
21
 
36
- {
37
- 'message' => "#{exception['class']}: #{exception['message']}",
38
- 'stacktrace' => "#{exception['message_lines'].join("\n")}\n#{exception['backtrace'].slice(0..spec_file_first_index).join("\n")}"
39
- }
40
- end
22
+ def name
23
+ raise NotImplementedError
41
24
  end
42
- private_class_method :failures_from_json_exceptions
43
25
 
44
- def self.failures_from_junit_exceptions(test)
45
- failures = test.search('failure')
46
- return [] if failures.empty?
26
+ def file
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def skipped
31
+ raise NotImplementedError
32
+ end
33
+
34
+ private
35
+
36
+ def failures_from_exceptions
37
+ raise NotImplementedError
38
+ end
39
+
40
+ class JsonTestResult < TestResult
41
+ def name
42
+ report['full_description']
43
+ end
44
+
45
+ def file
46
+ report['file_path']
47
+ end
48
+
49
+ def skipped
50
+ report['status'] == 'pending'
51
+ end
52
+
53
+ def testcase
54
+ report['testcase']
55
+ end
47
56
 
48
- failures.map do |exception|
49
- trace = exception.content.split("\n").map(&:strip)
50
- spec_file_first_index = trace.rindex do |line|
51
- line.include?(File.basename(test['file']))
57
+ def testcase=(new_testcase)
58
+ report['testcase'] = new_testcase
59
+ end
60
+
61
+ private
62
+
63
+ # rubocop:disable Metrics/AbcSize
64
+ def failures_from_exceptions
65
+ return [] unless report.key?('exceptions')
66
+
67
+ report['exceptions'].map do |exception|
68
+ spec_file_first_index = exception['backtrace'].rindex do |line|
69
+ line.include?(File.basename(report['file_path']))
70
+ end
71
+
72
+ {
73
+ 'message' => "#{exception['class']}: #{exception['message']}",
74
+ 'stacktrace' => "#{exception['message_lines'].join("\n")}\n#{exception['backtrace'].slice(0..spec_file_first_index).join("\n")}"
75
+ }
52
76
  end
77
+ end
78
+ # rubocop:enable Metrics/AbcSize
79
+ end
80
+
81
+ class JUnitTestResult < TestResult
82
+ def name
83
+ report['name']
84
+ end
53
85
 
54
- {
55
- 'message' => "#{exception['type']}: #{exception['message']}",
56
- 'stacktrace' => trace.slice(0..spec_file_first_index).join("\n")
57
- }
86
+ def file
87
+ report['file']
88
+ end
89
+
90
+ def skipped
91
+ report.search('skipped').any?
92
+ end
93
+
94
+ attr_accessor :testcase # Ignore it for now
95
+
96
+ private
97
+
98
+ def failures_from_exceptions
99
+ failures = report.search('failure')
100
+ return [] if failures.empty?
101
+
102
+ failures.map do |exception|
103
+ trace = exception.content.split("\n").map(&:strip)
104
+ spec_file_first_index = trace.rindex do |line|
105
+ line.include?(File.basename(report['file']))
106
+ end
107
+
108
+ {
109
+ 'message' => "#{exception['type']}: #{exception['message']}",
110
+ 'stacktrace' => trace.slice(0..spec_file_first_index).join("\n")
111
+ }
112
+ end
58
113
  end
59
114
  end
60
- private_class_method :failures_from_junit_exceptions
61
115
  end
62
116
  end
63
117
  end
@@ -62,6 +62,7 @@ module Gitlab
62
62
  'KNAPSACK_TEST_FILE_PATTERN' => :knapsack_test_file_pattern,
63
63
  'KNAPSACK_TEST_DIR' => :knapsack_test_dir,
64
64
  'CI' => :ci,
65
+ 'CI_JOB_ID' => :ci_job_id,
65
66
  'CI_RUNNER_ID' => :ci_runner_id,
66
67
  'CI_SERVER_HOST' => :ci_server_host,
67
68
  'CI_SERVER_PERSONAL_ACCESS_TOKEN' => :ci_server_personal_access_token,
@@ -24,7 +24,7 @@ module Gitlab
24
24
  start
25
25
  reconfigure
26
26
  process_exec_commands
27
- wait
27
+ wait_until_ready
28
28
  teardown!
29
29
  end
30
30
  end
@@ -41,7 +41,7 @@ module Gitlab
41
41
  prepare_gitlab_omnibus_config
42
42
  start
43
43
  reconfigure
44
- wait
44
+ wait_until_ready
45
45
 
46
46
  puts "Running Praefect specs!"
47
47
 
@@ -15,7 +15,7 @@ module Gitlab
15
15
  reconfigure
16
16
 
17
17
  restart
18
- wait
18
+ wait_until_ready
19
19
  teardown
20
20
  end
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '6.3.0'.freeze
3
+ VERSION = '6.4.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.0
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Bizon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-05 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -257,6 +257,7 @@ files:
257
257
  - lib/gitlab/qa/docker/shellout.rb
258
258
  - lib/gitlab/qa/docker/volumes.rb
259
259
  - lib/gitlab/qa/release.rb
260
+ - lib/gitlab/qa/report/base_test_results.rb
260
261
  - lib/gitlab/qa/report/gitlab_issue_client.rb
261
262
  - lib/gitlab/qa/report/json_test_results.rb
262
263
  - lib/gitlab/qa/report/junit_test_results.rb