mcollective-client 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mcollective-client might be problematic. Click here for more details.
- data/bin/mc-call-agent +54 -0
- data/bin/mco +27 -0
- data/lib/mcollective.rb +70 -0
- data/lib/mcollective/agents.rb +160 -0
- data/lib/mcollective/application.rb +354 -0
- data/lib/mcollective/applications.rb +145 -0
- data/lib/mcollective/client.rb +292 -0
- data/lib/mcollective/config.rb +202 -0
- data/lib/mcollective/connector.rb +18 -0
- data/lib/mcollective/connector/base.rb +24 -0
- data/lib/mcollective/facts.rb +39 -0
- data/lib/mcollective/facts/base.rb +86 -0
- data/lib/mcollective/log.rb +103 -0
- data/lib/mcollective/logger.rb +5 -0
- data/lib/mcollective/logger/base.rb +73 -0
- data/lib/mcollective/logger/console_logger.rb +61 -0
- data/lib/mcollective/logger/file_logger.rb +46 -0
- data/lib/mcollective/logger/syslog_logger.rb +53 -0
- data/lib/mcollective/matcher.rb +16 -0
- data/lib/mcollective/matcher/parser.rb +93 -0
- data/lib/mcollective/matcher/scanner.rb +123 -0
- data/lib/mcollective/message.rb +201 -0
- data/lib/mcollective/monkey_patches.rb +104 -0
- data/lib/mcollective/optionparser.rb +164 -0
- data/lib/mcollective/pluginmanager.rb +180 -0
- data/lib/mcollective/pluginpackager.rb +26 -0
- data/lib/mcollective/pluginpackager/agent_definition.rb +79 -0
- data/lib/mcollective/pluginpackager/standard_definition.rb +59 -0
- data/lib/mcollective/registration.rb +16 -0
- data/lib/mcollective/registration/base.rb +75 -0
- data/lib/mcollective/rpc.rb +188 -0
- data/lib/mcollective/rpc/actionrunner.rb +142 -0
- data/lib/mcollective/rpc/agent.rb +441 -0
- data/lib/mcollective/rpc/audit.rb +38 -0
- data/lib/mcollective/rpc/client.rb +793 -0
- data/lib/mcollective/rpc/ddl.rb +258 -0
- data/lib/mcollective/rpc/helpers.rb +339 -0
- data/lib/mcollective/rpc/progress.rb +63 -0
- data/lib/mcollective/rpc/reply.rb +61 -0
- data/lib/mcollective/rpc/request.rb +51 -0
- data/lib/mcollective/rpc/result.rb +41 -0
- data/lib/mcollective/rpc/stats.rb +185 -0
- data/lib/mcollective/runnerstats.rb +90 -0
- data/lib/mcollective/security.rb +26 -0
- data/lib/mcollective/security/base.rb +237 -0
- data/lib/mcollective/shell.rb +87 -0
- data/lib/mcollective/ssl.rb +246 -0
- data/lib/mcollective/unix_daemon.rb +37 -0
- data/lib/mcollective/util.rb +274 -0
- data/lib/mcollective/vendor.rb +41 -0
- data/lib/mcollective/vendor/require_vendored.rb +2 -0
- data/lib/mcollective/windows_daemon.rb +25 -0
- data/spec/Rakefile +16 -0
- data/spec/fixtures/application/test.rb +7 -0
- data/spec/fixtures/test-cert.pem +15 -0
- data/spec/fixtures/test-private.pem +15 -0
- data/spec/fixtures/test-public.pem +6 -0
- data/spec/monkey_patches/instance_variable_defined.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/unit/agents_spec.rb +280 -0
- data/spec/unit/application_spec.rb +636 -0
- data/spec/unit/applications_spec.rb +155 -0
- data/spec/unit/array.rb +30 -0
- data/spec/unit/config_spec.rb +148 -0
- data/spec/unit/facts/base_spec.rb +118 -0
- data/spec/unit/facts_spec.rb +39 -0
- data/spec/unit/log_spec.rb +71 -0
- data/spec/unit/logger/base_spec.rb +110 -0
- data/spec/unit/logger/syslog_logger_spec.rb +86 -0
- data/spec/unit/matcher/parser_spec.rb +106 -0
- data/spec/unit/matcher/scanner_spec.rb +71 -0
- data/spec/unit/message_spec.rb +401 -0
- data/spec/unit/optionparser_spec.rb +113 -0
- data/spec/unit/pluginmanager_spec.rb +173 -0
- data/spec/unit/pluginpackager/agent_definition_spec.rb +130 -0
- data/spec/unit/pluginpackager/standard_definition_spec.rb +75 -0
- data/spec/unit/plugins/mcollective/connector/activemq_spec.rb +533 -0
- data/spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb +34 -0
- data/spec/unit/plugins/mcollective/connector/stomp_spec.rb +417 -0
- data/spec/unit/plugins/mcollective/packagers/ospackage_spec.rb +229 -0
- data/spec/unit/plugins/mcollective/security/psk_spec.rb +156 -0
- data/spec/unit/registration/base_spec.rb +77 -0
- data/spec/unit/rpc/actionrunner_spec.rb +213 -0
- data/spec/unit/rpc/agent_spec.rb +155 -0
- data/spec/unit/rpc/client_spec.rb +523 -0
- data/spec/unit/rpc/ddl_spec.rb +388 -0
- data/spec/unit/rpc/helpers_spec.rb +55 -0
- data/spec/unit/rpc/reply_spec.rb +143 -0
- data/spec/unit/rpc/request_spec.rb +115 -0
- data/spec/unit/rpc/result_spec.rb +66 -0
- data/spec/unit/rpc/stats_spec.rb +288 -0
- data/spec/unit/runnerstats_spec.rb +40 -0
- data/spec/unit/security/base_spec.rb +279 -0
- data/spec/unit/shell_spec.rb +144 -0
- data/spec/unit/ssl_spec.rb +244 -0
- data/spec/unit/symbol.rb +11 -0
- data/spec/unit/unix_daemon.rb +41 -0
- data/spec/unit/util_spec.rb +342 -0
- data/spec/unit/vendor_spec.rb +34 -0
- data/spec/unit/windows_daemon.rb +43 -0
- data/spec/windows_spec.opts +1 -0
- metadata +242 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module MCollective
|
6
|
+
module RPC
|
7
|
+
describe Request do
|
8
|
+
before(:each) do
|
9
|
+
@req = {:msgtime => Time.now,
|
10
|
+
:senderid => "spec test",
|
11
|
+
:requestid => "12345",
|
12
|
+
:callerid => "rip"}
|
13
|
+
|
14
|
+
@req[:body] = {:action => "test",
|
15
|
+
:data => {:foo => "bar", :process_results => true},
|
16
|
+
:agent => "tester"}
|
17
|
+
|
18
|
+
@request = Request.new(@req)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#initialize" do
|
22
|
+
it "should set time" do
|
23
|
+
@request.time.should == @req[:msgtime]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should set action" do
|
27
|
+
@request.action.should == "test"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should set data" do
|
31
|
+
@request.data.should == {:foo => "bar", :process_results => true}
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should set sender" do
|
35
|
+
@request.sender.should == "spec test"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set agent" do
|
39
|
+
@request.agent.should == "tester"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should set uniqid" do
|
43
|
+
@request.uniqid.should == "12345"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should set caller" do
|
47
|
+
@request.caller.should == "rip"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should set unknown caller if none is supplied" do
|
51
|
+
@req.delete(:callerid)
|
52
|
+
Request.new(@req).caller.should == "unknown"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#include?" do
|
57
|
+
it "should correctly report on hash contents" do
|
58
|
+
@request.include?(:foo).should == true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return false for non hash data" do
|
62
|
+
@req[:body][:data] = "foo"
|
63
|
+
Request.new(@req).include?(:foo).should == false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#should_respond?" do
|
68
|
+
it "should return true if the header is absent" do
|
69
|
+
@req[:body][:data].delete(:process_results)
|
70
|
+
Request.new(@req).should_respond?.should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return correct value" do
|
74
|
+
@req[:body][:data][:process_results] = false
|
75
|
+
Request.new(@req).should_respond?.should == false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#[]" do
|
80
|
+
it "should return nil for non hash data" do
|
81
|
+
@req[:body][:data] = "foo"
|
82
|
+
Request.new(@req)["foo"].should == nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return correct data" do
|
86
|
+
@request[:foo].should == "bar"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return nil for absent data" do
|
90
|
+
@request[:bar].should == nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#to_hash" do
|
95
|
+
it "should have the correct keys" do
|
96
|
+
@request.to_hash.keys.sort.should == [:action, :agent, :data]
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should return the correct agent" do
|
100
|
+
@request.to_hash[:agent].should == "tester"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should return the correct action" do
|
104
|
+
@request.to_hash[:action].should == "test"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should return the correct data" do
|
108
|
+
@request.to_hash[:data].should == {:foo => "bar",
|
109
|
+
:process_results => true}
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module MCollective
|
6
|
+
module RPC
|
7
|
+
describe Result do
|
8
|
+
before(:each) do
|
9
|
+
@result = Result.new("tester", "test", {:foo => "bar", :bar => "baz"})
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should include Enumerable" do
|
13
|
+
Result.ancestors.include?(Enumerable).should == true
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#initialize" do
|
17
|
+
it "should set the agent" do
|
18
|
+
@result.agent.should == "tester"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should set the action" do
|
22
|
+
@result.action.should == "test"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the results" do
|
26
|
+
@result.results.should == {:foo => "bar", :bar => "baz"}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#[]" do
|
31
|
+
it "should access the results hash and return correct data" do
|
32
|
+
@result[:foo].should == "bar"
|
33
|
+
@result[:bar].should == "baz"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#[]=" do
|
38
|
+
it "should set the correct result data" do
|
39
|
+
@result[:meh] = "blah"
|
40
|
+
|
41
|
+
@result[:foo].should == "bar"
|
42
|
+
@result[:bar].should == "baz"
|
43
|
+
@result[:meh].should == "blah"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#each" do
|
48
|
+
it "should itterate all the pairs" do
|
49
|
+
data = {}
|
50
|
+
|
51
|
+
@result.each {|k,v| data[k] = v}
|
52
|
+
|
53
|
+
data[:foo].should == "bar"
|
54
|
+
data[:bar].should == "baz"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#to_json" do
|
59
|
+
it "should correctly json encode teh data" do
|
60
|
+
result = Result.new("tester", "test", {:statuscode => 0, :statusmsg => "OK", :sender => "rspec", :data => {:foo => "bar", :bar => "baz"}})
|
61
|
+
JSON.load(result.to_json).should == {"agent" => "tester", "action" => "test", "statuscode" => 0, "statusmsg" => "OK", "sender" => "rspec", "data" => {"foo" => "bar", "bar" => "baz"}}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module MCollective
|
6
|
+
module RPC
|
7
|
+
describe Stats do
|
8
|
+
before(:each) do
|
9
|
+
@expected = {:discoverytime=>0,
|
10
|
+
:okcount=>0,
|
11
|
+
:blocktime=>0,
|
12
|
+
:failcount=>0,
|
13
|
+
:noresponsefrom=>[],
|
14
|
+
:responses=>0,
|
15
|
+
:totaltime=>0,
|
16
|
+
:discovered=>0,
|
17
|
+
:starttime=>1300031826.0,
|
18
|
+
:discovered_nodes=>[]}
|
19
|
+
|
20
|
+
@stats = Stats.new
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#initialize" do
|
24
|
+
it "should reset stats on creation" do
|
25
|
+
Stats.any_instance.stubs(:reset).returns(true).once
|
26
|
+
s = Stats.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#reset" do
|
31
|
+
it "should initialize data correctly" do
|
32
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
33
|
+
s = Stats.new
|
34
|
+
|
35
|
+
@expected.keys.each do |k|
|
36
|
+
@expected[k].should == s.send(k)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#to_hash" do
|
42
|
+
it "should return correct stats" do
|
43
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
44
|
+
s = Stats.new
|
45
|
+
|
46
|
+
@expected.keys.each do |k|
|
47
|
+
@expected[k].should == s.to_hash[k]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#[]" do
|
53
|
+
it "should return stat values" do
|
54
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
55
|
+
s = Stats.new
|
56
|
+
|
57
|
+
@expected.keys.each do |k|
|
58
|
+
@expected[k].should == s[k]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return nil for unknown values" do
|
63
|
+
@stats["foo"].should == nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#ok" do
|
68
|
+
it "should increment stats" do
|
69
|
+
@stats.ok
|
70
|
+
@stats[:okcount].should == 1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#fail" do
|
75
|
+
it "should increment stats" do
|
76
|
+
@stats.fail
|
77
|
+
@stats.failcount.should == 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#time_discovery" do
|
82
|
+
it "should set start time correctly" do
|
83
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
84
|
+
|
85
|
+
@stats.time_discovery(:start)
|
86
|
+
|
87
|
+
@stats.instance_variable_get("@discovery_start").should == 1300031826.0
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should record the difference correctly" do
|
91
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
92
|
+
@stats.time_discovery(:start)
|
93
|
+
|
94
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
95
|
+
@stats.time_discovery(:end)
|
96
|
+
|
97
|
+
@stats.discoverytime.should == 1.0
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should handle unknown actions and set discovery time to 0" do
|
101
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
102
|
+
@stats.time_discovery(:start)
|
103
|
+
|
104
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
105
|
+
@stats.time_discovery(:stop)
|
106
|
+
|
107
|
+
@stats.discoverytime.should == 0
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#client_stats=" do
|
113
|
+
it "should store stats correctly" do
|
114
|
+
data = {}
|
115
|
+
keys = [:noresponsefrom, :responses, :starttime, :blocktime, :totaltime, :discoverytime]
|
116
|
+
keys.each {|k| data[k] = k}
|
117
|
+
|
118
|
+
@stats.client_stats = data
|
119
|
+
|
120
|
+
keys.each do |k|
|
121
|
+
@stats[k].should == data[k]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should not store discovery time if it was already stored" do
|
126
|
+
data = {}
|
127
|
+
keys = [:noresponsefrom, :responses, :starttime, :blocktime, :totaltime, :discoverytime]
|
128
|
+
keys.each {|k| data[k] = k}
|
129
|
+
|
130
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
131
|
+
@stats.time_discovery(:start)
|
132
|
+
|
133
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
134
|
+
@stats.time_discovery(:end)
|
135
|
+
|
136
|
+
dtime = @stats.discoverytime
|
137
|
+
|
138
|
+
@stats.client_stats = data
|
139
|
+
|
140
|
+
@stats.discoverytime.should == dtime
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#time_block_execution" do
|
145
|
+
it "should set start time correctly" do
|
146
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
147
|
+
|
148
|
+
@stats.time_block_execution(:start)
|
149
|
+
|
150
|
+
@stats.instance_variable_get("@block_start").should == 1300031826.0
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should record the difference correctly" do
|
154
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
155
|
+
@stats.time_block_execution(:start)
|
156
|
+
|
157
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
158
|
+
@stats.time_block_execution(:end)
|
159
|
+
|
160
|
+
@stats.blocktime.should == 1
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should handle unknown actions and set discovery time to 0" do
|
164
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
165
|
+
@stats.time_block_execution(:start)
|
166
|
+
|
167
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
168
|
+
@stats.time_block_execution(:stop)
|
169
|
+
|
170
|
+
@stats.blocktime.should == 0
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "#discovered_agents" do
|
175
|
+
it "should set discovered_nodes" do
|
176
|
+
nodes = ["one", "two"]
|
177
|
+
@stats.discovered_agents(nodes)
|
178
|
+
@stats.discovered_nodes.should == nodes
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should set discovered count" do
|
182
|
+
nodes = ["one", "two"]
|
183
|
+
@stats.discovered_agents(nodes)
|
184
|
+
@stats.discovered.should == 2
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "#finish_request" do
|
189
|
+
it "should calculate totaltime correctly" do
|
190
|
+
Time.stubs(:now).returns(Time.at(1300031824))
|
191
|
+
@stats.time_discovery(:start)
|
192
|
+
|
193
|
+
Time.stubs(:now).returns(Time.at(1300031825))
|
194
|
+
@stats.time_discovery(:end)
|
195
|
+
|
196
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
197
|
+
@stats.time_block_execution(:start)
|
198
|
+
|
199
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
200
|
+
@stats.time_block_execution(:end)
|
201
|
+
|
202
|
+
@stats.discovered_agents(["one", "two", "three"])
|
203
|
+
@stats.node_responded("one")
|
204
|
+
@stats.node_responded("two")
|
205
|
+
|
206
|
+
@stats.finish_request
|
207
|
+
|
208
|
+
@stats.totaltime.should == 2
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should calculate no responses correctly" do
|
212
|
+
Time.stubs(:now).returns(Time.at(1300031824))
|
213
|
+
@stats.time_discovery(:start)
|
214
|
+
|
215
|
+
Time.stubs(:now).returns(Time.at(1300031825))
|
216
|
+
@stats.time_discovery(:end)
|
217
|
+
|
218
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
219
|
+
@stats.time_block_execution(:start)
|
220
|
+
|
221
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
222
|
+
@stats.time_block_execution(:end)
|
223
|
+
|
224
|
+
@stats.discovered_agents(["one", "two", "three"])
|
225
|
+
@stats.node_responded("one")
|
226
|
+
@stats.node_responded("two")
|
227
|
+
|
228
|
+
@stats.finish_request
|
229
|
+
|
230
|
+
@stats.noresponsefrom.should == ["three"]
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should recover from failure correctly" do
|
234
|
+
Time.stubs(:now).returns(Time.at(1300031824))
|
235
|
+
@stats.time_discovery(:start)
|
236
|
+
|
237
|
+
Time.stubs(:now).returns(Time.at(1300031825))
|
238
|
+
@stats.time_discovery(:end)
|
239
|
+
|
240
|
+
Time.stubs(:now).returns(Time.at(1300031826))
|
241
|
+
@stats.time_block_execution(:start)
|
242
|
+
|
243
|
+
Time.stubs(:now).returns(Time.at(1300031827))
|
244
|
+
@stats.time_block_execution(:end)
|
245
|
+
|
246
|
+
# cause the .each to raise an exception
|
247
|
+
@stats.instance_variable_set("@responsesfrom", nil)
|
248
|
+
@stats.finish_request
|
249
|
+
|
250
|
+
@stats.noresponsefrom.should == []
|
251
|
+
@stats.totaltime.should == 0
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "#node_responded" do
|
256
|
+
it "should append to the list of nodes" do
|
257
|
+
@stats.node_responded "foo"
|
258
|
+
@stats.responsesfrom.should == ["foo"]
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should create a new array if adding fails" do
|
262
|
+
# cause the << to fail
|
263
|
+
@stats.instance_variable_set("@responsesfrom", nil)
|
264
|
+
|
265
|
+
@stats.node_responded "foo"
|
266
|
+
@stats.responsesfrom.should == ["foo"]
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
describe "#no_response_report" do
|
271
|
+
it "should create an empty report if all nodes responded" do
|
272
|
+
@stats.discovered_agents ["foo"]
|
273
|
+
@stats.node_responded "foo"
|
274
|
+
@stats.finish_request
|
275
|
+
|
276
|
+
@stats.no_response_report.should == ""
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should list all nodes that did not respond" do
|
280
|
+
@stats.discovered_agents ["foo", "bar"]
|
281
|
+
@stats.finish_request
|
282
|
+
|
283
|
+
@stats.no_response_report.should match(Regexp.new(/No response from.+foo.+bar/m))
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|