right_aws 1.10.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/History.txt +53 -15
  2. data/Manifest.txt +16 -0
  3. data/README.txt +10 -9
  4. data/Rakefile +13 -15
  5. data/lib/acf/right_acf_interface.rb +224 -118
  6. data/lib/acf/right_acf_origin_access_identities.rb +230 -0
  7. data/lib/acf/right_acf_streaming_interface.rb +236 -0
  8. data/lib/acw/right_acw_interface.rb +249 -0
  9. data/lib/as/right_as_interface.rb +699 -0
  10. data/lib/awsbase/right_awsbase.rb +232 -51
  11. data/lib/awsbase/support.rb +4 -0
  12. data/lib/ec2/right_ec2.rb +33 -1375
  13. data/lib/ec2/right_ec2_ebs.rb +452 -0
  14. data/lib/ec2/right_ec2_images.rb +373 -0
  15. data/lib/ec2/right_ec2_instances.rb +755 -0
  16. data/lib/ec2/right_ec2_monitoring.rb +70 -0
  17. data/lib/ec2/right_ec2_reserved_instances.rb +170 -0
  18. data/lib/ec2/right_ec2_security_groups.rb +280 -0
  19. data/lib/ec2/right_ec2_spot_instances.rb +399 -0
  20. data/lib/ec2/right_ec2_vpc.rb +571 -0
  21. data/lib/elb/right_elb_interface.rb +496 -0
  22. data/lib/rds/right_rds_interface.rb +998 -0
  23. data/lib/right_aws.rb +18 -4
  24. data/lib/s3/right_s3.rb +39 -7
  25. data/lib/s3/right_s3_interface.rb +77 -53
  26. data/lib/sdb/active_sdb.rb +203 -11
  27. data/lib/sdb/right_sdb_interface.rb +68 -45
  28. data/lib/sqs/right_sqs_gen2.rb +73 -16
  29. data/lib/sqs/right_sqs_gen2_interface.rb +131 -51
  30. data/lib/sqs/right_sqs_interface.rb +2 -4
  31. data/test/acf/test_right_acf.rb +10 -18
  32. data/test/rds/test_helper.rb +2 -0
  33. data/test/rds/test_right_rds.rb +120 -0
  34. data/test/s3/test_right_s3.rb +10 -8
  35. data/test/s3/test_right_s3_stubbed.rb +6 -4
  36. data/test/sdb/test_active_sdb.rb +70 -12
  37. data/test/sdb/test_right_sdb.rb +13 -7
  38. data/test/sqs/test_right_sqs_gen2.rb +104 -49
  39. metadata +103 -14
@@ -7,8 +7,13 @@ class TestSqsGen2 < Test::Unit::TestCase
7
7
 
8
8
 
9
9
  def setup
10
+ $stdout.sync = true
11
+ @grantee_aws_id = '100000000001'
10
12
  @sqs = Rightscale::SqsGen2Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
11
- @queue_name = 'right_sqs_test_gen2_queue'
13
+ @queue_name = 'right_sqs_test_gen2_queue'
14
+ @queue2_name = @queue_name + '_2'
15
+ @queue3_name = @queue_name + '_3'
16
+ @queue4_name = @queue_name + '_4'
12
17
  # for classes
13
18
  @s = Rightscale::SqsGen2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
14
19
  end
@@ -19,18 +24,24 @@ class TestSqsGen2 < Test::Unit::TestCase
19
24
  # the additional faults then wait a bit...
20
25
  def wait_for_queue_url(queue_name)
21
26
  queue_url = nil
22
- until queue_url
27
+ do_sleep(180) do
23
28
  queue_url = @sqs.queue_url_by_name(queue_name)
24
- unless queue_url
25
- print '-'
26
- STDOUT.flush
27
- sleep 1
28
- end
29
29
  end
30
+ sleep 30
30
31
  queue_url
31
32
  end
32
-
33
-
33
+
34
+ def do_sleep(delay, &block)
35
+ puts "sleeping #{block ? 'up to ' : ''}#{delay} seconds:"
36
+ wake_up_at = Time.now+delay
37
+ while Time.now < wake_up_at do
38
+ sleep 1
39
+ print '.'
40
+ break if block && block.call
41
+ end
42
+ puts
43
+ end
44
+
34
45
  #---------------------------
35
46
  # Rightscale::SqsInterface
36
47
  #---------------------------
@@ -48,13 +59,51 @@ class TestSqsGen2 < Test::Unit::TestCase
48
59
 
49
60
  def test_03_set_and_get_queue_attributes
50
61
  queue_url = @sqs.queue_url_by_name(@queue_name)
51
- assert queue_url[/http.*#{@queue_name}/], "#{@queue_name} must exist!"
62
+ assert queue_url[/https.*#{@queue_name}/], "#{@queue_name} must exist!"
52
63
  assert @sqs.set_queue_attributes(queue_url, 'VisibilityTimeout', 111), 'Set_queue_attributes fail'
53
- sleep 20 # Amazon needs some time to change attribute
64
+ do_sleep 60 # Amazon needs some time to change attribute
54
65
  assert_equal '111', @sqs.get_queue_attributes(queue_url)['VisibilityTimeout'], 'New VisibilityTimeout must be equal to 111'
55
66
  end
56
-
57
- def test_06_send_message
67
+
68
+ def test_04_get_queue_attributes_forms
69
+ queue_url = @sqs.queue_url_by_name(@queue_name)
70
+ all = nil
71
+ assert_nothing_raised do
72
+ all = @sqs.get_queue_attributes(queue_url, 'All')
73
+ end
74
+ assert_nothing_raised do
75
+ assert all, @sqs.get_queue_attributes(queue_url)
76
+ end
77
+ assert_nothing_raised do
78
+ attributes = @sqs.get_queue_attributes(queue_url, 'ApproximateNumberOfMessages', 'VisibilityTimeout')
79
+ assert_equal 2, attributes.size
80
+ end
81
+ assert_nothing_raised do
82
+ attributes = @sqs.get_queue_attributes(queue_url, ['ApproximateNumberOfMessages', 'VisibilityTimeout'])
83
+ assert_equal 2, attributes.size
84
+ end
85
+ end
86
+
87
+ def test_05_add_permissions
88
+ queue_url = @sqs.queue_url_by_name(@queue_name)
89
+ assert @sqs.add_permissions(queue_url, 'test01', @grantee_aws_id, 'SendMessage')
90
+ assert @sqs.add_permissions(queue_url, 'test02', @grantee_aws_id, ['DeleteMessage','ReceiveMessage'])
91
+ do_sleep 60
92
+ end
93
+
94
+ def test_06_test_permissions
95
+ queue_url = @sqs.queue_url_by_name(@queue_name)
96
+ permissions = @sqs.get_queue_attributes(queue_url, 'Policy')
97
+ assert !permissions.blank?
98
+ end
99
+
100
+ def test_07_revoke_permissions
101
+ queue_url = @sqs.queue_url_by_name(@queue_name)
102
+ assert @sqs.remove_permissions(queue_url, 'test01')
103
+ assert @sqs.remove_permissions(queue_url, 'test02')
104
+ end
105
+
106
+ def test_14_send_message
58
107
  queue_url = @sqs.queue_url_by_name(@queue_name)
59
108
  # send 5 messages for the tests below
60
109
  assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
@@ -62,28 +111,29 @@ class TestSqsGen2 < Test::Unit::TestCase
62
111
  assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
63
112
  assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
64
113
  assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
114
+ do_sleep 60
65
115
  end
66
116
 
67
- def test_07_get_queue_length
117
+ def test_15_get_queue_length
68
118
  queue_url = @sqs.queue_url_by_name(@queue_name)
69
119
  assert_equal 5, @sqs.get_queue_length(queue_url), 'Queue must have 5 messages'
70
120
  end
71
121
 
72
- def test_08_receive_message
122
+ def test_16_receive_message
73
123
  queue_url = @sqs.queue_url_by_name(@queue_name)
74
124
  r_message = @sqs.receive_message(queue_url, 1)[0]
75
125
  assert r_message, "Receive returned no message(s), but this is not necessarily incorrect"
76
126
  assert_equal RIGHT_MESSAGE_TEXT, r_message['Body'], 'Receive message got wrong message text'
77
127
  end
78
128
 
79
- def test_09_delete_message
129
+ def test_17_delete_message
80
130
  queue_url = @sqs.queue_url_by_name(@queue_name)
81
131
  message = @sqs.receive_message(queue_url)[0]
82
132
  assert @sqs.delete_message(queue_url, message['ReceiptHandle']), 'Delete_message fail'
83
133
  assert @sqs.pop_message(queue_url), 'Pop_message fail'
84
134
  end
85
135
 
86
- def test_10_clear_and_delete_queue
136
+ def test_18_clear_and_delete_queue
87
137
  queue_url = @sqs.queue_url_by_name(@queue_name)
88
138
  assert @sqs.delete_queue(queue_url)
89
139
  end
@@ -92,31 +142,36 @@ class TestSqsGen2 < Test::Unit::TestCase
92
142
  # Rightscale::Sqs classes
93
143
  #---------------------------
94
144
 
95
- def test_20_sqs_create_delete_queue
145
+ def test_20_sqs_create_queue
96
146
  assert @s, 'Rightscale::SqsGen2 must exist'
97
147
  # get queues list
98
148
  queues_size = @s.queues.size
99
149
  # create new queue
100
- queue = @s.queue("#{@queue_name}_20", true)
150
+ queue = @s.queue(@queue2_name, true)
101
151
  # check that it is created
102
152
  assert queue.is_a?(Rightscale::SqsGen2::Queue)
103
- wait_for_queue_url(@queue_name)
153
+ wait_for_queue_url(queue.name)
104
154
  # check that amount of queues has increased
105
155
  assert_equal queues_size + 1, @s.queues.size
106
- # delete queue
156
+ do_sleep 10
157
+ end
158
+
159
+ def test_21_sqs_delete_queue
160
+ queue = @s.queue(@queue2_name, false)
107
161
  assert queue.delete
108
162
  end
109
163
 
110
- def test_21_queue_create
164
+ def test_22_queue_create
111
165
  # create new queue
112
- queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_21", true)
166
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue3_name, true)
113
167
  # check that it is created
114
168
  assert queue.is_a?(Rightscale::SqsGen2::Queue)
115
- wait_for_queue_url(@queue_name)
169
+ wait_for_queue_url("#{@queue_name}_21")
170
+ do_sleep 10
116
171
  end
117
172
 
118
- def test_22_queue_attributes
119
- queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_21", false)
173
+ def test_23_queue_attributes
174
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue3_name, false)
120
175
  # get a list of attrinutes
121
176
  attributes = queue.get_attribute
122
177
  assert attributes.is_a?(Hash) && attributes.size>0
@@ -125,7 +180,7 @@ class TestSqsGen2 < Test::Unit::TestCase
125
180
  # set attribute
126
181
  assert queue.set_attribute('VisibilityTimeout', v)
127
182
  # wait a bit
128
- sleep 20
183
+ do_sleep 60
129
184
  # check that attribute has changed
130
185
  assert_equal v, queue.get_attribute('VisibilityTimeout')
131
186
  # get queue visibility timeout
@@ -135,25 +190,34 @@ class TestSqsGen2 < Test::Unit::TestCase
135
190
  # make sure that it is changed
136
191
  assert v.to_i + 10, queue.visibility
137
192
  end
193
+
194
+ def test_24
195
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue3_name, false)
196
+ assert queue.delete
197
+ end
138
198
 
139
- def test_24_send_size
140
- queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", true)
199
+ def test_25_send_size
200
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue4_name, true)
141
201
  # send 5 messages
142
202
  assert queue.push('a1')
143
203
  assert queue.push('a2')
144
204
  assert queue.push('a3')
145
205
  assert queue.push('a4')
146
206
  assert queue.push('a5')
207
+ #
208
+ do_sleep(300){ queue.size == 5 }
147
209
  # check queue size
148
210
  assert_equal 5, queue.size
149
211
  # send one more
150
212
  assert queue.push('a6')
213
+ #
214
+ do_sleep(300){ queue.size == 6 }
151
215
  # check queue size again
152
216
  assert_equal 6, queue.size
153
217
  end
154
218
 
155
- def test_25_message_receive_pop_delete
156
- queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", false)
219
+ def test_26_message_receive_pop_delete
220
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue4_name, false)
157
221
  # get queue size
158
222
  size = queue.size
159
223
  # get first message
@@ -162,25 +226,31 @@ class TestSqsGen2 < Test::Unit::TestCase
162
226
  # pop second message
163
227
  m2 = queue.pop
164
228
  assert m2.is_a?(Rightscale::SqsGen2::Message)
229
+ #
230
+ do_sleep 30
165
231
  # make sure that queue size has decreased
166
232
  assert_equal size-1, queue.size
167
233
  # delete messsage
168
234
  assert m1.delete
235
+ #
236
+ do_sleep 15
169
237
  # make sure that queue size has decreased again
170
238
  assert_equal size-2, queue.size
171
239
  end
172
240
 
173
- def test_26
174
- queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", false)
241
+ def test_27
242
+ queue = Rightscale::SqsGen2::Queue.create(@s, @queue4_name, false)
175
243
  # lock message
176
244
  queue.receive(100)
177
245
  # clear queue
178
246
  assert queue.clear
179
247
  # queue size is greater than zero
180
248
  assert queue.size>0
249
+ # delete queue
250
+ assert queue.delete
181
251
  end
182
252
 
183
- def test_27_set_amazon_problems
253
+ def test_28_set_amazon_problems
184
254
  original_problems = Rightscale::SqsGen2Interface.amazon_problems
185
255
  assert(original_problems.length > 0)
186
256
  Rightscale::SqsGen2Interface.amazon_problems= original_problems << "A New Problem"
@@ -190,20 +260,5 @@ class TestSqsGen2 < Test::Unit::TestCase
190
260
  Rightscale::SqsGen2Interface.amazon_problems= nil
191
261
  assert_nil(Rightscale::SqsGen2Interface.amazon_problems)
192
262
  end
193
-
194
- def test_28_check_threading_model
195
- assert(!@sqs.multi_thread)
196
- newsqs = Rightscale::SqsGen2Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, {:multi_thread => true})
197
- assert(newsqs.multi_thread)
198
- end
199
-
200
- def test_29_signature_version_0
201
- sqs = Rightscale::SqsInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '0')
202
- assert_nothing_raised do
203
- sqs.list_queues
204
- end
205
- # check that the request has correct signature version
206
- assert sqs.last_request.path.include?('SignatureVersion=0')
207
- end
208
263
 
209
264
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - RightScale, Inc.
@@ -9,21 +14,85 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-02-24 00:00:00 -08:00
17
+ date: 2010-04-28 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: right_http_connection
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 1
31
+ version: 1.2.1
17
32
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rubyforge
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
23
- version: 1.2.4
24
- version:
25
- description: "== DESCRIPTION: The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and CloudFront. These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon. The RightScale AWS gems comprise: - RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud) and the associated EBS (Elastic Block Store) - RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service) - RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service) (API version 2007-05-01) - RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service) (API version 2008-01-01) - RightAws::SdbInterface and RightAws::ActiveSdb -- interface to Amazon SDB (SimpleDB) - RightAws::AcfInterface -- interface to Amazon CloudFront, a content distribution service == FEATURES:"
26
- email: rubygems@rightscale.com
41
+ segments:
42
+ - 2
43
+ - 0
44
+ - 4
45
+ version: 2.0.4
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: gemcutter
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 5
58
+ - 0
59
+ version: 0.5.0
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 2
71
+ - 5
72
+ - 0
73
+ version: 2.5.0
74
+ type: :development
75
+ version_requirements: *id004
76
+ description: |-
77
+ == DESCRIPTION:
78
+
79
+ The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and CloudFront.
80
+ These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon.
81
+ The RightScale AWS gems comprise:
82
+
83
+ - RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud), VPC (Virtual Private Cloud) and the associated EBS (Elastic Block Store)
84
+ - RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service)
85
+ - RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service)
86
+ - RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service)
87
+ - RightAws::SdbInterface and RightAws::ActiveSdb -- interface to Amazon SDB (SimpleDB)
88
+ - RightAws::AcfInterface -- interface to Amazon CloudFront, a content distribution service
89
+ - RightAws::AsInterface -- interface to Amazon Auto Scaling
90
+ - RightAws::AcwInterface -- interface to Amazon Cloud Watch
91
+ - RightAws::ElbInterface -- interface to Amazon Elastic Load Balancer
92
+ - RightAws::RdsInterface -- interface to Amazon RDS instances
93
+
94
+ == FEATURES:
95
+ email: support@rightscale.com
27
96
  executables: []
28
97
 
29
98
  extensions: []
@@ -41,8 +110,19 @@ files:
41
110
  - lib/awsbase/right_awsbase.rb
42
111
  - lib/awsbase/support.rb
43
112
  - lib/ec2/right_ec2.rb
113
+ - lib/ec2/right_ec2_images.rb
114
+ - lib/ec2/right_ec2_instances.rb
115
+ - lib/ec2/right_ec2_security_groups.rb
116
+ - lib/ec2/right_ec2_spot_instances.rb
117
+ - lib/ec2/right_ec2_ebs.rb
118
+ - lib/ec2/right_ec2_reserved_instances.rb
119
+ - lib/ec2/right_ec2_vpc.rb
120
+ - lib/ec2/right_ec2_monitoring.rb
44
121
  - lib/right_aws.rb
45
122
  - lib/s3/right_s3.rb
123
+ - lib/acw/right_acw_interface.rb
124
+ - lib/elb/right_elb_interface.rb
125
+ - lib/as/right_as_interface.rb
46
126
  - lib/s3/right_s3_interface.rb
47
127
  - lib/sdb/active_sdb.rb
48
128
  - lib/sdb/right_sdb_interface.rb
@@ -51,6 +131,9 @@ files:
51
131
  - lib/sqs/right_sqs_gen2_interface.rb
52
132
  - lib/sqs/right_sqs_interface.rb
53
133
  - lib/acf/right_acf_interface.rb
134
+ - lib/acf/right_acf_streaming_interface.rb
135
+ - lib/acf/right_acf_origin_access_identities.rb
136
+ - lib/rds/right_rds_interface.rb
54
137
  - test/ec2/test_helper.rb
55
138
  - test/ec2/test_right_ec2.rb
56
139
  - test/http_connection.rb
@@ -67,8 +150,12 @@ files:
67
150
  - test/ts_right_aws.rb
68
151
  - test/acf/test_helper.rb
69
152
  - test/acf/test_right_acf.rb
153
+ - test/rds/test_helper.rb
154
+ - test/rds/test_right_rds.rb
70
155
  has_rdoc: true
71
156
  homepage:
157
+ licenses: []
158
+
72
159
  post_install_message:
73
160
  rdoc_options:
74
161
  - --main
@@ -79,20 +166,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
166
  requirements:
80
167
  - - ">="
81
168
  - !ruby/object:Gem::Version
169
+ segments:
170
+ - 0
82
171
  version: "0"
83
- version:
84
172
  required_rubygems_version: !ruby/object:Gem::Requirement
85
173
  requirements:
86
174
  - - ">="
87
175
  - !ruby/object:Gem::Version
176
+ segments:
177
+ - 0
88
178
  version: "0"
89
- version:
90
179
  requirements: []
91
180
 
92
- rubyforge_project: rightscale
93
- rubygems_version: 1.3.1
181
+ rubyforge_project: rightaws
182
+ rubygems_version: 1.3.6
94
183
  signing_key:
95
- specification_version: 2
96
- summary: Interface classes for the Amazon EC2/EBS, SQS, S3, SDB, and ACF Web Services
184
+ specification_version: 3
185
+ summary: Interface classes for the Amazon EC2, SQS, and S3 Web Services
97
186
  test_files:
98
187
  - test/ts_right_aws.rb