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.
- data/History.txt +53 -15
- data/Manifest.txt +16 -0
- data/README.txt +10 -9
- data/Rakefile +13 -15
- data/lib/acf/right_acf_interface.rb +224 -118
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +236 -0
- data/lib/acw/right_acw_interface.rb +249 -0
- data/lib/as/right_as_interface.rb +699 -0
- data/lib/awsbase/right_awsbase.rb +232 -51
- data/lib/awsbase/support.rb +4 -0
- data/lib/ec2/right_ec2.rb +33 -1375
- data/lib/ec2/right_ec2_ebs.rb +452 -0
- data/lib/ec2/right_ec2_images.rb +373 -0
- data/lib/ec2/right_ec2_instances.rb +755 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +170 -0
- data/lib/ec2/right_ec2_security_groups.rb +280 -0
- data/lib/ec2/right_ec2_spot_instances.rb +399 -0
- data/lib/ec2/right_ec2_vpc.rb +571 -0
- data/lib/elb/right_elb_interface.rb +496 -0
- data/lib/rds/right_rds_interface.rb +998 -0
- data/lib/right_aws.rb +18 -4
- data/lib/s3/right_s3.rb +39 -7
- data/lib/s3/right_s3_interface.rb +77 -53
- data/lib/sdb/active_sdb.rb +203 -11
- data/lib/sdb/right_sdb_interface.rb +68 -45
- data/lib/sqs/right_sqs_gen2.rb +73 -16
- data/lib/sqs/right_sqs_gen2_interface.rb +131 -51
- data/lib/sqs/right_sqs_interface.rb +2 -4
- data/test/acf/test_right_acf.rb +10 -18
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -0
- data/test/s3/test_right_s3.rb +10 -8
- data/test/s3/test_right_s3_stubbed.rb +6 -4
- data/test/sdb/test_active_sdb.rb +70 -12
- data/test/sdb/test_right_sdb.rb +13 -7
- data/test/sqs/test_right_sqs_gen2.rb +104 -49
- metadata +103 -14
@@ -56,7 +56,7 @@ module RightAws
|
|
56
56
|
# {:server => 'queue.amazonaws.com' # Amazon service host: 'queue.amazonaws.com'(default)
|
57
57
|
# :port => 443 # Amazon service port: 80 or 443(default)
|
58
58
|
# :multi_thread => true|false # Multi-threaded (connection per each thread): true or false(default)
|
59
|
-
# :signature_version => '0' # The signature version : '0' or '
|
59
|
+
# :signature_version => '0' # The signature version : '0', '1' or '2'(default)
|
60
60
|
# :logger => Logger Object} # Logger instance: logs to STDOUT if omitted }
|
61
61
|
#
|
62
62
|
def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
|
@@ -128,9 +128,7 @@ module RightAws
|
|
128
128
|
# Sends request to Amazon and parses the response
|
129
129
|
# Raises AwsError if any banana happened
|
130
130
|
def request_info(request, parser) # :nodoc:
|
131
|
-
|
132
|
-
thread[:sqs_connection] ||= Rightscale::HttpConnection.new(:exception => AwsError, :logger => @logger)
|
133
|
-
request_info_impl(thread[:sqs_connection], @@bench, request, parser)
|
131
|
+
request_info_impl(:sqs_connection, @@bench, request, parser)
|
134
132
|
end
|
135
133
|
|
136
134
|
|
data/test/acf/test_right_acf.rb
CHANGED
@@ -9,7 +9,7 @@ class TestAcf < Test::Unit::TestCase
|
|
9
9
|
def setup
|
10
10
|
@acf= Rightscale::AcfInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
11
11
|
@s3 = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
12
|
-
@bucket_name = "right-acf-awesome-test-bucket-
|
12
|
+
@bucket_name = "right-acf-awesome-test-bucket-xxx1"
|
13
13
|
@bucket_domain = "#{@bucket_name}.s3.amazonaws.com"
|
14
14
|
end
|
15
15
|
|
@@ -27,13 +27,18 @@ class TestAcf < Test::Unit::TestCase
|
|
27
27
|
@acf.create_distribution("right-cloudfront-awesome-test-bucket-not-exist", "Mustn't to be born", true)
|
28
28
|
end
|
29
29
|
# a bucket is not a domain naming complied guy
|
30
|
-
bucket_name = '
|
30
|
+
bucket_name = 'right_cloudfront_awesome_test_bucket_BAD_XXX'
|
31
31
|
@s3.bucket(bucket_name, :create)
|
32
32
|
assert_raise(Rightscale::AwsError) do
|
33
33
|
@acf.create_distribution(bucket_name, "Mustn't to be born", true)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_02_x_delete_bad_bucket
|
38
|
+
bucket_name = 'right_cloudfront_awesome_test_bucket_BAD_XXX'
|
39
|
+
@s3.bucket(bucket_name, false).delete
|
40
|
+
end
|
41
|
+
|
37
42
|
def test_03_create
|
38
43
|
comment = 'WooHoo!!!'
|
39
44
|
# create a test bucket
|
@@ -69,8 +74,8 @@ class TestAcf < Test::Unit::TestCase
|
|
69
74
|
end
|
70
75
|
# change a config
|
71
76
|
config[:enabled] = false
|
72
|
-
config[:cnames] << '
|
73
|
-
config[:cnames] << '
|
77
|
+
config[:cnames] << 'xxx1.myawesomesite.com'
|
78
|
+
config[:cnames] << 'xxx2.myawesomesite.com'
|
74
79
|
# set config
|
75
80
|
set_config_result = nil
|
76
81
|
assert_nothing_raised do
|
@@ -83,7 +88,7 @@ class TestAcf < Test::Unit::TestCase
|
|
83
88
|
new_config = @acf.get_distribution_config(old[:aws_id])
|
84
89
|
end
|
85
90
|
assert !new_config[:enabled]
|
86
|
-
assert_equal new_config[:cnames].sort, ['
|
91
|
+
assert_equal new_config[:cnames].sort, ['xxx1.myawesomesite.com', 'xxx2.myawesomesite.com']
|
87
92
|
assert_not_equal config[:e_tag], new_config[:e_tag]
|
88
93
|
|
89
94
|
# try to update the old config again (must fail because ETAG has changed)
|
@@ -92,19 +97,6 @@ class TestAcf < Test::Unit::TestCase
|
|
92
97
|
end
|
93
98
|
end
|
94
99
|
|
95
|
-
def test_07_caching
|
96
|
-
# enable caching
|
97
|
-
@acf.params[:cache] = true
|
98
|
-
# list distributions
|
99
|
-
@acf.list_distributions
|
100
|
-
# list the distributions again - cache should hit
|
101
|
-
assert_raise(Rightscale::AwsNoChange) do
|
102
|
-
@acf.list_distributions
|
103
|
-
end
|
104
|
-
# disable caching
|
105
|
-
@acf.params[:cache] = true
|
106
|
-
end
|
107
|
-
|
108
100
|
def test_08_delete_distribution
|
109
101
|
# we need ETAG so use get_distribution
|
110
102
|
distribution = @acf.get_distribution(get_test_distribution[:aws_id])
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestRds < Test::Unit::TestCase
|
4
|
+
|
5
|
+
STDOUT.sync = true
|
6
|
+
|
7
|
+
TEST_SG_NAME = 'RightRdsSGTest0123456789'
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@rds = Rightscale::RdsInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_00_instances
|
14
|
+
assert_nothing_raised do
|
15
|
+
items = @rds.describe_db_instances
|
16
|
+
assert items.is_a?(Array)
|
17
|
+
end
|
18
|
+
#
|
19
|
+
assert_nothing_raised do
|
20
|
+
@rds.describe_db_instances do |response|
|
21
|
+
assert response.is_a?(Hash)
|
22
|
+
assert response[:db_instances].is_a?(Array)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_10_security_groups
|
28
|
+
assert_nothing_raised do
|
29
|
+
items = @rds.describe_db_security_groups
|
30
|
+
assert items.is_a?(Array)
|
31
|
+
end
|
32
|
+
#
|
33
|
+
assert_nothing_raised do
|
34
|
+
@rds.describe_db_security_groups do |response|
|
35
|
+
assert response.is_a?(Hash)
|
36
|
+
assert response[:db_security_groups].is_a?(Array)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_11_remove_security_group
|
42
|
+
@rds.delete_db_security_group rescue nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_12_create_security_group
|
46
|
+
sg = nil
|
47
|
+
assert_nothing_raised do
|
48
|
+
sg = @rds.create_db_security_group(TEST_SG_NAME, 'sg-description')
|
49
|
+
end
|
50
|
+
assert sg.is_a?(Hash)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_13_authorize
|
54
|
+
assert_nothing_raised do
|
55
|
+
sg = @rds.authorize_db_security_group_ingress(TEST_SG_NAME, :cidrip => '131.0.0.1/8')
|
56
|
+
assert sg.is_a?(Hash)
|
57
|
+
assert_equal 1, sg[:ip_ranges].size
|
58
|
+
end
|
59
|
+
assert_nothing_raised do
|
60
|
+
sg = @rds.authorize_db_security_group_ingress(TEST_SG_NAME, :ec2_security_group_owner => '826693181925',
|
61
|
+
:ec2_security_group_name => 'default' )
|
62
|
+
assert sg.is_a?(Hash)
|
63
|
+
assert_equal 1, sg[:ec2_security_groups].size
|
64
|
+
end
|
65
|
+
sleep 30
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_14_revoke
|
69
|
+
assert_nothing_raised do
|
70
|
+
sg = @rds.revoke_db_security_group_ingress(TEST_SG_NAME, :cidrip => '131.0.0.1/8')
|
71
|
+
assert sg.is_a?(Hash)
|
72
|
+
end
|
73
|
+
assert_nothing_raised do
|
74
|
+
sg = @rds.revoke_db_security_group_ingress(TEST_SG_NAME, :ec2_security_group_owner => '826693181925',
|
75
|
+
:ec2_security_group_name => 'default' )
|
76
|
+
assert sg.is_a?(Hash)
|
77
|
+
end
|
78
|
+
sleep 30
|
79
|
+
#
|
80
|
+
sg = @rds.describe_db_security_groups(TEST_SG_NAME).first
|
81
|
+
assert_equal 0, sg[:ip_ranges].size
|
82
|
+
assert_equal 0, sg[:ec2_security_groups].size
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_15_delete_security_group
|
86
|
+
assert_nothing_raised do
|
87
|
+
@rds.delete_db_security_group(TEST_SG_NAME)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def test_20_db_snapshots
|
93
|
+
assert_nothing_raised do
|
94
|
+
items = @rds.describe_db_snapshots
|
95
|
+
assert items.is_a?(Array)
|
96
|
+
end
|
97
|
+
#
|
98
|
+
assert_nothing_raised do
|
99
|
+
@rds.describe_db_snapshots do |response|
|
100
|
+
assert response.is_a?(Hash)
|
101
|
+
assert response[:db_snapshots].is_a?(Array)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_30_events
|
107
|
+
assert_nothing_raised do
|
108
|
+
items = @rds.describe_events
|
109
|
+
assert items.is_a?(Array)
|
110
|
+
end
|
111
|
+
#
|
112
|
+
assert_nothing_raised do
|
113
|
+
@rds.describe_events do |response|
|
114
|
+
assert response.is_a?(Hash)
|
115
|
+
assert response[:events].is_a?(Array)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
data/test/s3/test_right_s3.rb
CHANGED
@@ -6,8 +6,8 @@ class TestS3 < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@s3 = Rightscale::S3Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
9
|
-
@bucket = '
|
10
|
-
@bucket2 = '
|
9
|
+
@bucket = 'right_s3_awesome_test_bucket_000B1'
|
10
|
+
@bucket2 = 'right_s3_awesome_test_bucket_000B2'
|
11
11
|
@key1 = 'test/woohoo1/'
|
12
12
|
@key2 = 'test1/key/woohoo2'
|
13
13
|
@key3 = 'test2/A%B@C_D&E?F+G=H"I'
|
@@ -403,17 +403,19 @@ class TestS3 < Test::Unit::TestCase
|
|
403
403
|
assert grantee.grant(['READ_ACP', 'WRITE'])
|
404
404
|
|
405
405
|
assert bucket.enable_logging(:targetbucket => targetbucket, :targetprefix => "loggylogs/")
|
406
|
+
sleep 10
|
406
407
|
|
407
|
-
assert_equal(
|
408
|
+
assert_equal({:enabled => true, :targetbucket => @bucket2, :targetprefix => "loggylogs/"}, bucket.logging_info)
|
408
409
|
|
409
410
|
assert bucket.disable_logging
|
410
411
|
|
411
412
|
# check 'Drop' method
|
412
|
-
assert grantee.drop
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
413
|
+
assert grantee.drop
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_40_delete_buckets
|
417
|
+
Rightscale::S3::Bucket.create(@s, @bucket, false).delete(true)
|
418
|
+
Rightscale::S3::Bucket.create(@s, @bucket2, false).delete(true)
|
417
419
|
end
|
418
420
|
|
419
421
|
end
|
@@ -81,15 +81,17 @@ class TestS3Stubbed < Test::Unit::TestCase
|
|
81
81
|
def test_116_move_key
|
82
82
|
# move a key
|
83
83
|
Rightscale::HttpConnection.push(413, 'not found')
|
84
|
-
|
85
|
-
|
84
|
+
assert_raise RightAws::AwsError do
|
85
|
+
@s3.move(@bucket, @key1, @bucket, @key1_new_name)
|
86
|
+
end
|
86
87
|
end
|
87
88
|
|
88
89
|
def test_117_rename_key
|
89
90
|
# rename a key
|
90
91
|
Rightscale::HttpConnection.push(500, 'not found')
|
91
|
-
|
92
|
-
|
92
|
+
assert_raise RightAws::AwsError do
|
93
|
+
@s3.rename(@bucket, @key2, @key2_new_name)
|
94
|
+
end
|
93
95
|
end
|
94
96
|
|
95
97
|
end
|
data/test/sdb/test_active_sdb.rb
CHANGED
@@ -1,11 +1,25 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
3
|
class TestSdb < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
DOMAIN_PREFIX = 'right_sdb_awesome_test'
|
5
|
+
CLIENT_DOMAIN = "#{DOMAIN_PREFIX}_client"
|
6
|
+
PERSON_DOMAIN = "#{DOMAIN_PREFIX}_person"
|
7
|
+
|
7
8
|
class Client < RightAws::ActiveSdb::Base
|
8
|
-
set_domain_name
|
9
|
+
set_domain_name CLIENT_DOMAIN
|
10
|
+
end
|
11
|
+
|
12
|
+
class Person < RightAws::ActiveSdb::Base
|
13
|
+
set_domain_name PERSON_DOMAIN
|
14
|
+
|
15
|
+
columns do
|
16
|
+
name
|
17
|
+
email
|
18
|
+
score :Integer
|
19
|
+
is_active :Boolean
|
20
|
+
registered_at :DateTime
|
21
|
+
created_at :DateTime, :default => lambda{ Time.now }
|
22
|
+
end
|
9
23
|
end
|
10
24
|
|
11
25
|
def setup
|
@@ -17,6 +31,13 @@ class TestSdb < Test::Unit::TestCase
|
|
17
31
|
{ 'name' => 'Mary', 'country' => 'USA', 'gender' => 'female', 'hobby' => ['patchwork', 'bundle jumping'] },
|
18
32
|
{ 'name' => 'Sandy', 'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking'] },
|
19
33
|
{ 'name' => 'Mary', 'country' => 'Russia', 'gender' => 'female', 'hobby' => ['flowers', 'cats', 'cooking'] } ]
|
34
|
+
@people = [
|
35
|
+
{ :name => 'Yetta E. Andrews', :email => 'nulla.facilisis@metus.com', :score => 100, :is_active => true, :registered_at => Time.local(2000, 1, 1) },
|
36
|
+
{ :name => 'Sybill O. Olson', :email => 'nisi.Aenean.eget@urna.com', :score => 87, :is_active => true, :registered_at => Time.local(2008, 7, 6) },
|
37
|
+
{ :name => 'Isabelle K. Flynn', :email => 'velit@amet.com', :score => 98, :is_active => false, :registered_at => Time.local(2003, 5, 20) },
|
38
|
+
{ :name => 'Juliet H. Witt', :email => 'egestas@pretiumaliquet.ca', :score => 72, :is_active => true, :registered_at => Time.local(2007, 2, 28) },
|
39
|
+
{ :name => 'Lucy N. Christensen', :email => 'lacus.v12@stu.edu', :score => 94, :is_active => false, :registered_at => Time.local(2005, 10, 26) }
|
40
|
+
]
|
20
41
|
RightAws::ActiveSdb.establish_connection(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
21
42
|
end
|
22
43
|
|
@@ -37,18 +58,20 @@ class TestSdb < Test::Unit::TestCase
|
|
37
58
|
#---------------------------
|
38
59
|
|
39
60
|
def test_00_delete_domain
|
40
|
-
assert RightAws::ActiveSdb.delete_domain(
|
61
|
+
assert RightAws::ActiveSdb.delete_domain(CLIENT_DOMAIN)
|
62
|
+
assert RightAws::ActiveSdb.delete_domain(PERSON_DOMAIN)
|
41
63
|
wait SDB_DELAY, 'test 00: after domain deletion'
|
42
64
|
end
|
43
65
|
|
44
66
|
def test_01_create_domain
|
45
67
|
# check that domain does not exist
|
46
|
-
assert !RightAws::ActiveSdb.domains.include?(
|
68
|
+
assert !RightAws::ActiveSdb.domains.include?(CLIENT_DOMAIN)
|
47
69
|
# create domain
|
48
70
|
assert Client.create_domain
|
71
|
+
assert Person.create_domain
|
49
72
|
wait SDB_DELAY, 'test 01: after domain creation'
|
50
73
|
# check that we have received new domain from Amazin
|
51
|
-
assert RightAws::ActiveSdb.domains.include?(
|
74
|
+
assert RightAws::ActiveSdb.domains.include?(CLIENT_DOMAIN)
|
52
75
|
end
|
53
76
|
|
54
77
|
def test_02_create_items
|
@@ -287,12 +310,47 @@ class TestSdb < Test::Unit::TestCase
|
|
287
310
|
wait SDB_DELAY, 'test 11: after delete item'
|
288
311
|
assert_nil Client.find_by_name('Putin')
|
289
312
|
end
|
290
|
-
|
291
|
-
def
|
313
|
+
|
314
|
+
def test_14_dynamic_attribute_accessors
|
315
|
+
bush = Client.find_by_name('Bush')
|
316
|
+
bush.reload
|
317
|
+
assert_nothing_raised {
|
318
|
+
assert_equal ['male'], bush.gender
|
319
|
+
bush.name = 'George'
|
320
|
+
assert_equal ['George'], bush.name
|
321
|
+
}
|
322
|
+
assert_raise(NoMethodError) { bush.flarble }
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_15_column_emulation
|
326
|
+
@people.each do |person|
|
327
|
+
Person.create person
|
328
|
+
end
|
329
|
+
wait SDB_DELAY, 'test 15: after people creation'
|
330
|
+
person = Person.find_by_email 'nulla.facilisis@metus.com'
|
331
|
+
person.reload
|
332
|
+
|
333
|
+
assert_equal 'Yetta E. Andrews', person.name
|
334
|
+
assert_equal DateTime, person.registered_at.class
|
335
|
+
assert person['registered_at'].is_a?(DateTime)
|
336
|
+
assert person[:registered_at].is_a?(DateTime)
|
337
|
+
|
338
|
+
assert ! person[:created_at].nil?
|
339
|
+
assert_equal DateTime, person.created_at.class
|
340
|
+
assert person['created_at'].is_a?(DateTime)
|
341
|
+
assert person[:created_at].is_a?(DateTime)
|
342
|
+
|
343
|
+
assert person.is_active
|
344
|
+
|
345
|
+
assert_equal 100, person.score
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_999_delete_domain
|
292
349
|
assert Client.delete_domain
|
293
|
-
|
294
|
-
|
295
|
-
|
350
|
+
assert Person.delete_domain
|
351
|
+
wait SDB_DELAY, 'test 999: after delete domain'
|
352
|
+
assert_raise(Rightscale::AwsError) do
|
353
|
+
Client.find :all
|
296
354
|
end
|
297
355
|
end
|
298
356
|
|
data/test/sdb/test_right_sdb.rb
CHANGED
@@ -11,7 +11,7 @@ class TestSdb < Test::Unit::TestCase
|
|
11
11
|
@sdb = Rightscale::SdbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
12
12
|
end
|
13
13
|
|
14
|
-
SDB_DELAY =
|
14
|
+
SDB_DELAY = 7
|
15
15
|
|
16
16
|
def wait(delay, msg='')
|
17
17
|
print "waiting #{delay} seconds #{msg}"
|
@@ -51,7 +51,7 @@ class TestSdb < Test::Unit::TestCase
|
|
51
51
|
|
52
52
|
def test_03_get_attributes
|
53
53
|
# get attributes
|
54
|
-
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].
|
54
|
+
values = Array(@sdb.get_attributes(@domain, @item)[:attributes]['Jon']).sort
|
55
55
|
# compare to original list
|
56
56
|
assert_equal values, @attr['Jon'].sort
|
57
57
|
end
|
@@ -62,7 +62,7 @@ class TestSdb < Test::Unit::TestCase
|
|
62
62
|
@sdb.put_attributes @domain, @item, {'Jon' => new_value}
|
63
63
|
wait SDB_DELAY, 'after putting attributes'
|
64
64
|
# get attributes ('girls' must be added to already existent attributes)
|
65
|
-
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].
|
65
|
+
values = Array(@sdb.get_attributes(@domain, @item)[:attributes]['Jon']).sort
|
66
66
|
assert_equal values, (@attr['Jon'] << new_value).sort
|
67
67
|
end
|
68
68
|
|
@@ -80,7 +80,7 @@ class TestSdb < Test::Unit::TestCase
|
|
80
80
|
@sdb.put_attributes @domain, @item, {'Jon' => ['girls','vodka']}
|
81
81
|
wait SDB_DELAY, 'after adding attributes'
|
82
82
|
# get attributes ('girls' and 'vodka' must be added 'pub')
|
83
|
-
values = @sdb.get_attributes(@domain, @item)[:attributes]['Jon'].
|
83
|
+
values = Array(@sdb.get_attributes(@domain, @item)[:attributes]['Jon']).sort
|
84
84
|
assert_equal values, ['girls', 'pub', 'vodka']
|
85
85
|
# delete a single value 'girls' from attribute 'Jon'
|
86
86
|
@sdb.delete_attributes @domain, @item, 'Jon' => ['girls']
|
@@ -100,10 +100,11 @@ class TestSdb < Test::Unit::TestCase
|
|
100
100
|
@sdb.put_attributes @domain, @item, {'Volodya' => ['girls','vodka']}
|
101
101
|
wait SDB_DELAY, 'after adding attributes'
|
102
102
|
# get attributes ('girls' and 'vodka' must be there)
|
103
|
-
values = @sdb.get_attributes(@domain, @item)[:attributes]['Volodya'].
|
103
|
+
values = Array(@sdb.get_attributes(@domain, @item)[:attributes]['Volodya']).sort
|
104
104
|
assert_equal values, ['girls', 'vodka']
|
105
105
|
# delete an item
|
106
106
|
@sdb.delete_attributes @domain, @item
|
107
|
+
wait SDB_DELAY, 'after deleting attributes'
|
107
108
|
# get attributes (values must be empty)
|
108
109
|
values = @sdb.get_attributes(@domain, @item)[:attributes]['Volodya']
|
109
110
|
assert_equal values, nil
|
@@ -128,7 +129,7 @@ class TestSdb < Test::Unit::TestCase
|
|
128
129
|
assert sdb.put_attributes(@domain, item, attributes)
|
129
130
|
wait SDB_DELAY, 'after putting attributes'
|
130
131
|
# get attributes
|
131
|
-
values = sdb.get_attributes(@domain, item)[:attributes]['Jurgen'].
|
132
|
+
values = Array(sdb.get_attributes(@domain, item)[:attributes]['Jurgen']).sort
|
132
133
|
# compare to original list
|
133
134
|
assert_equal values, attributes['Jurgen'].sort
|
134
135
|
# check that the request has correct signature version
|
@@ -173,6 +174,7 @@ class TestSdb < Test::Unit::TestCase
|
|
173
174
|
assert_nothing_thrown do
|
174
175
|
@sdb.put_attributes(@domain, item, {:one=>nil, :two=>nil, :three=>'chunder'})
|
175
176
|
end
|
177
|
+
wait SDB_DELAY, 'after putting attributes'
|
176
178
|
assert_nothing_thrown do
|
177
179
|
res = @sdb.get_attributes(@domain, item)
|
178
180
|
end
|
@@ -186,6 +188,7 @@ class TestSdb < Test::Unit::TestCase
|
|
186
188
|
content = {:a=>"one & two & three",
|
187
189
|
:b=>"one ? two / three"}
|
188
190
|
@sdb.put_attributes(@domain, item, content)
|
191
|
+
wait SDB_DELAY, 'after putting attributes'
|
189
192
|
|
190
193
|
res = @sdb.get_attributes(@domain, item)
|
191
194
|
assert_equal(content[:a], res[:attributes]['a'][0])
|
@@ -201,6 +204,7 @@ class TestSdb < Test::Unit::TestCase
|
|
201
204
|
i += 1
|
202
205
|
end
|
203
206
|
@sdb.put_attributes(@domain, item, {:a => sa, :b => sa, :c => sa, :d => sa, :e => sa})
|
207
|
+
wait SDB_DELAY, 'after putting attributes'
|
204
208
|
end
|
205
209
|
|
206
210
|
def test_20_query_with_atributes
|
@@ -209,12 +213,13 @@ class TestSdb < Test::Unit::TestCase
|
|
209
213
|
items = {};
|
210
214
|
response[:items].each{ |item| items.merge!(item) }
|
211
215
|
# check we have receied all 5 items each full of attributes
|
212
|
-
assert_equal
|
216
|
+
assert_equal 6, items.keys.size
|
213
217
|
assert items['toys'].size > 0
|
214
218
|
assert items['nils'].size > 0
|
215
219
|
assert items['urlescapes'].size > 0
|
216
220
|
assert items['multiples'].size > 0
|
217
221
|
assert items['reqgirth'].size > 0
|
222
|
+
assert items['zeroes'].size > 0
|
218
223
|
# fetch only Jon's attributes from all items
|
219
224
|
response = @sdb.query_with_attributes(@domain,['Jon'])
|
220
225
|
items = {};
|
@@ -227,6 +232,7 @@ class TestSdb < Test::Unit::TestCase
|
|
227
232
|
assert_equal 0, items['urlescapes'].size
|
228
233
|
assert_equal 0, items['multiples'].size
|
229
234
|
assert_equal 0, items['reqgirth'].size
|
235
|
+
assert_equal 0, items['zeroes'].size
|
230
236
|
# kust Jurgen's attriburs
|
231
237
|
response = @sdb.query_with_attributes(@domain,['Jurgen'], "['Jurgen'='piglet']")
|
232
238
|
items = {};
|