kerryb-right_aws 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +172 -0
- data/Manifest.txt +32 -0
- data/README.txt +146 -0
- data/Rakefile +96 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/file_fix.rb +33 -0
- data/lib/awsbase/right_awsbase.rb +660 -0
- data/lib/awsbase/support.rb +111 -0
- data/lib/ec2/right_ec2.rb +1223 -0
- data/lib/right_aws.rb +69 -0
- data/lib/s3/right_s3.rb +1056 -0
- data/lib/s3/right_s3_interface.rb +990 -0
- data/lib/sdb/active_sdb.rb +695 -0
- data/lib/sdb/right_sdb_interface.rb +475 -0
- data/lib/sqs/right_sqs.rb +380 -0
- data/lib/sqs/right_sqs_gen2.rb +278 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +451 -0
- data/lib/sqs/right_sqs_interface.rb +604 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +76 -0
- data/test/http_connection.rb +87 -0
- data/test/s3/test_helper.rb +2 -0
- data/test/s3/test_right_s3.rb +388 -0
- data/test/s3/test_right_s3_stubbed.rb +95 -0
- data/test/sdb/test_active_sdb.rb +249 -0
- data/test/sdb/test_helper.rb +2 -0
- data/test/sdb/test_right_sdb.rb +147 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +291 -0
- data/test/sqs/test_right_sqs_gen2.rb +209 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +13 -0
- metadata +106 -0
@@ -0,0 +1,209 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestSqsGen2 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
GRANTEE_EMAIL_ADDRESS = 'fester@example.com'
|
6
|
+
RIGHT_MESSAGE_TEXT = 'Right test message'
|
7
|
+
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@sqs = Rightscale::SqsGen2Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
11
|
+
@queue_name = 'right_sqs_test_gen2_queue'
|
12
|
+
# for classes
|
13
|
+
@s = Rightscale::SqsGen2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Wait for the queue to appear in the queues list.
|
17
|
+
# Amazon needs some time to after the queue creation to place
|
18
|
+
# it to the accessible queues list. If we dont want to get
|
19
|
+
# the additional faults then wait a bit...
|
20
|
+
def wait_for_queue_url(queue_name)
|
21
|
+
queue_url = nil
|
22
|
+
until queue_url
|
23
|
+
queue_url = @sqs.queue_url_by_name(queue_name)
|
24
|
+
unless queue_url
|
25
|
+
print '-'
|
26
|
+
STDOUT.flush
|
27
|
+
sleep 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
queue_url
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#---------------------------
|
35
|
+
# Rightscale::SqsInterface
|
36
|
+
#---------------------------
|
37
|
+
|
38
|
+
def test_01_create_queue
|
39
|
+
queue_url = @sqs.create_queue @queue_name
|
40
|
+
assert queue_url[/http.*#{@queue_name}/], 'New queue creation failed'
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_02_list_queues
|
44
|
+
wait_for_queue_url(@queue_name)
|
45
|
+
queues = @sqs.list_queues('right_')
|
46
|
+
assert queues.size>0, 'Must more that 0 queues in list'
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_03_set_and_get_queue_attributes
|
50
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
51
|
+
assert queue_url[/http.*#{@queue_name}/], "#{@queue_name} must exist!"
|
52
|
+
assert @sqs.set_queue_attributes(queue_url, 'VisibilityTimeout', 111), 'Set_queue_attributes fail'
|
53
|
+
sleep 20 # Amazon needs some time to change attribute
|
54
|
+
assert_equal '111', @sqs.get_queue_attributes(queue_url)['VisibilityTimeout'], 'New VisibilityTimeout must be equal to 111'
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_06_send_message
|
58
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
59
|
+
# send 5 messages for the tests below
|
60
|
+
assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
|
61
|
+
assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
|
62
|
+
assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
|
63
|
+
assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
|
64
|
+
assert @sqs.send_message(queue_url, RIGHT_MESSAGE_TEXT)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_07_get_queue_length
|
68
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
69
|
+
assert_equal 5, @sqs.get_queue_length(queue_url), 'Queue must have 5 messages'
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_08_receive_message
|
73
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
74
|
+
r_message = @sqs.receive_message(queue_url, 1)[0]
|
75
|
+
assert r_message, "Receive returned no message(s), but this is not necessarily incorrect"
|
76
|
+
assert_equal RIGHT_MESSAGE_TEXT, r_message['Body'], 'Receive message got wrong message text'
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_09_delete_message
|
80
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
81
|
+
message = @sqs.receive_message(queue_url)[0]
|
82
|
+
assert @sqs.delete_message(queue_url, message['ReceiptHandle']), 'Delete_message fail'
|
83
|
+
assert @sqs.pop_message(queue_url), 'Pop_message fail'
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_10_clear_and_delete_queue
|
87
|
+
queue_url = @sqs.queue_url_by_name(@queue_name)
|
88
|
+
assert @sqs.delete_queue(queue_url)
|
89
|
+
end
|
90
|
+
|
91
|
+
#---------------------------
|
92
|
+
# Rightscale::Sqs classes
|
93
|
+
#---------------------------
|
94
|
+
|
95
|
+
def test_20_sqs_create_delete_queue
|
96
|
+
assert @s, 'Rightscale::SqsGen2 must exist'
|
97
|
+
# get queues list
|
98
|
+
queues_size = @s.queues.size
|
99
|
+
# create new queue
|
100
|
+
queue = @s.queue("#{@queue_name}_20", true)
|
101
|
+
# check that it is created
|
102
|
+
assert queue.is_a?(Rightscale::SqsGen2::Queue)
|
103
|
+
wait_for_queue_url(@queue_name)
|
104
|
+
# check that amount of queues has increased
|
105
|
+
assert_equal queues_size + 1, @s.queues.size
|
106
|
+
# delete queue
|
107
|
+
assert queue.delete
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_21_queue_create
|
111
|
+
# create new queue
|
112
|
+
queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_21", true)
|
113
|
+
# check that it is created
|
114
|
+
assert queue.is_a?(Rightscale::SqsGen2::Queue)
|
115
|
+
wait_for_queue_url(@queue_name)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_22_queue_attributes
|
119
|
+
queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_21", false)
|
120
|
+
# get a list of attrinutes
|
121
|
+
attributes = queue.get_attribute
|
122
|
+
assert attributes.is_a?(Hash) && attributes.size>0
|
123
|
+
# get attribute value and increase it by 10
|
124
|
+
v = (queue.get_attribute('VisibilityTimeout').to_i + 10).to_s
|
125
|
+
# set attribute
|
126
|
+
assert queue.set_attribute('VisibilityTimeout', v)
|
127
|
+
# wait a bit
|
128
|
+
sleep 20
|
129
|
+
# check that attribute has changed
|
130
|
+
assert_equal v, queue.get_attribute('VisibilityTimeout')
|
131
|
+
# get queue visibility timeout
|
132
|
+
assert_equal v, queue.visibility
|
133
|
+
# change it
|
134
|
+
queue.visibility = queue.visibility.to_i + 10
|
135
|
+
# make sure that it is changed
|
136
|
+
assert v.to_i + 10, queue.visibility
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_24_send_size
|
140
|
+
queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", true)
|
141
|
+
# send 5 messages
|
142
|
+
assert queue.push('a1')
|
143
|
+
assert queue.push('a2')
|
144
|
+
assert queue.push('a3')
|
145
|
+
assert queue.push('a4')
|
146
|
+
assert queue.push('a5')
|
147
|
+
# check queue size
|
148
|
+
assert_equal 5, queue.size
|
149
|
+
# send one more
|
150
|
+
assert queue.push('a6')
|
151
|
+
# check queue size again
|
152
|
+
assert_equal 6, queue.size
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_25_message_receive_pop_delete
|
156
|
+
queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", false)
|
157
|
+
# get queue size
|
158
|
+
size = queue.size
|
159
|
+
# get first message
|
160
|
+
m1 = queue.receive(10)
|
161
|
+
assert m1.is_a?(Rightscale::SqsGen2::Message)
|
162
|
+
# pop second message
|
163
|
+
m2 = queue.pop
|
164
|
+
assert m2.is_a?(Rightscale::SqsGen2::Message)
|
165
|
+
# make sure that queue size has decreased
|
166
|
+
assert_equal size-1, queue.size
|
167
|
+
# delete messsage
|
168
|
+
assert m1.delete
|
169
|
+
# make sure that queue size has decreased again
|
170
|
+
assert_equal size-2, queue.size
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_26
|
174
|
+
queue = Rightscale::SqsGen2::Queue.create(@s, "#{@queue_name}_24", false)
|
175
|
+
# lock message
|
176
|
+
queue.receive(100)
|
177
|
+
# clear queue
|
178
|
+
assert queue.clear
|
179
|
+
# queue size is greater than zero
|
180
|
+
assert queue.size>0
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_27_set_amazon_problems
|
184
|
+
original_problems = Rightscale::SqsGen2Interface.amazon_problems
|
185
|
+
assert(original_problems.length > 0)
|
186
|
+
Rightscale::SqsGen2Interface.amazon_problems= original_problems << "A New Problem"
|
187
|
+
new_problems = Rightscale::SqsGen2Interface.amazon_problems
|
188
|
+
assert_equal(new_problems, original_problems)
|
189
|
+
|
190
|
+
Rightscale::SqsGen2Interface.amazon_problems= nil
|
191
|
+
assert_nil(Rightscale::SqsGen2Interface.amazon_problems)
|
192
|
+
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
|
+
|
209
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class TestCredentials
|
2
|
+
|
3
|
+
@@aws_access_key_id = nil
|
4
|
+
@@aws_secret_access_key = nil
|
5
|
+
@@account_number = nil
|
6
|
+
|
7
|
+
def self.aws_access_key_id
|
8
|
+
@@aws_access_key_id
|
9
|
+
end
|
10
|
+
def self.aws_access_key_id=(newval)
|
11
|
+
@@aws_access_key_id = newval
|
12
|
+
end
|
13
|
+
def self.account_number
|
14
|
+
@@account_number
|
15
|
+
end
|
16
|
+
def self.account_number=(newval)
|
17
|
+
@@account_number = newval
|
18
|
+
end
|
19
|
+
def self.aws_secret_access_key
|
20
|
+
@@aws_secret_access_key
|
21
|
+
end
|
22
|
+
def self.aws_secret_access_key=(newval)
|
23
|
+
@@aws_secret_access_key = newval
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_credentials
|
27
|
+
Dir.chdir do
|
28
|
+
begin
|
29
|
+
Dir.chdir('./.rightscale') do
|
30
|
+
require 'testcredentials'
|
31
|
+
end
|
32
|
+
rescue Exception => e
|
33
|
+
puts "Couldn't chdir to ~/.rightscale: #{e.message}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$: << File.dirname(__FILE__)
|
3
|
+
require 'test_credentials'
|
4
|
+
TestCredentials.get_credentials
|
5
|
+
|
6
|
+
require 'http_connection'
|
7
|
+
require 'awsbase/test_right_awsbase.rb'
|
8
|
+
require 'ec2/test_right_ec2.rb'
|
9
|
+
require 's3/test_right_s3.rb'
|
10
|
+
require 's3/test_right_s3_stubbed.rb'
|
11
|
+
require 'sqs/test_right_sqs.rb'
|
12
|
+
require 'sqs/test_right_sqs_gen2.rb'
|
13
|
+
require 'sdb/test_right_sdb.rb'
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kerryb-right_aws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- RightScale, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-04 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: right_http_connection
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.9.0
|
34
|
+
version:
|
35
|
+
description: "== DESCRIPTION: The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, Amazon S3, Amazon SQS, and Amazon SDB. 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) - 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) == FEATURES:"
|
36
|
+
email: support@rightscale.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- History.txt
|
43
|
+
- Manifest.txt
|
44
|
+
- README.txt
|
45
|
+
files:
|
46
|
+
- History.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.txt
|
49
|
+
- Rakefile
|
50
|
+
- lib/awsbase/benchmark_fix.rb
|
51
|
+
- lib/awsbase/file_fix.rb
|
52
|
+
- lib/awsbase/right_awsbase.rb
|
53
|
+
- lib/awsbase/support.rb
|
54
|
+
- lib/ec2/right_ec2.rb
|
55
|
+
- lib/right_aws.rb
|
56
|
+
- lib/s3/right_s3.rb
|
57
|
+
- lib/s3/right_s3_interface.rb
|
58
|
+
- lib/sdb/active_sdb.rb
|
59
|
+
- lib/sdb/right_sdb_interface.rb
|
60
|
+
- lib/sqs/right_sqs.rb
|
61
|
+
- lib/sqs/right_sqs_gen2.rb
|
62
|
+
- lib/sqs/right_sqs_gen2_interface.rb
|
63
|
+
- lib/sqs/right_sqs_interface.rb
|
64
|
+
- test/ec2/test_helper.rb
|
65
|
+
- test/ec2/test_right_ec2.rb
|
66
|
+
- test/http_connection.rb
|
67
|
+
- test/s3/test_helper.rb
|
68
|
+
- test/s3/test_right_s3.rb
|
69
|
+
- test/s3/test_right_s3_stubbed.rb
|
70
|
+
- test/sdb/test_active_sdb.rb
|
71
|
+
- test/sdb/test_helper.rb
|
72
|
+
- test/sdb/test_right_sdb.rb
|
73
|
+
- test/sqs/test_helper.rb
|
74
|
+
- test/sqs/test_right_sqs.rb
|
75
|
+
- test/sqs/test_right_sqs_gen2.rb
|
76
|
+
- test/test_credentials.rb
|
77
|
+
- test/ts_right_aws.rb
|
78
|
+
has_rdoc: true
|
79
|
+
homepage:
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options:
|
82
|
+
- --main
|
83
|
+
- README.txt
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: rightaws
|
101
|
+
rubygems_version: 1.2.0
|
102
|
+
signing_key:
|
103
|
+
specification_version: 2
|
104
|
+
summary: Interface classes for the Amazon EC2, SQS, and S3 Web Services
|
105
|
+
test_files:
|
106
|
+
- test/ts_right_aws.rb
|