mcollective-client 2.2.4 → 2.4.0
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.
Potentially problematic release.
This version of mcollective-client might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/mcollective/application.rb +25 -34
- data/lib/mcollective/client.rb +91 -33
- data/lib/mcollective/config.rb +42 -43
- data/lib/mcollective/data/base.rb +1 -1
- data/lib/mcollective/data/result.rb +6 -2
- data/lib/mcollective/ddl/agentddl.rb +28 -1
- data/lib/mcollective/ddl/base.rb +8 -6
- data/lib/mcollective/log.rb +11 -3
- data/lib/mcollective/logger/file_logger.rb +4 -4
- data/lib/mcollective/matcher.rb +9 -1
- data/lib/mcollective/message.rb +14 -23
- data/lib/mcollective/optionparser.rb +9 -1
- data/lib/mcollective/pluginpackager.rb +24 -3
- data/lib/mcollective/pluginpackager/agent_definition.rb +12 -12
- data/lib/mcollective/pluginpackager/standard_definition.rb +12 -12
- data/lib/mcollective/rpc/agent.rb +15 -12
- data/lib/mcollective/rpc/client.rb +67 -31
- data/lib/mcollective/rpc/helpers.rb +7 -1
- data/lib/mcollective/rpc/reply.rb +3 -1
- data/lib/mcollective/shell.rb +45 -8
- data/lib/mcollective/util.rb +37 -1
- data/lib/mcollective/windows_daemon.rb +14 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/application_spec.rb +45 -26
- data/spec/unit/cache_spec.rb +3 -3
- data/spec/unit/client_spec.rb +269 -24
- data/spec/unit/config_spec.rb +89 -26
- data/spec/unit/data/base_spec.rb +1 -0
- data/spec/unit/data/result_spec.rb +19 -1
- data/spec/unit/data_spec.rb +3 -0
- data/spec/unit/ddl/agentddl_spec.rb +32 -0
- data/spec/unit/ddl/base_spec.rb +4 -0
- data/spec/unit/ddl/dataddl_spec.rb +1 -1
- data/spec/unit/log_spec.rb +44 -27
- data/spec/unit/logger/base_spec.rb +1 -1
- data/spec/unit/matcher_spec.rb +14 -0
- data/spec/unit/message_spec.rb +24 -0
- data/spec/unit/optionparser_spec.rb +99 -0
- data/spec/unit/pluginpackager/agent_definition_spec.rb +48 -17
- data/spec/unit/pluginpackager/standard_definition_spec.rb +44 -20
- data/spec/unit/pluginpackager_spec.rb +31 -7
- data/spec/unit/plugins/mcollective/agent/rpcutil_spec.rb +176 -0
- data/spec/unit/plugins/mcollective/application/plugin_spec.rb +81 -0
- data/spec/unit/plugins/mcollective/audit/logfile_spec.rb +44 -0
- data/spec/unit/plugins/mcollective/connector/activemq_spec.rb +118 -27
- data/spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb +168 -34
- data/spec/unit/plugins/mcollective/data/agent_data_spec.rb +1 -0
- data/spec/unit/plugins/mcollective/data/fstat_data_spec.rb +1 -0
- data/spec/unit/plugins/mcollective/discovery/flatfile_spec.rb +10 -0
- data/spec/unit/plugins/mcollective/discovery/stdin_spec.rb +65 -0
- data/spec/unit/plugins/mcollective/facts/yaml_facts_spec.rb +65 -0
- data/spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb +240 -219
- data/spec/unit/plugins/mcollective/packagers/modulepackage_packager_spec.rb +209 -0
- data/spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb +223 -109
- data/spec/unit/rpc/actionrunner_spec.rb +2 -1
- data/spec/unit/rpc/agent_spec.rb +130 -1
- data/spec/unit/rpc/client_spec.rb +169 -3
- data/spec/unit/security/base_spec.rb +0 -1
- data/spec/unit/shell_spec.rb +76 -3
- data/spec/unit/util_spec.rb +69 -1
- data/spec/unit/windows_daemon_spec.rb +30 -9
- metadata +104 -90
- data/spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb +0 -34
- data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +0 -424
- data/spec/unit/plugins/mcollective/validator/any_validator_spec.rb +0 -15
data/spec/unit/util_spec.rb
CHANGED
@@ -395,7 +395,6 @@ module MCollective
|
|
395
395
|
end
|
396
396
|
|
397
397
|
it "should return the correct dimensions if ENV columns and lines are set" do
|
398
|
-
|
399
398
|
stdout = mock()
|
400
399
|
stdout.expects(:tty?).returns(true)
|
401
400
|
Util.expects(:windows?).returns(false)
|
@@ -452,6 +451,36 @@ module MCollective
|
|
452
451
|
end
|
453
452
|
end
|
454
453
|
|
454
|
+
describe "#absolute_path?" do
|
455
|
+
it "should work correctly validate the path" do
|
456
|
+
Util.absolute_path?('.', '/', '\\').should == false
|
457
|
+
Util.absolute_path?('foo/foo', '/', '\\').should == false
|
458
|
+
Util.absolute_path?('foo\\bar', '/', '\\').should == false
|
459
|
+
Util.absolute_path?('../foo/bar', '/', '\\').should == false
|
460
|
+
|
461
|
+
Util.absolute_path?('\\foo/foo', '/', '\\').should == true
|
462
|
+
Util.absolute_path?('\\', '/', '\\').should == true
|
463
|
+
Util.absolute_path?('/foo', '/', '\\').should == true
|
464
|
+
Util.absolute_path?('/foo/foo', '/', '\\').should == true
|
465
|
+
|
466
|
+
Util.absolute_path?('.', '/', nil).should == false
|
467
|
+
Util.absolute_path?('foo/foo', '/', nil).should == false
|
468
|
+
Util.absolute_path?('foo\\bar', '/', nil).should == false
|
469
|
+
Util.absolute_path?('../foo/bar', '/', nil).should == false
|
470
|
+
|
471
|
+
Util.absolute_path?('\\foo/foo', '/', nil).should == false
|
472
|
+
Util.absolute_path?('\\', '/', nil).should == false
|
473
|
+
Util.absolute_path?('/foo', '/', nil).should == true
|
474
|
+
Util.absolute_path?('/foo/foo', '/', nil).should == true
|
475
|
+
end
|
476
|
+
|
477
|
+
it "should correctly validate paths on Windows" do
|
478
|
+
['C:\foo', '\foo\bar', '\C\FOO\Bar', '/C/FOO/Bar'].each do |path|
|
479
|
+
Util.absolute_path?(path, '/', '\\').should be_true
|
480
|
+
end
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
455
484
|
describe "#versioncmp" do
|
456
485
|
it "should be able to sort a long set of various unordered versions" do
|
457
486
|
ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06 1.2.10 1.2.8}
|
@@ -461,5 +490,44 @@ module MCollective
|
|
461
490
|
newary.should == ["0002", "1", "1.06", "1.1-3", "1.1-4", "1.1-5", "1.1.6", "1.1.a", "1.1a", "1.2", "1.2.8", "1.2.10", "1.5", "2.3", "2.3.0", "2.3.1", "2.3a.1", "2.4", "2.4", "2.4b", "2.40.2", "3.0", "3.1"]
|
462
491
|
end
|
463
492
|
end
|
493
|
+
|
494
|
+
describe "str_to_bool" do
|
495
|
+
it "should transform true like strings into TrueClass" do
|
496
|
+
["1", "y", "yes", "Y", "YES", "t", "true", "T", "TRUE", true].each do |val|
|
497
|
+
Util.str_to_bool(val).should be_true
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
it "should transform false like strings into FalseClass" do
|
502
|
+
["0", "n", "no", "N", "NO", "f", "false", "F", "FALSE", false].each do |val|
|
503
|
+
Util.str_to_bool(val).should be_false
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
it "should raise an exception if the string does not match the boolean pattern" do
|
508
|
+
["yep", "nope", "yess", "noway", "rspec", "YES!", "NO?"].each do |val|
|
509
|
+
expect { Util.str_to_bool(val) }.to raise_error("Cannot convert string value '#{val}' into a boolean.")
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
describe "#templatepath" do
|
515
|
+
before do
|
516
|
+
config = mock
|
517
|
+
config.stubs(:configfile).returns("/rspec/server.cfg")
|
518
|
+
Config.stubs(:instance).returns(config)
|
519
|
+
end
|
520
|
+
it "should look for a template in the config dir" do
|
521
|
+
File.stubs(:exists?).with("/rspec/test-help.erb").returns(true)
|
522
|
+
Util.templatepath("test-help.erb").should == "/rspec/test-help.erb"
|
523
|
+
end
|
524
|
+
|
525
|
+
it "should look for a template in the default dir" do
|
526
|
+
File.stubs(:exists?).with("/rspec/test-help.erb").returns(false)
|
527
|
+
File.stubs(:exists?).with("/etc/mcollective/test-help.erb").returns(true)
|
528
|
+
Util.templatepath("test-help.erb").should == "/etc/mcollective/test-help.erb"
|
529
|
+
|
530
|
+
end
|
531
|
+
end
|
464
532
|
end
|
465
533
|
end
|
@@ -18,23 +18,44 @@ module MCollective
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should start the mainloop" do
|
21
|
+
Util.stubs(:windows?).returns(true)
|
21
22
|
WindowsDaemon.expects(:mainloop)
|
22
23
|
WindowsDaemon.daemonize_runner
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
describe "#
|
27
|
-
it "should
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
describe "#service_main" do
|
28
|
+
it "should start the runner" do
|
29
|
+
runner = mock
|
30
|
+
Runner.stubs(:new).returns(runner)
|
31
|
+
d = WindowsDaemon.new
|
32
|
+
d.stubs(:running?).returns(true,false)
|
33
|
+
d.stubs(:state).returns(WindowsDaemon::RUNNING)
|
34
|
+
runner.expects(:run)
|
35
|
+
d.service_main
|
36
|
+
end
|
34
37
|
|
38
|
+
it "should kill any other living threads on exit" do
|
35
39
|
d = WindowsDaemon.new
|
36
|
-
d.
|
40
|
+
d.stubs(:running?).returns(false)
|
41
|
+
other = mock
|
42
|
+
Thread.stubs(:list).returns([Thread.current, other])
|
43
|
+
Thread.current.expects(:kill).never
|
44
|
+
other.expects(:kill)
|
45
|
+
d.service_main
|
46
|
+
end
|
47
|
+
end
|
37
48
|
|
49
|
+
describe "#service_stop" do
|
50
|
+
it "should log, disconnect, stop the runner and exit" do
|
51
|
+
runner = mock
|
52
|
+
connector = mock
|
53
|
+
connector.expects(:disconnect)
|
54
|
+
Log.expects(:info)
|
55
|
+
PluginManager.stubs(:[]).with("connector_plugin").returns(connector)
|
56
|
+
d = WindowsDaemon.new
|
57
|
+
d.instance_variable_set(:@runner, runner)
|
58
|
+
runner.expects(:stop)
|
38
59
|
d.service_stop
|
39
60
|
end
|
40
61
|
end
|
metadata
CHANGED
@@ -1,75 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcollective-client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
- 4
|
10
|
-
version: 2.2.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Puppet Labs
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: systemu
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
32
20
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: json
|
36
21
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
46
34
|
type: :runtime
|
47
|
-
|
48
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
49
42
|
name: stomp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
50
49
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
60
62
|
type: :runtime
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Client libraries for the Mcollective Application Server
|
70
|
+
email: info@puppetlabs.com
|
71
|
+
executables:
|
65
72
|
- mco
|
66
73
|
extensions: []
|
67
|
-
|
68
74
|
extra_rdoc_files: []
|
69
|
-
|
70
|
-
files:
|
71
|
-
- bin/mc-call-agent
|
72
|
-
- bin/mco
|
75
|
+
files:
|
73
76
|
- lib/mcollective.rb
|
74
77
|
- lib/mcollective/agent.rb
|
75
78
|
- lib/mcollective/agents.rb
|
@@ -146,6 +149,8 @@ files:
|
|
146
149
|
- lib/mcollective/vendor.rb
|
147
150
|
- lib/mcollective/vendor/require_vendored.rb
|
148
151
|
- lib/mcollective/windows_daemon.rb
|
152
|
+
- bin/mc-call-agent
|
153
|
+
- bin/mco
|
149
154
|
- spec/Rakefile
|
150
155
|
- spec/fixtures/application/test.rb
|
151
156
|
- spec/fixtures/test-cert.pem
|
@@ -203,22 +208,25 @@ files:
|
|
203
208
|
- spec/unit/pluginpackager/agent_definition_spec.rb
|
204
209
|
- spec/unit/pluginpackager/standard_definition_spec.rb
|
205
210
|
- spec/unit/pluginpackager_spec.rb
|
211
|
+
- spec/unit/plugins/mcollective/agent/rpcutil_spec.rb
|
206
212
|
- spec/unit/plugins/mcollective/aggregate/average_spec.rb
|
207
213
|
- spec/unit/plugins/mcollective/aggregate/sum_spec.rb
|
208
214
|
- spec/unit/plugins/mcollective/aggregate/summary_spec.rb
|
215
|
+
- spec/unit/plugins/mcollective/application/plugin_spec.rb
|
216
|
+
- spec/unit/plugins/mcollective/audit/logfile_spec.rb
|
209
217
|
- spec/unit/plugins/mcollective/connector/activemq_spec.rb
|
210
218
|
- spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb
|
211
|
-
- spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
|
212
|
-
- spec/unit/plugins/mcollective/connector/stomp_spec.rb
|
213
219
|
- spec/unit/plugins/mcollective/data/agent_data_spec.rb
|
214
220
|
- spec/unit/plugins/mcollective/data/fstat_data_spec.rb
|
215
221
|
- spec/unit/plugins/mcollective/discovery/flatfile_spec.rb
|
216
222
|
- spec/unit/plugins/mcollective/discovery/mc_spec.rb
|
223
|
+
- spec/unit/plugins/mcollective/discovery/stdin_spec.rb
|
224
|
+
- spec/unit/plugins/mcollective/facts/yaml_facts_spec.rb
|
217
225
|
- spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
|
226
|
+
- spec/unit/plugins/mcollective/packagers/modulepackage_packager_spec.rb
|
218
227
|
- spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
|
219
228
|
- spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
|
220
229
|
- spec/unit/plugins/mcollective/security/psk_spec.rb
|
221
|
-
- spec/unit/plugins/mcollective/validator/any_validator_spec.rb
|
222
230
|
- spec/unit/plugins/mcollective/validator/array_validator_spec.rb
|
223
231
|
- spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb
|
224
232
|
- spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb
|
@@ -250,38 +258,41 @@ files:
|
|
250
258
|
- spec/windows_spec.opts
|
251
259
|
homepage: https://docs.puppetlabs.com/mcollective/
|
252
260
|
licenses: []
|
253
|
-
|
261
|
+
metadata: {}
|
254
262
|
post_install_message:
|
255
|
-
rdoc_options:
|
256
|
-
|
257
|
-
|
263
|
+
rdoc_options:
|
264
|
+
- --line-numbers
|
265
|
+
- --main
|
266
|
+
- Mcollective
|
267
|
+
- --exclude
|
268
|
+
- mcollective/vendor
|
269
|
+
- --exclude
|
270
|
+
- spec
|
271
|
+
- --exclude
|
272
|
+
- ext
|
273
|
+
- --exclude
|
274
|
+
- website
|
275
|
+
- --exclude
|
276
|
+
- plugins
|
277
|
+
require_paths:
|
258
278
|
- lib
|
259
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
none: false
|
270
|
-
requirements:
|
271
|
-
- - ">="
|
272
|
-
- !ruby/object:Gem::Version
|
273
|
-
hash: 3
|
274
|
-
segments:
|
275
|
-
- 0
|
276
|
-
version: "0"
|
279
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
280
|
+
requirements:
|
281
|
+
- - '>='
|
282
|
+
- !ruby/object:Gem::Version
|
283
|
+
version: '0'
|
284
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
|
+
requirements:
|
286
|
+
- - '>='
|
287
|
+
- !ruby/object:Gem::Version
|
288
|
+
version: '0'
|
277
289
|
requirements: []
|
278
|
-
|
279
290
|
rubyforge_project:
|
280
|
-
rubygems_version:
|
291
|
+
rubygems_version: 2.0.3
|
281
292
|
signing_key:
|
282
|
-
specification_version:
|
283
|
-
summary: Client libraries for
|
284
|
-
test_files:
|
293
|
+
specification_version: 4
|
294
|
+
summary: Client libraries for the Mcollective Application Server
|
295
|
+
test_files:
|
285
296
|
- spec/Rakefile
|
286
297
|
- spec/fixtures/application/test.rb
|
287
298
|
- spec/fixtures/test-cert.pem
|
@@ -339,22 +350,25 @@ test_files:
|
|
339
350
|
- spec/unit/pluginpackager/agent_definition_spec.rb
|
340
351
|
- spec/unit/pluginpackager/standard_definition_spec.rb
|
341
352
|
- spec/unit/pluginpackager_spec.rb
|
353
|
+
- spec/unit/plugins/mcollective/agent/rpcutil_spec.rb
|
342
354
|
- spec/unit/plugins/mcollective/aggregate/average_spec.rb
|
343
355
|
- spec/unit/plugins/mcollective/aggregate/sum_spec.rb
|
344
356
|
- spec/unit/plugins/mcollective/aggregate/summary_spec.rb
|
357
|
+
- spec/unit/plugins/mcollective/application/plugin_spec.rb
|
358
|
+
- spec/unit/plugins/mcollective/audit/logfile_spec.rb
|
345
359
|
- spec/unit/plugins/mcollective/connector/activemq_spec.rb
|
346
360
|
- spec/unit/plugins/mcollective/connector/rabbitmq_spec.rb
|
347
|
-
- spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
|
348
|
-
- spec/unit/plugins/mcollective/connector/stomp_spec.rb
|
349
361
|
- spec/unit/plugins/mcollective/data/agent_data_spec.rb
|
350
362
|
- spec/unit/plugins/mcollective/data/fstat_data_spec.rb
|
351
363
|
- spec/unit/plugins/mcollective/discovery/flatfile_spec.rb
|
352
364
|
- spec/unit/plugins/mcollective/discovery/mc_spec.rb
|
365
|
+
- spec/unit/plugins/mcollective/discovery/stdin_spec.rb
|
366
|
+
- spec/unit/plugins/mcollective/facts/yaml_facts_spec.rb
|
353
367
|
- spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
|
368
|
+
- spec/unit/plugins/mcollective/packagers/modulepackage_packager_spec.rb
|
354
369
|
- spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
|
355
370
|
- spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
|
356
371
|
- spec/unit/plugins/mcollective/security/psk_spec.rb
|
357
|
-
- spec/unit/plugins/mcollective/validator/any_validator_spec.rb
|
358
372
|
- spec/unit/plugins/mcollective/validator/array_validator_spec.rb
|
359
373
|
- spec/unit/plugins/mcollective/validator/ipv4address_validator_spec.rb
|
360
374
|
- spec/unit/plugins/mcollective/validator/ipv6address_validator_spec.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
MCollective::PluginManager.clear
|
6
|
-
|
7
|
-
require File.dirname(__FILE__) + '/../../../../../../plugins/mcollective/connector/stomp.rb'
|
8
|
-
|
9
|
-
module MCollective
|
10
|
-
module Connector
|
11
|
-
class Stomp
|
12
|
-
describe EventLogger do
|
13
|
-
before do
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should have valid call back methods" do
|
17
|
-
plugin = EventLogger.new
|
18
|
-
|
19
|
-
[:on_miscerr, :on_connecting, :on_connected, :on_disconnect, :on_connectfail, :on_ssl_connecting, :on_ssl_connected].each do |meth|
|
20
|
-
plugin.respond_to?(meth).should == true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#stomp_url" do
|
25
|
-
it "should create valid stomp urls" do
|
26
|
-
EventLogger.new.stomp_url({:cur_login => "rspec", :cur_host => "localhost", :cur_port => 123}).should == "stomp://rspec@localhost:123"
|
27
|
-
EventLogger.new.stomp_url({:cur_login => "rspec", :cur_host => "localhost", :cur_port => 123, :cur_ssl => false}).should == "stomp://rspec@localhost:123"
|
28
|
-
EventLogger.new.stomp_url({:cur_login => "rspec", :cur_host => "localhost", :cur_port => 123, :cur_ssl => true}).should == "stomp+ssl://rspec@localhost:123"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,424 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
MCollective::PluginManager.clear
|
6
|
-
|
7
|
-
require File.dirname(__FILE__) + '/../../../../../plugins/mcollective/connector/stomp.rb'
|
8
|
-
|
9
|
-
module MCollective
|
10
|
-
module Connector
|
11
|
-
describe Stomp do
|
12
|
-
before do
|
13
|
-
unless ::Stomp::Error.constants.map{|c| c.to_s}.include?("NoCurrentConnection")
|
14
|
-
class ::Stomp::Error::NoCurrentConnection < RuntimeError ; end
|
15
|
-
end
|
16
|
-
|
17
|
-
@config = mock
|
18
|
-
@config.stubs(:configured).returns(true)
|
19
|
-
@config.stubs(:identity).returns("rspec")
|
20
|
-
@config.stubs(:collectives).returns(["mcollective"])
|
21
|
-
@config.stubs(:topicprefix).returns("/topic/")
|
22
|
-
@config.stubs(:topicsep).returns(".")
|
23
|
-
|
24
|
-
logger = mock
|
25
|
-
logger.stubs(:log)
|
26
|
-
logger.stubs(:start)
|
27
|
-
Log.configure(logger)
|
28
|
-
|
29
|
-
Config.stubs(:instance).returns(@config)
|
30
|
-
|
31
|
-
@msg = mock
|
32
|
-
@msg.stubs(:base64_encode!)
|
33
|
-
@msg.stubs(:payload).returns("msg")
|
34
|
-
@msg.stubs(:agent).returns("agent")
|
35
|
-
@msg.stubs(:type).returns(:reply)
|
36
|
-
@msg.stubs(:collective).returns("mcollective")
|
37
|
-
|
38
|
-
@subscription = mock
|
39
|
-
@subscription.stubs("<<").returns(true)
|
40
|
-
@subscription.stubs("include?").returns(false)
|
41
|
-
@subscription.stubs("delete").returns(false)
|
42
|
-
|
43
|
-
@connection = mock
|
44
|
-
@connection.stubs(:subscribe).returns(true)
|
45
|
-
@connection.stubs(:unsubscribe).returns(true)
|
46
|
-
|
47
|
-
@c = Stomp.new
|
48
|
-
@c.instance_variable_set("@subscriptions", @subscription)
|
49
|
-
@c.instance_variable_set("@connection", @connection)
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#initialize" do
|
53
|
-
it "should be deprecated" do
|
54
|
-
Log.expects(:info).with(regexp_matches(/please migrate to the/))
|
55
|
-
Stomp.new
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should set the @config variable" do
|
59
|
-
c = Stomp.new
|
60
|
-
c.instance_variable_get("@config").should == @config
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should set @subscriptions to an empty list" do
|
64
|
-
c = Stomp.new
|
65
|
-
c.instance_variable_get("@subscriptions").should == []
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#connect" do
|
70
|
-
it "should not try to reconnect if already connected" do
|
71
|
-
Log.expects(:debug).with("Already connection, not re-initializing connection").once
|
72
|
-
@c.connect
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should support old style config" do
|
76
|
-
@config.expects(:pluginconf).returns({}).at_least_once
|
77
|
-
@c.expects(:get_bool_option).with("stomp.base64", false)
|
78
|
-
@c.expects(:get_option).with("stomp.priority", 0)
|
79
|
-
@c.expects(:get_env_or_option).with("STOMP_SERVER", "stomp.host").returns("host")
|
80
|
-
@c.expects(:get_env_or_option).with("STOMP_PORT", "stomp.port", 6163).returns(6163)
|
81
|
-
@c.expects(:get_env_or_option).with("STOMP_USER", "stomp.user").returns("test_user")
|
82
|
-
@c.expects(:get_env_or_option).with("STOMP_PASSWORD", "stomp.password").returns("test_password")
|
83
|
-
|
84
|
-
connector = mock
|
85
|
-
connector.expects(:new).with("test_user", "test_password", "host", 6163, true)
|
86
|
-
|
87
|
-
@c.instance_variable_set("@connection", nil)
|
88
|
-
@c.connect(connector)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should support new style config" do
|
92
|
-
pluginconf = {"stomp.pool.size" => "2",
|
93
|
-
"stomp.pool.host1" => "host1",
|
94
|
-
"stomp.pool.port1" => "6163",
|
95
|
-
"stomp.pool.user1" => "user1",
|
96
|
-
"stomp.pool.password1" => "password1",
|
97
|
-
"stomp.pool.ssl1" => "false",
|
98
|
-
"stomp.pool.host2" => "host2",
|
99
|
-
"stomp.pool.port2" => "6164",
|
100
|
-
"stomp.pool.user2" => "user2",
|
101
|
-
"stomp.pool.password2" => "password2",
|
102
|
-
"stomp.pool.ssl2" => "true",
|
103
|
-
"stomp.pool.initial_reconnect_delay" => "0.02",
|
104
|
-
"stomp.pool.max_reconnect_delay" => "40",
|
105
|
-
"stomp.pool.use_exponential_back_off" => "false",
|
106
|
-
"stomp.pool.back_off_multiplier" => "3",
|
107
|
-
"stomp.pool.max_reconnect_attempts" => "5",
|
108
|
-
"stomp.pool.randomize" => "true",
|
109
|
-
"stomp.pool.backup" => "true",
|
110
|
-
"stomp.pool.connect_timeout" => 30,
|
111
|
-
"stomp.pool.timeout" => "1"}
|
112
|
-
|
113
|
-
|
114
|
-
ENV.delete("STOMP_USER")
|
115
|
-
ENV.delete("STOMP_PASSWORD")
|
116
|
-
|
117
|
-
@config.expects(:pluginconf).returns(pluginconf).at_least_once
|
118
|
-
|
119
|
-
Stomp::EventLogger.expects(:new).returns("logger")
|
120
|
-
|
121
|
-
connector = mock
|
122
|
-
connector.expects(:new).with(:backup => true,
|
123
|
-
:back_off_multiplier => 2,
|
124
|
-
:max_reconnect_delay => 40.0,
|
125
|
-
:timeout => 1,
|
126
|
-
:use_exponential_back_off => false,
|
127
|
-
:max_reconnect_attempts => 5,
|
128
|
-
:initial_reconnect_delay => 0.02,
|
129
|
-
:connect_timeout => 30,
|
130
|
-
:randomize => true,
|
131
|
-
:reliable => true,
|
132
|
-
:logger => "logger",
|
133
|
-
:hosts => [{:passcode => 'password1',
|
134
|
-
:host => 'host1',
|
135
|
-
:port => 6163,
|
136
|
-
:ssl => false,
|
137
|
-
:login => 'user1'},
|
138
|
-
{:passcode => 'password2',
|
139
|
-
:host => 'host2',
|
140
|
-
:port => 6164,
|
141
|
-
:ssl => true,
|
142
|
-
:login => 'user2'}
|
143
|
-
])
|
144
|
-
|
145
|
-
@c.instance_variable_set("@connection", nil)
|
146
|
-
@c.connect(connector)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "#receive" do
|
151
|
-
it "should receive from the middleware" do
|
152
|
-
payload = mock
|
153
|
-
payload.stubs(:body).returns("msg")
|
154
|
-
payload.stubs(:headers).returns("headers")
|
155
|
-
|
156
|
-
@connection.expects(:receive).returns(payload)
|
157
|
-
|
158
|
-
Message.expects(:new).with("msg", payload, :base64 => true, :headers => "headers").returns("message")
|
159
|
-
@c.instance_variable_set("@base64", true)
|
160
|
-
|
161
|
-
received = @c.receive
|
162
|
-
received.should == "message"
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should sleep and retry if recieving while disconnected" do
|
166
|
-
payload = mock
|
167
|
-
payload.stubs(:body).returns("msg")
|
168
|
-
payload.stubs(:headers).returns("headers")
|
169
|
-
|
170
|
-
Message.stubs(:new).returns("rspec")
|
171
|
-
@connection.expects(:receive).raises(::Stomp::Error::NoCurrentConnection).returns(payload).twice
|
172
|
-
@c.expects(:sleep).with(1)
|
173
|
-
|
174
|
-
@c.receive.should == "rspec"
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "#publish" do
|
179
|
-
before do
|
180
|
-
@connection.stubs("respond_to?").with("publish").returns(true)
|
181
|
-
@connection.stubs(:publish).with("test", "msg", {}).returns(true)
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should base64 encode a message if configured to do so" do
|
185
|
-
@c.instance_variable_set("@base64", true)
|
186
|
-
@c.expects(:msgheaders).returns({})
|
187
|
-
@c.expects(:make_target).returns("test")
|
188
|
-
@connection.expects(:publish).with("test", "msg", {})
|
189
|
-
|
190
|
-
@msg.stubs(:reply_to)
|
191
|
-
|
192
|
-
@c.publish(@msg)
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should not base64 encode if not configured to do so" do
|
196
|
-
@c.instance_variable_set("@base64", false)
|
197
|
-
@c.expects(:msgheaders).returns({})
|
198
|
-
@c.expects(:make_target).returns("test")
|
199
|
-
|
200
|
-
@connection.expects(:publish).with("test", "msg", {})
|
201
|
-
|
202
|
-
@msg.stubs(:reply_to)
|
203
|
-
|
204
|
-
@c.publish(@msg)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should publish direct requests for each discovered host" do
|
208
|
-
@msg.expects(:type).returns(:direct_request).times(3)
|
209
|
-
@msg.expects(:discovered_hosts).returns(["one", "two"])
|
210
|
-
|
211
|
-
@c.expects(:make_target).with("agent", :direct_request, "mcollective", "one").returns("target_one")
|
212
|
-
@c.expects(:make_target).with("agent", :direct_request, "mcollective", "two").returns("target_two")
|
213
|
-
|
214
|
-
@c.expects(:publish_msg).with("target_one", "msg")
|
215
|
-
@c.expects(:publish_msg).with("target_two", "msg")
|
216
|
-
|
217
|
-
@msg.stubs(:reply_to)
|
218
|
-
|
219
|
-
@c.publish(@msg)
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should raise an error if specific reply targets are requested" do
|
223
|
-
@c.instance_variable_set("@base64", false)
|
224
|
-
|
225
|
-
@msg.expects(:reply_to).returns(:foo)
|
226
|
-
|
227
|
-
expect { @c.publish(@msg) }.to raise_error("Cannot set specific reply to targets with the STOMP plugin")
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe "#publish_msg" do
|
232
|
-
it "should use the publish method if it exists" do
|
233
|
-
@connection.expects("respond_to?").with("publish").returns(true)
|
234
|
-
@connection.expects(:publish).with("test", "msg", {}).once
|
235
|
-
@c.stubs(:msgheaders).returns({})
|
236
|
-
|
237
|
-
@c.publish_msg("test", "msg")
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should use the send method if publish does not exist" do
|
241
|
-
@connection.expects("respond_to?").with('publish').returns(false)
|
242
|
-
@connection.expects(:send).with("test", "msg", {}).once
|
243
|
-
@c.stubs(:msgheaders).returns({})
|
244
|
-
|
245
|
-
@c.publish_msg("test", "msg")
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should publish the correct message to the correct target with msgheaders" do
|
249
|
-
@connection.expects("respond_to?").with("publish").returns(true)
|
250
|
-
@connection.expects(:publish).with("test", "msg", {"test" => "test"}).once
|
251
|
-
@c.expects(:msgheaders).returns({"test" => "test"})
|
252
|
-
|
253
|
-
@c.publish_msg("test", "msg")
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
describe "#make_target" do
|
259
|
-
it "should create correct targets" do
|
260
|
-
@config.expects(:queueprefix).returns("/queue/").twice
|
261
|
-
|
262
|
-
@c.make_target("test", :broadcast, "mcollective").should == "/topic/mcollective.test.command"
|
263
|
-
@c.make_target("test", :directed, "mcollective").should == "/queue/mcollective.2bc84dc69b73db9383b9c6711d2011b7"
|
264
|
-
@c.make_target("test", :direct_request, "mcollective", "rspec").should == "/queue/mcollective.2bc84dc69b73db9383b9c6711d2011b7"
|
265
|
-
@c.make_target("test", :reply, "mcollective").should == "/topic/mcollective.test.reply"
|
266
|
-
@c.make_target("test", :request, "mcollective").should == "/topic/mcollective.test.command"
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should raise an error for unknown collectives" do
|
270
|
-
expect {
|
271
|
-
@c.make_target("test", :broadcast, "foo")
|
272
|
-
}.to raise_error("Unknown collective 'foo' known collectives are 'mcollective'")
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should raise an error for unknown types" do
|
276
|
-
expect {
|
277
|
-
@c.make_target("test", :test, "mcollective")
|
278
|
-
}.to raise_error("Unknown target type test")
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe "#unsubscribe" do
|
283
|
-
it "should use make_target correctly" do
|
284
|
-
@c.expects("make_target").with("test", :broadcast, "mcollective").returns({:target => "test", :headers => {}})
|
285
|
-
@c.unsubscribe("test", :broadcast, "mcollective")
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should unsubscribe from the target" do
|
289
|
-
@c.expects("make_target").with("test", :broadcast, "mcollective").returns("test")
|
290
|
-
@connection.expects(:unsubscribe).with("test").once
|
291
|
-
|
292
|
-
@c.unsubscribe("test", :broadcast, "mcollective")
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should delete the source from subscriptions" do
|
296
|
-
@c.expects("make_target").with("test", :broadcast, "mcollective").returns({:target => "test", :headers => {}})
|
297
|
-
@subscription.expects(:delete).with({:target => "test", :headers => {}}).once
|
298
|
-
|
299
|
-
@c.unsubscribe("test", :broadcast, "mcollective")
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
describe "#subscribe" do
|
304
|
-
it "should use the make_target correctly" do
|
305
|
-
@c.expects("make_target").with("test", :broadcast, "mcollective").returns("test")
|
306
|
-
@c.subscribe("test", :broadcast, "mcollective")
|
307
|
-
end
|
308
|
-
|
309
|
-
it "should check for existing subscriptions" do
|
310
|
-
@c.expects("make_target").returns("test").once
|
311
|
-
@subscription.expects("include?").with("test").returns(false)
|
312
|
-
@connection.expects(:subscribe).never
|
313
|
-
|
314
|
-
@c.subscribe("test", :broadcast, "mcollective")
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should subscribe to the middleware" do
|
318
|
-
@c.expects("make_target").returns("test")
|
319
|
-
@connection.expects(:subscribe).with("test").once
|
320
|
-
@c.subscribe("test", :broadcast, "mcollective")
|
321
|
-
end
|
322
|
-
|
323
|
-
it "should add to the list of subscriptions" do
|
324
|
-
@c.expects("make_target").returns("test")
|
325
|
-
@subscription.expects("<<").with("test")
|
326
|
-
@c.subscribe("test", :broadcast, "mcollective")
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
describe "#disconnect" do
|
331
|
-
it "should disconnect from the stomp connection" do
|
332
|
-
@connection.expects(:disconnect)
|
333
|
-
@c.disconnect
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
describe "#msgheaders" do
|
338
|
-
it "should return empty headers if priority is 0" do
|
339
|
-
@c.instance_variable_set("@msgpriority", 0)
|
340
|
-
@c.msgheaders.should == {}
|
341
|
-
end
|
342
|
-
|
343
|
-
it "should return a priority if prioritu is non 0" do
|
344
|
-
@c.instance_variable_set("@msgpriority", 1)
|
345
|
-
@c.msgheaders.should == {"priority" => 1}
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "#get_env_or_option" do
|
350
|
-
it "should return the environment variable if set" do
|
351
|
-
ENV["test"] = "rspec_env_test"
|
352
|
-
|
353
|
-
@c.get_env_or_option("test", nil, nil).should == "rspec_env_test"
|
354
|
-
|
355
|
-
ENV.delete("test")
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should return the config option if set" do
|
359
|
-
@config.expects(:pluginconf).returns({"test" => "rspec_test"}).twice
|
360
|
-
@c.get_env_or_option("test", "test", "test").should == "rspec_test"
|
361
|
-
end
|
362
|
-
|
363
|
-
it "should return default if nothing else matched" do
|
364
|
-
@config.expects(:pluginconf).returns({}).once
|
365
|
-
@c.get_env_or_option("test", "test", "test").should == "test"
|
366
|
-
end
|
367
|
-
|
368
|
-
it "should raise an error if no default is supplied" do
|
369
|
-
@config.expects(:pluginconf).returns({}).once
|
370
|
-
|
371
|
-
expect {
|
372
|
-
@c.get_env_or_option("test", "test")
|
373
|
-
}.to raise_error("No test environment or plugin.test configuration option given")
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
describe "#get_option" do
|
378
|
-
it "should return the config option if set" do
|
379
|
-
@config.expects(:pluginconf).returns({"test" => "rspec_test"}).twice
|
380
|
-
@c.get_option("test").should == "rspec_test"
|
381
|
-
end
|
382
|
-
|
383
|
-
it "should return default option was not found" do
|
384
|
-
@config.expects(:pluginconf).returns({}).once
|
385
|
-
@c.get_option("test", "test").should == "test"
|
386
|
-
end
|
387
|
-
|
388
|
-
it "should raise an error if no default is supplied" do
|
389
|
-
@config.expects(:pluginconf).returns({}).once
|
390
|
-
|
391
|
-
expect {
|
392
|
-
@c.get_option("test")
|
393
|
-
}.to raise_error("No plugin.test configuration option given")
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
|
-
describe "#get_bool_option" do
|
398
|
-
it "should return the default if option isnt set" do
|
399
|
-
@config.expects(:pluginconf).returns({}).once
|
400
|
-
@c.get_bool_option("test", "default").should == "default"
|
401
|
-
end
|
402
|
-
|
403
|
-
["1", "yes", "true"].each do |boolean|
|
404
|
-
it "should map options to true correctly" do
|
405
|
-
@config.expects(:pluginconf).returns({"test" => boolean}).twice
|
406
|
-
@c.get_bool_option("test", "default").should == true
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
["0", "no", "false"].each do |boolean|
|
411
|
-
it "should map options to false correctly" do
|
412
|
-
@config.expects(:pluginconf).returns({"test" => boolean}).twice
|
413
|
-
@c.get_bool_option("test", "default").should == false
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
it "should return default for non boolean options" do
|
418
|
-
@config.expects(:pluginconf).returns({"test" => "foo"}).twice
|
419
|
-
@c.get_bool_option("test", "default").should == "default"
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|