parallel_report_portal 3.0.1 → 3.0.2.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa816eee089ddc4b187164a08791c5d2f1d6a1558b85574313bdd080c7caec25
4
- data.tar.gz: 4e2b2123fe5a51e3e583975a19847e02c2c088b171952a93ab6a8a2566733d2d
3
+ metadata.gz: e1d5cb1312e5c4b45d5581eea41e02df63266535ee5e3b58412f5d9fde5fd0dd
4
+ data.tar.gz: a10beda80c2270a68c06ff13a18701cf1cd0734eae91bd0c81c37cf0ecfd0623
5
5
  SHA512:
6
- metadata.gz: 4dce56b66318bdcd43d41e0f8c7a14062f22022438d2c8b4e64a539af3c39b6f56fc8ba5d5af91f65dbcca7407633aea5f5ba19392fa999c04c81dbda57e4eb6
7
- data.tar.gz: 807457edccdbf26c310ce41d667ecfc313bd58f85aa502daad3d06b5585f354c6820a144df7307e5bc2227d3d945b1fdbc0eba2eeaf3e200026b75ebe2543c0c
6
+ metadata.gz: aa2e9ce388cd7de1df78bbcd958c44f6bd329e8ebc7c40c0f550b5e79febd82b2a5913e141fc74f3e80206968f801c9e885539b7df2a4f5c06ae4508b9df11a6
7
+ data.tar.gz: 02b361da3143afa20ecd5d2111cd74fef9655b848a56174b2624d60193b2f2ee40b996ccd0dbf29abefa165e271836cac7a8c08bcab63a71d08a7c80306be85d
@@ -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( 'root' )
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 possilbe that this method could be called
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+' ) do |file|
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
- @launch_id = file.readline
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
- response = ParallelReportPortal.req_feature_finished(node.content, clock) unless node.is_root?
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
- ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.hierarchy_file, 'a+b' ) do |file|
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
- ! test_step.source.last.respond_to?(:keyword)
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
@@ -6,6 +6,8 @@ module ParallelReportPortal
6
6
  # REST interface.
7
7
  module HTTP
8
8
 
9
+ class HTTPBadGatewayError < StandardError; end
10
+
9
11
  # Creating class level logger and setting log level
10
12
  @@logger = Logger.new(STDOUT)
11
13
  @@logger.level = Logger::ERROR
@@ -93,9 +95,30 @@ module ParallelReportPortal
93
95
  # Send a request to Report Portal to finish a launch.
94
96
  # It will bubble up any Faraday connection exceptions.
95
97
  def req_launch_finished(launch_id, time)
96
- ParallelReportPortal.http_connection.put("launch/#{launch_id}/finish") do |req|
98
+ @@logger.debug { "Launch finish with ID: '#{launch_id}'" }
99
+
100
+ response = ParallelReportPortal.http_connection.put("launch/#{launch_id}/finish") do |req|
97
101
  req.body = { end_time: time }.to_json
98
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
99
122
  end
100
123
 
101
124
  # Send a request to ReportPortal to start a feature.
@@ -145,9 +168,14 @@ module ParallelReportPortal
145
168
 
146
169
  # Send a request to Report Portal that a feature has completed.
147
170
  def req_feature_finished(feature_id, time)
148
- ParallelReportPortal.http_connection.put("item/#{feature_id}") do |req|
171
+ response = ParallelReportPortal.http_connection.put("item/#{feature_id}") do |req|
149
172
  req.body = { end_time: time }.to_json
150
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
151
179
  end
152
180
 
153
181
  # Send a request to ReportPortal to start a test case.
@@ -236,5 +264,23 @@ module ParallelReportPortal
236
264
  end
237
265
  end
238
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
239
285
  end
240
286
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelReportPortal
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2.beta.1"
3
3
  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
@@ -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', '~> 1.0'
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_report_portal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-01-02 00:00:00.000000000 Z
12
+ date: 2024-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -177,14 +177,14 @@ dependencies:
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.0'
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: '1.0'
187
+ version: '2.0'
188
188
  - !ruby/object:Gem::Dependency
189
189
  name: net-http-persistent
190
190
  requirement: !ruby/object:Gem::Requirement