icehouse-right_aws 1.11.0 → 2.2.0
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/History.txt +93 -15
- data/Manifest.txt +15 -1
- data/README.txt +0 -4
- data/Rakefile +34 -17
- data/lib/acf/right_acf_interface.rb +260 -124
- data/lib/acf/right_acf_invalidations.rb +144 -0
- data/lib/acf/right_acf_origin_access_identities.rb +230 -0
- data/lib/acf/right_acf_streaming_interface.rb +229 -0
- data/lib/acw/right_acw_interface.rb +4 -5
- data/lib/as/right_as_interface.rb +59 -51
- data/lib/awsbase/benchmark_fix.rb +0 -0
- data/lib/awsbase/right_awsbase.rb +351 -104
- data/lib/awsbase/support.rb +2 -82
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +97 -246
- data/lib/ec2/right_ec2_ebs.rb +88 -68
- data/lib/ec2/right_ec2_images.rb +90 -50
- data/lib/ec2/right_ec2_instances.rb +118 -89
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +51 -44
- data/lib/ec2/right_ec2_security_groups.rb +396 -0
- data/lib/ec2/right_ec2_spot_instances.rb +425 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +152 -140
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +205 -39
- data/lib/iam/right_iam_access_keys.rb +71 -0
- data/lib/iam/right_iam_groups.rb +195 -0
- data/lib/iam/right_iam_interface.rb +341 -0
- data/lib/iam/right_iam_mfa_devices.rb +67 -0
- data/lib/iam/right_iam_users.rb +251 -0
- data/lib/rds/right_rds_interface.rb +591 -205
- data/lib/right_aws.rb +16 -12
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +34 -13
- data/lib/s3/right_s3_interface.rb +17 -14
- data/lib/sdb/active_sdb.rb +215 -38
- data/lib/sdb/right_sdb_interface.rb +93 -12
- data/lib/sqs/right_sqs.rb +1 -2
- data/lib/sqs/right_sqs_gen2.rb +0 -1
- data/lib/sqs/right_sqs_gen2_interface.rb +9 -9
- data/lib/sqs/right_sqs_interface.rb +6 -7
- data/right_aws.gemspec +91 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +0 -0
- data/test/acf/test_right_acf.rb +10 -18
- data/test/awsbase/test_helper.rb +0 -0
- data/test/awsbase/test_right_awsbase.rb +0 -1
- data/test/ec2/test_helper.rb +0 -0
- data/test/ec2/test_right_ec2.rb +0 -1
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +0 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_helper.rb +0 -0
- data/test/s3/test_right_s3.rb +11 -9
- data/test/s3/test_right_s3_stubbed.rb +6 -4
- data/test/sdb/test_active_sdb.rb +71 -13
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +0 -0
- data/test/sdb/test_right_sdb.rb +13 -7
- data/test/sqs/test_helper.rb +0 -0
- data/test/sqs/test_right_sqs.rb +0 -6
- data/test/sqs/test_right_sqs_gen2.rb +22 -34
- data/test/test_credentials.rb +0 -0
- data/test/ts_right_aws.rb +0 -0
- metadata +146 -16
- data/VERSION +0 -1
data/test/awsbase/test_helper.rb
CHANGED
File without changes
|
data/test/ec2/test_helper.rb
CHANGED
File without changes
|
data/test/ec2/test_right_ec2.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestElb < Test::Unit::TestCase
|
4
|
+
|
5
|
+
STDOUT.sync = true
|
6
|
+
BALANCER_NAME = 'right-aws-test-lb'
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@elb = Rightscale::ElbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
10
|
+
|
11
|
+
unless @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
12
|
+
@elb.create_load_balancer(BALANCER_NAME, %w[us-east-1b], [])
|
13
|
+
end
|
14
|
+
@lb = @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
15
|
+
end
|
16
|
+
|
17
|
+
# At the end of the day when you want to shut down the test balancer:
|
18
|
+
# * Uncomment this method.
|
19
|
+
# * Comment out all test except one.
|
20
|
+
# * Run this test file.
|
21
|
+
#
|
22
|
+
# def teardown
|
23
|
+
# @elb.delete_load_balancer BALANCER_NAME
|
24
|
+
# end
|
25
|
+
|
26
|
+
def test_00_describe_load_balancers
|
27
|
+
items = @elb.describe_load_balancers
|
28
|
+
assert items.is_a?(Array)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_description
|
32
|
+
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:dns_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_description_has_canonical_hosted_zone_name
|
36
|
+
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:canonical_hosted_zone_name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_description_has_canonical_hosted_zone_name_id
|
40
|
+
assert_match /^[A-Z0-9]+$/, @lb[:canonical_hosted_zone_name_id]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/http_connection.rb
CHANGED
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/">
|
3
|
+
<ChangeBatch>
|
4
|
+
<Changes>
|
5
|
+
<Change>
|
6
|
+
<Action>CREATE</Action>
|
7
|
+
<ResourceRecordSet>
|
8
|
+
<Name>host.right-aws.example.com.</Name>
|
9
|
+
<Type>A</Type>
|
10
|
+
<TTL>600</TTL>
|
11
|
+
<ResourceRecords>
|
12
|
+
<ResourceRecord><Value>10.0.0.1</Value></ResourceRecord>
|
13
|
+
</ResourceRecords>
|
14
|
+
</ResourceRecordSet>
|
15
|
+
</Change>
|
16
|
+
</Changes>
|
17
|
+
</ChangeBatch>
|
18
|
+
</ChangeResourceRecordSetsRequest>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/">
|
3
|
+
<ChangeBatch>
|
4
|
+
<Changes>
|
5
|
+
<Change>
|
6
|
+
<Action>CREATE</Action>
|
7
|
+
<ResourceRecordSet>
|
8
|
+
<Name>right-aws.example.com.</Name>
|
9
|
+
<Type>A</Type>
|
10
|
+
<AliasTarget>
|
11
|
+
<HostedZoneId>Z1234567890123</HostedZoneId>
|
12
|
+
<DNSName>example-load-balancer-1111111111.us-east-1.elb.amazonaws.com.</DNSName>
|
13
|
+
</AliasTarget>
|
14
|
+
</ResourceRecordSet>
|
15
|
+
</Change>
|
16
|
+
</Changes>
|
17
|
+
</ChangeBatch>
|
18
|
+
</ChangeResourceRecordSetsRequest>
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestRoute53 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
STDOUT.sync = true
|
6
|
+
BALANCER_NAME = 'right-aws-test-lb'
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@r53 = Rightscale::Route53Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
10
|
+
@zone_config = {:name => "right-aws.example.com.", :config => {:comment => 'a comment'}}
|
11
|
+
|
12
|
+
@elb = Rightscale::ElbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@r53.list_hosted_zones.each do |zone|
|
17
|
+
next unless zone[:name] == @zone_config[:name]
|
18
|
+
zone_id = zone[:aws_id]
|
19
|
+
puts zone_id
|
20
|
+
records = @r53.list_resource_record_sets(zone_id)
|
21
|
+
# The NS and SOA records are provided by AWS and must not be deleted
|
22
|
+
records.reject! { |rr| %w[NS SOA].include? rr[:type] }
|
23
|
+
if records.any?
|
24
|
+
response = @r53.delete_resource_record_sets(zone_id, records)
|
25
|
+
puts response.inspect
|
26
|
+
end
|
27
|
+
puts @r53.delete_hosted_zone(zone_id).inspect
|
28
|
+
end
|
29
|
+
# Uncomment to shut down at the end of the day.
|
30
|
+
# @elb.delete_load_balancer BALANCER_NAME
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_00_list_hosted_zones
|
34
|
+
items = @r53.list_hosted_zones
|
35
|
+
assert items.is_a?(Array)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_create_and_delete_zone
|
39
|
+
response = @r53.create_hosted_zone(@zone_config)
|
40
|
+
assert_equal response[:name], @zone_config[:name]
|
41
|
+
assert response[:aws_id].is_a?(String)
|
42
|
+
assert response[:name_servers].is_a?(Array)
|
43
|
+
|
44
|
+
response2 = @r53.delete_hosted_zone(response[:aws_id])
|
45
|
+
assert_equal response2[:status], 'PENDING'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_add_and_remove_A_record
|
49
|
+
zone = @r53.create_hosted_zone(@zone_config)
|
50
|
+
zone_id = zone[:aws_id]
|
51
|
+
# add
|
52
|
+
a_record = { :name => 'host.right-aws.example.com.', :type => 'A', :ttl => 600, :resource_records => ['10.0.0.1'] }
|
53
|
+
response = @r53.create_resource_record_sets(zone_id, [a_record.dup]) # .dup since it will get :action => :create
|
54
|
+
assert_equal response[:status], 'PENDING'
|
55
|
+
|
56
|
+
# It should be there now
|
57
|
+
records = @r53.list_resource_record_sets(zone_id)
|
58
|
+
assert records.is_a?(Array)
|
59
|
+
assert records.detect { |rr| rr == a_record }, "Could not find '#{a_record.inspect}' in '#{records.inspect}'"
|
60
|
+
|
61
|
+
# remove
|
62
|
+
response = @r53.delete_resource_record_sets(zone_id, [a_record.dup])
|
63
|
+
assert_equal response[:status], 'PENDING'
|
64
|
+
|
65
|
+
# It should not be there anymore
|
66
|
+
records = @r53.list_resource_record_sets(zone_id)
|
67
|
+
assert records.is_a?(Array)
|
68
|
+
assert ! records.detect { |rr| rr == a_record }, "Record '#{a_record.inspect}' is still in '#{records.inspect}'"
|
69
|
+
|
70
|
+
@r53.delete_hosted_zone(zone_id)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_add_and_remove_Alias_record
|
74
|
+
lb = find_or_create_load_balancer
|
75
|
+
|
76
|
+
zone = @r53.create_hosted_zone(@zone_config)
|
77
|
+
zone_id = zone[:aws_id]
|
78
|
+
|
79
|
+
# add
|
80
|
+
alias_target = { :hosted_zone_id => lb[:canonical_hosted_zone_name_id], :dns_name => lb[:dns_name] }
|
81
|
+
alias_record = { :name => 'right-aws.example.com', :type => 'A', :alias_target => alias_target }
|
82
|
+
response = @r53.create_resource_record_sets(zone_id, [alias_record.dup]) # .dup since it will get :action => :create
|
83
|
+
assert_equal response[:status], 'PENDING'
|
84
|
+
|
85
|
+
# It should be there now
|
86
|
+
records = @r53.list_resource_record_sets(zone_id)
|
87
|
+
assert records.is_a?(Array)
|
88
|
+
record = records.detect { |rr| rr[:alias_target] }
|
89
|
+
assert record, "Could not find '#{alias_record.inspect}' in '#{records.inspect}'"
|
90
|
+
# AWS adds final dots to names
|
91
|
+
assert_equal "#{alias_record[:name]}.", record[:name]
|
92
|
+
assert_equal "#{alias_target[:dns_name]}.", record[:alias_target][:dns_name]
|
93
|
+
|
94
|
+
# remove
|
95
|
+
response = @r53.delete_resource_record_sets(zone_id, [alias_record.dup])
|
96
|
+
assert_equal response[:status], 'PENDING'
|
97
|
+
|
98
|
+
# It should not be there anymore
|
99
|
+
records = @r53.list_resource_record_sets(zone_id)
|
100
|
+
assert records.is_a?(Array)
|
101
|
+
record = records.detect { |rr| rr[:alias_target] }
|
102
|
+
assert ! record, "Record '#{alias_record.inspect}' is still in '#{records.inspect}'"
|
103
|
+
|
104
|
+
@r53.delete_hosted_zone(zone_id)
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_or_create_load_balancer
|
108
|
+
unless @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
109
|
+
@elb.create_load_balancer(BALANCER_NAME, %w[us-east-1b], [])
|
110
|
+
puts "WARNING: Started load balancer. Remember to shut it down (see teardown)."
|
111
|
+
puts "NOTE: Tests might not pass during first few seconds after load balancer is created."
|
112
|
+
end
|
113
|
+
@elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_rr_sets_to_xml
|
117
|
+
a_record = { :name => 'host.right-aws.example.com.', :type => 'A', :ttl => 600, :resource_records => ['10.0.0.1'], :action => :create }
|
118
|
+
expected = load_fixture('a_record.xml')
|
119
|
+
assert_equal expected, @r53.resource_record_sets_to_xml([a_record], '')
|
120
|
+
|
121
|
+
# Note final full stop
|
122
|
+
alias_target = { :hosted_zone_id => 'Z1234567890123', :dns_name => 'example-load-balancer-1111111111.us-east-1.elb.amazonaws.com.' }
|
123
|
+
alias_record = { :name => 'right-aws.example.com.', :type => 'A', :alias_target => alias_target, :action => :create }
|
124
|
+
expected = load_fixture('alias_record.xml')
|
125
|
+
assert_same_lines expected, @r53.resource_record_sets_to_xml([alias_record], '')
|
126
|
+
end
|
127
|
+
|
128
|
+
def load_fixture (name)
|
129
|
+
File.read(File.join(File.dirname(__FILE__), 'fixtures', name))
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_same_lines (expected, actual)
|
133
|
+
expected = expected.split "\n"
|
134
|
+
actual = actual.split "\n"
|
135
|
+
previous = []
|
136
|
+
while e = expected.shift and a = actual.shift
|
137
|
+
assert_equal e, a, "After:\n#{previous.join("\n")}"
|
138
|
+
previous << e
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/test/s3/test_helper.rb
CHANGED
File without changes
|
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'
|
@@ -264,7 +264,7 @@ class TestS3 < Test::Unit::TestCase
|
|
264
264
|
# create a key
|
265
265
|
key = bucket.key('test/copy/30')
|
266
266
|
key.put(RIGHT_OBJECT_TEXT)
|
267
|
-
assert key.meta_headers.
|
267
|
+
assert key.meta_headers.right_blank?
|
268
268
|
# store some meta keys
|
269
269
|
meta = {'family' => 'oops','race' => 'troll'}
|
270
270
|
assert_equal meta, key.save_meta(meta)
|
@@ -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,24 +58,26 @@ 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
|
55
78
|
# check that DB is empty
|
56
79
|
clients = Client.find(:all)
|
57
|
-
assert clients.
|
80
|
+
assert clients.right_blank?
|
58
81
|
# put some clients there
|
59
82
|
@clients.each do |client|
|
60
83
|
Client.create client
|
@@ -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
|
|