nirvdrum-amazon-ec2 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +9 -0
  2. data/.yardopts +1 -0
  3. data/ChangeLog +304 -0
  4. data/LICENSE +66 -0
  5. data/README.rdoc +359 -0
  6. data/README_dev.rdoc +10 -0
  7. data/Rakefile +70 -0
  8. data/VERSION +1 -0
  9. data/amazon-ec2.gemspec +142 -0
  10. data/bin/ec2-gem-example.rb +137 -0
  11. data/bin/ec2-gem-profile.rb +10 -0
  12. data/bin/ec2sh +62 -0
  13. data/bin/setup.rb +29 -0
  14. data/deps.rip +1 -0
  15. data/lib/AWS.rb +321 -0
  16. data/lib/AWS/Autoscaling.rb +70 -0
  17. data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
  18. data/lib/AWS/Cloudwatch.rb +32 -0
  19. data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
  20. data/lib/AWS/EC2.rb +33 -0
  21. data/lib/AWS/EC2/availability_zones.rb +29 -0
  22. data/lib/AWS/EC2/console.rb +25 -0
  23. data/lib/AWS/EC2/devpay.rb +18 -0
  24. data/lib/AWS/EC2/elastic_ips.rb +86 -0
  25. data/lib/AWS/EC2/image_attributes.rb +133 -0
  26. data/lib/AWS/EC2/images.rb +117 -0
  27. data/lib/AWS/EC2/instances.rb +234 -0
  28. data/lib/AWS/EC2/keypairs.rb +47 -0
  29. data/lib/AWS/EC2/products.rb +21 -0
  30. data/lib/AWS/EC2/security_groups.rb +164 -0
  31. data/lib/AWS/EC2/snapshots.rb +102 -0
  32. data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
  33. data/lib/AWS/EC2/volumes.rb +100 -0
  34. data/lib/AWS/ELB.rb +71 -0
  35. data/lib/AWS/ELB/load_balancers.rb +178 -0
  36. data/lib/AWS/RDS.rb +73 -0
  37. data/lib/AWS/RDS/rds.rb +522 -0
  38. data/lib/AWS/exceptions.rb +200 -0
  39. data/lib/AWS/responses.rb +21 -0
  40. data/perftools/ec2prof +0 -0
  41. data/perftools/ec2prof-results.dot +132 -0
  42. data/perftools/ec2prof-results.txt +100 -0
  43. data/perftools/ec2prof.symbols +102 -0
  44. data/test/test_Autoscaling_groups.rb +337 -0
  45. data/test/test_EC2.rb +68 -0
  46. data/test/test_EC2_availability_zones.rb +49 -0
  47. data/test/test_EC2_console.rb +54 -0
  48. data/test/test_EC2_elastic_ips.rb +144 -0
  49. data/test/test_EC2_image_attributes.rb +238 -0
  50. data/test/test_EC2_images.rb +229 -0
  51. data/test/test_EC2_instances.rb +611 -0
  52. data/test/test_EC2_keypairs.rb +123 -0
  53. data/test/test_EC2_products.rb +48 -0
  54. data/test/test_EC2_responses.rb +53 -0
  55. data/test/test_EC2_s3_xmlsimple.rb +80 -0
  56. data/test/test_EC2_security_groups.rb +205 -0
  57. data/test/test_EC2_snapshots.rb +83 -0
  58. data/test/test_EC2_spot_instance_requests.rb +178 -0
  59. data/test/test_EC2_volumes.rb +142 -0
  60. data/test/test_ELB_load_balancers.rb +239 -0
  61. data/test/test_RDS.rb +354 -0
  62. data/test/test_helper.rb +23 -0
  63. data/wsdl/2007-08-29.ec2.wsdl +1269 -0
  64. data/wsdl/2008-02-01.ec2.wsdl +1614 -0
  65. data/wsdl/2008-05-05.ec2.wsdl +2052 -0
  66. data/wsdl/2008-12-01.ec2.wsdl +2354 -0
  67. data/wsdl/2009-10-31.ec2.wsdl +4261 -0
  68. data/wsdl/2009-11-30.ec2.wsdl +4668 -0
  69. metadata +199 -0
@@ -0,0 +1,102 @@
1
+ 0000000100037f3a: garbage_collector
2
+ 000000010016bbe9: Array#map
3
+ 0000000102818079: XmlSimple#node_to_text
4
+ 0000000102818051: XmlSimple#collapse_text_node
5
+ 0000000102817f99: XmlSimple#collapse
6
+ 00000001028f9eb1: REXML::Elements#each
7
+ 000000020521dbb1: REXML::XPath.each
8
+ 0000000102902299: REXML::Element#each_element
9
+ 000000010017a719: Class#new
10
+ 00000001028a2949: REXML::Parsers::TreeParser#parse
11
+ 00000001028a3f11: REXML::Document#build
12
+ 00000001028a0d39: REXML::Document#initialize
13
+ 0000000102810de1: XmlSimple#parse
14
+ 0000000102817f71: XmlSimple#xml_in
15
+ 0000000205025409: XmlSimple.xml_in
16
+ 0000000204f566d9: AWS::Response.parse
17
+ 00000001028123e1: AWS::Base#response_generator
18
+ 00000001027f30e1: AWS::EC2::Base#describe_images
19
+ 00000001029b0211: REXML::Child#find
20
+ 000000010016bcb9: Array#each
21
+ 00000001029c5ec1: REXML::Parent#each
22
+ 00000001028fa09f: REXML::Elements#empty?
23
+ 0000000102902277: REXML::Element#has_elements?
24
+ 00000001028a6b49: REXML::Document#doctype
25
+ 000000010016bb61: Object#find
26
+ 00000001029655e9: REXML::Text#value
27
+ 000000010017e629: Kernel#gem_original_require
28
+ 000000010017bf71: Object#require
29
+ 00000001029b0229: REXML::Child#find_all
30
+ 0000000102902361: REXML::Element#texts
31
+ 000000010281804f: XmlSimple#has_mixed_content?
32
+ 00000001029011e9: REXML::Attributes#each_attribute
33
+ 00000001028f8f39: REXML::Attributes#each
34
+ 0000000102818031: XmlSimple#get_attributes
35
+ 00000001028fa4c9: REXML::Elements#add
36
+ 0000000102902111: REXML::Element#add_element
37
+ 000000010290476d: REXML::Parsers::XPathParser#AdditiveExpr
38
+ 0000000102904765: REXML::Parsers::XPathParser#RelationalExpr
39
+ 000000010290475d: REXML::Parsers::XPathParser#EqualityExpr
40
+ 0000000102904755: REXML::Parsers::XPathParser#AndExpr
41
+ 00000001029046ed: REXML::Parsers::XPathParser#OrExpr
42
+ 00000001028fdc59: REXML::Parsers::XPathParser#parse
43
+ 00000001028fd169: REXML::XPathParser#parse
44
+ 00000001028aca99: Set#initialize
45
+ 00000001028b46c9: REXML::Parsers::BaseParser#pull
46
+ 00000001029be149: REXML::Child#initialize
47
+ 00000001029c5ab1: REXML::Parent#initialize
48
+ 00000001028f9b19: REXML::Element#initialize
49
+ 000000010016c759: Array#delete_if
50
+ 00000001029039c1: REXML::XPathParser#expr
51
+ 00000001028faf79: REXML::XPathParser#match
52
+ 00000002052d17d9: REXML::Text.unnormalize
53
+ 00000001028fc2e1: REXML::Element#text
54
+ 0000000102902297: REXML::Element#has_text?
55
+ 00000001029c506e: REXML::Parent#<<
56
+ 0000000102964c39: REXML::Text#initialize
57
+ 00000001029c64d9: REXML::Parent#add
58
+ 0000000102a143b9: Net::BufferedIO#read
59
+ 0000000102a15919: Net::HTTPResponse#read_chunked
60
+ 0000000102a15909: Net::HTTPResponse#read_body_0
61
+ 0000000102a15271: Net::HTTPResponse#read_body
62
+ 0000000102a12ad9: Net::HTTPResponse#body
63
+ 0000000102a15521: Net::HTTPResponse#reading_body
64
+ 0000000102a16b19: Net::HTTP#request
65
+ 0000000102811831: AWS::Base#make_request
66
+ 0000000102a125d9: Net::HTTP#start
67
+ 0000000102a14401: Net::BufferedIO#readline
68
+ 0000000102a1b031: Net::BufferedIO#rbuf_fill
69
+ 0000000203164251: Timeout.timeout
70
+ 000000010017ec59: Object#timeout
71
+ 00000001028abec7: REXML::Parsers::BaseParser#empty?
72
+ 0000000102904785: REXML::Parsers::XPathParser#UnionExpr
73
+ 000000010290477d: REXML::Parsers::XPathParser#UnaryExpr
74
+ 0000000102904775: REXML::Parsers::XPathParser#MultiplicativeExpr
75
+ 000000010037eed9: Gem::GemPathSearcher#matching_files
76
+ 000000010037f5cf: Gem::GemPathSearcher#matching_file?
77
+ 000000010037d021: Gem::GemPathSearcher#find
78
+ 000000010017a531: Object#clone
79
+ 00000001029022d1: REXML::Element#get_text
80
+ 00000001028180d7: XmlSimple#force_array?
81
+ 000000010280f5b1: XmlSimple#merge
82
+ 00000001001692bc: Hash#[]
83
+ 0000000102902219: REXML::Element#ignore_whitespace_nodes
84
+ 00000001029021f9: REXML::Element#whitespace
85
+ 000000010297920f: REXML::Source#empty?
86
+ 000000010290383c: REXML::XPathParser#variables=
87
+ 00000001028ff359: REXML::Element#document
88
+ 00000001028fde41: REXML::Element#root
89
+ 00000001028f9c34: REXML::Parent#name=
90
+ 0000000102979211: REXML::Source#match
91
+ 0000000102904795: REXML::Parsers::XPathParser#FilterExpr
92
+ 000000010290478d: REXML::Parsers::XPathParser#PathExpr
93
+ 000000010016a111: Hash#each
94
+ 0000000102818059: XmlSimple#fold_arrays
95
+ 000000010016c261: Array#join
96
+ 0000000102978c11: REXML::Source#initialize
97
+ 00000002052fa051: REXML::SourceFactory.create_from
98
+ 00000001028b4524: REXML::Parsers::BaseParser#stream=
99
+ 00000001028ab8c9: REXML::Parsers::BaseParser#initialize
100
+ 00000001028a0159: REXML::Parsers::TreeParser#initialize
101
+ 0000000102904715: REXML::Parsers::XPathParser#RelativeLocationPath
102
+ 000000010290470d: REXML::Parsers::XPathParser#LocationPath
@@ -0,0 +1,337 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ context "autoscaling " do
4
+ before do
5
+ @as = AWS::Autoscaling::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
6
+
7
+ @valid_create_launch_configuration_params = {
8
+ :image_id => "ami-ed46a784",
9
+ :launch_configuration_name => "TestAutoscalingGroupName",
10
+ :instance_type => "m1.small"
11
+ }
12
+
13
+ @error_response_for_creation = <<-RESPONSE
14
+ <ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2009-05-15/">
15
+ <Error>
16
+ <Type>Sender</Type>
17
+ <Code>AlreadyExists</Code>
18
+ <Message>Launch Configuration by this name already exists - A launch configuration already exists with the name TestAutoscalingGroupName</Message>
19
+ </Error>
20
+ <RequestId>31d00b03-ad6a-11de-a47f-a5c562feca13</RequestId>
21
+ </ErrorResponse>
22
+ RESPONSE
23
+
24
+ @delete_launch_configuration_response = <<-RESPONSE
25
+ <DeleteLaunchConfigurationResponse xmlns="http://autoscaling.amazonaws.com/doc/2009-05-15/">
26
+ <ResponseMetadata>
27
+ <RequestId>5f5717d3-ad6c-11de-b1c0-1b00aadc5f72</RequestId>
28
+ </ResponseMetadata>
29
+ </DeleteLaunchConfigurationResponse>
30
+ RESPONSE
31
+
32
+ @create_launch_configuration_response = "<CreateLaunchConfigurationResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">\n <ResponseMetadata>\n <RequestId>6062466f-ad6c-11de-b82f-996c936914c5</RequestId>\n </ResponseMetadata>\n</CreateLaunchConfigurationResponse>\n"
33
+
34
+ @create_autoscaling_group_response = "<CreateAutoScalingGroupResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">\n <ResponseMetadata>\n <RequestId>cc4f9960-ad6e-11de-b82f-996c936914c5</RequestId>\n </ResponseMetadata>\n</CreateAutoScalingGroupResponse>\n"
35
+
36
+ @delete_autoscaling_group = "<DeleteAutoScalingGroupResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
37
+ <ResponseMetadata><RequestId>e64fc4c3-e10b-11dd-a73e-2d774d6aee71</RequestId></ResponseMetadata></DeleteAutoScalingGroupResponse>"
38
+ @create_or_update_trigger_response = "<CreateOrUpdateScalingTriggerResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
39
+ <ResponseMetadata>
40
+ <RequestId>503d309d-e10b-11dd-a73e-2d774d6aee71</RequestId>
41
+ </ResponseMetadata>
42
+ </CreateOrUpdateScalingTriggerResponse>"
43
+ end
44
+
45
+ specify "AWS::Autoscaling::Base should give back a nice response if there is an error" do
46
+ @as.stubs(:make_request).with('CreateLaunchConfiguration', {
47
+ 'ImageId' => 'ami-ed46a784',
48
+ 'LaunchConfigurationName' => 'TestAutoscalingGroupName',
49
+ 'InstanceType' => "m1.small"
50
+ }).returns stub(:body => @error_response_for_creation, :is_a? => true)
51
+
52
+ response = @as.create_launch_configuration( :image_id => "ami-ed46a784", :launch_configuration_name => "TestAutoscalingGroupName", :instance_type => "m1.small")
53
+ response.should.be.an.instance_of Hash
54
+ response["Error"]["Message"].should.equal "Launch Configuration by this name already exists - A launch configuration already exists with the name TestAutoscalingGroupName"
55
+ end
56
+
57
+ specify "AWS::Autoscaling::Base should destroy a launch configuration just fine" do
58
+ @as.stubs(:make_request).with('DeleteLaunchConfiguration', {
59
+ 'LaunchConfigurationName' => 'TestAutoscalingGroupName1'
60
+ }).returns stub(:body => @delete_launch_configuration_response, :is_a? => true)
61
+
62
+ response = @as.delete_launch_configuration( :launch_configuration_name => "TestAutoscalingGroupName1" )
63
+ response.should.be.an.instance_of Hash
64
+ end
65
+
66
+ specify "AWS::Autoscaling::Base should create a launch configuration" do
67
+ @as.stubs(:make_request).with('CreateLaunchConfiguration', {
68
+ 'ImageId' => 'ami-ed46a784',
69
+ 'LaunchConfigurationName' => 'CustomTestAutoscalingGroupName',
70
+ 'InstanceType' => "m1.small"
71
+ }).returns stub(:body => @create_launch_configuration_response, :is_a? => true)
72
+
73
+ response = @as.create_launch_configuration( :image_id => "ami-ed46a784", :launch_configuration_name => "CustomTestAutoscalingGroupName", :instance_type => "m1.small")
74
+ response.should.be.an.instance_of Hash
75
+ end
76
+
77
+ specify "AWS::Autoscaling::Base should be able to create a new autoscaling group" do
78
+ @as.stubs(:make_request).with("CreateAutoScalingGroup", {
79
+ 'AutoScalingGroupName' => 'CloudteamTestAutoscalingGroup1',
80
+ 'AvailabilityZones.member.1' => 'us-east-1a',
81
+ 'LoadBalancerNames.member.1' => 'TestLoadBalancerName',
82
+ 'LoadBalancerNames.member.2' => 'TestLoadBalancerName2',
83
+ 'LaunchConfigurationName' => 'CloudteamTestAutoscaling',
84
+ 'MinSize' => "1", 'MaxSize' => "3"
85
+ }).returns stub(:body => @create_autoscaling_group_response, :is_a? => true)
86
+ response = @as.create_autoscaling_group(:autoscaling_group_name => "CloudteamTestAutoscalingGroup1", :availability_zones => "us-east-1a", :load_balancer_names => ["TestLoadBalancerName", "TestLoadBalancerName2"], :launch_configuration_name => "CloudteamTestAutoscaling", :min_size => 1, :max_size => 3)
87
+ response.should.be.an.instance_of Hash
88
+ end
89
+
90
+ specify "AWS::Autoscaling::Base should destroy an autoscaling group" do
91
+ @as.stubs(:make_request).with('DeleteAutoScalingGroup', {
92
+ 'AutoScalingGroupName' => 'TestAutoscalingGroupName1'
93
+ }).returns stub(:body => @delete_autoscaling_group, :is_a? => true)
94
+
95
+ response = @as.delete_autoscaling_group( :autoscaling_group_name => "TestAutoscalingGroupName1" )
96
+ response.should.be.an.instance_of Hash
97
+ end
98
+
99
+ specify "AWS::Autoscaling::Base should be able to create a new scaling trigger" do
100
+ @as.stubs(:make_request).with("CreateOrUpdateScalingTrigger", {
101
+ 'AutoScalingGroupName' => 'AutoScalingGroupName',
102
+ 'Unit' => "Seconds",
103
+ 'Dimensions.member.1.Name' => "AutoScalingGroupName",
104
+ 'Dimensions.member.1.Value' => "Bob",
105
+ 'MeasureName' => "CPUUtilization",
106
+ 'Statistic' => 'Average',
107
+ 'Period' => '120',
108
+ 'TriggerName' => "AFunNameForATrigger",
109
+ 'LowerThreshold' => "0.2",
110
+ 'LowerBreachScaleIncrement' => "-1",
111
+ 'UpperThreshold' => "1.5",
112
+ 'UpperBreachScaleIncrement' => "1",
113
+ 'BreachDuration' => "120"
114
+ }).returns stub(:body => @create_or_update_trigger_response, :is_a? => true)
115
+
116
+ valid_create_or_update_scaling_trigger_params = {:autoscaling_group_name => "AutoScalingGroupName", :dimensions => {:name => "AutoScalingGroupName", :value => "Bob"}, :unit => "Seconds", :measure_name => "CPUUtilization", :statistic => "Average", :period => 120, :trigger_name => "AFunNameForATrigger", :lower_threshold => 0.2, :lower_breach_scale_increment => "-1", :upper_threshold => 1.5, :upper_breach_scale_increment => 1, :breach_duration => 120}
117
+
118
+ %w(dimensions autoscaling_group_name measure_name statistic period trigger_name lower_threshold lower_breach_scale_increment upper_threshold upper_breach_scale_increment breach_duration).each do |meth_str|
119
+ lambda { @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params.merge(meth_str.to_sym=>nil)) }.should.raise(AWS::ArgumentError)
120
+ end
121
+
122
+ response = @as.create_or_updated_scaling_trigger(valid_create_or_update_scaling_trigger_params)
123
+ response.should.be.an.instance_of Hash
124
+ end
125
+
126
+ specify "AWS::Autoscaling::Base should destroy a launch configuration group" do
127
+ @as.stubs(:make_request).with('DeleteLaunchConfiguration', {
128
+ 'LaunchConfigurationName' => 'LaunchConfiguration'
129
+ }).returns stub(:body => " <DeleteLaunchConfigurationResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
130
+ <ResponseMetadata><RequestId>e64fc4c3-e10b-11dd-a73e-2d774d6aee71</RequestId></ResponseMetadata>
131
+ </DeleteLaunchConfigurationResponse>", :is_a? => true)
132
+
133
+ response = @as.delete_launch_configuration( :launch_configuration_name => "LaunchConfiguration" )
134
+ response.should.be.an.instance_of Hash
135
+ end
136
+
137
+ specify "AWS::Autoscaling::Base should destroy a scaling trigger" do
138
+ @as.stubs(:make_request).with('DeleteTrigger', {
139
+ 'TriggerName' => 'DeletingTrigger', 'AutoScalingGroupName' => "Name"
140
+ }).returns stub(:body => " <DeleteTriggerResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
141
+ <ResponseMetadata>
142
+ <RequestId>cca38097-e10b-11dd-a73e-2d774d6aee71</RequestId>
143
+ </ResponseMetadata>
144
+ </DeleteTriggerResponse>", :is_a? => true)
145
+
146
+ response = @as.delete_trigger( :trigger_name => "DeletingTrigger", :autoscaling_group_name => "Name" )
147
+ response.should.be.an.instance_of Hash
148
+ end
149
+
150
+ specify "AWS::Autoscaling::Base should describe the autoscaling groups" do
151
+ @as.stubs(:make_request).with('DescribeAutoScalingGroups', {
152
+ 'AutoScalingGroupNames.member.1' => "webtier"
153
+ }).returns stub(:body => "<DescribeAutoScalingGroupsResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
154
+ <DescribeAutoScalingGroupsResult>
155
+ <AutoScalingGroups>
156
+ <member>
157
+ <MinSize>0</MinSize>
158
+ <CreatedTime>2009-01-13T00:38:54Z</CreatedTime>
159
+ <AvailabilityZones>
160
+ <member>us-east-1c</member>
161
+ </AvailabilityZones>
162
+ <Cooldown>0</Cooldown>
163
+ <LaunchConfigurationName>wt20080929</LaunchConfigurationName>
164
+ <AutoScalingGroupName>webtier</AutoScalingGroupName>
165
+ <DesiredCapacity>1</DesiredCapacity>
166
+ <Instances>
167
+ <member>
168
+ <InstanceId>i-8fa224e6</InstanceId>
169
+ <LifecycleState>InService</LifecycleState>
170
+ <AvailabilityZone>us-east-1c</AvailabilityZone>
171
+ </member>
172
+ </Instances>
173
+ <MaxSize>1</MaxSize>
174
+ </member>
175
+ </AutoScalingGroups>
176
+ </DescribeAutoScalingGroupsResult>
177
+ <ResponseMetadata>
178
+ <RequestId>70f2e8af-e10b-11dd-a73e-2d774d6aee71</RequestId>
179
+ </ResponseMetadata>
180
+ </DescribeAutoScalingGroupsResponse>", :is_a? => true)
181
+
182
+ response = @as.describe_autoscaling_groups( :autoscaling_group_names => ["webtier"] )
183
+ response.should.be.an.instance_of Hash
184
+ end
185
+
186
+ specify "AWS::Autoscaling::Base should describe the launch configurations" do
187
+ @as.stubs(:make_request).with('DescribeLaunchConfigurations', {
188
+ 'AutoScalingGroupNames.member.1' => "webtier"
189
+ }).returns stub(:body => "<DescribeLaunchConfigurationsResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
190
+ <DescribeLaunchConfigurationsResult>
191
+ <LaunchConfigurations>
192
+ <member>
193
+ <InstanceType>m1.small</InstanceType>
194
+ <BlockDeviceMappings/>
195
+ <KeyName/>
196
+ <SecurityGroups/>
197
+ <ImageId>ami-f7c5219e</ImageId>
198
+ <RamdiskId/>
199
+ <CreatedTime>2009-01-13T00:35:31Z</CreatedTime>
200
+ <KernelId/>
201
+ <LaunchConfigurationName>wt20080929</LaunchConfigurationName>
202
+ <UserData/>
203
+ </member>
204
+ </LaunchConfigurations>
205
+ </DescribeLaunchConfigurationsResult>
206
+ <ResponseMetadata>
207
+ <RequestId>2e14cb6c-e10a-11dd-a73e-2d774d6aee71</RequestId>
208
+ </ResponseMetadata>
209
+ </DescribeLaunchConfigurationsResponse>", :is_a? => true)
210
+
211
+ response = @as.describe_launch_configurations( :launch_configuration_names => ["webtier"] )
212
+ response.should.be.an.instance_of Hash
213
+ end
214
+
215
+
216
+ specify "AWS::Autoscaling::Base should describe the launch configurations" do
217
+ @as.stubs(:make_request).with('DescribeScalingActivities', {
218
+ 'AutoScalingGroupName' => "webtier"
219
+ }).returns stub(:body => "<DescribeScalingActivitiesResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
220
+ <DescribeScalingActivitiesResult>
221
+ <Activities>
222
+ <member>
223
+ <ActivityId>885b2900-0f2e-497a-8ec6-b1b90a9ddee0</ActivityId>
224
+ <StartTime>2009-03-29T04:07:07Z</StartTime>
225
+ <Progress>0</Progress>
226
+ <StatusCode>InProgress</StatusCode>
227
+ <Cause>Automated Capacity Adjustment</Cause>
228
+ <Description>Launching a new EC2 instance</Description>
229
+ </member>
230
+ </Activities>
231
+ </DescribeScalingActivitiesResult>
232
+ <ResponseMetadata>
233
+ <RequestId>f0321780-e10a-11dd-a73e-2d774d6aee71</RequestId>
234
+ </ResponseMetadata>
235
+ </DescribeScalingActivitiesResponse>", :is_a? => true)
236
+
237
+ response = @as.describe_scaling_activities( :autoscaling_group_name => "webtier" )
238
+ response.should.be.an.instance_of Hash
239
+ end
240
+
241
+ specify "AWS::Autoscaling::Base should describe triggers" do
242
+ @as.stubs(:make_request).with('DescribeTriggers', {
243
+ 'AutoScalingGroupName' => "webtier"
244
+ }).returns stub(:body => " <DescribeTriggersResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
245
+ <DescribeTriggersResult>
246
+ <Triggers>
247
+ <member>
248
+ <BreachDuration>300</BreachDuration>
249
+ <UpperBreachScaleIncrement>1</UpperBreachScaleIncrement>
250
+ <CreatedTime>2009-01-13T00:44:19Z</CreatedTime>
251
+ <UpperThreshold>60.0</UpperThreshold>
252
+ <Status>NoData</Status>
253
+ <LowerThreshold>0.0</LowerThreshold>
254
+ <Period>60</Period>
255
+ <LowerBreachScaleIncrement>-1</LowerBreachScaleIncrement>
256
+ <TriggerName>tenpct</TriggerName>
257
+ <Statistic>Average</Statistic>
258
+ <Unit>None</Unit>
259
+ <Namespace>AWS/EC2</Namespace>
260
+ <Dimensions>
261
+
262
+ <member>
263
+ <Name>AutoScalingGroupName</Name>
264
+ <Value>webtier</Value>
265
+ </member>
266
+ </Dimensions>
267
+ <AutoScalingGroupName>webtier</AutoScalingGroupName>
268
+ <MeasureName>CPUUtilization</MeasureName>
269
+ </member>
270
+ </Triggers>
271
+ </DescribeTriggersResult>
272
+ <ResponseMetadata>
273
+ <RequestId>5c33c82a-e10b-11dd-a73e-2d774d6aee71</RequestId>
274
+ </ResponseMetadata>
275
+ </DescribeTriggersResponse>", :is_a? => true)
276
+
277
+ response = @as.describe_triggers( :autoscaling_group_name => "webtier" )
278
+ response.should.be.an.instance_of Hash
279
+ end
280
+
281
+ specify "AWS::Autoscaling::Base should describe triggers" do
282
+ @as.stubs(:make_request).with('SetDesiredCapacity', {
283
+ 'AutoScalingGroupName' => "name", 'DesiredCapacity' => '10'
284
+ }).returns stub(:body => " <SetDesiredCapacityResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
285
+ <ResponseMetadata>
286
+ <RequestId>d3f2091c-e10a-11dd-a73e- 2d774d6aee71</RequestId>
287
+ </ResponseMetadata>
288
+ </SetDesiredCapacityResponse>
289
+ ", :is_a? => true)
290
+
291
+ response = @as.set_desired_capacity( :autoscaling_group_name => "name", :desired_capacity => "10" )
292
+ response.should.be.an.instance_of Hash
293
+ end
294
+
295
+
296
+ specify "AWS::Autoscaling::Base should terminate an instance in an autoscaling group" do
297
+ @as.stubs(:make_request).with('TerminateInstanceInAutoScalingGroup', {
298
+ 'InstanceId' => "i-instance1"
299
+ }).returns stub(:body => " <DescribeTriggersResponse xmlns=\"http://autoscaling.amazonaws.com/doc/2009-05-15/\">
300
+ <DescribeTriggersResult>
301
+ <Triggers>
302
+ <member>
303
+ <BreachDuration>300</BreachDuration>
304
+ <UpperBreachScaleIncrement>1</UpperBreachScaleIncrement>
305
+ <CreatedTime>2009-01-13T00:44:19Z</CreatedTime>
306
+ <UpperThreshold>60.0</UpperThreshold>
307
+ <Status>NoData</Status>
308
+ <LowerThreshold>0.0</LowerThreshold>
309
+ <Period>60</Period>
310
+ <LowerBreachScaleIncrement>-1</LowerBreachScaleIncrement>
311
+ <TriggerName>tenpct</TriggerName>
312
+ <Statistic>Average</Statistic>
313
+ <Unit>None</Unit>
314
+ <Namespace>AWS/EC2</Namespace>
315
+ <Dimensions>
316
+
317
+ <member>
318
+ <Name>AutoScalingGroupName</Name>
319
+ <Value>webtier</Value>
320
+ </member>
321
+ </Dimensions>
322
+ <AutoScalingGroupName>webtier</AutoScalingGroupName>
323
+ <MeasureName>CPUUtilization</MeasureName>
324
+ </member>
325
+ </Triggers>
326
+ </DescribeTriggersResult>
327
+ <ResponseMetadata>
328
+ <RequestId>5c33c82a-e10b-11dd-a73e-2d774d6aee71</RequestId>
329
+ </ResponseMetadata>
330
+ </DescribeTriggersResponse>", :is_a? => true)
331
+
332
+ response = @as.terminate_instance_in_autoscaling_group( :instance_id => "i-instance1" )
333
+ response.should.be.an.instance_of Hash
334
+ end
335
+
336
+
337
+ end
@@ -0,0 +1,68 @@
1
+ #--
2
+ # Amazon Web Services EC2 Query API Ruby library
3
+ #
4
+ # Ruby Gem Name:: amazon-ec2
5
+ # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
+ # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
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 "The EC2 method " do
14
+
15
+ before do
16
+ end
17
+
18
+ specify "AWS::EC2::Base attribute readers should be available" do
19
+ @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key",
20
+ :secret_access_key => "not a secret",
21
+ :use_ssl => true,
22
+ :server => "foo.example.com" )
23
+
24
+ @ec2.use_ssl.should.equal true
25
+ @ec2.port.should.equal 443
26
+ @ec2.server.should.equal "foo.example.com"
27
+ end
28
+
29
+ specify "AWS::EC2::Base should work with insecure connections as well" do
30
+ @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key",
31
+ :secret_access_key => "not a secret",
32
+ :use_ssl => false,
33
+ :server => "foo.example.com" )
34
+
35
+ @ec2.use_ssl.should.equal false
36
+ @ec2.port.should.equal 80
37
+ @ec2.server.should.equal "foo.example.com"
38
+ end
39
+
40
+ specify "AWS::EC2::Base should allow specification of port" do
41
+ @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key",
42
+ :secret_access_key => "not a secret",
43
+ :use_ssl => true,
44
+ :server => "foo.example.com",
45
+ :port => 8443 )
46
+
47
+ @ec2.use_ssl.should.equal true
48
+ @ec2.port.should.equal 8443
49
+ @ec2.server.should.equal "foo.example.com"
50
+ end
51
+
52
+ specify "AWS.canonical_string(path) should conform to Amazon's requirements " do
53
+ path = {"name1" => "value1", "name2" => "value2", "name3" => "value3"}
54
+ if ENV['EC2_URL'].nil? || ENV['EC2_URL'] == 'https://ec2.amazonaws.com'
55
+ AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nec2.amazonaws.com\n/\nname1=value1&name2=value2&name3=value3"
56
+ elsif ENV['EC2_URL'] == 'https://us-east-1.ec2.amazonaws.com'
57
+ AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\nus-east-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2&name3=value3"
58
+ elsif ENV['EC2_URL'] == 'https://eu-west-1.ec2.amazonaws.com'
59
+ AWS.canonical_string(path, 'ec2.amazonaws.com').should.equal "POST\neu-west-1.ec2.amazonaws.com\n/\nname1=value1&name2=value2&name3=value3"
60
+ end
61
+ end
62
+
63
+ specify "AWS.encode should return the expected string" do
64
+ AWS.encode("secretaccesskey", "foobar123", urlencode=true).should.equal "e3jeuDc3DIX2mW8cVqWiByj4j5g%3D"
65
+ AWS.encode("secretaccesskey", "foobar123", urlencode=false).should.equal "e3jeuDc3DIX2mW8cVqWiByj4j5g="
66
+ end
67
+
68
+ end