hiptest-publisher 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiptest-publisher.rb +1 -1
- data/lib/hiptest-publisher/client.rb +61 -10
- metadata +28 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bcc0cd663f5ba7411031e5f8db901bd7229fe6d88a7deb815cbfc82dde9e8ea
|
4
|
+
data.tar.gz: 165c9da7b30f07d0eeacbdaef4aae5fefa9146533ee826898971d646ecc6adcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824256833f21ff08a6693ca63a5d5d40f1d15e54b9a6df78152d98bc94ac9f5fc67b04b0c371b6f2ac3d24ef9e0e3d454d680c4de4fe3ca7972f50e5ec6753a2
|
7
|
+
data.tar.gz: 9b58353c5f481931ca91ed563cff619d4738589a0c35bea5f3cfb7bf53324719999bc718697001e2d83623f2854e0251af76a4a14bb9e8328846d7a215194755
|
data/lib/hiptest-publisher.rb
CHANGED
@@ -21,6 +21,9 @@ module Hiptest
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
class AsyncExportUnavailable < StandardError
|
25
|
+
end
|
26
|
+
|
24
27
|
class MaximumRedirectionReachedError < StandardError
|
25
28
|
end
|
26
29
|
|
@@ -28,10 +31,12 @@ module Hiptest
|
|
28
31
|
|
29
32
|
class Client
|
30
33
|
attr_reader :cli_options
|
34
|
+
attr_writer :async_options
|
31
35
|
|
32
36
|
def initialize(cli_options, reporter = nil)
|
33
37
|
@cli_options = cli_options
|
34
38
|
@reporter = reporter || NullReporter.new
|
39
|
+
@async_options = { max_attempts: 200, sleep_time_between_attemps: 5 }
|
35
40
|
end
|
36
41
|
|
37
42
|
def url
|
@@ -86,7 +91,7 @@ module Hiptest
|
|
86
91
|
return "?filter_status=#{value}"
|
87
92
|
end
|
88
93
|
|
89
|
-
def
|
94
|
+
def fetch_project
|
90
95
|
cached = export_cache.cache_for(url)
|
91
96
|
|
92
97
|
unless cached.nil?
|
@@ -95,17 +100,18 @@ module Hiptest
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
98
|
-
@reporter.with_status_message I18n.t(:fetching_data) do
|
99
|
-
|
100
|
-
if response.code_type == Net::HTTPNotFound
|
101
|
-
raise ClientError, I18n.t('errors.project_not_found')
|
102
|
-
end
|
103
|
-
|
104
|
-
content = response.body
|
105
|
-
export_cache.cache(url, content)
|
103
|
+
content = @reporter.with_status_message I18n.t(:fetching_data) do
|
104
|
+
break fetch_project_export if use_synchronous_fetch?
|
106
105
|
|
107
|
-
|
106
|
+
begin
|
107
|
+
fetch_project_export_asynchronously
|
108
|
+
rescue AsyncExportUnavailable
|
109
|
+
fetch_project_export
|
110
|
+
end
|
108
111
|
end
|
112
|
+
|
113
|
+
export_cache.cache(url, content)
|
114
|
+
content
|
109
115
|
end
|
110
116
|
|
111
117
|
def available_test_runs
|
@@ -136,6 +142,50 @@ module Hiptest
|
|
136
142
|
|
137
143
|
private
|
138
144
|
|
145
|
+
def use_synchronous_fetch?
|
146
|
+
cli_options.push? || cli_options.leafless_export || test_run_id
|
147
|
+
end
|
148
|
+
|
149
|
+
def fetch_project_export
|
150
|
+
response = send_get_request(url)
|
151
|
+
if response.code_type == Net::HTTPNotFound
|
152
|
+
raise ClientError, I18n.t('errors.project_not_found')
|
153
|
+
end
|
154
|
+
|
155
|
+
response.body
|
156
|
+
end
|
157
|
+
|
158
|
+
def fetch_project_export_asynchronously
|
159
|
+
publication_export_id = fetch_asynchronous_publication_export_id
|
160
|
+
url = "#{base_publication_path}/async_project/#{publication_export_id}"
|
161
|
+
response = nil
|
162
|
+
|
163
|
+
# the server should respond with a timeout after 15 minutes
|
164
|
+
# it is about 180 attempts with a sleep time of 5 seconds between each requests
|
165
|
+
sleep_time_between_attemps = @async_options[:sleep_time_between_attemps]
|
166
|
+
max_attempts = @async_options[:max_attempts]
|
167
|
+
|
168
|
+
loop do
|
169
|
+
response = send_get_request(url)
|
170
|
+
|
171
|
+
break unless response.code_type == Net::HTTPAccepted
|
172
|
+
break if 0 >= (max_attempts -= 1)
|
173
|
+
|
174
|
+
sleep(sleep_time_between_attemps)
|
175
|
+
end
|
176
|
+
|
177
|
+
response.body
|
178
|
+
end
|
179
|
+
|
180
|
+
def fetch_asynchronous_publication_export_id
|
181
|
+
url = "#{base_publication_path}/async_project#{project_export_filters}"
|
182
|
+
response = send_post_request(url)
|
183
|
+
|
184
|
+
raise AsyncExportUnavailable if response.code_type == Net::HTTPNotFound
|
185
|
+
|
186
|
+
JSON.parse(response.body)['publication_export_id']
|
187
|
+
end
|
188
|
+
|
139
189
|
def export_cache
|
140
190
|
@export_cache ||= ExportCache.new(
|
141
191
|
@cli_options.cache_dir,
|
@@ -243,6 +293,7 @@ module Hiptest
|
|
243
293
|
response = http.request(request)
|
244
294
|
|
245
295
|
raise RedirectionError.new("Got redirected", response['location']) if response.is_a?(Net::HTTPRedirection)
|
296
|
+
|
246
297
|
response
|
247
298
|
end
|
248
299
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiptest-publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HipTest R&D
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.7'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 0.7.5
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.7'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.7'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 0.7.5
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.7'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: parseconfig
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.0'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: 1.0.4
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.0'
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: 1.0.4
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: i18n
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,22 +88,22 @@ dependencies:
|
|
88
88
|
name: multipart-post
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "~>"
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '2.1'
|
94
91
|
- - ">="
|
95
92
|
- !ruby/object:Gem::Version
|
96
93
|
version: 2.1.1
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.1'
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '2.1'
|
104
101
|
- - ">="
|
105
102
|
- !ruby/object:Gem::Version
|
106
103
|
version: 2.1.1
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.1'
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: ruby_version
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,22 +192,22 @@ dependencies:
|
|
192
192
|
name: codeclimate-test-reporter
|
193
193
|
requirement: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- - "~>"
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
version: '0.4'
|
198
195
|
- - ">="
|
199
196
|
- !ruby/object:Gem::Version
|
200
197
|
version: 0.4.6
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0.4'
|
201
201
|
type: :development
|
202
202
|
prerelease: false
|
203
203
|
version_requirements: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
|
-
- - "~>"
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
version: '0.4'
|
208
205
|
- - ">="
|
209
206
|
- !ruby/object:Gem::Version
|
210
207
|
version: 0.4.6
|
208
|
+
- - "~>"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0.4'
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
212
|
name: i18n-tasks
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
@@ -752,7 +752,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
752
752
|
- !ruby/object:Gem::Version
|
753
753
|
version: '0'
|
754
754
|
requirements: []
|
755
|
-
|
755
|
+
rubyforge_project:
|
756
|
+
rubygems_version: 2.7.6.2
|
756
757
|
signing_key:
|
757
758
|
specification_version: 4
|
758
759
|
summary: Export your tests from HipTest into executable tests.
|