SQS 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +11 -0
- data/test/all_tests.rb +0 -2
- data/test/unit/sqs_grant_test.rb +17 -3
- data/test/unit/sqs_message_test.rb +17 -2
- data/test/unit/sqs_queue_test.rb +166 -101
- data/test/unit/sqs_test.rb +18 -5
- metadata +46 -39
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.1.6
|
2
|
+
2008-02-19
|
3
|
+
* Maintenance release to keep up with Amazon SQS API changes. All but one test should be
|
4
|
+
passing. See next bullet.
|
5
|
+
* Still experiencing the problem outlined here:
|
6
|
+
http://developer.amazonwebservices.com/connect/thread.jspa?threadID=15798
|
7
|
+
* Added a random string to the test queues to allow deletion in teardown (without waiting for
|
8
|
+
60 seconds of propagation).
|
9
|
+
* Updated to require assert_statistically 0.2.1 (was using 0.1.1). Some tests may fail
|
10
|
+
with 0.1.1.
|
11
|
+
|
1
12
|
0.1.5
|
2
13
|
2007-07-18
|
3
14
|
* sqs_queue_test.rb is now dependent on the assert_statistically gem. You can still
|
data/test/all_tests.rb
CHANGED
data/test/unit/sqs_grant_test.rb
CHANGED
@@ -6,17 +6,31 @@ require "#{File.expand_path( File.dirname( __FILE__ ) )}/test_setup"
|
|
6
6
|
|
7
7
|
class SQS_GrantTest < Test::Unit::TestCase
|
8
8
|
def setup
|
9
|
-
@
|
9
|
+
@used_prefixes ||= {}
|
10
|
+
|
11
|
+
@queue_prefix = "testGRANTEE#{rand( 10040932 )}"
|
12
|
+
@queue_prefix = "testGRANTEE#{rand( 10040932 )}" while @used_prefixes[@queue_prefix]
|
13
|
+
|
14
|
+
@used_prefixes[@queue_prefix] = true
|
15
|
+
|
10
16
|
@q = SQS.create_queue( @queue_prefix ) unless SQStest.skip_live_tests?
|
11
17
|
end
|
12
18
|
def teardown
|
13
|
-
|
19
|
+
unless SQStest.skip_live_tests?
|
20
|
+
SQS.list_queues( @queue_prefix ).each do |q|
|
21
|
+
begin
|
22
|
+
q.delete! if q.exists?
|
23
|
+
rescue SQS::AWSSimpleQueueServiceNonExistentQueue
|
24
|
+
# Note that it's possible that the queue existed in
|
25
|
+
# the exists? clause, but does not exist in the delete clause
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
14
29
|
print SQS.counter if SQStest.print_counter?
|
15
30
|
end
|
16
31
|
|
17
32
|
unless SQStest.skip_live_tests?
|
18
33
|
|
19
|
-
|
20
34
|
end
|
21
35
|
|
22
36
|
|
@@ -15,11 +15,26 @@ end
|
|
15
15
|
|
16
16
|
class SQS_MessageTest < Test::Unit::TestCase
|
17
17
|
def setup
|
18
|
-
@
|
18
|
+
@used_prefixes ||= {}
|
19
|
+
|
20
|
+
@queue_prefix = "testMSG#{rand( 10040932 )}"
|
21
|
+
@queue_prefix = "testMSG#{rand( 10040932 )}" while @used_prefixes[@queue_prefix]
|
22
|
+
|
23
|
+
@used_prefixes[@queue_prefix] = true
|
24
|
+
|
19
25
|
@q = SQS.create_queue( @queue_prefix ) unless SQStest.skip_live_tests?
|
20
26
|
end
|
21
27
|
def teardown
|
22
|
-
|
28
|
+
unless SQStest.skip_live_tests?
|
29
|
+
SQS.list_queues( @queue_prefix ).each do |q|
|
30
|
+
begin
|
31
|
+
q.delete! if q.exists?
|
32
|
+
rescue SQS::AWSSimpleQueueServiceNonExistentQueue
|
33
|
+
# Note that it's possible that the queue existed in
|
34
|
+
# the exists? clause, but does not exist in the delete clause
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
23
38
|
print SQS.counter if SQStest.print_counter?
|
24
39
|
end
|
25
40
|
|
data/test/unit/sqs_queue_test.rb
CHANGED
@@ -7,6 +7,7 @@ require "#{File.expand_path( File.dirname( __FILE__ ) )}/test_setup"
|
|
7
7
|
require 'rubygems'
|
8
8
|
require 'assert_statistically'
|
9
9
|
|
10
|
+
gem 'assert_statistically', '>= 0.2.1'
|
10
11
|
|
11
12
|
class SQS_QueueTest < Test::Unit::TestCase
|
12
13
|
def self.other_aws_account
|
@@ -14,17 +15,27 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def setup
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
@used_prefixes ||= {}
|
19
|
+
|
20
|
+
@queue_prefix = "test_queue_#{rand( 10040932 )}"
|
21
|
+
@queue_prefix = "test_queue_#{rand( 10040932 )}" while @used_prefixes[@queue_prefix]
|
22
|
+
|
23
|
+
@used_prefixes[@queue_prefix] = true
|
24
|
+
|
25
|
+
if SQStest.skip_live_tests?
|
26
|
+
@q = SQS::Queue.new( 'http://nowhere.com/nothing' )
|
27
|
+
else
|
28
|
+
@q = SQS.create_queue( @queue_prefix )
|
29
|
+
|
30
|
+
unless @q.exists?
|
31
|
+
assert_statistically( :of => 2, :after => lambda{ |i,s| sleep 0.25 } ) do
|
32
|
+
begin
|
33
|
+
@q = SQS.get_queue( @queue_prefix )
|
34
|
+
rescue
|
35
|
+
false
|
36
|
+
else
|
37
|
+
true
|
38
|
+
end
|
28
39
|
end
|
29
40
|
end
|
30
41
|
end
|
@@ -32,7 +43,12 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
32
43
|
def teardown
|
33
44
|
unless SQStest.skip_live_tests?
|
34
45
|
SQS.list_queues( @queue_prefix ).each do |q|
|
35
|
-
|
46
|
+
begin
|
47
|
+
q.delete! if q.exists?
|
48
|
+
rescue SQS::AWSSimpleQueueServiceNonExistentQueue
|
49
|
+
# Note that it's possible that the queue existed in
|
50
|
+
# the exists? clause, but does not exist in the delete clause
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
|
@@ -40,6 +56,7 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
40
56
|
end
|
41
57
|
|
42
58
|
unless SQStest.skip_live_tests?
|
59
|
+
|
43
60
|
def test_delete
|
44
61
|
assert @q.is_a?( SQS::Queue )
|
45
62
|
q2 = SQS.get_queue( @queue_prefix )
|
@@ -48,6 +65,11 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
48
65
|
|
49
66
|
assert @q.delete
|
50
67
|
|
68
|
+
# Per the specs, it can take 60 seconds to delete a queue. Argh.
|
69
|
+
# http://docs.amazonwebservices.com/AWSSimpleQueueService/2007-05-01/SQSDeveloperGuide/
|
70
|
+
# See API Reference -> Query and SOAP API Reference -> DeleteQueue
|
71
|
+
sleep 60
|
72
|
+
|
51
73
|
begin
|
52
74
|
q3 = SQS.get_queue( @queue_prefix )
|
53
75
|
rescue
|
@@ -106,29 +128,29 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
106
128
|
(1..10).to_a.each do |i|
|
107
129
|
@q.send_message( "I am receiving message ##{i}" )
|
108
130
|
end
|
109
|
-
|
110
|
-
sleep 5
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
131
|
+
|
132
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 5 ) } ) do
|
133
|
+
begin
|
134
|
+
@q.delete
|
135
|
+
rescue
|
136
|
+
'SQS::AWSSimpleQueueServiceNonEmptyQueue' == $!.class.name
|
137
|
+
else
|
138
|
+
false
|
139
|
+
end
|
118
140
|
end
|
119
141
|
|
120
142
|
assert_nothing_raised do
|
121
143
|
@q.force_delete
|
122
144
|
end
|
123
145
|
|
124
|
-
sleep 5
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
146
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
147
|
+
begin
|
148
|
+
q = SQS.get_queue( @queue_prefix )
|
149
|
+
rescue
|
150
|
+
'SQS::UnavailableQueue' == $!.class.name
|
151
|
+
else
|
152
|
+
false
|
153
|
+
end
|
132
154
|
end
|
133
155
|
end
|
134
156
|
|
@@ -140,12 +162,13 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
140
162
|
assert q2.exist?
|
141
163
|
|
142
164
|
assert @q.delete
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
165
|
+
|
166
|
+
# Per the specs, it can take 60 seconds to delete a queue. Argh.
|
167
|
+
# http://docs.amazonwebservices.com/AWSSimpleQueueService/2007-05-01/SQSDeveloperGuide/
|
168
|
+
# See API Reference -> Query and SOAP API Reference -> DeleteQueue
|
169
|
+
assert_statistically( :of => 6, :before => lambda{ |i,s| sleep 10 } ) do
|
170
|
+
!( @q.exists? || @q.exist? || q2.exists? || q2.exist? )
|
171
|
+
end
|
149
172
|
|
150
173
|
q3 = SQS::Queue.new( 'http://borker.borked/borkee' )
|
151
174
|
assert !q3.exists?
|
@@ -170,7 +193,7 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
170
193
|
#
|
171
194
|
#Also, the Amazon API allows you to post a body to a URL
|
172
195
|
# with query parameters in it, to send a message up to 256K
|
173
|
-
# in length.
|
196
|
+
# in length. Something to consider.
|
174
197
|
end
|
175
198
|
|
176
199
|
def test_get_and_set_queue_attributes
|
@@ -186,7 +209,7 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
186
209
|
assert_nothing_raised do
|
187
210
|
@q.get_queue_attributes( true )
|
188
211
|
end
|
189
|
-
assert_statistically( :of => 10, :
|
212
|
+
assert_statistically( :of => 10, :after => lambda{ |i,s| sleep( i * 0.25 ) } ) do
|
190
213
|
@q.get_queue_attributes( true )
|
191
214
|
400 == @q.attributes[:VisibilityTimeout]
|
192
215
|
end
|
@@ -236,28 +259,31 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
236
259
|
|
237
260
|
# Update happens in situ
|
238
261
|
assert_equal 500, @q.visibility_timeout
|
239
|
-
assert_statistically( :of => 10, :
|
262
|
+
assert_statistically( :of => 10, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
240
263
|
@q.visibility_timeout( true ) == 500
|
241
264
|
end
|
242
265
|
end
|
243
266
|
|
244
267
|
def test_empty?
|
245
268
|
assert @q.empty?
|
246
|
-
|
269
|
+
|
247
270
|
@q.send_message( 'no longer empty' )
|
248
|
-
sleep
|
249
|
-
|
271
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
272
|
+
!@q.empty?
|
273
|
+
end
|
250
274
|
|
251
275
|
@q.send_message( 'no longer empty again' )
|
252
276
|
|
253
|
-
|
277
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep 0.5 } ) do
|
278
|
+
!@q.empty?
|
279
|
+
end
|
254
280
|
|
255
|
-
sleep 3
|
256
281
|
while m = @q.receive_message
|
257
282
|
m.delete
|
283
|
+
sleep 1
|
258
284
|
end
|
259
|
-
|
260
|
-
assert_statistically( :
|
285
|
+
|
286
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 1 ) }, :message => 'Attempt %d failed' ) do
|
261
287
|
@q.empty?
|
262
288
|
end
|
263
289
|
end
|
@@ -265,16 +291,20 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
265
291
|
|
266
292
|
def test_peek_message
|
267
293
|
@q.send_message( 'I am receiving a message from beyond' )
|
268
|
-
sleep 2
|
269
|
-
m = @q.peek_message
|
270
294
|
|
271
|
-
|
295
|
+
m = nil
|
296
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 3 ) } ) do
|
297
|
+
m = @q.peek_message
|
298
|
+
m.is_a?( SQS::Message )
|
299
|
+
end
|
272
300
|
assert_equal @q, m.queue
|
273
301
|
assert_equal 'I am receiving a message from beyond', m.body
|
274
302
|
|
275
|
-
|
276
|
-
|
277
|
-
|
303
|
+
m2 = nil
|
304
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep 0.5 } ) do
|
305
|
+
m2 = @q.receive_message
|
306
|
+
m2.is_a?( SQS::Message )
|
307
|
+
end
|
278
308
|
assert_equal m.id, m2.id
|
279
309
|
assert_equal m.body, m2.body
|
280
310
|
end
|
@@ -289,10 +319,11 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
289
319
|
@q.send_message( "I am receiving message #{i}" )
|
290
320
|
end
|
291
321
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
322
|
+
messages = nil
|
323
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
324
|
+
messages = @q.peek_messages :count => 2
|
325
|
+
messages.size == 1 || messages.size == 2
|
326
|
+
end
|
296
327
|
|
297
328
|
assert messages.is_a?( Array )
|
298
329
|
messages.each do |m|
|
@@ -305,20 +336,21 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
305
336
|
assert messages.is_a?( Array )
|
306
337
|
assert messages.size > 0 && messages.size < 12, "Weird array size: #{messages.size}"
|
307
338
|
|
308
|
-
sleep
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
assert messages.size > 0 && messages.size < 12, "Weird array size: #{messages.size}"
|
339
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
340
|
+
messages = @q.receive_messages :count => 12
|
341
|
+
messages.is_a?( Array ) && messages.size > 0 && messages.size < 12
|
342
|
+
end
|
313
343
|
end
|
314
344
|
|
315
|
-
|
316
345
|
def test_receive_message
|
317
346
|
@q.send_message( 'I am receiving a message from beyond' )
|
318
|
-
sleep 2
|
319
|
-
m = @q.receive_message
|
320
347
|
|
321
|
-
|
348
|
+
m = nil
|
349
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
350
|
+
m = @q.receive_message
|
351
|
+
m.is_a?( SQS::Message )
|
352
|
+
end
|
353
|
+
|
322
354
|
assert_equal @q, m.queue
|
323
355
|
assert_equal 'I am receiving a message from beyond', m.body
|
324
356
|
end
|
@@ -333,10 +365,11 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
333
365
|
@q.send_message( "I am receiving message #{i}" )
|
334
366
|
end
|
335
367
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
368
|
+
messages = nil
|
369
|
+
assert_statistically( :of => 3, :after => lambda{ |i,s| sleep( i * 0.5 ) } ) do
|
370
|
+
messages = @q.receive_messages :count => 2
|
371
|
+
messages.size == 1 || messages.size == 2
|
372
|
+
end
|
340
373
|
|
341
374
|
assert messages.is_a?( Array )
|
342
375
|
messages.each do |m|
|
@@ -350,7 +383,6 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
350
383
|
assert messages.size > 0 && messages.size < 12, "Weird array size: #{messages.size}"
|
351
384
|
end
|
352
385
|
|
353
|
-
|
354
386
|
class DUMMY
|
355
387
|
def self.email
|
356
388
|
SQS_QueueTest::other_aws_account[:email]
|
@@ -362,36 +394,42 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
362
394
|
|
363
395
|
assert_equal 1, @q.list_grants.size
|
364
396
|
|
365
|
-
assert @q.add_grant( :email => SQStest.other_aws_account[:email], :permission => :full )
|
366
|
-
assert_statistically( :of => 3, :min => 1, :sleep => 0.5 ) do
|
367
|
-
2 == @q.list_grants.size
|
368
|
-
end
|
369
|
-
|
370
397
|
assert @q.add_grant( :email => SQStest.other_aws_account[:email], :permission => :send )
|
371
|
-
assert_statistically( :of =>
|
372
|
-
|
398
|
+
assert_statistically( :of => 6, :after => lambda{ |i,s| sleep 5 } ) do
|
399
|
+
grants = @q.list_grants
|
400
|
+
2 == grants.size
|
373
401
|
end
|
374
402
|
|
375
403
|
assert @q.add_grant( :email => SQStest.other_aws_account[:email], :permission => :receive )
|
376
|
-
assert_statistically( :of =>
|
377
|
-
|
404
|
+
assert_statistically( :of => 6, :after => lambda{ |i,s| sleep 5 } ) do
|
405
|
+
grants = @q.list_grants
|
406
|
+
3 == grants.size
|
407
|
+
end
|
408
|
+
|
409
|
+
assert @q.add_grant( :email => SQStest.other_aws_account[:email], :permission => :full )
|
410
|
+
assert_statistically( :of => 6, :after => lambda{ |i,s| sleep 5 } ) do
|
411
|
+
grants = @q.list_grants
|
412
|
+
4 == grants.size
|
378
413
|
end
|
379
414
|
|
380
415
|
assert_nothing_raised do
|
381
416
|
#DUMMY responds to :email (is not an address itself)
|
382
417
|
@q.add_grant( :email => DUMMY, :permission => :receive )
|
383
418
|
end
|
384
|
-
|
419
|
+
assert_statistically( :of => 6, :after => lambda{ |i,s| sleep 5 } ) do
|
420
|
+
grants = @q.list_grants
|
421
|
+
4 == grants.size
|
422
|
+
end
|
385
423
|
|
386
424
|
begin
|
387
425
|
@q.add_grant( :email => 'invalid@email.address', :permission => :receive )
|
388
426
|
rescue
|
389
|
-
assert_equal 'SQS::
|
427
|
+
assert_equal 'SQS::InvalidParameterValue', $!.class.name
|
390
428
|
else
|
391
|
-
flunk "Was supposed to raise an SQS::
|
429
|
+
flunk "Was supposed to raise an SQS::InvalidParameterValue"
|
392
430
|
end
|
393
431
|
end
|
394
|
-
|
432
|
+
|
395
433
|
def test_remove_grant
|
396
434
|
assert_respond_to @q, :remove_grant
|
397
435
|
|
@@ -441,13 +479,55 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
441
479
|
end
|
442
480
|
end
|
443
481
|
end
|
444
|
-
|
482
|
+
|
483
|
+
def test_SQS_thread_15798
|
484
|
+
# See http://developer.amazonwebservices.com/connect/thread.jspa?threadID=15798
|
485
|
+
|
486
|
+
# Add a receive permission
|
487
|
+
@q.add_grant( :email => SQStest.other_aws_account[:email], :permission => :receive)
|
488
|
+
|
489
|
+
# There should be two total
|
490
|
+
grants = nil
|
491
|
+
assert_statistically( :of => 4, :after => lambda{ |i,s| sleep( i * 0.25 ) } ) do
|
492
|
+
grants = @q.list_grants
|
493
|
+
2 == grants.size
|
494
|
+
end
|
495
|
+
|
496
|
+
# There should be one send (my account)
|
497
|
+
grants = @q.list_grants( :permission => :send )
|
498
|
+
assert_equal 1, grants.size
|
499
|
+
grants.each do |g|
|
500
|
+
assert_kind_of SQS::Grant, g
|
501
|
+
assert_equal SQStest.my_aws_account[:display_name], g.display_name
|
502
|
+
end
|
503
|
+
|
504
|
+
# There should be one receive and it should be the other users
|
505
|
+
grants = @q.list_grants( :permission => :receive )
|
506
|
+
# This should fail until the issue is resolved.
|
507
|
+
assert_equal 1, grants.size, "Apparently http://developer.amazonwebservices.com/connect/thread.jspa?threadID=15798 is still unresolved"
|
508
|
+
assert_kind_of SQS::Grant, grants.first
|
509
|
+
assert_equal SQStest.other_aws_account[:display_name], grants.first.display_name
|
510
|
+
|
511
|
+
# There should be one with my email address
|
512
|
+
grants = @q.list_grants( :email => SQStest.my_aws_account[:email] )
|
513
|
+
assert_equal 1, grants.size
|
514
|
+
assert_kind_of SQS::Grant, grants.first
|
515
|
+
assert_equal SQStest.other_aws_account[:display_name], grants.first.display_name
|
516
|
+
|
517
|
+
# There should be one with the other email address
|
518
|
+
grants = @q.list_grants( :email => SQStest.other_aws_account[:email] )
|
519
|
+
# This should fail until the issue is resolved.
|
520
|
+
assert_equal 1, grants.size, "Apparently http://developer.amazonwebservices.com/connect/thread.jspa?threadID=15798 is still unresolved"
|
521
|
+
assert_kind_of SQS::Grant, grants.first
|
522
|
+
assert_equal SQStest.other_aws_account[:display_name], grants.first.display_name
|
523
|
+
end
|
524
|
+
|
445
525
|
def test_list_grants
|
446
526
|
assert_respond_to @q, :list_grants
|
447
527
|
grant = @q.list_grants
|
448
528
|
assert_equal 1, grant.size
|
449
529
|
grant = grant.first
|
450
|
-
assert_equal SQS.permissions[:full], grant.permission
|
530
|
+
assert_equal SQS.permissions[:full], grant.permission
|
451
531
|
assert_equal nil, grant.email
|
452
532
|
assert_equal SQStest.my_aws_account[:display_name], grant.display_name
|
453
533
|
|
@@ -455,7 +535,7 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
455
535
|
|
456
536
|
grants = @q.list_grants
|
457
537
|
if grants.size != 2
|
458
|
-
assert_statistically( :of => 4, :
|
538
|
+
assert_statistically( :of => 4, :after => lambda{ |i,s| sleep( i * 0.25 ) } ) do
|
459
539
|
grants = @q.list_grants
|
460
540
|
2 == grants.size
|
461
541
|
end
|
@@ -473,24 +553,8 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
473
553
|
flunk "'#{grant.display_name}' is an unknown display name"
|
474
554
|
end
|
475
555
|
end
|
476
|
-
|
477
|
-
|
478
|
-
grants = @q.list_grants( :email => SQStest.other_aws_account[:email] )
|
479
|
-
assert_equal 1, grants.size
|
480
|
-
grants.each do |g|
|
481
|
-
assert_kind_of SQS::Grant, g
|
482
|
-
assert_equal SQStest.other_aws_account[:display_name], g.display_name
|
483
|
-
end
|
484
|
-
|
485
|
-
grants = @q.list_grants( :permission => :receive )
|
486
|
-
assert_equal 1, grants.size
|
487
|
-
grants.each do |g|
|
488
|
-
assert_kind_of SQS::Grant, g
|
489
|
-
assert_equal SQStest.other_aws_account[:display_name], g.display_name
|
490
|
-
end
|
491
556
|
end
|
492
557
|
|
493
|
-
|
494
558
|
def test_each_message
|
495
559
|
assert_respond_to @q, :each_message
|
496
560
|
1.upto( 10 ) do |i|
|
@@ -585,6 +649,7 @@ class SQS_QueueTest < Test::Unit::TestCase
|
|
585
649
|
q.delete
|
586
650
|
end
|
587
651
|
end
|
652
|
+
|
588
653
|
end
|
589
654
|
|
590
655
|
def test_default_visibility_timeout
|
data/test/unit/sqs_test.rb
CHANGED
@@ -17,7 +17,13 @@ end
|
|
17
17
|
|
18
18
|
class SQSTest < Test::Unit::TestCase
|
19
19
|
def setup
|
20
|
-
@
|
20
|
+
@used_prefixes ||= {}
|
21
|
+
|
22
|
+
@queue_prefix = "testSQS#{rand( 10040932 )}"
|
23
|
+
@queue_prefix = "testSQS#{rand( 10040932 )}" while @used_prefixes[@queue_prefix]
|
24
|
+
|
25
|
+
@used_prefixes[@queue_prefix] = true
|
26
|
+
|
21
27
|
@q = SQS.create_queue( @queue_prefix ) unless SQStest.skip_live_tests?
|
22
28
|
|
23
29
|
SQS.add_reasons_to_retry 'ServiceUnavailable'
|
@@ -25,7 +31,16 @@ class SQSTest < Test::Unit::TestCase
|
|
25
31
|
SQS.retry_attempts = 10
|
26
32
|
end
|
27
33
|
def teardown
|
28
|
-
|
34
|
+
unless SQStest.skip_live_tests?
|
35
|
+
SQS.list_queues( @queue_prefix ).each do |q|
|
36
|
+
begin
|
37
|
+
q.delete! if q.exists?
|
38
|
+
rescue SQS::AWSSimpleQueueServiceNonExistentQueue
|
39
|
+
# Note that it's possible that the queue existed in
|
40
|
+
# the exists? clause, but does not exist in the delete clause
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
29
44
|
print SQS.counter if SQStest.print_counter?
|
30
45
|
end
|
31
46
|
|
@@ -94,7 +109,7 @@ class SQSTest < Test::Unit::TestCase
|
|
94
109
|
begin
|
95
110
|
SQS.call_web_service( :Something => 'for nothing' )
|
96
111
|
rescue
|
97
|
-
assert_equal 'SQS::
|
112
|
+
assert_equal 'SQS::MissingParameter', $!.class.name
|
98
113
|
else
|
99
114
|
flunk "Was supposed to raise an SQS::InvalidAction"
|
100
115
|
end
|
@@ -107,7 +122,6 @@ class SQSTest < Test::Unit::TestCase
|
|
107
122
|
end
|
108
123
|
end
|
109
124
|
|
110
|
-
|
111
125
|
def test_get_exception_class
|
112
126
|
assert_raises ArgumentError do
|
113
127
|
SQS.get_exception_class
|
@@ -517,7 +531,6 @@ class SQSTest < Test::Unit::TestCase
|
|
517
531
|
assert_equal 'SENDMESSAGE', SQS.permissions( 'SENDMESSAGE' )
|
518
532
|
assert_equal 'FULLCONTROL', SQS.permissions( 'FULLCONTROL' )
|
519
533
|
end
|
520
|
-
|
521
534
|
end
|
522
535
|
|
523
536
|
|
metadata
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: SQS
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-07-18 00:00:00 -07:00
|
8
|
-
summary: A Ruby interface to Amazon's Simple Queue Service
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: z@wzph.com
|
12
|
-
homepage:
|
13
|
-
rubyforge_project: SQS
|
14
|
-
description: SQS is a Ruby interface to Amazon's Simple Queue Service. SQS uses the Query API, exposing all the published API calls, plus a few more. For more information on the Simple Queue Service, see http://www.amazonaws.com
|
15
|
-
autorequire: sqs
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.1.6
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
|
-
-
|
7
|
+
- Zach Holt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-20 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: SQS is a Ruby interface to Amazon's Simple Queue Service. SQS uses the Query API, exposing all the published API calls, plus a few more. For more information on the Simple Queue Service, see http://www.amazonaws.com
|
17
|
+
email: z@wzph.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- MIT-LICENSE
|
25
|
+
- CHANGELOG
|
31
26
|
files:
|
32
27
|
- lib/sqs.rb
|
33
28
|
- lib/sqs/grant.rb
|
@@ -42,6 +37,32 @@ files:
|
|
42
37
|
- README
|
43
38
|
- MIT-LICENSE
|
44
39
|
- CHANGELOG
|
40
|
+
has_rdoc: false
|
41
|
+
homepage: http://sqs.rubyforge.org
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: SQS
|
62
|
+
rubygems_version: 1.0.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 2
|
65
|
+
summary: A Ruby interface to Amazon's Simple Queue Service
|
45
66
|
test_files:
|
46
67
|
- test/all_tests.rb
|
47
68
|
- test/unit/sqs_grant_test.rb
|
@@ -49,17 +70,3 @@ test_files:
|
|
49
70
|
- test/unit/sqs_queue_test.rb
|
50
71
|
- test/unit/sqs_test.rb
|
51
72
|
- test/unit/test_setup.rb
|
52
|
-
rdoc_options: []
|
53
|
-
|
54
|
-
extra_rdoc_files:
|
55
|
-
- README
|
56
|
-
- MIT-LICENSE
|
57
|
-
- CHANGELOG
|
58
|
-
executables: []
|
59
|
-
|
60
|
-
extensions: []
|
61
|
-
|
62
|
-
requirements: []
|
63
|
-
|
64
|
-
dependencies: []
|
65
|
-
|