aws 2.4.5 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README.markdown +9 -75
  2. data/lib/acf/acf_interface.rb +6 -4
  3. data/lib/aws.rb +2 -1
  4. data/lib/awsbase/awsbase.rb +98 -65
  5. data/lib/awsbase/errors.rb +9 -5
  6. data/lib/awsbase/parsers.rb +226 -226
  7. data/lib/awsbase/utils.rb +255 -207
  8. data/lib/ec2/ec2.rb +243 -105
  9. data/lib/ec2/mon_interface.rb +2 -1
  10. data/lib/iam/iam.rb +31 -25
  11. data/lib/right_aws.rb +1 -1
  12. data/lib/s3/bucket.rb +7 -8
  13. data/lib/s3/grantee.rb +238 -238
  14. data/lib/s3/key.rb +281 -281
  15. data/lib/s3/s3.rb +2 -1
  16. data/lib/s3/s3_interface.rb +45 -35
  17. data/lib/sdb/active_sdb.rb +19 -22
  18. data/lib/sdb/sdb_interface.rb +4 -5
  19. data/lib/ses/ses.rb +123 -0
  20. data/lib/sqs/sqs.rb +5 -0
  21. data/lib/sqs/sqs_interface.rb +3 -3
  22. metadata +53 -104
  23. data/lib/awsbase/support.rb +0 -142
  24. data/test/acf/test_acf.rb +0 -148
  25. data/test/acf/test_helper.rb +0 -2
  26. data/test/ec2/test_ec2.rb +0 -205
  27. data/test/ec2/test_helper.rb +0 -2
  28. data/test/ec2/test_mon.rb +0 -17
  29. data/test/elb/test_elb.rb +0 -51
  30. data/test/http_connection.rb +0 -87
  31. data/test/iam/test_iam.rb +0 -36
  32. data/test/rds/test_rds.rb +0 -181
  33. data/test/s3/s3_test_base.rb +0 -23
  34. data/test/s3/test_helper.rb +0 -3
  35. data/test/s3/test_s3.rb +0 -162
  36. data/test/s3/test_s3_class.rb +0 -179
  37. data/test/s3/test_s3_rights.rb +0 -139
  38. data/test/s3/test_s3_stubbed.rb +0 -97
  39. data/test/sdb/test_active_sdb.rb +0 -338
  40. data/test/sdb/test_helper.rb +0 -3
  41. data/test/sdb/test_sdb.rb +0 -220
  42. data/test/sqs/test_helper.rb +0 -2
  43. data/test/sqs/test_sqs.rb +0 -232
  44. data/test/test_credentials.rb +0 -54
  45. data/test/ts_right_aws.rb +0 -13
@@ -1,2 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../../lib/right_aws'
@@ -1,232 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require File.dirname(__FILE__) + '/../test_credentials.rb'
3
-
4
-
5
- class TestSqs < Test::Unit::TestCase
6
-
7
- GRANTEE_EMAIL_ADDRESS = 'fester@example.com'
8
- RIGHT_MESSAGE_TEXT = 'Right test message'
9
-
10
-
11
- def setup
12
- TestCredentials.get_credentials
13
- @sqs = Aws::SqsInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
14
- @queue_name = 'right_sqs_test_gen2_queue'
15
- # for classes
16
- @s = Aws::Sqs.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
17
- end
18
-
19
- # Wait for the queue to appear in the queues list.
20
- # Amazon needs some time to after the queue creation to place
21
- # it to the accessible queues list. If we dont want to get
22
- # the additional faults then wait a bit...
23
- def wait_for_queue_url(queue_name)
24
- queue_url = nil
25
- until queue_url
26
- queue_url = @sqs.queue_url_by_name(queue_name)
27
- unless queue_url
28
- print '-'
29
- STDOUT.flush
30
- sleep 1
31
- end
32
- end
33
- queue_url
34
- end
35
-
36
- def test_on_exception_no_method_error
37
- assert_raise Aws::ResourceNotFoundError do
38
- Aws::Sqs::Queue.new(@s, "some_nonexistant_queue")
39
- end
40
- end
41
-
42
-
43
-
44
- #---------------------------
45
- # Rightscale::SqsInterface
46
- #---------------------------
47
-
48
- def test_01_create_queue
49
- queue_url = @sqs.create_queue @queue_name
50
- assert queue_url[/http.*#{@queue_name}/], 'New queue creation failed'
51
- end
52
-
53
- def test_02_list_queues
54
- wait_for_queue_url(@queue_name)
55
- queues = @sqs.list_queues('right_')
56
- assert queues.size>0, 'Must more that 0 queues in list'
57
- end
58
-
59
- def test_03_set_and_get_queue_attributes
60
- queue_url = @sqs.queue_url_by_name(@queue_name)
61
- assert queue_url[/http.*#{@queue_name}/], "#{@queue_name} must exist!"
62
- assert @sqs.set_queue_attributes(queue_url, 'VisibilityTimeout', 111), 'Set_queue_attributes fail'
63
- sleep 20 # Amazon needs some time to change attribute
64
- assert_equal '111', @sqs.get_queue_attributes(queue_url)['VisibilityTimeout'], 'New VisibilityTimeout must be equal to 111'
65
- end
66
-
67
- def test_06_send_message
68
- queue_url = @sqs.queue_url_by_name(@queue_name)
69
- # send 5 messages for the tests below
70
- assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
71
- assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
72
- assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
73
- assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
74
- assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
75
- sleep 2
76
- end
77
-
78
- def test_07_get_queue_length
79
- queue_url = @sqs.queue_url_by_name(@queue_name)
80
- assert_equal 5, @sqs.get_queue_length(queue_url), 'Queue must have 5 messages'
81
- end
82
-
83
- def test_08_receive_message
84
- queue_url = @sqs.queue_url_by_name(@queue_name)
85
- r_message = @sqs.receive_message(queue_url, 1)[0]
86
- assert r_message, "Receive returned no message(s), but this is not necessarily incorrect"
87
- assert_equal RIGHT_MESSAGE_TEXT, r_message['Body'], 'Receive message got wrong message text'
88
- end
89
-
90
- def test_09_delete_message
91
- queue_url = @sqs.queue_url_by_name(@queue_name)
92
- message = @sqs.receive_message(queue_url)[0]
93
- assert @sqs.delete_message(queue_url, message['ReceiptHandle']), 'Delete_message fail'
94
- assert @sqs.pop_message(queue_url), 'Pop_message fail'
95
- end
96
-
97
- def test_10_clear_and_delete_queue
98
- queue_url = @sqs.queue_url_by_name(@queue_name)
99
- assert @sqs.delete_queue(queue_url)
100
- end
101
-
102
- #---------------------------
103
- # Aws::Sqs classes
104
- #---------------------------
105
-
106
- def test_20_sqs_create_delete_queue
107
- assert @s, 'Aws::Sqs must exist'
108
- # get queues list
109
- queues_size = @s.queues.size
110
- # create new queue
111
- queue = @s.queue("#{@queue_name}_20", true)
112
- # check that it is created
113
- assert queue.is_a?(Aws::Sqs::Queue)
114
- wait_for_queue_url(@queue_name)
115
- # check that amount of queues has increased
116
- assert_equal queues_size + 1, @s.queues.size
117
- # delete queue
118
- assert queue.delete
119
- end
120
-
121
- def test_21_queue_create
122
- # create new queue
123
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_21", true)
124
- # check that it is created
125
- assert queue.is_a?(Aws::Sqs::Queue)
126
- wait_for_queue_url(@queue_name)
127
- end
128
-
129
- def test_22_queue_attributes
130
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_21", false)
131
- # get a list of attrinutes
132
- attributes = queue.get_attribute
133
- assert attributes.is_a?(Hash) && attributes.size>0
134
- # get attribute value and increase it by 10
135
- v = (queue.get_attribute('VisibilityTimeout').to_i + 10).to_s
136
- # set attribute
137
- assert queue.set_attribute('VisibilityTimeout', v)
138
- # wait a bit
139
- sleep 20
140
- # check that attribute has changed
141
- assert_equal v, queue.get_attribute('VisibilityTimeout')
142
- # get queue visibility timeout
143
- assert_equal v, queue.visibility
144
- # change it
145
- queue.visibility = queue.visibility.to_i + 10
146
- # make sure that it is changed
147
- assert v.to_i + 10, queue.visibility
148
- end
149
-
150
- def test_24_send_size
151
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_24", true)
152
- # send 5 messages
153
- assert queue.push('a1')
154
- assert queue.push('a2')
155
- assert queue.push('a3')
156
- assert queue.push('a4')
157
- assert queue.push('a5')
158
- sleep 2
159
- # check queue size
160
- assert_equal 5, queue.size
161
- # send one more
162
- assert queue.push('a6')
163
- sleep 2
164
- # check queue size again
165
- assert_equal 6, queue.size
166
- end
167
-
168
- def test_25_message_receive_pop_delete
169
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_24", false)
170
- # get queue size
171
- size = queue.size
172
- # get first message
173
- m1 = queue.receive(10)
174
- assert m1.is_a?(Aws::Sqs::Message)
175
- # pop second message
176
- m2 = queue.pop
177
- assert m2.is_a?(Aws::Sqs::Message)
178
- # make sure that queue size has decreased
179
- assert_equal size-1, queue.size
180
- # delete messsage
181
- assert m1.delete
182
- # make sure that queue size has decreased again
183
- assert_equal size-2, queue.size
184
- end
185
-
186
- def test_26
187
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_24", false)
188
- # lock message
189
- queue.receive(100)
190
- # clear queue
191
- assert queue.clear
192
- # queue size is greater than zero
193
- assert queue.size>0
194
- end
195
-
196
- def test_27_set_amazon_problems
197
- original_problems = Aws::SqsInterface.amazon_problems
198
- assert(original_problems.length > 0)
199
- Aws::SqsInterface.amazon_problems= original_problems << "A New Problem"
200
- new_problems = Aws::SqsInterface.amazon_problems
201
- assert_equal(new_problems, original_problems)
202
-
203
- Aws::SqsInterface.amazon_problems= nil
204
- assert_nil(Aws::SqsInterface.amazon_problems)
205
- end
206
-
207
- def test_28_check_threading_model
208
- assert(!@sqs.multi_thread)
209
- newsqs = Aws::SqsInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, {:multi_thread => true})
210
- assert(newsqs.multi_thread)
211
- end
212
-
213
- # Note that just like the other tests, this one does not clean up
214
- # after itself (queue does not get deleted)
215
- def test_29_change_message_visibility
216
- queue = Aws::Sqs::Queue.create(@s, "#{@queue_name}_29", true, 10)
217
- # Be sure the queue is empty. Useful when rerunning the tests.
218
- queue.clear
219
- queue.send_message(RIGHT_MESSAGE_TEXT)
220
- m = nil
221
- # Wait for the message to be delivered
222
- while m.nil?
223
- m = queue.receive
224
- end
225
- m.visibility = 60
226
- sleep(20)
227
- # Had the visibility timeout been not updated, the message would be available
228
- # at this point.
229
- assert queue.receive.nil?
230
- end
231
-
232
- end
@@ -1,54 +0,0 @@
1
- class TestCredentials
2
-
3
- @@aws_access_key_id = nil
4
- @@aws_secret_access_key = nil
5
- @@account_number = nil
6
- @@config = nil
7
-
8
- def self.config
9
- @@config
10
- end
11
-
12
- def self.aws_access_key_id
13
- @@aws_access_key_id
14
- end
15
-
16
- def self.aws_access_key_id=(newval)
17
- @@aws_access_key_id = newval
18
- end
19
-
20
- def self.account_number
21
- @@account_number
22
- end
23
-
24
- def self.account_number=(newval)
25
- @@account_number = newval
26
- end
27
-
28
- def self.aws_secret_access_key
29
- @@aws_secret_access_key
30
- end
31
-
32
- def self.aws_secret_access_key=(newval)
33
- @@aws_secret_access_key = newval
34
- end
35
-
36
- require 'yaml'
37
-
38
- def self.get_credentials
39
- #Dir.chdir do
40
- begin
41
-
42
- Dir.chdir(File.expand_path("~/.test_configs")) do
43
- credentials = YAML::load(File.open("aws.yml"))
44
- @@config = credentials
45
- self.aws_access_key_id = credentials["amazon"]["access_key"]
46
- self.aws_secret_access_key = credentials["amazon"]["secret_key"]
47
- end
48
- rescue Exception => e
49
- puts "#{e.message}"
50
- raise e
51
- end
52
- #end
53
- end
54
- end
@@ -1,13 +0,0 @@
1
- require 'test/unit'
2
- $: << File.dirname(__FILE__)
3
- require 'test_credentials'
4
- TestCredentials.get_credentials
5
-
6
- require 'http_connection'
7
- require 'ec2/test_ec2.rb'
8
- require 's3/test_s3.rb'
9
- require 's3/test_s3_stubbed.rb'
10
- require 'sqs/test_sqs.rb'
11
- require 'sqs/test_right_sqs_gen2.rb'
12
- require 'sdb/test_sdb.rb'
13
- require 'acf/test_acf.rb'