right_aws 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +38 -0
- data/Manifest.txt +3 -0
- data/README.txt +23 -6
- data/Rakefile +8 -1
- data/lib/awsbase/right_awsbase.rb +113 -21
- data/lib/awsbase/support.rb +8 -0
- data/lib/ec2/right_ec2.rb +46 -76
- data/lib/right_aws.rb +4 -3
- data/lib/s3/right_s3.rb +85 -37
- data/lib/s3/right_s3_interface.rb +173 -56
- data/lib/sdb/right_sdb_interface.rb +470 -0
- data/test/s3/test_right_s3.rb +36 -13
- data/test/sdb/test_helper.rb +2 -0
- data/test/sdb/test_right_sdb.rb +128 -0
- data/test/ts_right_aws.rb +1 -1
- metadata +8 -5
data/test/s3/test_right_s3.rb
CHANGED
@@ -7,8 +7,9 @@ class TestS3 < Test::Unit::TestCase
|
|
7
7
|
def setup
|
8
8
|
@s3 = Rightscale::S3Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
9
9
|
@bucket = 'right_s3_awesome_test_bucket'
|
10
|
-
@key1 = 'test/woohoo1'
|
10
|
+
@key1 = 'test/woohoo1/'
|
11
11
|
@key2 = 'test1/key/woohoo2'
|
12
|
+
@key3 = 'test2/A%B@C_D&E?F+G=H"I'
|
12
13
|
@s = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
13
14
|
end
|
14
15
|
|
@@ -31,6 +32,7 @@ class TestS3 < Test::Unit::TestCase
|
|
31
32
|
def test_04_put
|
32
33
|
assert @s3.put(@bucket, @key1, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo1!'), 'Put bucket fail'
|
33
34
|
assert @s3.put(@bucket, @key2, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo2!'), 'Put bucket fail'
|
35
|
+
assert @s3.put(@bucket, @key3, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo3!'), 'Put bucket fail'
|
34
36
|
end
|
35
37
|
|
36
38
|
def test_05_get_and_get_object
|
@@ -39,6 +41,7 @@ class TestS3 < Test::Unit::TestCase
|
|
39
41
|
assert_equal RIGHT_OBJECT_TEXT, data1[:object], "Object text must be equal to '#{RIGHT_OBJECT_TEXT}'"
|
40
42
|
assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key1), "Get_object text must return '#{RIGHT_OBJECT_TEXT}'"
|
41
43
|
assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
|
44
|
+
assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key3), "Get_object text must return '#{RIGHT_OBJECT_TEXT}'"
|
42
45
|
end
|
43
46
|
|
44
47
|
def test_06_head
|
@@ -63,12 +66,20 @@ class TestS3 < Test::Unit::TestCase
|
|
63
66
|
assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
|
64
67
|
end
|
65
68
|
|
66
|
-
def
|
69
|
+
def test_08_keys
|
70
|
+
keys = @s3.list_bucket(@bucket).map{|b| b[:key]}
|
71
|
+
assert_equal keys.size, 3, "There should be 3 keys"
|
72
|
+
assert(keys.include? @key1)
|
73
|
+
assert(keys.include? @key2)
|
74
|
+
assert(keys.include? @key3)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_09_delete_folder
|
67
78
|
assert_equal 1, @s3.delete_folder(@bucket, 'test').size, "Only one key(#{@key1}) must be deleted!"
|
68
79
|
end
|
69
80
|
|
70
81
|
|
71
|
-
def
|
82
|
+
def test_10_delete_bucket
|
72
83
|
assert_raise(Rightscale::AwsError) { @s3.delete_bucket(@bucket) }
|
73
84
|
assert @s3.clear_bucket(@bucket), 'Clear_bucket fail'
|
74
85
|
assert_equal 0, @s3.list_bucket(@bucket).size, 'Bucket must be empty'
|
@@ -98,11 +109,11 @@ class TestS3 < Test::Unit::TestCase
|
|
98
109
|
assert @s.buckets.map{|b| b.name}.include?(@bucket)
|
99
110
|
assert bucket.keys.empty?
|
100
111
|
# put data
|
101
|
-
assert bucket.put(@
|
112
|
+
assert bucket.put(@key3, RIGHT_OBJECT_TEXT, {'family'=>'123456'})
|
102
113
|
# get data and compare
|
103
|
-
assert_equal RIGHT_OBJECT_TEXT, bucket.get(@
|
114
|
+
assert_equal RIGHT_OBJECT_TEXT, bucket.get(@key3)
|
104
115
|
# get key object
|
105
|
-
key = bucket.key(@
|
116
|
+
key = bucket.key(@key3, true)
|
106
117
|
assert_equal Rightscale::S3::Key, key.class
|
107
118
|
assert key.exists?
|
108
119
|
assert_equal '123456', key.meta_headers['family']
|
@@ -111,10 +122,10 @@ class TestS3 < Test::Unit::TestCase
|
|
111
122
|
def test_22_keys
|
112
123
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
113
124
|
# create first key
|
114
|
-
|
115
|
-
|
116
|
-
assert
|
117
|
-
assert_equal '123456',
|
125
|
+
key3 = Rightscale::S3::Key.create(bucket, @key3)
|
126
|
+
key3.refresh
|
127
|
+
assert key3.exists?
|
128
|
+
assert_equal '123456', key3.meta_headers['family']
|
118
129
|
# create second key
|
119
130
|
key2 = Rightscale::S3::Key.create(bucket, @key2)
|
120
131
|
assert !key2.refresh
|
@@ -162,9 +173,10 @@ class TestS3 < Test::Unit::TestCase
|
|
162
173
|
|
163
174
|
def test_32_grant_revoke_drop
|
164
175
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
165
|
-
|
166
|
-
|
167
|
-
|
176
|
+
# Take 'AllUsers' grantee
|
177
|
+
grantee = Rightscale::S3::Grantee.new(bucket,'http://acs.amazonaws.com/groups/global/AllUsers')
|
178
|
+
# Check exists?
|
179
|
+
assert grantee.exists?
|
168
180
|
# Add grant as String
|
169
181
|
assert grantee.grant('WRITE')
|
170
182
|
# Add grants as Array
|
@@ -177,8 +189,19 @@ class TestS3 < Test::Unit::TestCase
|
|
177
189
|
grantee.perms -= ['READ_ACP']
|
178
190
|
grantee.apply
|
179
191
|
assert_equal 2, grantee.perms.size
|
192
|
+
# Check grantee removal if it has no permissions
|
193
|
+
assert grantee.perms = []
|
194
|
+
assert grantee.apply
|
195
|
+
assert !grantee.exists?
|
196
|
+
# Check multiple perms assignment
|
197
|
+
assert grantee.grant 'FULL_CONTROL', 'READ', 'WRITE'
|
198
|
+
assert_equal ['FULL_CONTROL','READ','WRITE'].sort, grantee.perms.sort
|
199
|
+
# Check multiple perms removal
|
200
|
+
assert grantee.revoke 'FULL_CONTROL', 'WRITE'
|
201
|
+
assert_equal ['READ'], grantee.perms
|
180
202
|
# check 'Drop' method
|
181
203
|
assert grantee.drop
|
204
|
+
assert !grantee.exists?
|
182
205
|
assert_equal 1, bucket.grantees.size
|
183
206
|
# Delete bucket
|
184
207
|
bucket.delete(true)
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestSdb < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
STDOUT.sync = true
|
7
|
+
@domain = 'right_sdb_awesome_test_domain'
|
8
|
+
@item = 'toys'
|
9
|
+
@attr = { 'Jon' => %w{beer car} }
|
10
|
+
# Interface instance
|
11
|
+
@sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
SDB_DELAY = 2
|
15
|
+
|
16
|
+
def wait(delay, msg='')
|
17
|
+
print "waiting #{delay} seconds #{msg}"
|
18
|
+
while delay>0 do
|
19
|
+
delay -= 1
|
20
|
+
print '.'
|
21
|
+
sleep 1
|
22
|
+
end
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
|
26
|
+
#---------------------------
|
27
|
+
# Rightscale::SdbInterface
|
28
|
+
#---------------------------
|
29
|
+
|
30
|
+
def test_00_delete_domain
|
31
|
+
# delete the domain to reset all the things
|
32
|
+
assert @sdb.delete_domain(@domain), 'delete_domain fail'
|
33
|
+
wait SDB_DELAY, 'after domain deletion'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_01_create_domain
|
37
|
+
# check that domain does not exist
|
38
|
+
assert !@sdb.list_domains[:domains].include?(@domain)
|
39
|
+
# create domain
|
40
|
+
assert @sdb.create_domain(@domain), 'create_domain fail'
|
41
|
+
wait SDB_DELAY, 'after domain creation'
|
42
|
+
# check that we have received new domain from Amazin
|
43
|
+
assert @sdb.list_domains[:domains].include?(@domain)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_02_put_attributes
|
47
|
+
# put attributes
|
48
|
+
assert @sdb.put_attributes(@domain, @item, @attr)
|
49
|
+
wait SDB_DELAY, 'after putting attributes'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_03_get_attributes
|
53
|
+
# get attributes
|
54
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
|
55
|
+
# compare to original list
|
56
|
+
assert_equal values, @attr['Jon'].sort
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_04_add_attributes
|
60
|
+
# add new attribute
|
61
|
+
new_value = 'girls'
|
62
|
+
@sdb.put_attributes @domain, @item, {'Jon' => new_value}
|
63
|
+
wait SDB_DELAY, 'after putting attributes'
|
64
|
+
# get attributes ('girls' must be added to already existent attributes)
|
65
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
|
66
|
+
assert_equal values, (@attr['Jon'] << new_value).sort
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_05_replace_attributes
|
70
|
+
# replace attributes
|
71
|
+
@sdb.put_attributes @domain, @item, {'Jon' => 'pub'}, :replace
|
72
|
+
wait SDB_DELAY, 'after replacing attributes'
|
73
|
+
# get attributes (all must be removed except of 'pub')
|
74
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
|
75
|
+
assert_equal values, ['pub']
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_06_delete_attribute
|
79
|
+
# add value 'girls' and 'vodka' to 'Jon'
|
80
|
+
@sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
|
81
|
+
wait SDB_DELAY, 'after adding attributes'
|
82
|
+
# get attributes ('girls' and 'vodka' must be added 'pub')
|
83
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
|
84
|
+
assert_equal values, ['girls', 'pub', 'vodka']
|
85
|
+
# delete a single value 'girls' from attribute 'Jon'
|
86
|
+
@sdb.delete_attributes @domain, @item, 'Jon' => ['girls']
|
87
|
+
wait SDB_DELAY, 'after the deletion of attribute'
|
88
|
+
# get attributes ('girls' must be removed)
|
89
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
|
90
|
+
assert_equal values, ['pub', 'vodka']
|
91
|
+
# delete all values from attribute 'Jon'
|
92
|
+
@sdb.delete_attributes @domain, @item, ['Jon']
|
93
|
+
wait SDB_DELAY, 'after the deletion of attributes'
|
94
|
+
# get attributes (values must be empty)
|
95
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
|
96
|
+
assert_equal values, nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_07_delete_item
|
100
|
+
@sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
|
101
|
+
wait SDB_DELAY, 'after adding attributes'
|
102
|
+
# get attributes ('girls' and 'vodka' must be there)
|
103
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].to_a.sort
|
104
|
+
assert_equal values, ['girls', 'vodka']
|
105
|
+
# delete an item
|
106
|
+
@sdb.delete_attributes @domain, @item
|
107
|
+
# get attributes (values must be empty)
|
108
|
+
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon']
|
109
|
+
assert_equal values, nil
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_08_query
|
113
|
+
# add some values for query
|
114
|
+
@sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
|
115
|
+
wait SDB_DELAY, 'after adding attributes'
|
116
|
+
items = @sdb.query(@domain, ['[?=?]', 'Jon','vodka'])[:items]
|
117
|
+
assert_equal items.size, 1
|
118
|
+
assert_equal items.first, @item
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_09_delete_domain
|
122
|
+
assert @sdb.delete_domain(@domain), 'delete_domain fail'
|
123
|
+
wait SDB_DELAY, 'after domain deletion'
|
124
|
+
# check that domain does not exist
|
125
|
+
assert !@sdb.list_domains[:domains].include?(@domain)
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
data/test/ts_right_aws.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: right_aws
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date:
|
6
|
+
version: 1.5.0
|
7
|
+
date: 2008-02-11 00:00:00 -08:00
|
8
8
|
summary: Interface classes for the Amazon EC2, SQS, and S3 Web Services
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: support@rightscale.com
|
12
12
|
homepage:
|
13
13
|
rubyforge_project: rightaws
|
14
|
-
description: "== DESCRIPTION: The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, Amazon
|
14
|
+
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 Amazon SQS (Simple Queue Service) - RightAws::SdbInterface -- interface to Amazon SDB (SimpleDB) == FEATURES:"
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/ec2/right_ec2.rb
|
41
41
|
- lib/s3/right_s3.rb
|
42
42
|
- lib/s3/right_s3_interface.rb
|
43
|
+
- lib/sdb/right_sdb_interface.rb
|
43
44
|
- lib/sqs/right_sqs.rb
|
44
45
|
- lib/sqs/right_sqs_interface.rb
|
45
46
|
- test/ec2/test_helper.rb
|
@@ -47,6 +48,8 @@ files:
|
|
47
48
|
- test/s3/test_helper.rb
|
48
49
|
- test/s3/test_right_s3.rb
|
49
50
|
- test/s3/test_right_s3_stubbed.rb
|
51
|
+
- test/sdb/test_right_sdb.rb
|
52
|
+
- test/sdb/test_helper.rb
|
50
53
|
- test/sqs/test_helper.rb
|
51
54
|
- test/sqs/test_right_sqs.rb
|
52
55
|
- test/ts_right_aws.rb
|
@@ -75,7 +78,7 @@ dependencies:
|
|
75
78
|
requirements:
|
76
79
|
- - ">="
|
77
80
|
- !ruby/object:Gem::Version
|
78
|
-
version: 1.2.
|
81
|
+
version: 1.2.1
|
79
82
|
version:
|
80
83
|
- !ruby/object:Gem::Dependency
|
81
84
|
name: hoe
|