allq_rest 1.2.2 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +27 -27
- data/allq_rest-1.2.5.gem +0 -0
- data/allq_rest.gemspec +1 -1
- data/deploy.sh +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/allq_rest/api_client.rb +4 -3
- data/lib/allq_rest/configuration.rb +1 -4
- data/lib/allq_rest/models/stats_tube.rb +14 -3
- data/lib/allq_rest/version.rb +1 -1
- data/spec/api/actions_api_spec.rb +101 -91
- data/spec/configuration_spec.rb +5 -5
- data/spec/spec_helper.rb +2 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1408b8a497b82506fd034da76191cad3d63532784dc93126b21a22aa7301e4ff
|
4
|
+
data.tar.gz: 902c1bff0103082afef6a355ed407ea5cf7c0a64d8cae21e9e70f329a233df72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc3060e0d79318cff373dbf151aae42268548f136cabdc1170d55fb8ce94be248abceccecf4b0b59492d9bf7575ca744c0ef7d455ae1f8d7c8a7b9594d4218f0
|
7
|
+
data.tar.gz: 52e03790fcce1e8fc5bc83ade3cc91532e2645755a242fe51617da9f7cfcd500c580010bab1a0ff5c06f2596cb213fe8e651ab3e717897eb4254604a6d29fec6
|
data/Gemfile.lock
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
allq_rest (1.
|
4
|
+
allq_rest (1.2.5)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
typhoeus (~> 1.0, >= 1.0.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ZenTest (4.
|
12
|
-
addressable (2.
|
13
|
-
public_suffix (>= 2.0.2, <
|
11
|
+
ZenTest (4.12.0)
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
14
|
autotest (4.4.6)
|
15
15
|
ZenTest (>= 4.4.1)
|
16
|
-
autotest-fsevent (0.2.
|
16
|
+
autotest-fsevent (0.2.17)
|
17
17
|
sys-uname
|
18
18
|
autotest-growl (0.2.16)
|
19
19
|
autotest-rails-pure (4.1.2)
|
20
20
|
crack (0.4.3)
|
21
21
|
safe_yaml (~> 1.0.0)
|
22
|
-
diff-lcs (1.
|
23
|
-
ethon (0.
|
24
|
-
ffi (>= 1.
|
25
|
-
ffi (1.
|
26
|
-
hashdiff (0.
|
27
|
-
json (2.1
|
28
|
-
public_suffix (
|
22
|
+
diff-lcs (1.4.4)
|
23
|
+
ethon (0.14.0)
|
24
|
+
ffi (>= 1.15.0)
|
25
|
+
ffi (1.15.1)
|
26
|
+
hashdiff (1.0.1)
|
27
|
+
json (2.5.1)
|
28
|
+
public_suffix (4.0.6)
|
29
29
|
rake (12.0.0)
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
30
|
+
rspec (3.9.0)
|
31
|
+
rspec-core (~> 3.9.0)
|
32
|
+
rspec-expectations (~> 3.9.0)
|
33
|
+
rspec-mocks (~> 3.9.0)
|
34
|
+
rspec-core (3.9.2)
|
35
|
+
rspec-support (~> 3.9.3)
|
36
|
+
rspec-expectations (3.9.2)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.9.0)
|
39
|
+
rspec-mocks (3.9.1)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
43
|
-
safe_yaml (1.0.
|
44
|
-
sys-uname (1.
|
41
|
+
rspec-support (~> 3.9.0)
|
42
|
+
rspec-support (3.9.3)
|
43
|
+
safe_yaml (1.0.5)
|
44
|
+
sys-uname (1.2.1)
|
45
45
|
ffi (>= 1.0.0)
|
46
|
-
typhoeus (1.
|
46
|
+
typhoeus (1.4.0)
|
47
47
|
ethon (>= 0.9.0)
|
48
48
|
vcr (3.0.3)
|
49
49
|
webmock (1.24.6)
|
@@ -66,4 +66,4 @@ DEPENDENCIES
|
|
66
66
|
webmock (~> 1.24, >= 1.24.3)
|
67
67
|
|
68
68
|
BUNDLED WITH
|
69
|
-
|
69
|
+
2.2.3
|
data/allq_rest-1.2.5.gem
ADDED
Binary file
|
data/allq_rest.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = "Ruby REST client for Allq platform"
|
14
14
|
s.description = "Allq API Client"
|
15
15
|
# TODO uncommnet and update below with a proper license
|
16
|
-
|
16
|
+
s.license = "Apache 2.0"
|
17
17
|
s.required_ruby_version = "> 2.3"
|
18
18
|
|
19
19
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
data/deploy.sh
CHANGED
data/lib/.DS_Store
CHANGED
Binary file
|
data/lib/allq_rest/api_client.rb
CHANGED
@@ -27,9 +27,10 @@ module Allq
|
|
27
27
|
# @return [Hash]
|
28
28
|
attr_accessor :default_headers
|
29
29
|
|
30
|
-
# Initializes the
|
30
|
+
# Initializes the ApiClient
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
|
+
Ethon.logger = Logger.new(nil)
|
33
34
|
@config = config
|
34
35
|
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
35
36
|
@default_headers = {
|
@@ -39,7 +40,7 @@ module Allq
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def self.default
|
42
|
-
@@default ||=
|
43
|
+
@@default ||= ApiClient.new
|
43
44
|
end
|
44
45
|
|
45
46
|
# Call an API with given options.
|
@@ -263,7 +264,7 @@ module Allq
|
|
263
264
|
def build_request_url(path)
|
264
265
|
# Add leading and trailing slashes to path
|
265
266
|
path = "/#{path}".gsub(/\/+/, '/')
|
266
|
-
|
267
|
+
@config.base_url + path
|
267
268
|
end
|
268
269
|
|
269
270
|
# Builds the HTTP request body
|
@@ -10,8 +10,6 @@ Swagger Codegen version: 2.4.2
|
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require 'uri'
|
14
|
-
|
15
13
|
module Allq
|
16
14
|
class Configuration
|
17
15
|
# Defines url scheme
|
@@ -144,7 +142,6 @@ module Allq
|
|
144
142
|
@inject_format = false
|
145
143
|
@force_ending_format = false
|
146
144
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
147
|
-
|
148
145
|
yield(self) if block_given?
|
149
146
|
end
|
150
147
|
|
@@ -175,7 +172,7 @@ module Allq
|
|
175
172
|
|
176
173
|
def base_url
|
177
174
|
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
178
|
-
|
175
|
+
url
|
179
176
|
end
|
180
177
|
|
181
178
|
# Gets API key (with prefix if set).
|
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.21
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -33,6 +33,9 @@ module Allq
|
|
33
33
|
# TPS of throttle
|
34
34
|
attr_accessor :throttle_size
|
35
35
|
|
36
|
+
# Average duration of job
|
37
|
+
attr_accessor :avg
|
38
|
+
|
36
39
|
# Name of tube
|
37
40
|
attr_accessor :tube
|
38
41
|
|
@@ -45,6 +48,7 @@ module Allq
|
|
45
48
|
:'buried' => :'buried',
|
46
49
|
:'parents' => :'parents',
|
47
50
|
:'throttle_size' => :'throttle_size',
|
51
|
+
:'avg' => :'avg',
|
48
52
|
:'tube' => :'tube'
|
49
53
|
}
|
50
54
|
end
|
@@ -58,6 +62,7 @@ module Allq
|
|
58
62
|
:'buried' => :'Integer',
|
59
63
|
:'parents' => :'Integer',
|
60
64
|
:'throttle_size' => :'Integer',
|
65
|
+
:'avg' => :'Integer',
|
61
66
|
:'tube' => :'String'
|
62
67
|
}
|
63
68
|
end
|
@@ -104,6 +109,10 @@ module Allq
|
|
104
109
|
self.throttle_size = attributes[:'throttle_size']
|
105
110
|
end
|
106
111
|
|
112
|
+
if attributes.has_key?(:'avg')
|
113
|
+
self.avg = attributes[:'avg']
|
114
|
+
end
|
115
|
+
|
107
116
|
if attributes.has_key?(:'tube')
|
108
117
|
self.tube = attributes[:'tube']
|
109
118
|
end
|
@@ -163,6 +172,7 @@ module Allq
|
|
163
172
|
buried == o.buried &&
|
164
173
|
parents == o.parents &&
|
165
174
|
throttle_size == o.throttle_size &&
|
175
|
+
avg == o.avg &&
|
166
176
|
tube == o.tube
|
167
177
|
end
|
168
178
|
|
@@ -175,7 +185,7 @@ module Allq
|
|
175
185
|
# Calculates hash code according to all attributes.
|
176
186
|
# @return [Fixnum] Hash code
|
177
187
|
def hash
|
178
|
-
[ready, delayed, reserved, buried, parents, throttle_size, tube].hash
|
188
|
+
[ready, delayed, reserved, buried, parents, throttle_size, avg, tube].hash
|
179
189
|
end
|
180
190
|
|
181
191
|
# Builds the object from hash
|
@@ -185,7 +195,7 @@ module Allq
|
|
185
195
|
return nil unless attributes.is_a?(Hash)
|
186
196
|
self.class.swagger_types.each_pair do |key, type|
|
187
197
|
if type =~ /\AArray<(.*)>/i
|
188
|
-
# check to ensure the input is an array given that the
|
198
|
+
# check to ensure the input is an array given that the attribute
|
189
199
|
# is documented as an array but the input is not
|
190
200
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
191
201
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -281,5 +291,6 @@ module Allq
|
|
281
291
|
value
|
282
292
|
end
|
283
293
|
end
|
294
|
+
|
284
295
|
end
|
285
296
|
end
|
data/lib/allq_rest/version.rb
CHANGED
@@ -21,8 +21,16 @@ ALT_TUBE = ""
|
|
21
21
|
describe 'ActionsApi' do
|
22
22
|
before do
|
23
23
|
# run before each test
|
24
|
-
|
25
|
-
|
24
|
+
allq_conf = Allq::Configuration.new do |config|
|
25
|
+
config.host = ENV['ALLQ_CLIENT_LOCATION'] || 'localhost:8091'
|
26
|
+
end
|
27
|
+
raw_client = Allq::ApiClient.new(allq_conf)
|
28
|
+
@instance = Allq::ActionsApi.new(raw_client)
|
29
|
+
@admin_tools = Allq::AdminApi.new(raw_client)
|
30
|
+
|
31
|
+
@allq_tool = AllQTools.new(@instance, @admin_tools)
|
32
|
+
|
33
|
+
stats_result = @allq_tool.get_stats[0]
|
26
34
|
stats_result.stats.each do |stat|
|
27
35
|
@instance.tube_delete(stat.tube)
|
28
36
|
end
|
@@ -46,12 +54,12 @@ describe 'ActionsApi' do
|
|
46
54
|
# @return [BasicResponse]
|
47
55
|
describe 'bury_put test' do
|
48
56
|
it "should work" do
|
49
|
-
|
50
|
-
expect(
|
57
|
+
@allq_tool.add_job
|
58
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
51
59
|
job = @instance.job_get(DEFAULT_TUBE)
|
52
60
|
@instance.bury_put(job.id)
|
53
|
-
expect(
|
54
|
-
expect(
|
61
|
+
expect(@allq_tool.get_buried(DEFAULT_TUBE)).to eq(1)
|
62
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
@@ -64,11 +72,11 @@ describe 'ActionsApi' do
|
|
64
72
|
# @return [BasicResponse]
|
65
73
|
describe 'job_delete test' do
|
66
74
|
it "should work" do
|
67
|
-
|
68
|
-
expect(
|
75
|
+
@allq_tool.add_job
|
76
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
69
77
|
job = @instance.peek_get(DEFAULT_TUBE)
|
70
78
|
@instance.job_delete(job.id, tube: DEFAULT_TUBE)
|
71
|
-
expect(
|
79
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
@@ -80,9 +88,9 @@ describe 'ActionsApi' do
|
|
80
88
|
# @return [JobResponse]
|
81
89
|
describe 'job_get test' do
|
82
90
|
it "should work" do
|
83
|
-
|
91
|
+
@allq_tool.add_job
|
84
92
|
job = @instance.job_get(DEFAULT_TUBE)
|
85
|
-
expect(
|
93
|
+
expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
|
86
94
|
expect(job.id).to be_truthy
|
87
95
|
end
|
88
96
|
end
|
@@ -96,19 +104,19 @@ describe 'ActionsApi' do
|
|
96
104
|
describe 'mulitple_job_get test' do
|
97
105
|
it "should work" do
|
98
106
|
1.upto(6) do
|
99
|
-
|
107
|
+
@allq_tool.add_job
|
100
108
|
end
|
101
109
|
multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
|
102
110
|
expect(multiple_jobs.jobs.length).to eq(4)
|
103
|
-
expect(
|
111
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
|
104
112
|
multiple_jobs.jobs.each do |job|
|
105
113
|
@instance.job_delete(job.id)
|
106
114
|
end
|
107
|
-
expect(
|
115
|
+
expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(0)
|
108
116
|
|
109
117
|
multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
|
110
118
|
expect(multiple_jobs.jobs.length).to eq(2)
|
111
|
-
expect(
|
119
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
112
120
|
end
|
113
121
|
end
|
114
122
|
|
@@ -120,8 +128,8 @@ describe 'ActionsApi' do
|
|
120
128
|
# @return [JobRef]
|
121
129
|
describe 'job_post test' do
|
122
130
|
it "should work" do
|
123
|
-
|
124
|
-
expect(
|
131
|
+
@allq_tool.add_job
|
132
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
125
133
|
job = @instance.job_get(DEFAULT_TUBE)
|
126
134
|
expect(job.id).to be_truthy
|
127
135
|
end
|
@@ -144,18 +152,18 @@ describe 'ActionsApi' do
|
|
144
152
|
run_on_timeout: false,
|
145
153
|
limit: 2)
|
146
154
|
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
147
|
-
expect(
|
148
|
-
job =
|
155
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
156
|
+
job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
149
157
|
@instance.job_post(job)
|
150
|
-
job =
|
158
|
+
job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
151
159
|
@instance.job_post(job)
|
152
|
-
expect(
|
153
|
-
|
154
|
-
|
155
|
-
expect(
|
156
|
-
expect(
|
157
|
-
|
158
|
-
expect(
|
160
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
|
161
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
162
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
163
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
164
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
|
165
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
166
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
159
167
|
end
|
160
168
|
end
|
161
169
|
|
@@ -176,19 +184,19 @@ describe 'ActionsApi' do
|
|
176
184
|
run_on_timeout: false,
|
177
185
|
limit: 2)
|
178
186
|
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
179
|
-
expect(
|
187
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
180
188
|
|
181
|
-
job =
|
189
|
+
job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
|
182
190
|
@instance.job_post(job)
|
183
|
-
job =
|
191
|
+
job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
|
184
192
|
@instance.job_post(job)
|
185
|
-
expect(
|
186
|
-
|
187
|
-
|
188
|
-
expect(
|
189
|
-
expect(
|
190
|
-
|
191
|
-
expect(
|
193
|
+
expect(@allq_tool.get_ready('foo')).to eq(2)
|
194
|
+
@allq_tool.get_finish('foo')
|
195
|
+
@allq_tool.get_finish('foo')
|
196
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
197
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
|
198
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
199
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
192
200
|
end
|
193
201
|
end
|
194
202
|
|
@@ -209,16 +217,16 @@ describe 'ActionsApi' do
|
|
209
217
|
run_on_timeout: true,
|
210
218
|
limit: 2)
|
211
219
|
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
212
|
-
expect(
|
220
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
213
221
|
|
214
|
-
job =
|
222
|
+
job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
|
215
223
|
@instance.job_post(job)
|
216
|
-
expect(
|
217
|
-
expect(
|
224
|
+
expect(@allq_tool.get_ready('foo')).to eq(1)
|
225
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
218
226
|
|
219
227
|
sleep(7)
|
220
|
-
expect(
|
221
|
-
expect(
|
228
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
|
229
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
222
230
|
end
|
223
231
|
end
|
224
232
|
|
@@ -231,7 +239,7 @@ describe 'ActionsApi' do
|
|
231
239
|
# @return [JobResponse]
|
232
240
|
describe 'peek_get test' do
|
233
241
|
it "should work" do
|
234
|
-
|
242
|
+
@allq_tool.add_job
|
235
243
|
job = @instance.peek_get(DEFAULT_TUBE)
|
236
244
|
expect(job.id).to be_truthy
|
237
245
|
end
|
@@ -239,7 +247,7 @@ describe 'ActionsApi' do
|
|
239
247
|
|
240
248
|
describe 'peek_get buried test' do
|
241
249
|
it "should work" do
|
242
|
-
|
250
|
+
@allq_tool.add_job
|
243
251
|
job = @instance.peek_get(DEFAULT_TUBE, buried: true)
|
244
252
|
expect(job.id).to be_falsey
|
245
253
|
job = @instance.job_get(DEFAULT_TUBE)
|
@@ -272,20 +280,20 @@ describe 'ActionsApi' do
|
|
272
280
|
# @return [BasicResponse]
|
273
281
|
describe 'release_put test' do
|
274
282
|
it "should work" do
|
275
|
-
|
276
|
-
expect(
|
283
|
+
@allq_tool.add_job
|
284
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
277
285
|
job = @instance.job_get(DEFAULT_TUBE)
|
278
|
-
expect(
|
286
|
+
expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
|
279
287
|
expect(job.id).to be_truthy
|
280
288
|
@instance.release_put(job.id)
|
281
|
-
expect(
|
289
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
282
290
|
end
|
283
291
|
end
|
284
292
|
|
285
293
|
describe 'release should increment release' do
|
286
294
|
it "should work" do
|
287
|
-
|
288
|
-
expect(
|
295
|
+
@allq_tool.add_job
|
296
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
289
297
|
job = @instance.job_get(DEFAULT_TUBE)
|
290
298
|
expect(job.releases).to eq(0)
|
291
299
|
@instance.release_put(job.id)
|
@@ -317,25 +325,25 @@ describe 'ActionsApi' do
|
|
317
325
|
run_on_timeout: false,
|
318
326
|
limit: nil)
|
319
327
|
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
320
|
-
expect(
|
321
|
-
job =
|
328
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
329
|
+
job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
322
330
|
@instance.job_post(job)
|
323
|
-
job =
|
331
|
+
job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
324
332
|
@instance.job_post(job)
|
325
|
-
expect(
|
326
|
-
|
327
|
-
|
333
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
|
334
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
335
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
328
336
|
# After jobs have already finished
|
329
|
-
expect(
|
337
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
330
338
|
# Parent still waiting
|
331
|
-
expect(
|
339
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
|
332
340
|
# Set limit on parent
|
333
341
|
@instance.set_children_started_put(new_parent_job_response.job_id)
|
334
342
|
# Now parent gets moved to ready
|
335
|
-
expect(
|
336
|
-
expect(
|
337
|
-
|
338
|
-
expect(
|
343
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
344
|
+
expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
|
345
|
+
@allq_tool.get_finish(DEFAULT_TUBE)
|
346
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
|
339
347
|
end
|
340
348
|
end
|
341
349
|
|
@@ -360,10 +368,10 @@ describe 'ActionsApi' do
|
|
360
368
|
# @return [TubeRef]
|
361
369
|
describe 'throttle_post test' do
|
362
370
|
it "should work" do
|
363
|
-
|
364
|
-
expect(
|
371
|
+
@allq_tool.add_job
|
372
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
365
373
|
@instance.job_get(DEFAULT_TUBE)
|
366
|
-
stats_result =
|
374
|
+
stats_result = @allq_tool.get_stats[0]
|
367
375
|
expect(stats_result.action_count > 1).to eq(true)
|
368
376
|
end
|
369
377
|
end
|
@@ -376,8 +384,8 @@ describe 'ActionsApi' do
|
|
376
384
|
# @return [BasicResponse]
|
377
385
|
describe 'touch_put test' do
|
378
386
|
it "should work" do
|
379
|
-
|
380
|
-
expect(
|
387
|
+
@allq_tool.add_job
|
388
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
|
381
389
|
job = @instance.job_get(DEFAULT_TUBE)
|
382
390
|
@instance.touch_put(job.id)
|
383
391
|
end
|
@@ -427,31 +435,31 @@ describe 'ActionsApi' do
|
|
427
435
|
priority: 5,
|
428
436
|
parent_id: nil)
|
429
437
|
@instance.job_post(new_job)
|
430
|
-
expect(
|
438
|
+
expect(@allq_tool.get_ready("alt_tube2")).to eq(2) # OK..it's there
|
431
439
|
reserved_job = @instance.job_get("alt_tube2")
|
432
440
|
|
433
441
|
# Other tube has 1 ready, 1 reserved
|
434
|
-
expect(
|
435
|
-
expect(
|
442
|
+
expect(@allq_tool.get_ready("alt_tube2")).to eq(1)
|
443
|
+
expect(@allq_tool.get_reserved("alt_tube2")).to eq(1)
|
436
444
|
|
437
445
|
# Get 1 into buried, 1 into reserved, and 1 in ready so we can clear it
|
438
|
-
expect(
|
446
|
+
expect(@allq_tool.get_ready(alt_tube_name)).to eq(3) # OK..it's there
|
439
447
|
reserved_job = @instance.job_get(alt_tube_name)
|
440
|
-
expect(
|
448
|
+
expect(@allq_tool.get_reserved(alt_tube_name)).to eq(1) # OK..it's there
|
441
449
|
reserved_job = @instance.job_get(alt_tube_name)
|
442
|
-
expect(
|
450
|
+
expect(@allq_tool.get_reserved(alt_tube_name)).to eq(2) # OK..it's there
|
443
451
|
@instance.bury_put(reserved_job.id)
|
444
|
-
expect(
|
452
|
+
expect(@allq_tool.get_buried(alt_tube_name)).to eq(1)
|
445
453
|
|
446
454
|
# Now check that first tube is empty
|
447
455
|
@instance.tube_delete(alt_tube_name)
|
448
|
-
expect(
|
449
|
-
expect(
|
450
|
-
expect(
|
456
|
+
expect(@allq_tool.get_buried(alt_tube_name)).to eq(0)
|
457
|
+
expect(@allq_tool.get_reserved(alt_tube_name)).to eq(0) # OK..it's there
|
458
|
+
expect(@allq_tool.get_ready(alt_tube_name)).to eq(0)
|
451
459
|
|
452
460
|
# ..and other tubes are fine
|
453
|
-
expect(
|
454
|
-
expect(
|
461
|
+
expect(@allq_tool.get_ready("alt_tube2")).to eq(1)
|
462
|
+
expect(@allq_tool.get_reserved("alt_tube2")).to eq(1)
|
455
463
|
end
|
456
464
|
end
|
457
465
|
|
@@ -466,9 +474,9 @@ describe 'ActionsApi' do
|
|
466
474
|
priority: 5,
|
467
475
|
parent_id: nil)
|
468
476
|
@instance.job_post(new_job)
|
469
|
-
expect(
|
477
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0) # Too soon to show up
|
470
478
|
sleep(4)
|
471
|
-
expect(
|
479
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1) # OK..it's there
|
472
480
|
end
|
473
481
|
end
|
474
482
|
|
@@ -485,18 +493,21 @@ describe 'ActionsApi' do
|
|
485
493
|
@instance.job_post(new_job)
|
486
494
|
sleep(1)
|
487
495
|
@instance.job_get(DEFAULT_TUBE)
|
488
|
-
expect(
|
496
|
+
expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
|
489
497
|
sleep(5)
|
490
|
-
expect(
|
491
|
-
expect(
|
498
|
+
expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(0) # Should expire
|
499
|
+
expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1) # ..and be back in ready
|
492
500
|
end
|
493
501
|
end
|
494
502
|
|
495
503
|
end
|
496
504
|
|
497
505
|
|
498
|
-
|
499
|
-
|
506
|
+
class AllQTools
|
507
|
+
def initialize(action_client, admin_client)
|
508
|
+
@action_client = action_client
|
509
|
+
@admin_client = admin_client
|
510
|
+
end
|
500
511
|
|
501
512
|
def new_job(tube = 'default', body = nil, parent_id = nil)
|
502
513
|
body = (0...8).map { (65 + rand(26)).chr }.join unless body
|
@@ -511,20 +522,20 @@ module AllQTools
|
|
511
522
|
end
|
512
523
|
|
513
524
|
def add_job(tube = DEFAULT_TUBE)
|
514
|
-
client =
|
525
|
+
client = @action_client
|
515
526
|
job = new_job(tube)
|
516
527
|
job = client.job_post(new_job)
|
517
528
|
return job
|
518
529
|
end
|
519
530
|
|
520
531
|
def get_finish(tube)
|
521
|
-
client =
|
532
|
+
client = @action_client
|
522
533
|
job = client.job_get(tube)
|
523
534
|
client.job_delete(job.id)
|
524
535
|
end
|
525
536
|
|
526
537
|
def get_stats
|
527
|
-
client =
|
538
|
+
client = @admin_client
|
528
539
|
client.stats_get
|
529
540
|
end
|
530
541
|
|
@@ -571,5 +582,4 @@ module AllQTools
|
|
571
582
|
end
|
572
583
|
end
|
573
584
|
end
|
574
|
-
end
|
575
585
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -18,11 +18,11 @@ describe Allq::Configuration do
|
|
18
18
|
before(:each) do
|
19
19
|
# uncomment below to setup host and base_path
|
20
20
|
#require 'URI'
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
uri = URI.parse("http://localhost:8091")
|
22
|
+
Allq.configure do |c|
|
23
|
+
c.host = uri.host
|
24
|
+
c.base_path = uri.path
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#base_url' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allq_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- support@blitline.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- Gemfile.lock
|
202
202
|
- README.md
|
203
203
|
- Rakefile
|
204
|
+
- allq_rest-1.2.5.gem
|
204
205
|
- allq_rest.gemspec
|
205
206
|
- deploy.sh
|
206
207
|
- docs/ActionsApi.md
|
@@ -256,7 +257,8 @@ files:
|
|
256
257
|
- spec/models/tube_ref_spec.rb
|
257
258
|
- spec/spec_helper.rb
|
258
259
|
homepage: http://www.blitline.com
|
259
|
-
licenses:
|
260
|
+
licenses:
|
261
|
+
- Apache 2.0
|
260
262
|
metadata: {}
|
261
263
|
post_install_message:
|
262
264
|
rdoc_options: []
|
@@ -273,8 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
275
|
- !ruby/object:Gem::Version
|
274
276
|
version: '0'
|
275
277
|
requirements: []
|
276
|
-
|
277
|
-
rubygems_version: 2.7.9
|
278
|
+
rubygems_version: 3.0.9
|
278
279
|
signing_key:
|
279
280
|
specification_version: 4
|
280
281
|
summary: Ruby REST client for Allq platform
|