krisr-amazon-ec2 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/ChangeLog +284 -0
- data/LICENSE +66 -0
- data/README.rdoc +329 -0
- data/Rakefile +101 -0
- data/VERSION +1 -0
- data/amazon-ec2.gemspec +123 -0
- data/bin/ec2-gem-example.rb +66 -0
- data/bin/ec2-gem-profile.rb +10 -0
- data/bin/ec2sh +62 -0
- data/bin/setup.rb +26 -0
- data/deps.rip +1 -0
- data/lib/AWS.rb +239 -0
- data/lib/AWS/EC2.rb +67 -0
- data/lib/AWS/EC2/availability_zones.rb +43 -0
- data/lib/AWS/EC2/console.rb +46 -0
- data/lib/AWS/EC2/elastic_ips.rb +154 -0
- data/lib/AWS/EC2/image_attributes.rb +168 -0
- data/lib/AWS/EC2/images.rb +136 -0
- data/lib/AWS/EC2/instances.rb +218 -0
- data/lib/AWS/EC2/keypairs.rb +96 -0
- data/lib/AWS/EC2/products.rb +45 -0
- data/lib/AWS/EC2/security_groups.rb +234 -0
- data/lib/AWS/EC2/snapshots.rb +96 -0
- data/lib/AWS/EC2/volumes.rb +172 -0
- data/lib/AWS/ELB.rb +57 -0
- data/lib/AWS/ELB/load_balancers.rb +201 -0
- data/lib/AWS/exceptions.rb +169 -0
- data/lib/AWS/responses.rb +61 -0
- data/lib/EC2.rb +31 -0
- data/perftools/ec2prof +0 -0
- data/perftools/ec2prof-results.dot +193 -0
- data/perftools/ec2prof-results.txt +126 -0
- data/perftools/ec2prof.symbols +129 -0
- data/test/test_EC2.rb +68 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_elastic_ips.rb +144 -0
- data/test/test_EC2_image_attributes.rb +238 -0
- data/test/test_EC2_images.rb +197 -0
- data/test/test_EC2_instances.rb +348 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_products.rb +48 -0
- data/test/test_EC2_responses.rb +52 -0
- data/test/test_EC2_s3_xmlsimple.rb +80 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_ELB_load_balancers.rb +238 -0
- data/test/test_helper.rb +19 -0
- data/wsdl/2007-08-29.ec2.wsdl +1269 -0
- data/wsdl/2008-02-01.ec2.wsdl +1614 -0
- data/wsdl/2008-05-05.ec2.wsdl +2052 -0
- data/wsdl/2008-12-01.ec2.wsdl +2354 -0
- metadata +184 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library, EBS snapshots support
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Yann Klis (mailto:yann.klis@novelys.com)
|
6
|
+
# Copyright:: Copyright (c) 2008 Yann Klis
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 snaphots " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_snapshots_response_body = <<-RESPONSE
|
19
|
+
<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
20
|
+
<snapshotId>snap-78a54011</snapshotId>
|
21
|
+
<volumeId>vol-4d826724</volumeId>
|
22
|
+
<status>pending</status>
|
23
|
+
<startTime>2008-05-07T12:51:50.000Z</startTime>
|
24
|
+
<progress>80%</progress>
|
25
|
+
</DescribeSnapshotsResponse>
|
26
|
+
RESPONSE
|
27
|
+
|
28
|
+
@create_snapshot_response_body = <<-RESPONSE
|
29
|
+
<CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
30
|
+
<snapshotId>snap-78a54011</snapshotId>
|
31
|
+
<volumeId>vol-4d826724</volumeId>
|
32
|
+
<status>pending</status>
|
33
|
+
<startTime>2008-05-07T12:51:50.000Z</startTime>
|
34
|
+
<progress></progress>
|
35
|
+
</CreateSnapshotResponse>
|
36
|
+
RESPONSE
|
37
|
+
|
38
|
+
@delete_snapshot_response_body = <<-RESPONSE
|
39
|
+
<DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
40
|
+
<return>true</return>
|
41
|
+
</DeleteSnapshotResponse>
|
42
|
+
RESPONSE
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
specify "should be able to be described with describe_snapshots" do
|
48
|
+
@ec2.stubs(:make_request).with('DescribeSnapshots', {"SnapshotId.1"=>"snap-78a54011"}).
|
49
|
+
returns stub(:body => @describe_snapshots_response_body, :is_a? => true)
|
50
|
+
|
51
|
+
@ec2.describe_snapshots( :snapshot_id => "snap-78a54011" ).should.be.an.instance_of Hash
|
52
|
+
|
53
|
+
response = @ec2.describe_snapshots( :snapshot_id => "snap-78a54011" )
|
54
|
+
response.snapshotId.should.equal "snap-78a54011"
|
55
|
+
response.volumeId.should.equal "vol-4d826724"
|
56
|
+
response.status.should.equal "pending"
|
57
|
+
response.progress.should.equal "80%"
|
58
|
+
end
|
59
|
+
|
60
|
+
specify "should be able to be created with a volume_id" do
|
61
|
+
@ec2.stubs(:make_request).with('CreateSnapshot', {"VolumeId" => "vol-4d826724"}).
|
62
|
+
returns stub(:body => @create_snapshot_response_body, :is_a? => true)
|
63
|
+
|
64
|
+
@ec2.create_snapshot( :volume_id => "vol-4d826724" ).should.be.an.instance_of Hash
|
65
|
+
|
66
|
+
response = @ec2.create_snapshot( :volume_id => "vol-4d826724" )
|
67
|
+
response.snapshotId.should.equal "snap-78a54011"
|
68
|
+
response.volumeId.should.equal "vol-4d826724"
|
69
|
+
response.status.should.equal "pending"
|
70
|
+
response.progress.should.equal nil
|
71
|
+
end
|
72
|
+
|
73
|
+
specify "should be able to be deleted with a snapsot_id" do
|
74
|
+
@ec2.stubs(:make_request).with('DeleteSnapshot', {"SnapshotId" => "snap-78a54011"}).
|
75
|
+
returns stub(:body => @delete_snapshot_response_body, :is_a? => true)
|
76
|
+
|
77
|
+
@ec2.delete_snapshot( :snapshot_id => "snap-78a54011" ).should.be.an.instance_of Hash
|
78
|
+
|
79
|
+
response = @ec2.delete_snapshot( :snapshot_id => "snap-78a54011" )
|
80
|
+
response.return.should.equal "true"
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library, EBS volumes support
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Yann Klis (mailto:yann.klis@novelys.com)
|
6
|
+
# Copyright:: Copyright (c) 2008 Yann Klis
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 volumes " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_volumes_response_body = <<-RESPONSE
|
19
|
+
<DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
20
|
+
<volumeSet>
|
21
|
+
<item>
|
22
|
+
<volumeId>vol-4282672b</volumeId>
|
23
|
+
<size>800</size>
|
24
|
+
<status>in-use</status>
|
25
|
+
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
26
|
+
<attachmentSet>
|
27
|
+
<item>
|
28
|
+
<volumeId>vol-4282672b</volumeId>
|
29
|
+
<instanceId>i-6058a509</instanceId>
|
30
|
+
<size>800</size>
|
31
|
+
<status>attached</status>
|
32
|
+
<attachTime>2008-05-07T12:51:50.000Z</attachTime>
|
33
|
+
</item>
|
34
|
+
</attachmentSet>
|
35
|
+
</item>
|
36
|
+
</volumeSet>
|
37
|
+
</DescribeVolumesResponse>
|
38
|
+
RESPONSE
|
39
|
+
|
40
|
+
@create_volume_response_body = <<-RESPONSE
|
41
|
+
<CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
42
|
+
<volumeId>vol-4d826724</volumeId>
|
43
|
+
<size>800</size>
|
44
|
+
<status>creating</status>
|
45
|
+
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
46
|
+
<zone>us-east-1a</zone>
|
47
|
+
<snapshotId></snapshotId>
|
48
|
+
</CreateVolumeResponse>
|
49
|
+
RESPONSE
|
50
|
+
|
51
|
+
@delete_volume_response_body = <<-RESPONSE
|
52
|
+
<ReleaseAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
53
|
+
<return>true</return>
|
54
|
+
</ReleaseAddressResponse>
|
55
|
+
RESPONSE
|
56
|
+
|
57
|
+
@attach_volume_response_body = <<-RESPONSE
|
58
|
+
<AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
59
|
+
<volumeId>vol-4d826724</volumeId>
|
60
|
+
<instanceId>i-6058a509</instanceId>
|
61
|
+
<device>/dev/sdh</device>
|
62
|
+
<status>attaching</status>
|
63
|
+
<attachTime>2008-05-07T11:51:50.000Z</attachTime>
|
64
|
+
</AttachVolumeResponse>
|
65
|
+
RESPONSE
|
66
|
+
|
67
|
+
@detach_volume_response_body = <<-RESPONSE
|
68
|
+
<DetachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
69
|
+
<volumeId>vol-4d826724</volumeId>
|
70
|
+
<instanceId>i-6058a509</instanceId>
|
71
|
+
<device>/dev/sdh</device>
|
72
|
+
<status>detaching</status>
|
73
|
+
<attachTime>2008-05-08T11:51:50.000Z</attachTime>
|
74
|
+
</DetachVolumeResponse>
|
75
|
+
RESPONSE
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
specify "should be able to be described with describe_volumes" do
|
81
|
+
@ec2.stubs(:make_request).with('DescribeVolumes', {"VolumeId.1"=>"vol-4282672b"}).
|
82
|
+
returns stub(:body => @describe_volumes_response_body, :is_a? => true)
|
83
|
+
|
84
|
+
@ec2.describe_volumes( :volume_id => ["vol-4282672b"] ).should.be.an.instance_of Hash
|
85
|
+
|
86
|
+
response = @ec2.describe_volumes( :volume_id => ["vol-4282672b"] )
|
87
|
+
response.volumeSet.item[0].volumeId.should.equal "vol-4282672b"
|
88
|
+
response.volumeSet.item[0].attachmentSet.item[0]['size'].should.equal "800"
|
89
|
+
response.volumeSet.item[0].attachmentSet.item[0].volumeId.should.equal "vol-4282672b"
|
90
|
+
response.volumeSet.item[0].attachmentSet.item[0].instanceId.should.equal "i-6058a509"
|
91
|
+
end
|
92
|
+
|
93
|
+
specify "should be able to be created with an availability_zone with size" do
|
94
|
+
@ec2.stubs(:make_request).with('CreateVolume', {"AvailabilityZone" => "us-east-1a", "Size"=>"800", "SnapshotId"=>""}).
|
95
|
+
returns stub(:body => @create_volume_response_body, :is_a? => true)
|
96
|
+
|
97
|
+
@ec2.create_volume( :availability_zone => "us-east-1a", :size => "800" ).should.be.an.instance_of Hash
|
98
|
+
|
99
|
+
response = @ec2.create_volume( :availability_zone => "us-east-1a", :size => "800" )
|
100
|
+
response.volumeId.should.equal "vol-4d826724"
|
101
|
+
response['size'].should.equal "800"
|
102
|
+
response.status.should.equal "creating"
|
103
|
+
response.zone.should.equal "us-east-1a"
|
104
|
+
end
|
105
|
+
|
106
|
+
specify "should be able to be deleted with a volume_id" do
|
107
|
+
@ec2.stubs(:make_request).with('DeleteVolume', {"VolumeId" => "vol-4282672b"}).
|
108
|
+
returns stub(:body => @delete_volume_response_body, :is_a? => true)
|
109
|
+
|
110
|
+
@ec2.delete_volume( :volume_id => "vol-4282672b" ).should.be.an.instance_of Hash
|
111
|
+
|
112
|
+
response = @ec2.delete_volume( :volume_id => "vol-4282672b" )
|
113
|
+
response.return.should.equal "true"
|
114
|
+
end
|
115
|
+
|
116
|
+
specify "should be able to be attached with a volume_id with an instance_id with a device" do
|
117
|
+
@ec2.stubs(:make_request).with('AttachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"/dev/sdh"}).
|
118
|
+
returns stub(:body => @attach_volume_response_body, :is_a? => true)
|
119
|
+
|
120
|
+
@ec2.attach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :device => "/dev/sdh" ).should.be.an.instance_of Hash
|
121
|
+
|
122
|
+
response = @ec2.attach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :device => "/dev/sdh" )
|
123
|
+
response.volumeId.should.equal "vol-4d826724"
|
124
|
+
response.instanceId.should.equal "i-6058a509"
|
125
|
+
response.device.should.equal "/dev/sdh"
|
126
|
+
response.status.should.equal "attaching"
|
127
|
+
end
|
128
|
+
|
129
|
+
specify "should be able to be detached with a volume_id with an instance_id" do
|
130
|
+
@ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>""}).
|
131
|
+
returns stub(:body => @detach_volume_response_body, :is_a? => true)
|
132
|
+
|
133
|
+
@ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509" ).should.be.an.instance_of Hash
|
134
|
+
|
135
|
+
response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509" )
|
136
|
+
response.volumeId.should.equal "vol-4d826724"
|
137
|
+
response.instanceId.should.equal "i-6058a509"
|
138
|
+
response.device.should.equal "/dev/sdh"
|
139
|
+
response.status.should.equal "detaching"
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
context "elb load balancers " do
|
4
|
+
before do
|
5
|
+
@elb = AWS::ELB::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
6
|
+
|
7
|
+
@valid_create_load_balancer_params = {
|
8
|
+
:load_balancer_name => 'Test Name',
|
9
|
+
:availability_zones => ['east-1a'],
|
10
|
+
:listeners => [{:protocol => 'HTTP', :load_balancer_port => '80', :instance_port => '80'}]
|
11
|
+
}
|
12
|
+
|
13
|
+
@create_load_balancer_response_body = <<-RESPONSE
|
14
|
+
<CreateLoadBalancerResult>
|
15
|
+
<DNSName>TestLoadBalancer-380544827.us-east-1.ec2.amazonaws.com</DNSName>
|
16
|
+
</CreateLoadBalancerResult>
|
17
|
+
RESPONSE
|
18
|
+
|
19
|
+
@valid_delete_load_balancer_params = {
|
20
|
+
:load_balancer_name => 'Test Name'
|
21
|
+
}
|
22
|
+
|
23
|
+
@delete_load_balancer_response_body = <<-RESPONSE
|
24
|
+
<DeleteLoadBalancerResult>
|
25
|
+
<return>true</return>
|
26
|
+
</DeleteLoadBalancerResult>
|
27
|
+
RESPONSE
|
28
|
+
|
29
|
+
@valid_describe_load_balancer_params = {
|
30
|
+
}
|
31
|
+
|
32
|
+
@describe_load_balancer_response_body = <<-RESPONSE
|
33
|
+
<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2009-05-15/">
|
34
|
+
<DescribeLoadBalancersResult>
|
35
|
+
<LoadBalancerDescriptions>
|
36
|
+
<member>
|
37
|
+
<Listeners>
|
38
|
+
<member>
|
39
|
+
<Protocol>HTTP</Protocol>
|
40
|
+
<LoadBalancerPort>80</LoadBalancerPort>
|
41
|
+
<InstancePort>80</InstancePort>
|
42
|
+
</member>
|
43
|
+
</Listeners>
|
44
|
+
<CreatedTime>2009-07-02T01:07:55.080Z</CreatedTime>
|
45
|
+
<LoadBalancerName>TestLB</LoadBalancerName>
|
46
|
+
<DNSName>TestLB-1459724896.us-east-1.elb.amazonaws.com</DNSName>
|
47
|
+
<HealthCheck>
|
48
|
+
<Interval>30</Interval>
|
49
|
+
<Target>TCP:80</Target>
|
50
|
+
<HealthyThreshold>10</HealthyThreshold>
|
51
|
+
<Timeout>5</Timeout>
|
52
|
+
<UnhealthyThreshold>2</UnhealthyThreshold>
|
53
|
+
</HealthCheck>
|
54
|
+
<Instances/>
|
55
|
+
<AvailabilityZones>
|
56
|
+
<member>us-east-1a</member>
|
57
|
+
</AvailabilityZones>
|
58
|
+
</member>
|
59
|
+
</LoadBalancerDescriptions>
|
60
|
+
</DescribeLoadBalancersResult>
|
61
|
+
<ResponseMetadata>
|
62
|
+
<RequestId>67dd800e-66a5-11de-b844-07deabfcc881</RequestId>
|
63
|
+
</ResponseMetadata>
|
64
|
+
</DescribeLoadBalancersResponse>
|
65
|
+
RESPONSE
|
66
|
+
|
67
|
+
@valid_register_instances_with_load_balancer_params = {
|
68
|
+
:load_balancer_name => 'Test Name',
|
69
|
+
:instances => ['i-6055fa09']
|
70
|
+
}
|
71
|
+
|
72
|
+
@register_instances_with_load_balancer_response_body = <<-RESPONSE
|
73
|
+
<RegisterInstancesWithLoadBalancerResult>
|
74
|
+
<Instances>
|
75
|
+
<member>
|
76
|
+
<InstanceId>i-6055fa09</InstanceId>
|
77
|
+
</member>
|
78
|
+
</Instances>
|
79
|
+
</RegisterInstancesWithLoadBalancerResult>
|
80
|
+
RESPONSE
|
81
|
+
|
82
|
+
@valid_deregister_instances_from_load_balancer_params = @valid_register_instances_with_load_balancer_params
|
83
|
+
@deregister_instances_from_load_balancer_response_body = <<-RESPONSE
|
84
|
+
<DeregisterInstancesFromLoadBalancerResult>
|
85
|
+
<Instances/>
|
86
|
+
</DeregisterInstancesFromLoadBalancerResult>
|
87
|
+
RESPONSE
|
88
|
+
|
89
|
+
@valid_configure_health_check_params = {
|
90
|
+
:load_balancer_name => 'Test Name',
|
91
|
+
:health_check => {
|
92
|
+
:target => 'HTTP:80/servlets-examples/servlet/',
|
93
|
+
:timeout => '2',
|
94
|
+
:interval => '5',
|
95
|
+
:unhealthy_threshold => '2',
|
96
|
+
:healthy_threshold => '2'
|
97
|
+
}
|
98
|
+
}
|
99
|
+
@configure_health_check_response_body = <<-RESPONSE
|
100
|
+
<ConfigureHealthCheckResult>
|
101
|
+
<HealthCheck>
|
102
|
+
<Interval>5</Interval>
|
103
|
+
<Target>HTTP:80/servlets-examples/servlet/</Target>
|
104
|
+
<HealthyThreshold>2</HealthyThreshold>
|
105
|
+
<Timeout>2</Timeout>
|
106
|
+
<UnhealthyThreshold>2</UnhealthyThreshold>
|
107
|
+
</HealthCheck>
|
108
|
+
</ConfigureHealthCheckResult>
|
109
|
+
RESPONSE
|
110
|
+
end
|
111
|
+
|
112
|
+
specify "should be able to be created" do
|
113
|
+
@elb.stubs(:make_request).with('CreateLoadBalancer', {
|
114
|
+
'LoadBalancerName' => 'Test Name',
|
115
|
+
'AvailabilityZones.member.1' => 'east-1a',
|
116
|
+
'Listeners.member.1.Protocol' => 'HTTP',
|
117
|
+
'Listeners.member.1.LoadBalancerPort' => '80',
|
118
|
+
'Listeners.member.1.InstancePort' => '80'
|
119
|
+
}).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
120
|
+
|
121
|
+
response = @elb.create_load_balancer(@valid_create_load_balancer_params)
|
122
|
+
response.should.be.an.instance_of Hash
|
123
|
+
response.DNSName.should.equal "TestLoadBalancer-380544827.us-east-1.ec2.amazonaws.com"
|
124
|
+
end
|
125
|
+
|
126
|
+
specify "method create_load_balancer should reject bad arguments" do
|
127
|
+
@elb.stubs(:make_request).with('CreateLoadBalancer', {
|
128
|
+
'LoadBalancerName' => 'Test Name',
|
129
|
+
'AvailabilityZones.member.1' => 'east-1a',
|
130
|
+
'Listeners.member.1.Protocol' => 'HTTP',
|
131
|
+
'Listeners.member.1.LoadBalancerPort' => '80',
|
132
|
+
'Listeners.member.1.InstancePort' => '80'
|
133
|
+
}).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
134
|
+
|
135
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params) }.should.not.raise(AWS::ArgumentError)
|
136
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError)
|
137
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:load_balancer_name=>'')) }.should.raise(AWS::ArgumentError)
|
138
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>'')) }.should.raise(AWS::ArgumentError)
|
139
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:availability_zones=>[])) }.should.raise(AWS::ArgumentError)
|
140
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>[])) }.should.raise(AWS::ArgumentError)
|
141
|
+
lambda { @elb.create_load_balancer(@valid_create_load_balancer_params.merge(:listeners=>nil)) }.should.raise(AWS::ArgumentError)
|
142
|
+
end
|
143
|
+
|
144
|
+
specify "should be able to be deleted with delete_load_balancer" do
|
145
|
+
@elb.stubs(:make_request).with('DeleteLoadBalancer', {'LoadBalancerName' => 'Test Name'}).
|
146
|
+
returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
147
|
+
|
148
|
+
response = @elb.delete_load_balancer( :load_balancer_name => "Test Name" )
|
149
|
+
response.should.be.an.instance_of Hash
|
150
|
+
response.return.should.equal "true"
|
151
|
+
end
|
152
|
+
|
153
|
+
specify "should be able to be described with describe_load_balancer" do
|
154
|
+
@elb.stubs(:make_request).with('DescribeLoadBalancers', {}).
|
155
|
+
returns stub(:body => @describe_load_balancer_response_body, :is_a? => true)
|
156
|
+
|
157
|
+
response = @elb.describe_load_balancers()
|
158
|
+
response.should.be.an.instance_of Hash
|
159
|
+
|
160
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions.member.length.should == 1
|
161
|
+
end
|
162
|
+
|
163
|
+
specify "should be able to be register instances to load balancers with register_instances_with_load_balancer" do
|
164
|
+
@elb.stubs(:make_request).with('RegisterInstancesWithLoadBalancer', {
|
165
|
+
'LoadBalancerName' => 'Test Name',
|
166
|
+
'Instances.member.1.InstanceId' => 'i-6055fa09'
|
167
|
+
}).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
168
|
+
|
169
|
+
response = @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params)
|
170
|
+
response.should.be.an.instance_of Hash
|
171
|
+
|
172
|
+
response.Instances.member.length.should == 1
|
173
|
+
end
|
174
|
+
|
175
|
+
specify "method register_instances_with_load_balancer should reject bad arguments" do
|
176
|
+
@elb.stubs(:make_request).with('RegisterInstancesWithLoadBalancer', {
|
177
|
+
'LoadBalancerName' => 'Test Name',
|
178
|
+
'Instances.member.1.InstanceId' => 'i-6055fa09'
|
179
|
+
}).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
180
|
+
|
181
|
+
lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params) }.should.not.raise(AWS::ArgumentError)
|
182
|
+
lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError)
|
183
|
+
lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWS::ArgumentError)
|
184
|
+
lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError)
|
185
|
+
end
|
186
|
+
|
187
|
+
specify "should be able to degresiter instances from load balancers with degregister_instances_from_load_balancer" do
|
188
|
+
@elb.stubs(:make_request).with('DeregisterInstancesFromLoadBalancer', {
|
189
|
+
'LoadBalancerName' => 'Test Name',
|
190
|
+
'Instances.member.1.InstanceId' => 'i-6055fa09'
|
191
|
+
}).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
192
|
+
|
193
|
+
response = @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params)
|
194
|
+
response.should.be.an.instance_of Hash
|
195
|
+
end
|
196
|
+
|
197
|
+
specify "method deregister_instances_from_load_balancer should reject bad arguments" do
|
198
|
+
@elb.stubs(:make_request).with('DeregisterInstancesFromLoadBalancer', {
|
199
|
+
'LoadBalancerName' => 'Test Name',
|
200
|
+
'Instances.member.1.InstanceId' => 'i-6055fa09'
|
201
|
+
}).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
202
|
+
|
203
|
+
lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params) }.should.not.raise(AWS::ArgumentError)
|
204
|
+
lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError)
|
205
|
+
lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>nil)) }.should.raise(AWS::ArgumentError)
|
206
|
+
lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError)
|
207
|
+
end
|
208
|
+
|
209
|
+
specify "should be able to degresiter instances from load balancers with degregister_instances_from_load_balancer" do
|
210
|
+
@elb.stubs(:make_request).with('ConfigureHealthCheck', {
|
211
|
+
'LoadBalancerName' => 'Test Name',
|
212
|
+
'HealthCheck.Interval' => '5',
|
213
|
+
'HealthCheck.Target' => 'HTTP:80/servlets-examples/servlet/',
|
214
|
+
'HealthCheck.HealthyThreshold' => '2',
|
215
|
+
'HealthCheck.Timeout' => '2',
|
216
|
+
'HealthCheck.UnhealthyThreshold' => '2'
|
217
|
+
}).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
218
|
+
|
219
|
+
response = @elb.configure_health_check(@valid_configure_health_check_params)
|
220
|
+
response.should.be.an.instance_of Hash
|
221
|
+
end
|
222
|
+
|
223
|
+
specify "method degregister_instances_from_load_balancer should reject bad arguments" do
|
224
|
+
@elb.stubs(:make_request).with('ConfigureHealthCheck', {
|
225
|
+
'LoadBalancerName' => 'Test Name',
|
226
|
+
'HealthCheck.Interval' => '5',
|
227
|
+
'HealthCheck.Target' => 'HTTP:80/servlets-examples/servlet/',
|
228
|
+
'HealthCheck.HealthyThreshold' => '2',
|
229
|
+
'HealthCheck.Timeout' => '2',
|
230
|
+
'HealthCheck.UnhealthyThreshold' => '2'
|
231
|
+
}).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
232
|
+
|
233
|
+
lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWS::ArgumentError)
|
234
|
+
lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name=>nil)) }.should.raise(AWS::ArgumentError)
|
235
|
+
lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check=>nil)) }.should.raise(AWS::ArgumentError)
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|