mcollective-client 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -300,6 +300,36 @@ module MCollective
300
300
  m.decode!
301
301
  }.to raise_error('callerid in request is not valid, surpressing reply to potentially forged request')
302
302
  end
303
+
304
+ it 'should handle the securityprovider failing to decodemsg - log for reply' do
305
+ security = mock('securityprovider')
306
+ security.expects(:decodemsg).raises('squirrel attack')
307
+
308
+ PluginManager.expects("[]").with("security_plugin").returns(security).once
309
+
310
+ m = Message.new("payload", "message", :type => :reply)
311
+ m.stubs(:headers).returns({'mc_sender' => 'trees'})
312
+ Log.expects(:warn).with("Failed to decode a message from 'trees': squirrel attack")
313
+
314
+ expect {
315
+ m.decode!
316
+ }.to_not raise_error
317
+ end
318
+
319
+ it 'should handle the securityprovider failing to decodemsg' do
320
+ security = mock('securityprovider')
321
+ security.expects(:decodemsg).raises('squirrel attack')
322
+
323
+ PluginManager.expects("[]").with("security_plugin").returns(security).once
324
+
325
+ m = Message.new("payload", "message", :type => :request)
326
+ Log.expects(:warn).never
327
+
328
+ expect {
329
+ m.decode!
330
+ }.to raise_error(/squirrel attack/)
331
+ end
332
+
303
333
  end
304
334
 
305
335
  describe "#validate_compound_filter" do
@@ -197,6 +197,12 @@ module MCollective
197
197
  @parser.instance_variable_get(:@options)[:discovery_options].should == ['nodes.txt']
198
198
  end
199
199
 
200
+ it 'should parse the --nodes option' do
201
+ ARGV << '--connection-timeout=1'
202
+ @parser.parse
203
+ @parser.instance_variable_get(:@options)[:connection_timeout].should == 1
204
+ end
205
+
200
206
  it 'should fail on the --nodes option if discovery_method or discovery_options have already been set' do
201
207
  end
202
208
 
@@ -87,6 +87,7 @@ module MCollective
87
87
  describe "#agent" do
88
88
  before do
89
89
  AgentDefinition.any_instance.expects(:client).once
90
+ PluginPackager.expects(:get_plugin_path).with(".").returns(".")
90
91
  end
91
92
 
92
93
  it "should not populate the agent files if the agent directory is empty" do
@@ -101,14 +102,27 @@ module MCollective
101
102
  PluginPackager.stubs(:check_dir_present).returns(true)
102
103
  File.stubs(:join).with(".", "agent").returns("tmpdir/agent")
103
104
  File.stubs(:join).with("tmpdir/agent", "*.ddl").returns("tmpdir/agent/*.ddl")
104
- File.stubs(:join).with("tmpdir/agent", "*").returns("tmpdir/agent/*")
105
+ File.stubs(:join).with("tmpdir/agent", "**", "**").returns("tmpdir/agent/**/**")
105
106
  Dir.stubs(:glob).with("tmpdir/agent/*.ddl").returns([])
106
- Dir.stubs(:glob).with("tmpdir/agent/*").returns(["implementation.rb"])
107
+ Dir.stubs(:glob).with("tmpdir/agent/**/**").returns(["implementation.rb"])
107
108
 
108
109
  agent = AgentDefinition.new(configuration, {}, "agent")
109
110
  agent.packagedata[:agent][:files].should == ["implementation.rb"]
110
111
  end
111
112
 
113
+ it "should recursively populate the file list if the agent directory contains subdirectories" do
114
+ AgentDefinition.any_instance.expects(:common).returns(nil)
115
+ PluginPackager.stubs(:check_dir_present).returns(true)
116
+ File.stubs(:join).with(".", "agent").returns("tmpdir/agent")
117
+ File.stubs(:join).with("tmpdir/agent", "*.ddl").returns("tmpdir/agent/*.ddl")
118
+ File.stubs(:join).with("tmpdir/agent", "**", "**").returns("tmpdir/agent/**/**")
119
+ Dir.stubs(:glob).with("tmpdir/agent/*.ddl").returns([])
120
+ Dir.stubs(:glob).with("tmpdir/agent/**/**").returns(["implementation.rb", "test/test.rb"])
121
+
122
+ agent = AgentDefinition.new(configuration, {}, "agent")
123
+ agent.packagedata[:agent][:files].should == ["implementation.rb", "test/test.rb"]
124
+ end
125
+
112
126
  it "should add common package as dependency if present" do
113
127
  AgentDefinition.any_instance.expects(:common).returns({:files=> ["test.rb"]})
114
128
  PluginPackager.expects(:check_dir_present).with("tmpdir/agent").returns(true)
@@ -125,6 +139,10 @@ module MCollective
125
139
  end
126
140
 
127
141
  describe "#common" do
142
+ before :each do
143
+ PluginPackager.expects(:get_plugin_path).with(".").returns(".")
144
+ end
145
+
128
146
  it "should populate the common files if there are any" do
129
147
  AgentDefinition.any_instance.expects(:agent)
130
148
  AgentDefinition.any_instance.expects(:client)
@@ -163,6 +181,7 @@ module MCollective
163
181
  AgentDefinition.any_instance.expects(:agent).returns(nil)
164
182
  File.expects(:join).with(".", "application").returns("clientdir")
165
183
  File.expects(:join).with(".", "aggregate").returns("aggregatedir")
184
+ PluginPackager.expects(:get_plugin_path).with(".").returns(".")
166
185
  end
167
186
 
168
187
  it "should populate client files if all directories are present" do
@@ -73,6 +73,9 @@ module MCollective
73
73
  end
74
74
 
75
75
  describe "#plugin" do
76
+ before :each do
77
+ PluginPackager.expects(:get_plugin_path).with(".").returns(".")
78
+ end
76
79
 
77
80
  it "should return nil if the plugin doesn't contain any files" do
78
81
  StandardDefinition.any_instance.expects(:common).returns(nil)
@@ -102,8 +105,9 @@ module MCollective
102
105
  end
103
106
 
104
107
  describe "#common" do
105
- before do
108
+ before :each do
106
109
  StandardDefinition.any_instance.expects(:plugin).returns(false)
110
+ PluginPackager.expects(:get_plugin_path).with(".").returns(".")
107
111
  end
108
112
 
109
113
  it "should return nil if common doesn't contain any files" do
@@ -110,7 +110,7 @@ module MCollective
110
110
  Activemq.any_instance.stubs(:get_bool_option).with("activemq.backup", "false").returns(true)
111
111
  Activemq.any_instance.stubs(:get_option).with("activemq.timeout", -1).returns(1)
112
112
  Activemq.any_instance.stubs(:get_option).with("activemq.connect_timeout", 30).returns(5)
113
- Activemq.any_instance.stubs(:get_option).with("activemq.max_hbrlck_fails", 2).returns(2)
113
+ Activemq.any_instance.stubs(:get_option).with("activemq.max_hbrlck_fails", 0).returns(0)
114
114
  Activemq.any_instance.stubs(:get_option).with("activemq.max_hbread_fails", 2).returns(2)
115
115
  Activemq.any_instance.stubs(:get_bool_option).with("activemq.base64", 'false').returns(false)
116
116
  Activemq.any_instance.stubs(:get_option).with("activemq.priority", 0).returns(0)
@@ -150,8 +150,8 @@ module MCollective
150
150
  :use_exponential_back_off => true,
151
151
  :max_reconnect_attempts => 5,
152
152
  :initial_reconnect_delay => 0.01,
153
+ :max_hbrlck_fails => 0,
153
154
  :max_hbread_fails => 2,
154
- :max_hbrlck_fails => 2,
155
155
  :randomize => true,
156
156
  :reliable => true,
157
157
  :logger => "logger",
@@ -651,6 +651,15 @@ module MCollective
651
651
  headers["timestamp"].should == "1368557431000"
652
652
  headers["expires"].should == "1368557541000"
653
653
  end
654
+
655
+ it "should set mc_sender based on the identity" do
656
+ message = mock
657
+ message.expects(:type).returns(:foo)
658
+ message.stubs(:ttl).returns(100)
659
+
660
+ headers = connector.headers_for(message)
661
+ headers['mc_sender'].should == 'rspec'
662
+ end
654
663
  end
655
664
 
656
665
  describe "#make_target" do
@@ -111,7 +111,7 @@ module MCollective
111
111
  Rabbitmq.any_instance.stubs(:get_bool_option).with("rabbitmq.backup", "false").returns(true)
112
112
  Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.timeout", -1).returns(1)
113
113
  Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.connect_timeout", 30).returns(5)
114
- Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.max_hbrlck_fails", 2).returns(2)
114
+ Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.max_hbrlck_fails", 0).returns(0)
115
115
  Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.max_hbread_fails", 2).returns(2)
116
116
  Rabbitmq.any_instance.stubs(:get_bool_option).with("rabbitmq.base64", 'false').returns(false)
117
117
  Rabbitmq.any_instance.stubs(:get_option).with("rabbitmq.pool.size").returns(2)
@@ -150,8 +150,8 @@ module MCollective
150
150
  :use_exponential_back_off => true,
151
151
  :max_reconnect_attempts => 5,
152
152
  :initial_reconnect_delay => 0.01,
153
+ :max_hbrlck_fails => 0,
153
154
  :max_hbread_fails => 2,
154
- :max_hbrlck_fails => 2,
155
155
  :randomize => true,
156
156
  :reliable => true,
157
157
  :logger => "logger",
@@ -453,8 +453,18 @@ module MCollective
453
453
  msg.stubs(:ttl).returns(60)
454
454
  msg.expects(:discovered_hosts).returns(["one", "two"])
455
455
 
456
- connection.expects(:publish).with('/exchange/mcollective_directed/one', 'msg', {'reply-to' => '/topic/mcollective', 'expiration' => '70000'})
457
- connection.expects(:publish).with('/exchange/mcollective_directed/two', 'msg', {'reply-to' => '/topic/mcollective', 'expiration' => '70000'})
456
+ connection.expects(:publish).with('/exchange/mcollective_directed/one',
457
+ 'msg',
458
+ { 'reply-to' => '/topic/mcollective',
459
+ 'expiration' => '70000',
460
+ 'mc_sender' => 'rspec',
461
+ })
462
+ connection.expects(:publish).with('/exchange/mcollective_directed/two',
463
+ 'msg',
464
+ { 'reply-to' => '/topic/mcollective',
465
+ 'expiration' => '70000',
466
+ 'mc_sender' => 'rspec',
467
+ })
458
468
 
459
469
  connector.publish(msg)
460
470
  end
@@ -551,7 +561,14 @@ module MCollective
551
561
 
552
562
  message.expects(:request).returns(request)
553
563
 
554
- connector.target_for(message).should == {:name => "foo", :headers => {"expiration" => "70000"}, :id => ""}
564
+ connector.target_for(message).should == {
565
+ :name => "foo",
566
+ :headers => {
567
+ "expiration" => "70000",
568
+ 'mc_sender' => 'rspec',
569
+ },
570
+ :id => "",
571
+ }
555
572
  end
556
573
 
557
574
  it "should create new request targets" do
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ require File.dirname(__FILE__) + "/../../../../../plugins/mcollective/data/collective_data.rb"
6
+
7
+ module MCollective
8
+ module Data
9
+ describe Collective_data do
10
+ describe "#query_data" do
11
+ before :each do
12
+ @ddl = mock('DDL')
13
+ @ddl.stubs(:dataquery_interface).returns({:output => {}})
14
+ @ddl.stubs(:meta).returns({:timeout => 1})
15
+ DDL.stubs(:new).returns(@ddl)
16
+ @plugin = Collective_data.new
17
+
18
+ Config.instance.stubs(:collectives).returns([ "collective_a", "collective_b" ])
19
+ end
20
+
21
+ it 'should return true if you are a member of the named collective' do
22
+ @plugin.query_data("collective_a")
23
+ @plugin.result[:member].should == true
24
+ end
25
+
26
+ it 'should return false if you are a member of the named collective' do
27
+ @plugin.query_data("no_such_collective")
28
+ @plugin.result[:member].should == false
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -125,6 +125,11 @@ module MCollective
125
125
  describe '#make_module' do
126
126
  it 'should copy the package content to the tmp build dir' do
127
127
  file = mock()
128
+
129
+ ['./agent/rspec.rb', './agent/rspec.ddl', './application/rspec.rb'].each do |m|
130
+ File.stubs(:expand_path).with(m).returns(m)
131
+ end
132
+
128
133
  File.stubs(:directory?).with('rspec_tmp/manifests').returns(false, true)
129
134
  File.stubs(:directory?).with('rspec_tmp/files/agent/mcollective/agent').returns(false, true)
130
135
  File.stubs(:directory?).with('rspec_tmp/files/common/mcollective/agent').returns(false, true)
@@ -189,25 +189,54 @@ module MCollective
189
189
  Config.instance.expects(:libdir).returns(["#{File::SEPARATOR}libdir1", "#{File::SEPARATOR}libdir2"])
190
190
 
191
191
  action_in_first_dir = File.join(File::SEPARATOR, "libdir1", "agent", "spectester", "action.sh")
192
+ action_in_first_dir_new = File.join(File::SEPARATOR, "libdir1", "mcollective", "agent", "spectester", "action.sh")
192
193
  action_in_last_dir = File.join(File::SEPARATOR, "libdir2", "agent", "spectester", "action.sh")
194
+ action_in_last_dir_new = File.join(File::SEPARATOR, "libdir2", "mcollective", "agent", "spectester", "action.sh")
193
195
 
194
- File.expects("exist?").with(action_in_first_dir).returns(true)
195
- File.expects("exist?").with(action_in_last_dir).never
196
-
196
+ File.expects("exists?").with(action_in_first_dir).returns(true)
197
+ File.expects("exists?").with(action_in_first_dir_new).returns(false)
198
+ File.expects("exists?").with(action_in_last_dir).never
199
+ File.expects("exists?").with(action_in_last_dir_new).never
197
200
  ActionRunner.new("action.sh", @req, :json).command.should == action_in_first_dir
198
201
  end
199
202
 
200
- it "should find the match even in the last libdir" do
203
+ it "should find the match in the last libdir" do
201
204
  Config.instance.expects(:libdir).returns(["#{File::SEPARATOR}libdir1", "#{File::SEPARATOR}libdir2"])
202
205
 
203
206
  action_in_first_dir = File.join(File::SEPARATOR, "libdir1", "agent", "spectester", "action.sh")
207
+ action_in_first_dir_new = File.join(File::SEPARATOR, "libdir1", "mcollective", "agent", "spectester", "action.sh")
204
208
  action_in_last_dir = File.join(File::SEPARATOR, "libdir2", "agent", "spectester", "action.sh")
209
+ action_in_last_dir_new = File.join(File::SEPARATOR, "libdir2", "mcollective", "agent", "spectester", "action.sh")
205
210
 
206
- File.expects("exist?").with(action_in_first_dir).returns(false)
207
- File.expects("exist?").with(action_in_last_dir).returns(true)
208
-
211
+ File.expects("exists?").with(action_in_first_dir).returns(false)
212
+ File.expects("exists?").with(action_in_first_dir_new).returns(false)
213
+ File.expects("exists?").with(action_in_last_dir).returns(true)
214
+ File.expects("exists?").with(action_in_last_dir_new).returns(false)
209
215
  ActionRunner.new("action.sh", @req, :json).command.should == action_in_last_dir
210
216
  end
217
+
218
+ it "should find the match in the 'new' directory layout" do
219
+ Config.instance.expects(:libdir).returns(["#{File::SEPARATOR}libdir1", "#{File::SEPARATOR}libdir2"])
220
+
221
+ action_in_new_dir = File.join(File::SEPARATOR, "libdir1", "mcollective", "agent", "spectester", "action.sh")
222
+ action_in_old_dir = File.join(File::SEPARATOR, "libdir1", "agent", "spectester", "action.sh")
223
+
224
+ File.expects("exists?").with(action_in_new_dir).returns(true)
225
+ File.expects("exists?").with(action_in_old_dir).returns(false)
226
+ ActionRunner.new("action.sh", @req, :json).command.should == action_in_new_dir
227
+ end
228
+
229
+ it "if the script is both the old and new locations, the new location should be preferred" do
230
+ Config.instance.expects(:libdir).returns(["#{File::SEPARATOR}libdir1", "#{File::SEPARATOR}libdir2"])
231
+
232
+ action_in_new_dir = File.join(File::SEPARATOR, "libdir1", "mcollective", "agent", "spectester", "action.sh")
233
+ action_in_old_dir = File.join(File::SEPARATOR, "libdir1", "agent", "spectester", "action.sh")
234
+
235
+ File.expects("exists?").with(action_in_new_dir).returns(true)
236
+ File.expects("exists?").with(action_in_old_dir).returns(true)
237
+
238
+ ActionRunner.new("action.sh", @req, :json).command.should == action_in_new_dir
239
+ end
211
240
  end
212
241
  end
213
242
  end
@@ -923,7 +923,11 @@ module MCollective
923
923
 
924
924
  rpcclient = Client.new("foo", {:options => {:filter => {"identity" => ["/foo/"], "agent" => []}, :config => "/nonexisting"}})
925
925
 
926
- rpcclient.client.expects(:discover).with({'identity' => ['/foo/'], 'agent' => ['foo']}, 2).once.returns(["foo"])
926
+ rpcclient.client.expects(:discover).with({
927
+ 'identity' => ['/foo/'],
928
+ 'agent' => ['foo'],
929
+ 'collective' => 'mcollective',
930
+ }, 2).once.returns(["foo"])
927
931
 
928
932
  rpcclient.discover
929
933
  rpcclient.instance_variable_get("@force_direct_request").should == false
@@ -934,9 +938,25 @@ module MCollective
934
938
  @stderr.expects(:print).with("Discovering hosts using the mc method for 2 second(s) .... ")
935
939
  @stderr.expects(:puts).with(1)
936
940
 
937
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => true, :disctimeout => 2, :stderr => @stderr, :stdout => @stdout}})
938
-
939
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
941
+ rpcclient = Client.new("foo", {
942
+ :options => {
943
+ :filter => Util.empty_filter,
944
+ :config => "/nonexisting",
945
+ :verbose => true,
946
+ :disctimeout => 2,
947
+ :stderr => @stderr,
948
+ :stdout => @stdout,
949
+ },
950
+ })
951
+
952
+ rpcclient.client.expects(:discover).with({
953
+ 'identity' => [],
954
+ 'compound' => [],
955
+ 'fact' => [],
956
+ 'agent' => ['foo'],
957
+ 'cf_class' => [],
958
+ 'collective' => 'mcollective',
959
+ }, 2).returns(["foo"])
940
960
 
941
961
  rpcclient.discover
942
962
  end
@@ -945,8 +965,24 @@ module MCollective
945
965
  @stderr.expects(:print).never
946
966
  @stderr.expects(:puts).never
947
967
 
948
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2, :stderr => @stderr, :stdout => @stdout}})
949
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
968
+ rpcclient = Client.new("foo", {
969
+ :options => {
970
+ :filter => Util.empty_filter,
971
+ :config => "/nonexisting",
972
+ :verbose => false,
973
+ :disctimeout => 2,
974
+ :stderr => @stderr,
975
+ :stdout => @stdout,
976
+ },
977
+ })
978
+ rpcclient.client.expects(:discover).with({
979
+ 'identity' => [],
980
+ 'compound' => [],
981
+ 'fact' => [],
982
+ 'agent' => ['foo'],
983
+ 'cf_class' => [],
984
+ 'collective' => 'mcollective',
985
+ }, 2).returns(["foo"])
950
986
 
951
987
  rpcclient.discover
952
988
  end
@@ -955,16 +991,44 @@ module MCollective
955
991
  Stats.any_instance.expects(:time_discovery).with(:start)
956
992
  Stats.any_instance.expects(:time_discovery).with(:end)
957
993
 
958
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
959
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
994
+ rpcclient = Client.new("foo", {
995
+ :options => {
996
+ :filter => Util.empty_filter,
997
+ :config => "/nonexisting",
998
+ :verbose => false,
999
+ :disctimeout => 2,
1000
+ },
1001
+ })
1002
+ rpcclient.client.expects(:discover).with({
1003
+ 'identity' => [],
1004
+ 'compound' => [],
1005
+ 'fact' => [],
1006
+ 'agent' => ['foo'],
1007
+ 'cf_class' => [],
1008
+ 'collective' => 'mcollective',
1009
+ }, 2).returns(["foo"])
960
1010
 
961
1011
  rpcclient.discover
962
1012
  end
963
1013
 
964
1014
  it "should discover using limits in :first rpclimit mode given a number" do
965
1015
  Config.instance.stubs(:rpclimitmethod).returns(:first)
966
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
967
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2, 1).returns(["foo"])
1016
+ rpcclient = Client.new("foo", {
1017
+ :options => {
1018
+ :filter => Util.empty_filter,
1019
+ :config => "/nonexisting",
1020
+ :verbose => false,
1021
+ :disctimeout => 2,
1022
+ },
1023
+ })
1024
+ rpcclient.client.expects(:discover).with({
1025
+ 'identity' => [],
1026
+ 'compound' => [],
1027
+ 'fact' => [],
1028
+ 'agent' => ['foo'],
1029
+ 'cf_class' => [],
1030
+ 'collective' => 'mcollective',
1031
+ }, 2, 1).returns(["foo"])
968
1032
 
969
1033
  rpcclient.limit_targets = 1
970
1034
 
@@ -973,8 +1037,22 @@ module MCollective
973
1037
 
974
1038
  it "should not discover using limits in :first rpclimit mode given a string" do
975
1039
  Config.instance.stubs(:rpclimitmethod).returns(:first)
976
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
977
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
1040
+ rpcclient = Client.new("foo", {
1041
+ :options => {
1042
+ :filter => Util.empty_filter,
1043
+ :config => "/nonexisting",
1044
+ :verbose => false,
1045
+ :disctimeout => 2,
1046
+ },
1047
+ })
1048
+ rpcclient.client.expects(:discover).with({
1049
+ 'identity' => [],
1050
+ 'compound' => [],
1051
+ 'fact' => [],
1052
+ 'agent' => ['foo'],
1053
+ 'cf_class' => [],
1054
+ 'collective' => 'mcollective',
1055
+ }, 2).returns(["foo"])
978
1056
  rpcclient.limit_targets = "10%"
979
1057
 
980
1058
  rpcclient.discover
@@ -983,16 +1061,44 @@ module MCollective
983
1061
  it "should not discover using limits when not in :first mode" do
984
1062
  Config.instance.stubs(:rpclimitmethod).returns(:random)
985
1063
 
986
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
987
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
1064
+ rpcclient = Client.new("foo", {
1065
+ :options => {
1066
+ :filter => Util.empty_filter,
1067
+ :config => "/nonexisting",
1068
+ :verbose => false,
1069
+ :disctimeout => 2,
1070
+ },
1071
+ })
1072
+ rpcclient.client.expects(:discover).with({
1073
+ 'identity' => [],
1074
+ 'compound' => [],
1075
+ 'fact' => [],
1076
+ 'agent' => ['foo'],
1077
+ 'cf_class' => [],
1078
+ 'collective' => 'mcollective',
1079
+ }, 2).returns(["foo"])
988
1080
 
989
1081
  rpcclient.limit_targets = 1
990
1082
  rpcclient.discover
991
1083
  end
992
1084
 
993
1085
  it "should ensure force_direct mode is false when doing traditional discovery" do
994
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
995
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
1086
+ rpcclient = Client.new("foo", {
1087
+ :options => {
1088
+ :filter => Util.empty_filter,
1089
+ :config => "/nonexisting",
1090
+ :verbose => false,
1091
+ :disctimeout => 2,
1092
+ },
1093
+ })
1094
+ rpcclient.client.expects(:discover).with({
1095
+ 'identity' => [],
1096
+ 'compound' => [],
1097
+ 'fact' => [],
1098
+ 'agent' => ['foo'],
1099
+ 'cf_class' => [],
1100
+ 'collective' => 'mcollective',
1101
+ }, 2).returns(["foo"])
996
1102
 
997
1103
  rpcclient.instance_variable_set("@force_direct_request", true)
998
1104
  rpcclient.discover
@@ -1000,16 +1106,44 @@ module MCollective
1000
1106
  end
1001
1107
 
1002
1108
  it "should store discovered nodes in stats" do
1003
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
1004
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
1109
+ rpcclient = Client.new("foo", {
1110
+ :options => {
1111
+ :filter => Util.empty_filter,
1112
+ :config => "/nonexisting",
1113
+ :verbose => false,
1114
+ :disctimeout => 2,
1115
+ },
1116
+ })
1117
+ rpcclient.client.expects(:discover).with({
1118
+ 'identity' => [],
1119
+ 'compound' => [],
1120
+ 'fact' => [],
1121
+ 'agent' => ['foo'],
1122
+ 'cf_class' => [],
1123
+ 'collective' => 'mcollective',
1124
+ }, 2).returns(["foo"])
1005
1125
 
1006
1126
  rpcclient.discover
1007
1127
  rpcclient.stats.discovered_nodes.should == ["foo"]
1008
1128
  end
1009
1129
 
1010
1130
  it "should save discovered nodes in RPC" do
1011
- rpcclient = Client.new("foo", {:options => {:filter => Util.empty_filter, :config => "/nonexisting", :verbose => false, :disctimeout => 2}})
1012
- rpcclient.client.expects(:discover).with({'identity' => [], 'compound' => [], 'fact' => [], 'agent' => ['foo'], 'cf_class' => []}, 2).returns(["foo"])
1131
+ rpcclient = Client.new("foo", {
1132
+ :options => {
1133
+ :filter => Util.empty_filter,
1134
+ :config => "/nonexisting",
1135
+ :verbose => false,
1136
+ :disctimeout => 2,
1137
+ },
1138
+ })
1139
+ rpcclient.client.expects(:discover).with({
1140
+ 'identity' => [],
1141
+ 'compound' => [],
1142
+ 'fact' => [],
1143
+ 'agent' => ['foo'],
1144
+ 'cf_class' => [],
1145
+ 'collective' => 'mcollective',
1146
+ }, 2).returns(["foo"])
1013
1147
 
1014
1148
  RPC.expects(:discovered).with(["foo"]).once
1015
1149
  rpcclient.discover
@@ -1018,31 +1152,31 @@ module MCollective
1018
1152
 
1019
1153
  describe "#determine_batch_mode" do
1020
1154
  let(:rpcclient) do
1021
- rpcclient = Client.new("foo",
1022
- {:options => {:filter => Util.empty_filter,
1023
- :config => "/nonexisting",
1024
- :verbose => false,
1155
+ rpcclient = Client.new("foo",
1156
+ {:options => {:filter => Util.empty_filter,
1157
+ :config => "/nonexisting",
1158
+ :verbose => false,
1025
1159
  :disctimeout => 2}})
1026
1160
  end
1027
1161
 
1028
1162
  it "should return true when batch_mode should be set" do
1029
1163
  rpcclient.send(:determine_batch_mode, "1").should == true
1030
- rpcclient.send(:determine_batch_mode, 1).should == true
1031
- rpcclient.send(:determine_batch_mode, "1%").should == true
1164
+ rpcclient.send(:determine_batch_mode, 1).should == true
1165
+ rpcclient.send(:determine_batch_mode, "1%").should == true
1032
1166
  end
1033
1167
 
1034
1168
  it "should return false when batch_mode shouldn't be set" do
1035
1169
  rpcclient.send(:determine_batch_mode, "0").should == false
1036
- rpcclient.send(:determine_batch_mode, 0).should == false
1170
+ rpcclient.send(:determine_batch_mode, 0).should == false
1037
1171
  end
1038
1172
  end
1039
1173
 
1040
1174
  describe "#validate_batch_size" do
1041
1175
  let(:rpcclient) do
1042
- rpcclient = Client.new("foo",
1043
- {:options => {:filter => Util.empty_filter,
1044
- :config => "/nonexisting",
1045
- :verbose => false,
1176
+ rpcclient = Client.new("foo",
1177
+ {:options => {:filter => Util.empty_filter,
1178
+ :config => "/nonexisting",
1179
+ :verbose => false,
1046
1180
  :disctimeout => 2}})
1047
1181
  end
1048
1182