topological_inventory-providers-common 2.0.0 → 2.1.4
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 +4 -4
- data/.codeclimate.yml +31 -0
- data/.rubocop.yml +1 -1
- data/.yamllint +8 -0
- data/CHANGELOG.md +26 -3
- data/README.md +1 -1
- data/lib/topological_inventory/providers/common.rb +1 -0
- data/lib/topological_inventory/providers/common/messaging_client.rb +40 -0
- data/lib/topological_inventory/providers/common/metrics.rb +109 -0
- data/lib/topological_inventory/providers/common/mixins/sources_api.rb +3 -0
- data/lib/topological_inventory/providers/common/mixins/statuses.rb +19 -0
- data/lib/topological_inventory/providers/common/operations/async_worker.rb +12 -7
- data/lib/topological_inventory/providers/common/operations/processor.rb +77 -0
- data/lib/topological_inventory/providers/common/operations/source.rb +83 -19
- data/lib/topological_inventory/providers/common/version.rb +1 -1
- data/spec/support/shared/availability_check.rb +254 -90
- data/spec/topological_inventory/providers/common/operations/async_worker_spec.rb +14 -5
- data/spec/topological_inventory/providers/common/operations/processor_spec.rb +71 -0
- data/topological_inventory-providers-common.gemspec +14 -10
- metadata +69 -6
@@ -0,0 +1,71 @@
|
|
1
|
+
require "topological_inventory/providers/common/operations/processor"
|
2
|
+
|
3
|
+
RSpec.describe TopologicalInventory::Providers::Common::Operations::Processor do
|
4
|
+
let(:operation_name) { 'Source.availability_check' }
|
5
|
+
let(:params) { {'source_id' => 1, 'external_tenant' => '12345'} }
|
6
|
+
let(:payload) { {"params" => params, "request_context" => double('request_context')} }
|
7
|
+
let(:message) { double("ManageIQ::Messaging::ReceivedMessage", :message => operation_name, :payload => payload) }
|
8
|
+
|
9
|
+
subject { described_class.new(message, nil) }
|
10
|
+
|
11
|
+
describe "#process" do
|
12
|
+
it "starts the operation if class and method exists" do
|
13
|
+
result = double('result')
|
14
|
+
|
15
|
+
klass = TopologicalInventory::Providers::Common::Operations::Source
|
16
|
+
allow(subject).to receive(:operation_class).and_return(klass)
|
17
|
+
|
18
|
+
source = klass.new(params, payload['request_context'], nil)
|
19
|
+
expect(klass).to receive(:new).with(params, payload['request_context'], nil).and_return(source)
|
20
|
+
expect(source).to receive(:availability_check).and_return(result)
|
21
|
+
|
22
|
+
expect(subject.process).to eq(result)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns 'not_implemented' if class of method doesn't exist" do
|
26
|
+
allow(subject).to receive(:operation_class).and_return(nil)
|
27
|
+
allow(subject).to receive(:method).and_return('awesome')
|
28
|
+
|
29
|
+
expect(subject.process).to eq(subject.operation_status[:not_implemented])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "updates task if not_implemented" do
|
33
|
+
allow(subject).to receive(:operation_class).and_return(nil)
|
34
|
+
allow(subject).to receive(:method).and_return('awesome')
|
35
|
+
|
36
|
+
subject.send(:params)['task_id'] = '1'
|
37
|
+
expect(subject).to(receive(:update_task).with('1',
|
38
|
+
:state => "completed",
|
39
|
+
:status => "error",
|
40
|
+
:context => anything))
|
41
|
+
subject.process
|
42
|
+
end
|
43
|
+
|
44
|
+
it "updates task if exception raised" do
|
45
|
+
subject.send(:params)['task_id'] = '1'
|
46
|
+
expect(subject).to(receive(:update_task).with('1',
|
47
|
+
:state => "completed",
|
48
|
+
:status => "error",
|
49
|
+
:context => anything))
|
50
|
+
expect { subject.process }.to raise_exception(NotImplementedError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#with_time_measure" do
|
55
|
+
let(:metrics) { double("Metrics") }
|
56
|
+
|
57
|
+
it "records time and yields if metrics provided" do
|
58
|
+
allow(subject).to receive(:metrics).and_return(metrics)
|
59
|
+
|
60
|
+
expect(metrics).to receive(:record_operation_time).with(operation_name).and_yield
|
61
|
+
|
62
|
+
expect(subject.send(:with_time_measure) { 42 }).to eq(42)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "only yields if metrics not present" do
|
66
|
+
expect(metrics).not_to receive(:record_operation_time)
|
67
|
+
|
68
|
+
expect(subject.send(:with_time_measure) { 42 }).to eq(42)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -26,16 +26,20 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_runtime_dependency 'activesupport', '~> 5.2.4.3'
|
27
27
|
spec.add_runtime_dependency 'config', '~> 1.7', '>= 1.7.2'
|
28
28
|
spec.add_runtime_dependency 'json', '~> 2.3'
|
29
|
-
spec.add_runtime_dependency
|
30
|
-
spec.add_runtime_dependency
|
31
|
-
spec.add_runtime_dependency
|
32
|
-
spec.add_runtime_dependency
|
29
|
+
spec.add_runtime_dependency 'manageiq-loggers', '>= 0.4.2'
|
30
|
+
spec.add_runtime_dependency 'manageiq-messaging', '~> 1.0.0'
|
31
|
+
spec.add_runtime_dependency 'more_core_extensions'
|
32
|
+
spec.add_runtime_dependency 'prometheus_exporter', '~> 0.4.17'
|
33
|
+
spec.add_runtime_dependency 'sources-api-client', '~> 3.0'
|
34
|
+
spec.add_runtime_dependency 'topological_inventory-api-client', '~> 3.0', '>= 3.0.1'
|
35
|
+
spec.add_runtime_dependency 'topological_inventory-ingress_api-client', '~> 1.0', '>= 1.0.3'
|
33
36
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency 'rubocop', '~>0.
|
38
|
-
spec.add_development_dependency 'rubocop-performance', '~>1.
|
39
|
-
spec.add_development_dependency
|
37
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
38
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 1.0.0'
|
41
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.8'
|
42
|
+
spec.add_development_dependency 'rubocop-rails', '~> 2.8'
|
43
|
+
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
40
44
|
spec.add_development_dependency 'webmock'
|
41
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topological_inventory-providers-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Slemr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,6 +72,48 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.4.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: manageiq-messaging
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.0.0
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.0.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: more_core_extensions
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: prometheus_exporter
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.4.17
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.4.17
|
75
117
|
- !ruby/object:Gem::Dependency
|
76
118
|
name: sources-api-client
|
77
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,28 +216,42 @@ dependencies:
|
|
174
216
|
requirements:
|
175
217
|
- - "~>"
|
176
218
|
- !ruby/object:Gem::Version
|
177
|
-
version: 0.
|
219
|
+
version: 1.0.0
|
178
220
|
type: :development
|
179
221
|
prerelease: false
|
180
222
|
version_requirements: !ruby/object:Gem::Requirement
|
181
223
|
requirements:
|
182
224
|
- - "~>"
|
183
225
|
- !ruby/object:Gem::Version
|
184
|
-
version: 0.
|
226
|
+
version: 1.0.0
|
185
227
|
- !ruby/object:Gem::Dependency
|
186
228
|
name: rubocop-performance
|
187
229
|
requirement: !ruby/object:Gem::Requirement
|
188
230
|
requirements:
|
189
231
|
- - "~>"
|
190
232
|
- !ruby/object:Gem::Version
|
191
|
-
version: '1.
|
233
|
+
version: '1.8'
|
234
|
+
type: :development
|
235
|
+
prerelease: false
|
236
|
+
version_requirements: !ruby/object:Gem::Requirement
|
237
|
+
requirements:
|
238
|
+
- - "~>"
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '1.8'
|
241
|
+
- !ruby/object:Gem::Dependency
|
242
|
+
name: rubocop-rails
|
243
|
+
requirement: !ruby/object:Gem::Requirement
|
244
|
+
requirements:
|
245
|
+
- - "~>"
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: '2.8'
|
192
248
|
type: :development
|
193
249
|
prerelease: false
|
194
250
|
version_requirements: !ruby/object:Gem::Requirement
|
195
251
|
requirements:
|
196
252
|
- - "~>"
|
197
253
|
- !ruby/object:Gem::Version
|
198
|
-
version: '
|
254
|
+
version: '2.8'
|
199
255
|
- !ruby/object:Gem::Dependency
|
200
256
|
name: simplecov
|
201
257
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,6 +287,7 @@ executables: []
|
|
231
287
|
extensions: []
|
232
288
|
extra_rdoc_files: []
|
233
289
|
files:
|
290
|
+
- ".codeclimate.yml"
|
234
291
|
- ".github/workflows/gem-push.yml"
|
235
292
|
- ".gitignore"
|
236
293
|
- ".rspec"
|
@@ -238,6 +295,7 @@ files:
|
|
238
295
|
- ".rubocop_cc.yml"
|
239
296
|
- ".rubocop_local.yml"
|
240
297
|
- ".travis.yml"
|
298
|
+
- ".yamllint"
|
241
299
|
- CHANGELOG.md
|
242
300
|
- Gemfile
|
243
301
|
- LICENSE.txt
|
@@ -252,11 +310,15 @@ files:
|
|
252
310
|
- lib/topological_inventory/providers/common/collector/parser.rb
|
253
311
|
- lib/topological_inventory/providers/common/collectors_pool.rb
|
254
312
|
- lib/topological_inventory/providers/common/logging.rb
|
313
|
+
- lib/topological_inventory/providers/common/messaging_client.rb
|
314
|
+
- lib/topological_inventory/providers/common/metrics.rb
|
255
315
|
- lib/topological_inventory/providers/common/mixins/sources_api.rb
|
316
|
+
- lib/topological_inventory/providers/common/mixins/statuses.rb
|
256
317
|
- lib/topological_inventory/providers/common/mixins/topology_api.rb
|
257
318
|
- lib/topological_inventory/providers/common/mixins/x_rh_headers.rb
|
258
319
|
- lib/topological_inventory/providers/common/operations/async_worker.rb
|
259
320
|
- lib/topological_inventory/providers/common/operations/health_check.rb
|
321
|
+
- lib/topological_inventory/providers/common/operations/processor.rb
|
260
322
|
- lib/topological_inventory/providers/common/operations/source.rb
|
261
323
|
- lib/topological_inventory/providers/common/save_inventory/exception.rb
|
262
324
|
- lib/topological_inventory/providers/common/save_inventory/saver.rb
|
@@ -272,6 +334,7 @@ files:
|
|
272
334
|
- spec/topological_inventory/providers/common/collectors_pool_spec.rb
|
273
335
|
- spec/topological_inventory/providers/common/logger_spec.rb
|
274
336
|
- spec/topological_inventory/providers/common/operations/async_worker_spec.rb
|
337
|
+
- spec/topological_inventory/providers/common/operations/processor_spec.rb
|
275
338
|
- spec/topological_inventory/providers/common/operations/source_spec.rb
|
276
339
|
- spec/topological_inventory/providers/common/save_inventory/saver_spec.rb
|
277
340
|
- spec/topological_inventory/providers/common_spec.rb
|