right_agent 0.10.13 → 0.13.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/lib/right_agent.rb +2 -0
  2. data/lib/right_agent/actor.rb +45 -10
  3. data/lib/right_agent/actor_registry.rb +5 -5
  4. data/lib/right_agent/actors/agent_manager.rb +4 -4
  5. data/lib/right_agent/agent.rb +97 -37
  6. data/lib/right_agent/agent_tag_manager.rb +1 -2
  7. data/lib/right_agent/command/command_io.rb +1 -3
  8. data/lib/right_agent/command/command_runner.rb +9 -3
  9. data/lib/right_agent/dispatched_cache.rb +110 -0
  10. data/lib/right_agent/dispatcher.rb +119 -180
  11. data/lib/right_agent/history.rb +136 -0
  12. data/lib/right_agent/log.rb +6 -3
  13. data/lib/right_agent/monkey_patches/ruby_patch.rb +0 -1
  14. data/lib/right_agent/pid_file.rb +1 -1
  15. data/lib/right_agent/platform.rb +2 -2
  16. data/lib/right_agent/platform/linux.rb +8 -1
  17. data/lib/right_agent/platform/windows.rb +1 -1
  18. data/lib/right_agent/sender.rb +57 -41
  19. data/right_agent.gemspec +4 -4
  20. data/spec/actor_registry_spec.rb +7 -8
  21. data/spec/actor_spec.rb +87 -24
  22. data/spec/agent_spec.rb +107 -8
  23. data/spec/command/command_runner_spec.rb +12 -1
  24. data/spec/dispatched_cache_spec.rb +142 -0
  25. data/spec/dispatcher_spec.rb +110 -129
  26. data/spec/history_spec.rb +234 -0
  27. data/spec/idempotent_request_spec.rb +1 -1
  28. data/spec/log_spec.rb +15 -0
  29. data/spec/operation_result_spec.rb +4 -2
  30. data/spec/platform/darwin_spec.rb +13 -0
  31. data/spec/platform/linux_spec.rb +38 -0
  32. data/spec/platform/platform_spec.rb +46 -51
  33. data/spec/platform/windows_spec.rb +13 -0
  34. data/spec/sender_spec.rb +81 -38
  35. metadata +12 -9
  36. data/lib/right_agent/monkey_patches/ruby_patch/singleton_patch.rb +0 -45
  37. data/spec/platform/darwin.rb +0 -11
  38. data/spec/platform/linux.rb +0 -23
  39. data/spec/platform/windows.rb +0 -11
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe RightScale::Platform do
4
+ subject { RightScale::Platform }
5
+
6
+ context 'under Windows' do
7
+ context :installer do
8
+ context :install do
9
+ specify { lambda { subject.installer.install([]) }.should raise_exception }
10
+ end
11
+ end
12
+ end
13
+ end if RightScale::Platform.windows?
data/spec/sender_spec.rb CHANGED
@@ -381,7 +381,6 @@ describe RightScale::Sender do
381
381
  @timer = flexmock("timer")
382
382
  flexmock(EM::Timer).should_receive(:new).and_return(@timer).by_default
383
383
  flexmock(EM).should_receive(:next_tick).and_yield.by_default
384
- flexmock(EM).should_receive(:defer).and_yield.by_default
385
384
  @broker_id = "broker"
386
385
  @broker_ids = [@broker_id]
387
386
  @broker = flexmock("Broker", :subscribe => true, :publish => @broker_ids, :connected? => true,
@@ -415,7 +414,7 @@ describe RightScale::Sender do
415
414
  it "should create a Request object" do
416
415
  @broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
417
416
  request.class.should == RightScale::Request
418
- end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
417
+ end, hsh(:persistent => false, :mandatory => true)).once
419
418
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
420
419
  end
421
420
 
@@ -433,7 +432,7 @@ describe RightScale::Sender do
433
432
  request.from.should == 'agent'
434
433
  request.target.should be_nil
435
434
  request.expires_at.should == 1000100
436
- end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
435
+ end, hsh(:persistent => false, :mandatory => true)).once
437
436
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
438
437
  end
439
438
 
@@ -445,14 +444,14 @@ describe RightScale::Sender do
445
444
  flexmock(Time).should_receive(:now).and_return(Time.at(1000000))
446
445
  @broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
447
446
  request.expires_at.should == 0
448
- end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
447
+ end, hsh(:persistent => false, :mandatory => true)).once
449
448
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
450
449
  end
451
450
 
452
451
  it "should set the correct target if specified" do
453
452
  @broker.should_receive(:publish).with(hsh(:name => "request"), on do |request|
454
453
  request.target.should == 'my-target'
455
- end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
454
+ end, hsh(:persistent => false, :mandatory => true)).once
456
455
  @instance.send_retryable_request('/welcome/aboard', 'iZac', 'my-target') {|response|}
457
456
  end
458
457
 
@@ -461,7 +460,7 @@ describe RightScale::Sender do
461
460
  request.tags.should == ['tag']
462
461
  request.selector.should == :any
463
462
  request.scope.should == {:account => 123}
464
- end, hsh(:persistent => false, :mandatory => true)).and_return(["rs-broker-host-123"]).once
463
+ end, hsh(:persistent => false, :mandatory => true)).once
465
464
  @instance.send_retryable_request('/welcome/aboard', 'iZac', :tags => ['tag'], :scope => {:account => 123})
466
465
  end
467
466
 
@@ -512,7 +511,7 @@ describe RightScale::Sender do
512
511
  @agent.should_receive(:options).and_return({:retry_timeout => nil})
513
512
  RightScale::Sender.new(@agent)
514
513
  @instance = RightScale::Sender.instance
515
- @broker.should_receive(:publish).and_return(["rs-broker-host-123"]).once
514
+ @broker.should_receive(:publish).once
516
515
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
517
516
  end
518
517
 
@@ -521,7 +520,7 @@ describe RightScale::Sender do
521
520
  @agent.should_receive(:options).and_return({:retry_interval => nil})
522
521
  RightScale::Sender.new(@agent)
523
522
  @instance = RightScale::Sender.instance
524
- @broker.should_receive(:publish).and_return(["rs-broker-host-123"]).once
523
+ @broker.should_receive(:publish).once
525
524
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
526
525
  end
527
526
 
@@ -534,20 +533,6 @@ describe RightScale::Sender do
534
533
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response|}
535
534
  end
536
535
 
537
- it "should respond with non-delivery if publish failed" do
538
- flexmock(EM).should_receive(:add_timer).never
539
- @agent.should_receive(:options).and_return({:retry_timeout => 60, :retry_interval => 60})
540
- RightScale::Sender.new(@agent)
541
- @instance = RightScale::Sender.instance
542
- @log.should_receive(:error).with(/Failed to publish request/, RightAMQP::HABrokerClient::NoConnectedBrokers).once
543
- @broker.should_receive(:publish).and_raise(RightAMQP::HABrokerClient::NoConnectedBrokers).once
544
- @instance.send_retryable_request('/welcome/aboard', 'iZac') do |response|
545
- result = RightScale::OperationResult.from_results(response)
546
- result.non_delivery?.should be_true
547
- result.content.should == "request send failed"
548
- end
549
- end
550
-
551
536
  it "should setup for retry if retry_timeout and retry_interval not nil and publish successful" do
552
537
  flexmock(EM).should_receive(:add_timer).with(60, any).once
553
538
  @agent.should_receive(:options).and_return({:retry_timeout => 60, :retry_interval => 60})
@@ -574,9 +559,12 @@ describe RightScale::Sender do
574
559
  @instance.send_retryable_request('/welcome/aboard', 'iZac') do |response|
575
560
  result = RightScale::OperationResult.from_results(response)
576
561
  end
562
+ header = flexmock("amqp header")
563
+ header.should_receive(:ack).once
577
564
  EM.add_timer(0.15) do
578
565
  @instance.pending_requests.empty?.should be_false
579
- @instance.handle_response(RightScale::Result.new(token, nil, {'from' => RightScale::OperationResult.success}, nil))
566
+ result = RightScale::Result.new(token, nil, {'from' => RightScale::OperationResult.success}, nil)
567
+ @instance.handle_response(result, header)
580
568
  end
581
569
  EM.add_timer(0.3) do
582
570
  EM.stop
@@ -751,55 +739,85 @@ describe RightScale::Sender do
751
739
  RightScale::Sender.new(@agent)
752
740
  @instance = RightScale::Sender.instance
753
741
  flexmock(RightScale::AgentIdentity, :generate => 'token1')
742
+ @header = flexmock("amqp header")
754
743
  end
755
744
 
756
745
  it "should deliver the response for a Request" do
757
746
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
758
747
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
759
- flexmock(@instance).should_receive(:deliver).with(response, RightScale::Sender::PendingRequest).once
760
- @instance.handle_response(response)
748
+ flexmock(@instance).should_receive(:deliver).with(response, RightScale::Sender::PendingRequest, @header).once
749
+ @instance.handle_response(response, @header)
761
750
  end
762
751
 
763
752
  it "should deliver the response for a Push" do
764
753
  @instance.send_push('/welcome/aboard', 'iZac') {|_|}
765
754
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
766
- flexmock(@instance).should_receive(:deliver).with(response, RightScale::Sender::PendingRequest).once
767
- @instance.handle_response(response)
755
+ flexmock(@instance).should_receive(:deliver).with(response, RightScale::Sender::PendingRequest, @header).once
756
+ @instance.handle_response(response, @header)
768
757
  end
769
758
 
770
759
  it "should not deliver TARGET_NOT_CONNECTED and TTL_EXPIRATION responses for send_retryable_request" do
760
+ @header.should_receive(:ack).twice
771
761
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
772
762
  flexmock(@instance).should_receive(:deliver).never
773
763
  non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TARGET_NOT_CONNECTED)
774
764
  response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
775
- @instance.handle_response(response)
765
+ @instance.handle_response(response, @header)
776
766
  non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::TTL_EXPIRATION)
777
767
  response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
778
- @instance.handle_response(response)
768
+ @instance.handle_response(response, @header)
779
769
  end
780
770
 
781
771
  it "should record non-delivery regardless of whether there is a response handler" do
772
+ @header.should_receive(:ack).once
782
773
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
783
774
  non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::NO_ROUTE_TO_TARGET)
784
775
  response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
785
- @instance.handle_response(response)
776
+ @instance.handle_response(response, @header)
786
777
  @instance.instance_variable_get(:@non_delivery_stats).total.should == 1
787
778
  end
788
779
 
789
780
  it "should log non-delivery if there is no response handler" do
781
+ @header.should_receive(:ack).once
790
782
  @log.should_receive(:info).with(/Non-delivery of/).once
791
783
  @instance.send_push('/welcome/aboard', 'iZac')
792
784
  non_delivery = RightScale::OperationResult.non_delivery(RightScale::OperationResult::NO_ROUTE_TO_TARGET)
793
785
  response = RightScale::Result.new('token1', 'to', non_delivery, 'target1')
794
- @instance.handle_response(response)
786
+ @instance.handle_response(response, @header)
795
787
  end
796
788
 
797
789
  it "should log a debug message if request no longer pending" do
790
+ @header.should_receive(:ack).once
798
791
  @log.should_receive(:debug).with(/No pending request for response/).once
799
792
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
800
793
  @instance.pending_requests['token1'].should_not be_nil
801
794
  @instance.pending_requests['token2'].should be_nil
802
795
  response = RightScale::Result.new('token2', 'to', RightScale::OperationResult.success, 'target1')
796
+ @instance.handle_response(response, @header)
797
+ end
798
+
799
+ it "should ack response even if fail while handling it" do
800
+ @header.should_receive(:ack).once
801
+ @instance.send_push('/welcome/aboard', 'iZac') {|_|}
802
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
803
+ flexmock(response).should_receive(:token).and_raise(Exception).once
804
+ flexmock(@instance).should_receive(:deliver).never
805
+ lambda { @instance.handle_response(response, @header) }.should raise_error(Exception)
806
+ end
807
+
808
+ it "should not attempt to ack response if fail while handling it and there is no header" do
809
+ @instance.send_push('/welcome/aboard', 'iZac') {|_|}
810
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
811
+ exception = Exception.new("test")
812
+ flexmock(response).should_receive(:token).and_raise(exception).once
813
+ flexmock(@instance).should_receive(:deliver).never
814
+ lambda { @instance.handle_response(response, nil) }.should raise_error(Exception, "test")
815
+ end
816
+
817
+ it "should not attempt to ack response if there is no header" do
818
+ @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
819
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
820
+ flexmock(@instance).should_receive(:deliver).with(response, RightScale::Sender::PendingRequest, nil).once
803
821
  @instance.handle_response(response)
804
822
  end
805
823
  end
@@ -814,13 +832,15 @@ describe RightScale::Sender do
814
832
  RightScale::Sender.new(@agent)
815
833
  @instance = RightScale::Sender.instance
816
834
  flexmock(RightScale::AgentIdentity, :generate => 'token1')
835
+ @header = flexmock("amqp header")
836
+ @header.should_receive(:ack).once.by_default
817
837
  end
818
838
 
819
839
  it "should delete all associated pending Request requests" do
820
840
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
821
841
  @instance.pending_requests['token1'].should_not be_nil
822
842
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
823
- @instance.handle_response(response)
843
+ @instance.handle_response(response, @header)
824
844
  @instance.pending_requests['token1'].should be_nil
825
845
  end
826
846
 
@@ -828,7 +848,7 @@ describe RightScale::Sender do
828
848
  @instance.send_push('/welcome/aboard', 'iZac') {|_|}
829
849
  @instance.pending_requests['token1'].should_not be_nil
830
850
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
831
- @instance.handle_response(response)
851
+ @instance.handle_response(response, @header)
832
852
  @instance.pending_requests['token1'].should_not be_nil
833
853
  end
834
854
 
@@ -838,7 +858,7 @@ describe RightScale::Sender do
838
858
  @instance.pending_requests['token2'] = @instance.pending_requests['token1'].dup
839
859
  @instance.pending_requests['token2'].retry_parent = 'token1'
840
860
  response = RightScale::Result.new('token2', 'to', RightScale::OperationResult.success, 'target1')
841
- @instance.handle_response(response)
861
+ @instance.handle_response(response, @header)
842
862
  @instance.pending_requests['token1'].should be_nil
843
863
  @instance.pending_requests['token2'].should be_nil
844
864
  end
@@ -847,7 +867,7 @@ describe RightScale::Sender do
847
867
  called = 0
848
868
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|response| called += 1}
849
869
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
850
- @instance.handle_response(response)
870
+ @instance.handle_response(response, @header)
851
871
  called.should == 1
852
872
  end
853
873
 
@@ -860,7 +880,7 @@ describe RightScale::Sender do
860
880
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
861
881
  flexmock(EM).should_receive(:defer).and_yield.once
862
882
  flexmock(EM).should_receive(:next_tick).never
863
- @instance.handle_response(response)
883
+ @instance.handle_response(response, @header)
864
884
  called.should == 1
865
885
  end
866
886
 
@@ -873,7 +893,7 @@ describe RightScale::Sender do
873
893
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
874
894
  flexmock(EM).should_receive(:next_tick).and_yield.once
875
895
  flexmock(EM).should_receive(:defer).never
876
- @instance.handle_response(response)
896
+ @instance.handle_response(response, @header)
877
897
  called.should == 1
878
898
  end
879
899
 
@@ -883,9 +903,32 @@ describe RightScale::Sender do
883
903
  @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_| raise Exception}
884
904
  @instance.pending_requests['token1'].should_not be_nil
885
905
  response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
886
- @instance.handle_response(response)
906
+ @instance.handle_response(response, @header)
887
907
  @instance.pending_requests['token1'].should be_nil
888
908
  end
909
+
910
+ it "should ack response even if fail while delivering it" do
911
+ flexmock(EM).should_receive(:defer).and_raise(Exception).once
912
+ @instance.send_push('/welcome/aboard', 'iZac') {|_|}
913
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
914
+ lambda { @instance.handle_response(response, @header) }.should raise_error(Exception)
915
+ end
916
+
917
+ it "should not attempt to ack response if fail while delivering it and there is no header" do
918
+ @header.should_receive(:ack).never
919
+ exception = Exception.new("test")
920
+ flexmock(EM).should_receive(:defer).and_raise(exception).once
921
+ @instance.send_push('/welcome/aboard', 'iZac') {|_|}
922
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
923
+ lambda { @instance.handle_response(response, nil) }.should raise_error(Exception, "test")
924
+ end
925
+
926
+ it "should not attempt to ack response if there is no header" do
927
+ @header.should_receive(:ack).never
928
+ @instance.send_retryable_request('/welcome/aboard', 'iZac') {|_|}
929
+ response = RightScale::Result.new('token1', 'to', RightScale::OperationResult.success, 'target1')
930
+ @instance.handle_response(response)
931
+ end
889
932
  end
890
933
 
891
934
  describe "when use offline queueing" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.13
5
+ version: 0.13.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Lee Kirchhoff
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2013-02-07 00:00:00 Z
15
+ date: 2012-10-03 00:00:00 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: right_support
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: "1.3"
24
+ version: 2.4.1
25
25
  - - <
26
26
  - !ruby/object:Gem::Version
27
27
  version: "3.0"
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: "0.3"
38
+ version: "0.4"
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: *id002
@@ -153,9 +153,11 @@ files:
153
153
  - lib/right_agent/core_payload_types/secure_document_location.rb
154
154
  - lib/right_agent/core_payload_types/software_repository_instantiation.rb
155
155
  - lib/right_agent/daemonize.rb
156
+ - lib/right_agent/dispatched_cache.rb
156
157
  - lib/right_agent/dispatcher.rb
157
158
  - lib/right_agent/enrollment_result.rb
158
159
  - lib/right_agent/exceptions.rb
160
+ - lib/right_agent/history.rb
159
161
  - lib/right_agent/idempotent_request.rb
160
162
  - lib/right_agent/log.rb
161
163
  - lib/right_agent/minimal.rb
@@ -166,7 +168,6 @@ files:
166
168
  - lib/right_agent/monkey_patches/ruby_patch/linux_patch.rb
167
169
  - lib/right_agent/monkey_patches/ruby_patch/linux_patch/file_patch.rb
168
170
  - lib/right_agent/monkey_patches/ruby_patch/object_patch.rb
169
- - lib/right_agent/monkey_patches/ruby_patch/singleton_patch.rb
170
171
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch.rb
171
172
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch/file_patch.rb
172
173
  - lib/right_agent/monkey_patches/ruby_patch/windows_patch/process_patch.rb
@@ -224,19 +225,21 @@ files:
224
225
  - spec/core_payload_types/login_user_spec.rb
225
226
  - spec/core_payload_types/right_script_attachment_spec.rb
226
227
  - spec/core_payload_types/spec_helper.rb
228
+ - spec/dispatched_cache_spec.rb
227
229
  - spec/dispatcher_spec.rb
228
230
  - spec/enrollment_result_spec.rb
231
+ - spec/history_spec.rb
229
232
  - spec/idempotent_request_spec.rb
230
233
  - spec/log_spec.rb
231
234
  - spec/monkey_patches/eventmachine_spec.rb
232
235
  - spec/multiplexer_spec.rb
233
236
  - spec/operation_result_spec.rb
234
237
  - spec/packets_spec.rb
235
- - spec/platform/darwin.rb
236
- - spec/platform/linux.rb
238
+ - spec/platform/darwin_spec.rb
239
+ - spec/platform/linux_spec.rb
237
240
  - spec/platform/linux_volume_manager_spec.rb
238
241
  - spec/platform/platform_spec.rb
239
- - spec/platform/windows.rb
242
+ - spec/platform/windows_spec.rb
240
243
  - spec/platform/windows_volume_manager_spec.rb
241
244
  - spec/results_mock.rb
242
245
  - spec/secure_identity_spec.rb
@@ -279,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
282
  requirements:
280
283
  - - ">="
281
284
  - !ruby/object:Gem::Version
282
- hash: 2192797536970431426
285
+ hash: -1208467833270175194
283
286
  segments:
284
287
  - 0
285
288
  version: "0"
@@ -1,45 +0,0 @@
1
- #
2
- # Copyright (c) 2011 RightScale Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
-
23
- require 'singleton'
24
-
25
- module RightScale
26
-
27
- module Singleton
28
-
29
- module ClassMethods
30
-
31
- # Redirect missing class methods to singleton instance.
32
- def method_missing(meth, *args, &blk)
33
- self.instance.__send__(meth, *args, &blk)
34
- end
35
- end
36
-
37
- # Upon inclusion, also include standard Singleton mixin
38
- def self.included(base)
39
- base.__send__(:include, ::Singleton)
40
- base.__send__(:extend, ClassMethods)
41
- end
42
-
43
- end
44
-
45
- end
@@ -1,11 +0,0 @@
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
@@ -1,23 +0,0 @@
1
- module RightScale
2
- describe Platform do
3
-
4
- context :installer do
5
- context :install do
6
- it 'should succeed if no packages are specified' do
7
- packages = []
8
- RightScale::Platform.installer.install(packages).should == true
9
- end
10
-
11
- it 'should succeed if all packages install successfully' do
12
- packages = ['syslog-ng']
13
- RightScale::Platform.installer.install(packages).should == true
14
- end
15
-
16
- it 'should fail if one more packages are not found' do
17
- packages = ['jdk-6u26-linux-x64']
18
- lambda { RightScale::Platform.installer.install(packages) }.should raise_error
19
- end
20
- end
21
- end
22
- end
23
- end