parallel_report_portal 3.0.0 → 3.0.2.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/deploy.yml +44 -0
- data/.github/workflows/tests.yml +8 -4
- data/README.md +1 -1
- data/lib/parallel_report_portal/configuration.rb +2 -4
- data/lib/parallel_report_portal/cucumber/report.rb +10 -21
- data/lib/parallel_report_portal/http.rb +48 -6
- data/lib/parallel_report_portal/version.rb +1 -1
- data/lib/parallel_report_portal.rb +5 -0
- data/parallel_report_portal.gemspec +2 -2
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d5cb1312e5c4b45d5581eea41e02df63266535ee5e3b58412f5d9fde5fd0dd
|
4
|
+
data.tar.gz: a10beda80c2270a68c06ff13a18701cf1cd0734eae91bd0c81c37cf0ecfd0623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2e9ce388cd7de1df78bbcd958c44f6bd329e8ebc7c40c0f550b5e79febd82b2a5913e141fc74f3e80206968f801c9e885539b7df2a4f5c06ae4508b9df11a6
|
7
|
+
data.tar.gz: 02b361da3143afa20ecd5d2111cd74fef9655b848a56174b2624d60193b2f2ee40b996ccd0dbf29abefa165e271836cac7a8c08bcab63a71d08a7c80306be85d
|
@@ -0,0 +1,44 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: [ 3.1, 3.2, 3.3 ]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v4
|
16
|
+
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
21
|
+
bundler-cache: true
|
22
|
+
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake
|
25
|
+
|
26
|
+
deploy:
|
27
|
+
needs: test
|
28
|
+
runs-on: ubuntu-latest
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v4
|
32
|
+
|
33
|
+
- name: Set up Ruby
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: 3.3
|
37
|
+
bundler-cache: true
|
38
|
+
|
39
|
+
- name: Publish to RubyGems
|
40
|
+
run: |
|
41
|
+
gem build *.gemspec
|
42
|
+
gem push *.gem
|
43
|
+
env:
|
44
|
+
GEM_HOST_API_KEY: ${{ secrets.PARALLEL_RP_RUBYGEMS_AUTH_TOKEN }}
|
data/.github/workflows/tests.yml
CHANGED
@@ -7,7 +7,9 @@
|
|
7
7
|
|
8
8
|
name: Ruby
|
9
9
|
|
10
|
-
on:
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches-ignore: [ master ]
|
11
13
|
|
12
14
|
jobs:
|
13
15
|
test:
|
@@ -15,14 +17,16 @@ jobs:
|
|
15
17
|
runs-on: ubuntu-latest
|
16
18
|
strategy:
|
17
19
|
matrix:
|
18
|
-
ruby-version: [
|
20
|
+
ruby-version: [ 3.1, 3.2, 3.3 ]
|
19
21
|
|
20
22
|
steps:
|
21
|
-
- uses: actions/checkout@
|
23
|
+
- uses: actions/checkout@v4
|
24
|
+
|
22
25
|
- name: Set up Ruby
|
23
26
|
uses: ruby/setup-ruby@v1
|
24
27
|
with:
|
25
28
|
ruby-version: ${{ matrix.ruby-version }}
|
26
|
-
bundler-cache: true
|
29
|
+
bundler-cache: true
|
30
|
+
|
27
31
|
- name: Run tests
|
28
32
|
run: bundle exec rake
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ read_timeout: 60
|
|
46
46
|
|
47
47
|
It will search for the following environment variables which may be in upper or lowercase (the official client defers to lower case, this is available here for compatibility).
|
48
48
|
|
49
|
-
- `
|
49
|
+
- `RP_API_KEY` - the API Key for this Report Portal instance which must be created in advance
|
50
50
|
- `RP_ENDPOINT` - the endpoint for this Report Portal instance
|
51
51
|
- `RP_PROJECT` - the Report Portal project name which must be created in advance and this user added as a member
|
52
52
|
- `RP_LAUNCH` - the name of this 'launch'
|
@@ -14,7 +14,7 @@ module ParallelReportPortal
|
|
14
14
|
#
|
15
15
|
# == Environment variables
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# RP_API_KEY:: The API key required for authentication
|
18
18
|
# RP_ENDPOINT:: the URL of the Report Portal API endpoint
|
19
19
|
# RP_PROJECT:: the Report Portal project name -- this must already exist within Report Port and this user must be a member of the project
|
20
20
|
# RP_LAUNCH:: The name of this launch
|
@@ -61,7 +61,7 @@ module ParallelReportPortal
|
|
61
61
|
def initialize
|
62
62
|
load_configuration_file
|
63
63
|
ATTRIBUTES.each do |attr|
|
64
|
-
env_value = get_env("rp_#{attr.to_s}")
|
64
|
+
env_value = get_env("rp_#{attr.to_s}")
|
65
65
|
send(:"#{attr}=", env_value) if env_value
|
66
66
|
end
|
67
67
|
|
@@ -153,8 +153,6 @@ module ParallelReportPortal
|
|
153
153
|
ATTRIBUTES.each do |attr|
|
154
154
|
yaml_key = if yaml.has_key?("rp_#{attr}".to_sym)
|
155
155
|
"rp_#{attr}".to_sym
|
156
|
-
elsif yaml.has_key?("report_portal_#{attr}".to_sym)
|
157
|
-
"report_portal_#{attr}".to_sym
|
158
156
|
else
|
159
157
|
attr
|
160
158
|
end
|
@@ -23,11 +23,10 @@ module ParallelReportPortal
|
|
23
23
|
unknown: 'UNKNOWN'
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
26
|
# Create a new instance of the report
|
28
27
|
def initialize(ast_lookup = nil)
|
29
28
|
@feature = nil
|
30
|
-
@tree = Tree::TreeNode.new(
|
29
|
+
@tree = Tree::TreeNode.new('root')
|
31
30
|
@ast_lookup = ast_lookup
|
32
31
|
check_faraday_compatibility
|
33
32
|
end
|
@@ -38,7 +37,7 @@ module ParallelReportPortal
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
# Issued to start a launch. It is
|
40
|
+
# Issued to start a launch. It is possible that this method could be called
|
42
41
|
# from multiple processes for the same launch if this is being run with
|
43
42
|
# parallel tests enabled. A temporary launch file will be created (using
|
44
43
|
# exclusive locking). The first time this method is called it will write the
|
@@ -48,13 +47,13 @@ module ParallelReportPortal
|
|
48
47
|
# @param start_time [Integer] the millis from the epoch
|
49
48
|
# @return [String] the UUID of this launch
|
50
49
|
def launch_started(start_time)
|
51
|
-
ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.launch_id_file, 'a+'
|
50
|
+
ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.launch_id_file, 'a+') do |file|
|
52
51
|
if file.size == 0
|
53
52
|
@launch_id = ParallelReportPortal.req_launch_started(start_time)
|
54
53
|
file.write(@launch_id)
|
55
54
|
file.flush
|
56
55
|
else
|
57
|
-
|
56
|
+
@launch_id = file.readline
|
58
57
|
end
|
59
58
|
@launch_id
|
60
59
|
end
|
@@ -65,12 +64,8 @@ module ParallelReportPortal
|
|
65
64
|
# @param clock [Integer] the millis from the epoch
|
66
65
|
def launch_finished(clock)
|
67
66
|
@tree.postordered_each do |node|
|
68
|
-
|
69
|
-
parse_report_link_from_response(response)
|
67
|
+
ParallelReportPortal.http_repeater { ParallelReportPortal.req_feature_finished(node.content, clock) } unless node.is_root?
|
70
68
|
end
|
71
|
-
response = ParallelReportPortal.req_launch_finished(launch_id, clock)
|
72
|
-
parse_report_link_from_response(response)
|
73
|
-
ParallelReportPortal.launch_finished_block.call if ParallelReportPortal.launch_finished_block
|
74
69
|
end
|
75
70
|
|
76
71
|
# Called to indicate that a feature has started.
|
@@ -114,7 +109,7 @@ module ParallelReportPortal
|
|
114
109
|
if (using_cucumber_messages? ? test_step : step_source).multiline_arg.doc_string?
|
115
110
|
detail << %(\n"""\n#{(using_cucumber_messages? ? test_step : step_source).multiline_arg.content}\n""")
|
116
111
|
elsif (using_cucumber_messages? ? test_step : step_source).multiline_arg.data_table?
|
117
|
-
detail << (using_cucumber_messages? ? test_step : step_source).multiline_arg.raw.reduce("\n") {|acc, row| acc << "| #{row.join(' | ')} |\n"}
|
112
|
+
detail << (using_cucumber_messages? ? test_step : step_source).multiline_arg.raw.reduce("\n") { |acc, row| acc << "| #{row.join(' | ')} |\n" }
|
118
113
|
end
|
119
114
|
|
120
115
|
ParallelReportPortal.req_log(@test_case_id, detail, status_to_level(:trace), clock)
|
@@ -155,13 +150,14 @@ module ParallelReportPortal
|
|
155
150
|
else
|
156
151
|
feature.location.file.split(File::SEPARATOR)
|
157
152
|
end
|
158
|
-
|
153
|
+
|
154
|
+
ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.hierarchy_file, 'a+b') do |file|
|
159
155
|
@tree = Marshal.load(File.read(file)) if file.size > 0
|
160
156
|
node = @tree.root
|
161
157
|
path_components[0..-2].each do |component|
|
162
158
|
next_node = node[component]
|
163
159
|
unless next_node
|
164
|
-
id = ParallelReportPortal.req_hierarchy(launch_id, "Folder: #{component}", node.content, 'SUITE', [], nil, clock
|
160
|
+
id = ParallelReportPortal.req_hierarchy(launch_id, "Folder: #{component}", node.content, 'SUITE', [], nil, clock)
|
165
161
|
next_node = Tree::TreeNode.new(component, id)
|
166
162
|
node << next_node
|
167
163
|
node = next_node
|
@@ -219,7 +215,7 @@ module ParallelReportPortal
|
|
219
215
|
if using_cucumber_messages?
|
220
216
|
test_step.hook?
|
221
217
|
else
|
222
|
-
!
|
218
|
+
!test_step.source.last.respond_to?(:keyword)
|
223
219
|
end
|
224
220
|
end
|
225
221
|
|
@@ -235,13 +231,6 @@ module ParallelReportPortal
|
|
235
231
|
LOG_LEVELS.fetch(status, LOG_LEVELS[:info])
|
236
232
|
end
|
237
233
|
end
|
238
|
-
|
239
|
-
def parse_report_link_from_response(response)
|
240
|
-
if response
|
241
|
-
json = JSON.parse(response.body)
|
242
|
-
ParallelReportPortal.report_url = json['link'] if json['link']
|
243
|
-
end
|
244
|
-
end
|
245
234
|
end
|
246
235
|
end
|
247
236
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'tempfile'
|
3
|
-
require 'pry'
|
4
3
|
|
5
4
|
module ParallelReportPortal
|
6
5
|
# A collection of methods for communicating with the ReportPortal
|
7
6
|
# REST interface.
|
8
7
|
module HTTP
|
9
8
|
|
9
|
+
class HTTPBadGatewayError < StandardError; end
|
10
|
+
|
10
11
|
# Creating class level logger and setting log level
|
11
12
|
@@logger = Logger.new(STDOUT)
|
12
13
|
@@logger.level = Logger::ERROR
|
@@ -84,9 +85,6 @@ module ParallelReportPortal
|
|
84
85
|
}.to_json
|
85
86
|
end
|
86
87
|
|
87
|
-
pp "#########################"
|
88
|
-
pp resp
|
89
|
-
|
90
88
|
if resp.success?
|
91
89
|
JSON.parse(resp.body)['id']
|
92
90
|
else
|
@@ -97,9 +95,30 @@ module ParallelReportPortal
|
|
97
95
|
# Send a request to Report Portal to finish a launch.
|
98
96
|
# It will bubble up any Faraday connection exceptions.
|
99
97
|
def req_launch_finished(launch_id, time)
|
100
|
-
|
98
|
+
@@logger.debug { "Launch finish with ID: '#{launch_id}'" }
|
99
|
+
|
100
|
+
response = ParallelReportPortal.http_connection.put("launch/#{launch_id}/finish") do |req|
|
101
101
|
req.body = { end_time: time }.to_json
|
102
102
|
end
|
103
|
+
|
104
|
+
@@logger.error { "Launch finish failed with response code #{response.status} -- message #{response.body}" } unless response.success?
|
105
|
+
response
|
106
|
+
end
|
107
|
+
|
108
|
+
def force_stop(launch_id, time)
|
109
|
+
resp = ParallelReportPortal.http_connection.put("launch/#{launch_id}/stop") do |req|
|
110
|
+
req.body = { end_time: time, status: :stopped }.to_json
|
111
|
+
end
|
112
|
+
@@logger.warn { "Failed to force stop: response code #{resp.status} -- message #{resp.body}" } unless resp.success?
|
113
|
+
|
114
|
+
resp
|
115
|
+
end
|
116
|
+
|
117
|
+
def parse_report_link_from_response(response)
|
118
|
+
if response
|
119
|
+
json = JSON.parse(response.body)
|
120
|
+
ParallelReportPortal.report_url = json['link'] if json['link']
|
121
|
+
end
|
103
122
|
end
|
104
123
|
|
105
124
|
# Send a request to ReportPortal to start a feature.
|
@@ -149,9 +168,14 @@ module ParallelReportPortal
|
|
149
168
|
|
150
169
|
# Send a request to Report Portal that a feature has completed.
|
151
170
|
def req_feature_finished(feature_id, time)
|
152
|
-
ParallelReportPortal.http_connection.put("item/#{feature_id}") do |req|
|
171
|
+
response = ParallelReportPortal.http_connection.put("item/#{feature_id}") do |req|
|
153
172
|
req.body = { end_time: time }.to_json
|
154
173
|
end
|
174
|
+
@@logger.debug { "Feature finish with ID: '#{feature_id}'" }
|
175
|
+
|
176
|
+
|
177
|
+
@@logger.error { "Feature finish failed with response code #{response.status} -- message #{response.body}" } unless response.success?
|
178
|
+
response
|
155
179
|
end
|
156
180
|
|
157
181
|
# Send a request to ReportPortal to start a test case.
|
@@ -240,5 +264,23 @@ module ParallelReportPortal
|
|
240
264
|
end
|
241
265
|
end
|
242
266
|
end
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
def http_repeater(&block)
|
271
|
+
tries = 0
|
272
|
+
begin
|
273
|
+
tries += 1
|
274
|
+
response = block.call
|
275
|
+
raise HTTPBadGatewayError if response && !response.success? && response.status == 502
|
276
|
+
rescue HTTPBadGatewayError => _e
|
277
|
+
if tries <= 3
|
278
|
+
sleep(1)
|
279
|
+
@@logger.warn { 'HTTP call failed, retrying...' }
|
280
|
+
retry
|
281
|
+
end
|
282
|
+
end
|
283
|
+
response
|
284
|
+
end
|
243
285
|
end
|
244
286
|
end
|
@@ -33,6 +33,11 @@ module ParallelReportPortal
|
|
33
33
|
if ParallelReportPortal.parallel?
|
34
34
|
if ParallelTests.first_process?
|
35
35
|
ParallelTests.wait_for_other_processes_to_finish
|
36
|
+
|
37
|
+
launch_id = File.read(launch_id_file)
|
38
|
+
response = http_repeater { req_launch_finished(launch_id, clock) }
|
39
|
+
response.success? ? parse_report_link_from_response(response) : force_stop(launch_id, clock)
|
40
|
+
|
36
41
|
delete_file(launch_id_file)
|
37
42
|
delete_file(hierarchy_file)
|
38
43
|
end
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "appraisal", '~> 2.4'
|
33
33
|
spec.add_development_dependency "bump", "~> 0.8"
|
34
34
|
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
-
spec.add_development_dependency "rake", "~>
|
35
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
37
|
spec.add_development_dependency "pry", "~> 0.12"
|
38
38
|
spec.add_development_dependency "webmock", "~> 3.12"
|
@@ -41,6 +41,6 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_runtime_dependency 'faraday-net_http_persistent', '~> 2.1'
|
42
42
|
spec.add_runtime_dependency 'faraday-multipart', '~> 1.0', '>= 1.0.4'
|
43
43
|
spec.add_runtime_dependency 'parallel_tests', '>= 2.29.1'
|
44
|
-
spec.add_runtime_dependency 'rubytree', '~>
|
44
|
+
spec.add_runtime_dependency 'rubytree', '~> 2.0'
|
45
45
|
spec.add_runtime_dependency 'net-http-persistent', '~> 4.0'
|
46
46
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_report_portal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Brookes-Thomas
|
8
8
|
- Thomas Feathers
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '13.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '13.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,14 +177,14 @@ dependencies:
|
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '2.0'
|
181
181
|
type: :runtime
|
182
182
|
prerelease: false
|
183
183
|
version_requirements: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
187
|
+
version: '2.0'
|
188
188
|
- !ruby/object:Gem::Dependency
|
189
189
|
name: net-http-persistent
|
190
190
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,6 +207,7 @@ executables: []
|
|
207
207
|
extensions: []
|
208
208
|
extra_rdoc_files: []
|
209
209
|
files:
|
210
|
+
- ".github/workflows/deploy.yml"
|
210
211
|
- ".github/workflows/tests.yml"
|
211
212
|
- ".gitignore"
|
212
213
|
- ".rspec"
|
@@ -240,7 +241,7 @@ licenses:
|
|
240
241
|
metadata:
|
241
242
|
homepage_uri: https://github.com/dvla/dvla-reportportal-ruby
|
242
243
|
source_code_uri: https://github.com/dvla/dvla-reportportal-ruby
|
243
|
-
post_install_message:
|
244
|
+
post_install_message:
|
244
245
|
rdoc_options: []
|
245
246
|
require_paths:
|
246
247
|
- lib
|
@@ -255,8 +256,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
256
|
- !ruby/object:Gem::Version
|
256
257
|
version: '0'
|
257
258
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
259
|
-
signing_key:
|
259
|
+
rubygems_version: 3.5.3
|
260
|
+
signing_key:
|
260
261
|
specification_version: 4
|
261
262
|
summary: Run Cucumber Tests in parallel and with Cucumber 3 and 4+
|
262
263
|
test_files: []
|