right_agent 0.6.6 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/lib/right_agent/agent.rb +26 -25
  2. data/lib/right_agent/agent_config.rb +28 -2
  3. data/lib/right_agent/command/command_constants.rb +2 -2
  4. data/lib/right_agent/core_payload_types/executable_bundle.rb +3 -21
  5. data/lib/right_agent/core_payload_types/login_user.rb +19 -4
  6. data/lib/right_agent/core_payload_types/recipe_instantiation.rb +7 -1
  7. data/lib/right_agent/core_payload_types/right_script_instantiation.rb +7 -1
  8. data/lib/right_agent/dispatcher.rb +6 -19
  9. data/lib/right_agent/idempotent_request.rb +72 -17
  10. data/lib/right_agent/monkey_patches/ruby_patch.rb +0 -1
  11. data/lib/right_agent/monkey_patches.rb +0 -1
  12. data/lib/right_agent/operation_result.rb +27 -4
  13. data/lib/right_agent/packets.rb +47 -23
  14. data/lib/right_agent/platform/darwin.rb +33 -2
  15. data/lib/right_agent/platform/linux.rb +98 -2
  16. data/lib/right_agent/platform/windows.rb +41 -6
  17. data/lib/right_agent/platform.rb +11 -2
  18. data/lib/right_agent/scripts/agent_controller.rb +2 -1
  19. data/lib/right_agent/scripts/agent_deployer.rb +2 -2
  20. data/lib/right_agent/scripts/stats_manager.rb +7 -3
  21. data/lib/right_agent/sender.rb +45 -28
  22. data/lib/right_agent.rb +2 -5
  23. data/right_agent.gemspec +5 -3
  24. data/spec/agent_config_spec.rb +1 -1
  25. data/spec/agent_spec.rb +26 -20
  26. data/spec/core_payload_types/login_user_spec.rb +7 -3
  27. data/spec/idempotent_request_spec.rb +218 -48
  28. data/spec/operation_result_spec.rb +19 -0
  29. data/spec/packets_spec.rb +42 -1
  30. data/spec/platform/darwin.rb +11 -0
  31. data/spec/platform/linux.rb +23 -0
  32. data/spec/platform/linux_volume_manager_spec.rb +43 -43
  33. data/spec/platform/platform_spec.rb +35 -32
  34. data/spec/platform/windows.rb +11 -0
  35. data/spec/sender_spec.rb +21 -25
  36. metadata +47 -40
  37. data/lib/right_agent/broker_client.rb +0 -686
  38. data/lib/right_agent/ha_broker_client.rb +0 -1327
  39. data/lib/right_agent/monkey_patches/amqp_patch.rb +0 -274
  40. data/lib/right_agent/monkey_patches/ruby_patch/string_patch.rb +0 -107
  41. data/lib/right_agent/stats_helper.rb +0 -745
  42. data/spec/broker_client_spec.rb +0 -962
  43. data/spec/ha_broker_client_spec.rb +0 -1695
  44. data/spec/monkey_patches/amqp_patch_spec.rb +0 -100
  45. data/spec/monkey_patches/string_patch_spec.rb +0 -99
  46. data/spec/stats_helper_spec.rb +0 -686
@@ -21,40 +21,43 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
 
23
23
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
24
-
25
-
26
- describe RightScale::Platform do
27
- before(:all) do
28
- @platform = RightScale::Platform
29
- end
30
-
31
- context :shell do
32
- context :uptime do
33
- it 'should be positive' do
34
- @platform.shell.uptime.should > 0
35
- end
36
-
37
- it 'should be strictly increasing' do
38
- u0 = @platform.shell.uptime
39
- sleep(1)
40
- u1 = @platform.shell.uptime
41
-
42
- (u1 - u0).should >= 0
24
+ require File.expand_path(File.join(File.dirname(__FILE__), 'darwin')) if RightScale::Platform.darwin?
25
+ require File.expand_path(File.join(File.dirname(__FILE__), 'windows')) if RightScale::Platform.windows?
26
+ require File.expand_path(File.join(File.dirname(__FILE__), 'linux')) if RightScale::Platform.linux?
27
+
28
+ module RightScale
29
+ describe Platform do
30
+ subject { RightScale::Platform }
31
+
32
+ context :shell do
33
+ context :uptime do
34
+ it 'should be positive' do
35
+ subject.shell.uptime.should > 0
36
+ end
37
+
38
+ it 'should be strictly increasing' do
39
+ u0 = subject.shell.uptime
40
+ sleep(1)
41
+ u1 = subject.shell.uptime
42
+
43
+ (u1 - u0).should >= 0
44
+ end
43
45
  end
44
- end
45
-
46
- context :booted_at do
47
- it 'should be some time in the past' do
48
- Time.at(@platform.shell.booted_at).to_i.should < Time.now.to_i
49
- end
50
-
51
- it 'should be constant' do
52
- b0 = @platform.shell.booted_at
53
- sleep(1)
54
- b1 = @platform.shell.booted_at
55
-
56
- b0.should == b1
46
+
47
+ context :booted_at do
48
+ it 'should be some time in the past' do
49
+ Time.at(subject.shell.booted_at).to_i.should < Time.now.to_i
50
+ end
51
+
52
+ it 'should be constant' do
53
+ b0 = subject.shell.booted_at
54
+ sleep(1)
55
+ b1 = subject.shell.booted_at
56
+
57
+ b0.should == b1
58
+ end
57
59
  end
58
60
  end
61
+
59
62
  end
60
63
  end
@@ -0,0 +1,11 @@
1
+ module RightScale
2
+ describe Platform do
3
+ subject { RightScale::Platform }
4
+
5
+ context :installer do
6
+ context :install do
7
+ specify { lambda { subject.installer.install([]) }.should raise_exception }
8
+ end
9
+ end
10
+ end
11
+ end
data/spec/sender_spec.rb CHANGED
@@ -62,7 +62,7 @@ describe RightScale::Sender do
62
62
  @now = Time.at(1000000)
63
63
  flexmock(Time).should_receive(:now).and_return(@now).by_default
64
64
  @broker = flexmock("Broker", :subscribe => true, :publish => ["broker"], :connected? => true,
65
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
65
+ :identity_parts => ["host", 123, 0, 0]).by_default
66
66
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker, :options => {:ping_interval => 0}).by_default
67
67
  end
68
68
 
@@ -153,14 +153,16 @@ describe RightScale::Sender do
153
153
  end
154
154
 
155
155
  it "should attempt to reconnect if mapper ping times out" do
156
- @log.should_receive(:warning).with(/Mapper ping via broker/).once
156
+ @log.should_receive(:error).with(/Mapper ping via broker/).once
157
157
  @agent.should_receive(:options).and_return(:ping_interval => 1000)
158
158
  broker_id = "rs-broker-localhost-5672"
159
- @broker.should_receive(:identity_parts).with(broker_id).and_return(["localhost", 5672, 0, 0, nil]).once
159
+ @broker.should_receive(:identity_parts).with(broker_id).and_return(["localhost", 5672, 0, 0]).once
160
160
  @agent.should_receive(:connect).with("localhost", 5672, 0, 0, true).once
161
161
  old_ping_timeout = RightScale::Sender::ConnectivityChecker::PING_TIMEOUT
162
+ old_max_ping_timeouts = RightScale::Sender::ConnectivityChecker::MAX_PING_TIMEOUTS
162
163
  begin
163
164
  RightScale::Sender::ConnectivityChecker.const_set(:PING_TIMEOUT, 0.5)
165
+ RightScale::Sender::ConnectivityChecker.const_set(:MAX_PING_TIMEOUTS, 1)
164
166
  EM.run do
165
167
  EM.add_timer(1) { EM.stop }
166
168
  RightScale::Sender.new(@agent)
@@ -170,6 +172,7 @@ describe RightScale::Sender do
170
172
  end
171
173
  ensure
172
174
  RightScale::Sender::ConnectivityChecker.const_set(:PING_TIMEOUT, old_ping_timeout)
175
+ RightScale::Sender::ConnectivityChecker.const_set(:MAX_PING_TIMEOUTS, old_max_ping_timeouts)
173
176
  end
174
177
  end
175
178
  end
@@ -365,7 +368,7 @@ describe RightScale::Sender do
365
368
  @broker_id = "broker"
366
369
  @broker_ids = [@broker_id]
367
370
  @broker = flexmock("Broker", :subscribe => true, :publish => @broker_ids, :connected? => true,
368
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
371
+ :all => @broker_ids, :identity_parts => ["host", 123, 0, 0]).by_default
369
372
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker).by_default
370
373
  @agent.should_receive(:options).and_return({:ping_interval => 0, :time_to_live => 100}).by_default
371
374
  RightScale::Sender.new(@agent)
@@ -488,18 +491,6 @@ describe RightScale::Sender do
488
491
  end
489
492
 
490
493
  describe "with retry" do
491
- it "should convert value to nil if 0" do
492
- @instance.__send__(:nil_if_zero, 0).should == nil
493
- end
494
-
495
- it "should not convert value to nil if not 0" do
496
- @instance.__send__(:nil_if_zero, 1).should == 1
497
- end
498
-
499
- it "should leave value as nil if nil" do
500
- @instance.__send__(:nil_if_zero, nil).should == nil
501
- end
502
-
503
494
  it "should not setup for retry if retry_timeout nil" do
504
495
  flexmock(EM).should_receive(:add_timer).never
505
496
  @agent.should_receive(:options).and_return({:retry_timeout => nil})
@@ -638,19 +629,24 @@ describe RightScale::Sender do
638
629
  @instance.connectivity_checker.ping_timer.should == nil
639
630
  end
640
631
 
641
- it "should try to reconnect if ping times out" do
642
- @log.should_receive(:warning).once
643
- flexmock(EM::Timer).should_receive(:new).and_yield.once
632
+ it "should try to reconnect if ping times out repeatedly" do
633
+ @log.should_receive(:warning).with(/timed out after 30 seconds/).twice
634
+ @log.should_receive(:error).with(/reached maximum of 3 timeouts/).once
635
+ flexmock(EM::Timer).should_receive(:new).and_yield.times(3)
644
636
  flexmock(@agent).should_receive(:connect).once
645
637
  @instance.connectivity_checker.check(@broker_id)
638
+ @instance.connectivity_checker.check(@broker_id)
639
+ @instance.connectivity_checker.check(@broker_id)
646
640
  @instance.connectivity_checker.ping_timer.should == nil
647
641
  end
648
642
 
649
643
  it "should log error if attempt to reconnect fails" do
650
- @log.should_receive(:warning).once
644
+ @log.should_receive(:warning).with(/timed out after 30 seconds/).twice
651
645
  @log.should_receive(:error).with(/Failed to reconnect/, Exception, :trace).once
652
646
  flexmock(@agent).should_receive(:connect).and_raise(Exception)
653
- flexmock(EM::Timer).should_receive(:new).and_yield.once
647
+ flexmock(EM::Timer).should_receive(:new).and_yield.times(3)
648
+ @instance.connectivity_checker.check(@broker_id)
649
+ @instance.connectivity_checker.check(@broker_id)
654
650
  @instance.connectivity_checker.check(@broker_id)
655
651
  end
656
652
  end
@@ -665,7 +661,7 @@ describe RightScale::Sender do
665
661
  @broker_id = "broker"
666
662
  @broker_ids = [@broker_id]
667
663
  @broker = flexmock("Broker", :subscribe => true, :publish => @broker_ids, :connected? => true,
668
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
664
+ :identity_parts => ["host", 123, 0, 0]).by_default
669
665
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker,
670
666
  :options => {:ping_interval => 0, :time_to_live => 100}).by_default
671
667
  RightScale::Sender.new(@agent)
@@ -720,7 +716,7 @@ describe RightScale::Sender do
720
716
  flexmock(EM).should_receive(:next_tick).and_yield.by_default
721
717
  flexmock(EM).should_receive(:defer).and_yield.by_default
722
718
  @broker = flexmock("Broker", :subscribe => true, :publish => ["broker"], :connected? => true,
723
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
719
+ :identity_parts => ["host", 123, 0, 0]).by_default
724
720
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker, :options => {:ping_interval => 0}).by_default
725
721
  RightScale::Sender.new(@agent)
726
722
  @instance = RightScale::Sender.instance
@@ -783,7 +779,7 @@ describe RightScale::Sender do
783
779
  flexmock(EM).should_receive(:next_tick).and_yield.by_default
784
780
  flexmock(EM).should_receive(:defer).and_yield.by_default
785
781
  @broker = flexmock("Broker", :subscribe => true, :publish => ["broker"], :connected? => true,
786
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
782
+ :identity_parts => ["host", 123, 0, 0]).by_default
787
783
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker, :options => {:ping_interval => 0}).by_default
788
784
  RightScale::Sender.new(@agent)
789
785
  @instance = RightScale::Sender.instance
@@ -865,7 +861,7 @@ describe RightScale::Sender do
865
861
  describe "when use offline queueing" do
866
862
  before(:each) do
867
863
  @broker = flexmock("Broker", :subscribe => true, :publish => ["broker"], :connected? => true,
868
- :identity_parts => ["host", 123, 0, 0, nil]).by_default
864
+ :identity_parts => ["host", 123, 0, 0]).by_default
869
865
  @agent = flexmock("Agent", :identity => "agent", :broker => @broker, :options => {:offline_queueing => true}).by_default
870
866
  RightScale::Sender.new(@agent)
871
867
  @instance = RightScale::Sender.instance
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 6
10
- version: 0.6.6
8
+ - 9
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lee Kirchhoff
@@ -17,44 +17,40 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-12-14 00:00:00 -08:00
20
+ date: 2012-03-07 00:00:00 -08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- type: :runtime
25
- name: right_support
26
- prerelease: false
27
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
27
  - - ~>
31
28
  - !ruby/object:Gem::Version
32
- hash: 15
29
+ hash: 9
33
30
  segments:
34
31
  - 1
35
- - 0
36
- version: "1.0"
32
+ - 3
33
+ version: "1.3"
37
34
  requirement: *id001
38
- - !ruby/object:Gem::Dependency
39
- type: :runtime
40
- name: amqp
35
+ name: right_support
41
36
  prerelease: false
37
+ type: :runtime
38
+ - !ruby/object:Gem::Dependency
42
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
43
40
  none: false
44
41
  requirements:
45
- - - "="
42
+ - - ~>
46
43
  - !ruby/object:Gem::Version
47
44
  hash: 9
48
45
  segments:
49
46
  - 0
50
- - 6
51
- - 7
52
- version: 0.6.7
47
+ - 1
48
+ version: "0.1"
53
49
  requirement: *id002
54
- - !ruby/object:Gem::Dependency
55
- type: :runtime
56
- name: json
50
+ name: right_amqp
57
51
  prerelease: false
52
+ type: :runtime
53
+ - !ruby/object:Gem::Dependency
58
54
  version_requirements: &id003 !ruby/object:Gem::Requirement
59
55
  none: false
60
56
  requirements:
@@ -66,10 +62,10 @@ dependencies:
66
62
  - 4
67
63
  version: "1.4"
68
64
  requirement: *id003
69
- - !ruby/object:Gem::Dependency
70
- type: :runtime
71
- name: eventmachine
65
+ name: json
72
66
  prerelease: false
67
+ type: :runtime
68
+ - !ruby/object:Gem::Dependency
73
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
74
70
  none: false
75
71
  requirements:
@@ -82,10 +78,10 @@ dependencies:
82
78
  - 10
83
79
  version: 0.12.10
84
80
  requirement: *id004
85
- - !ruby/object:Gem::Dependency
86
- type: :runtime
87
- name: right_popen
81
+ name: eventmachine
88
82
  prerelease: false
83
+ type: :runtime
84
+ - !ruby/object:Gem::Dependency
89
85
  version_requirements: &id005 !ruby/object:Gem::Requirement
90
86
  none: false
91
87
  requirements:
@@ -98,10 +94,10 @@ dependencies:
98
94
  - 11
99
95
  version: 1.0.11
100
96
  requirement: *id005
101
- - !ruby/object:Gem::Dependency
102
- type: :runtime
103
- name: msgpack
97
+ name: right_popen
104
98
  prerelease: false
99
+ type: :runtime
100
+ - !ruby/object:Gem::Dependency
105
101
  version_requirements: &id006 !ruby/object:Gem::Requirement
106
102
  none: false
107
103
  requirements:
@@ -114,6 +110,24 @@ dependencies:
114
110
  - 4
115
111
  version: 0.4.4
116
112
  requirement: *id006
113
+ name: msgpack
114
+ prerelease: false
115
+ type: :runtime
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 2
125
+ - 0
126
+ version: "2.0"
127
+ requirement: *id007
128
+ name: net-ssh
129
+ prerelease: false
130
+ type: :runtime
117
131
  description: |
118
132
  RightAgent provides a foundation for running an agent on a server to interface
119
133
  in a secure fashion with other agents in the RightScale system. A RightAgent
@@ -143,7 +157,6 @@ files:
143
157
  - lib/right_agent/agent_identity.rb
144
158
  - lib/right_agent/agent_tags_manager.rb
145
159
  - lib/right_agent/audit_formatter.rb
146
- - lib/right_agent/broker_client.rb
147
160
  - lib/right_agent/command.rb
148
161
  - lib/right_agent/command/agent_manager_commands.rb
149
162
  - lib/right_agent/command/command_client.rb
@@ -176,12 +189,10 @@ files:
176
189
  - lib/right_agent/dispatcher.rb
177
190
  - lib/right_agent/enrollment_result.rb
178
191
  - lib/right_agent/exceptions.rb
179
- - lib/right_agent/ha_broker_client.rb
180
192
  - lib/right_agent/idempotent_request.rb
181
193
  - lib/right_agent/log.rb
182
194
  - lib/right_agent/minimal.rb
183
195
  - lib/right_agent/monkey_patches.rb
184
- - lib/right_agent/monkey_patches/amqp_patch.rb
185
196
  - lib/right_agent/monkey_patches/ruby_patch.rb
186
197
  - lib/right_agent/monkey_patches/ruby_patch/array_patch.rb
187
198
  - lib/right_agent/monkey_patches/ruby_patch/darwin_patch.rb
@@ -189,7 +200,6 @@ files:
189
200
  - lib/right_agent/monkey_patches/ruby_patch/linux_patch/file_patch.rb
190
201
  - lib/right_agent/monkey_patches/ruby_patch/object_patch.rb
191
202
  - lib/right_agent/monkey_patches/ruby_patch/singleton_patch.rb
192
- - lib/right_agent/monkey_patches/ruby_patch/string_patch.rb
193
203
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch.rb
194
204
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch/file_patch.rb
195
205
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch/process_patch.rb
@@ -228,7 +238,6 @@ files:
228
238
  - lib/right_agent/serialize/secure_serializer_initializer.rb
229
239
  - lib/right_agent/serialize/serializable.rb
230
240
  - lib/right_agent/serialize/serializer.rb
231
- - lib/right_agent/stats_helper.rb
232
241
  - lib/right_agent/subprocess.rb
233
242
  - lib/right_agent/tracer.rb
234
243
  - right_agent.gemspec
@@ -237,7 +246,6 @@ files:
237
246
  - spec/agent_config_spec.rb
238
247
  - spec/agent_identity_spec.rb
239
248
  - spec/agent_spec.rb
240
- - spec/broker_client_spec.rb
241
249
  - spec/command/agent_manager_commands_spec.rb
242
250
  - spec/command/command_io_spec.rb
243
251
  - spec/command/command_parser_spec.rb
@@ -251,17 +259,17 @@ files:
251
259
  - spec/core_payload_types/spec_helper.rb
252
260
  - spec/dispatcher_spec.rb
253
261
  - spec/enrollment_result_spec.rb
254
- - spec/ha_broker_client_spec.rb
255
262
  - spec/idempotent_request_spec.rb
256
263
  - spec/log_spec.rb
257
- - spec/monkey_patches/amqp_patch_spec.rb
258
264
  - spec/monkey_patches/eventmachine_spec.rb
259
- - spec/monkey_patches/string_patch_spec.rb
260
265
  - spec/multiplexer_spec.rb
261
266
  - spec/operation_result_spec.rb
262
267
  - spec/packets_spec.rb
268
+ - spec/platform/darwin.rb
269
+ - spec/platform/linux.rb
263
270
  - spec/platform/linux_volume_manager_spec.rb
264
271
  - spec/platform/platform_spec.rb
272
+ - spec/platform/windows.rb
265
273
  - spec/results_mock.rb
266
274
  - spec/secure_identity_spec.rb
267
275
  - spec/security/cached_certificate_store_proxy_spec.rb
@@ -279,7 +287,6 @@ files:
279
287
  - spec/serialize/serializer_spec.rb
280
288
  - spec/spec.opts
281
289
  - spec/spec_helper.rb
282
- - spec/stats_helper_spec.rb
283
290
  - spec/tracer_spec.rb
284
291
  has_rdoc: true
285
292
  homepage: https://github.com/rightscale/right_agent