aboisvert_aws 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +329 -0
- data/Manifest.txt +61 -0
- data/README.txt +163 -0
- data/Rakefile +130 -0
- data/lib/acf/right_acf_interface.rb +549 -0
- 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 +248 -0
- data/lib/as/right_as_interface.rb +698 -0
- data/lib/awsbase/benchmark_fix.rb +39 -0
- data/lib/awsbase/right_awsbase.rb +1343 -0
- data/lib/awsbase/support.rb +35 -0
- data/lib/awsbase/version.rb +9 -0
- data/lib/ec2/right_ec2.rb +541 -0
- data/lib/ec2/right_ec2_ebs.rb +481 -0
- data/lib/ec2/right_ec2_images.rb +444 -0
- data/lib/ec2/right_ec2_instances.rb +788 -0
- data/lib/ec2/right_ec2_monitoring.rb +70 -0
- data/lib/ec2/right_ec2_placement_groups.rb +108 -0
- data/lib/ec2/right_ec2_reserved_instances.rb +184 -0
- data/lib/ec2/right_ec2_security_groups.rb +491 -0
- data/lib/ec2/right_ec2_spot_instances.rb +422 -0
- data/lib/ec2/right_ec2_tags.rb +139 -0
- data/lib/ec2/right_ec2_vpc.rb +590 -0
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/ec2/right_ec2_windows_mobility.rb +84 -0
- data/lib/elb/right_elb_interface.rb +573 -0
- data/lib/emr/right_emr_interface.rb +727 -0
- 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 +1384 -0
- data/lib/right_aws.rb +86 -0
- data/lib/route_53/right_route_53_interface.rb +640 -0
- data/lib/s3/right_s3.rb +1138 -0
- data/lib/s3/right_s3_interface.rb +1278 -0
- data/lib/sdb/active_sdb.rb +1107 -0
- data/lib/sdb/right_sdb_interface.rb +762 -0
- data/lib/sns/right_sns_interface.rb +286 -0
- data/lib/sqs/right_sqs.rb +387 -0
- data/lib/sqs/right_sqs_gen2.rb +342 -0
- data/lib/sqs/right_sqs_gen2_interface.rb +523 -0
- data/lib/sqs/right_sqs_interface.rb +593 -0
- data/right_aws.gemspec +90 -0
- data/test/README.mdown +39 -0
- data/test/acf/test_helper.rb +2 -0
- data/test/acf/test_right_acf.rb +138 -0
- data/test/awsbase/test_helper.rb +2 -0
- data/test/awsbase/test_right_awsbase.rb +11 -0
- data/test/ec2/test_helper.rb +2 -0
- data/test/ec2/test_right_ec2.rb +107 -0
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/http_connection.rb +87 -0
- data/test/rds/test_helper.rb +2 -0
- data/test/rds/test_right_rds.rb +120 -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 +2 -0
- data/test/s3/test_right_s3.rb +528 -0
- data/test/s3/test_right_s3_stubbed.rb +97 -0
- data/test/sdb/test_active_sdb.rb +357 -0
- data/test/sdb/test_batch_put_attributes.rb +54 -0
- data/test/sdb/test_helper.rb +3 -0
- data/test/sdb/test_right_sdb.rb +253 -0
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/sqs/test_helper.rb +2 -0
- data/test/sqs/test_right_sqs.rb +285 -0
- data/test/sqs/test_right_sqs_gen2.rb +264 -0
- data/test/test_credentials.rb +37 -0
- data/test/ts_right_aws.rb +15 -0
- metadata +257 -0
data/right_aws.gemspec
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#-- -*- mode: ruby; encoding: utf-8 -*-
|
2
|
+
# Copyright: Copyright (c) 2010 RightScale, Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# 'Software'), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "lib", "awsbase", "version"))
|
26
|
+
|
27
|
+
Gem::Specification.new do |spec|
|
28
|
+
spec.name = 'aboisvert_aws'
|
29
|
+
spec.rubyforge_project = 'rightaws'
|
30
|
+
spec.version = RightAws::VERSION::STRING
|
31
|
+
spec.authors = ['RightScale, Inc.']
|
32
|
+
spec.email = 'support@rightscale.com'
|
33
|
+
spec.summary = 'Interface classes for the Amazon EC2, SQS, and S3 Web Services'
|
34
|
+
spec.rdoc_options = ['--main', 'README.txt', '--title', '']
|
35
|
+
spec.extra_rdoc_files = ['README.txt']
|
36
|
+
spec.required_ruby_version = '>= 1.8.7'
|
37
|
+
spec.require_path = 'lib'
|
38
|
+
|
39
|
+
spec.add_dependency('right_http_connection', '>= 1.2.5')
|
40
|
+
#spec.requirements << "uuidtools >= 1.0.7 if you want to use ActiveSdb"
|
41
|
+
spec.requirements << "libxml-ruby >= 0.5.2.0 is encouraged"
|
42
|
+
|
43
|
+
spec.add_development_dependency('rake')
|
44
|
+
spec.add_development_dependency('rcov')
|
45
|
+
|
46
|
+
spec.description = <<-EOF
|
47
|
+
== DESCRIPTION:
|
48
|
+
|
49
|
+
The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and CloudFront.
|
50
|
+
These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon.
|
51
|
+
The RightScale AWS gems comprise:
|
52
|
+
|
53
|
+
- RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud) and the
|
54
|
+
associated EBS (Elastic Block Store)
|
55
|
+
- RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service)
|
56
|
+
- RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service) (API version 2007-05-01)
|
57
|
+
- RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service) (API version 2008-01-01)
|
58
|
+
- RightAws::SdbInterface and RightAws::ActiveSdb -- interface to Amazon SDB (SimpleDB)
|
59
|
+
- RightAws::AcfInterface -- interface to Amazon CloudFront, a content distribution service
|
60
|
+
|
61
|
+
== FEATURES:
|
62
|
+
|
63
|
+
- Full programmmatic access to EC2, EBS, S3, SQS, SDB, and CloudFront.
|
64
|
+
- Complete error handling: all operations check for errors and report complete
|
65
|
+
error information by raising an AwsError.
|
66
|
+
- Persistent HTTP connections with robust network-level retry layer using
|
67
|
+
RightHttpConnection). This includes socket timeouts and retries.
|
68
|
+
- Robust HTTP-level retry layer. Certain (user-adjustable) HTTP errors returned
|
69
|
+
by Amazon's services are classified as temporary errors.
|
70
|
+
These errors are automaticallly retried using exponentially increasing intervals.
|
71
|
+
The number of retries is user-configurable.
|
72
|
+
- Fast REXML-based parsing of responses (as fast as a pure Ruby solution allows).
|
73
|
+
- Uses libxml (if available) for faster response parsing.
|
74
|
+
- Support for large S3 list operations. Buckets and key subfolders containing
|
75
|
+
many (> 1000) keys are listed in entirety. Operations based on list (like
|
76
|
+
bucket clear) work on arbitrary numbers of keys.
|
77
|
+
- Support for streaming GETs from S3, and streaming PUTs to S3 if the data source is a file.
|
78
|
+
- Support for single-threaded usage, multithreaded usage, as well as usage with multiple
|
79
|
+
AWS accounts.
|
80
|
+
- Support for both first- and second-generation SQS (API versions 2007-05-01
|
81
|
+
and 2008-01-01). These versions of SQS are not compatible.
|
82
|
+
- Support for signature versions 0 and 1 on SQS, SDB, and EC2.
|
83
|
+
- Interoperability with any cloud running Eucalyptus (http://eucalyptus.cs.ucsb.edu)
|
84
|
+
- Test suite (requires AWS account to do "live" testing).
|
85
|
+
EOF
|
86
|
+
|
87
|
+
candidates = Dir.glob('{lib,test}/**/*') + ['History.txt', 'Manifest.txt', 'README.txt', 'Rakefile', 'right_aws.gemspec']
|
88
|
+
spec.files = candidates.sort
|
89
|
+
spec.test_files = Dir.glob('test/**/*')
|
90
|
+
end
|
data/test/README.mdown
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Notes and tips for developers
|
2
|
+
|
3
|
+
## Setting up credentials for testing
|
4
|
+
|
5
|
+
Before you can run any tests, you need to set up credentials (API key and secret) that
|
6
|
+
will be used when talking to AWS. The credentials are loaded in `test/test_credentials.rb`
|
7
|
+
and are expected to be found in `~/.rightscale/testcredentials.rb` and look like this:
|
8
|
+
|
9
|
+
TestCredentials.aws_access_key_id= 'AAAAAAAAAAAAAAAAAAAA'
|
10
|
+
TestCredentials.aws_secret_access_key= 'asdfasdfsadf'
|
11
|
+
TestCredentials.account_number= '???'
|
12
|
+
|
13
|
+
If you prefer to store your secret key in the OS X keychain, you can do this:
|
14
|
+
|
15
|
+
def secret_access_key_from_keychain (key_id)
|
16
|
+
dump = `security -q find-generic-password -a "#{key_id}" -g 2>&1`
|
17
|
+
dump[/password: "(.*)"/, 1]
|
18
|
+
end
|
19
|
+
|
20
|
+
TestCredentials.aws_access_key_id= 'AAAAAAAAAAAAAAAAAAAA'
|
21
|
+
TestCredentials.aws_secret_access_key= secret_access_key_from_keychain(TestCredentials.aws_access_key_id)
|
22
|
+
TestCredentials.account_number= '???'
|
23
|
+
|
24
|
+
## Running tests
|
25
|
+
|
26
|
+
There is no test suite that runs all tests. Each module is tested separately. E.g.,
|
27
|
+
to run the Load Balancer tests, run `rake testelb`. Run `rake -T` for a full list.
|
28
|
+
|
29
|
+
Some tests need to launch services on AWS to have something to test. This means two things:
|
30
|
+
|
31
|
+
1. Running all the tests will cost you money.
|
32
|
+
2. You will need to shut down some services separately once you are done, or things
|
33
|
+
will keep running and cost you money.
|
34
|
+
|
35
|
+
As an example, the ELB and Route 53 tests need a load balancer for testing. Starting a load balancer
|
36
|
+
for every test would make every test case cost as much as running the LB for one hour, so it makes
|
37
|
+
more sense to leave it running until it's no longer needed.
|
38
|
+
|
39
|
+
The ELB tests contain instructions for shutting down the load balancer.
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestAcf < Test::Unit::TestCase
|
4
|
+
|
5
|
+
RIGHT_OBJECT_TEXT = 'Right test message'
|
6
|
+
|
7
|
+
STDOUT.sync = true
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@acf= Rightscale::AcfInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
11
|
+
@s3 = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
12
|
+
@bucket_name = "right-acf-awesome-test-bucket-xxx1"
|
13
|
+
@bucket_domain = "#{@bucket_name}.s3.amazonaws.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_01_list_distributions_part1
|
17
|
+
distributions = nil
|
18
|
+
assert_nothing_raised(Rightscale::AwsError) do
|
19
|
+
distributions = @acf.list_distributions
|
20
|
+
end
|
21
|
+
assert distributions.is_a?(Array)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_02_try_to_create_for_bad_bucket
|
25
|
+
# a bucket does not exist
|
26
|
+
assert_raise(Rightscale::AwsError) do
|
27
|
+
@acf.create_distribution("right-cloudfront-awesome-test-bucket-not-exist", "Mustn't to be born", true)
|
28
|
+
end
|
29
|
+
# a bucket is not a domain naming complied guy
|
30
|
+
bucket_name = 'right_cloudfront_awesome_test_bucket_BAD_XXX'
|
31
|
+
@s3.bucket(bucket_name, :create)
|
32
|
+
assert_raise(Rightscale::AwsError) do
|
33
|
+
@acf.create_distribution(bucket_name, "Mustn't to be born", true)
|
34
|
+
end
|
35
|
+
end
|
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
|
+
|
42
|
+
def test_03_create
|
43
|
+
comment = 'WooHoo!!!'
|
44
|
+
# create a test bucket
|
45
|
+
@s3.bucket(@bucket_name, :create)
|
46
|
+
# create a distribution
|
47
|
+
distribution = @acf.create_distribution(@bucket_domain, comment, true)
|
48
|
+
assert_equal comment, distribution[:comment]
|
49
|
+
assert distribution[:cnames].size == 0
|
50
|
+
assert distribution[:enabled]
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_04_list_distributions_part2
|
54
|
+
distributions = @acf.list_distributions
|
55
|
+
assert distributions.size > 0
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_test_distribution
|
59
|
+
@acf.list_distributions.select{ |d| d[:origin] == @bucket_domain }.first
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_05_get_distribution
|
63
|
+
old = get_test_distribution
|
64
|
+
assert_nothing_raised do
|
65
|
+
@acf.get_distribution(old[:aws_id])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_06_get_and_set_config
|
70
|
+
config = nil
|
71
|
+
old = get_test_distribution
|
72
|
+
assert_nothing_raised do
|
73
|
+
config = @acf.get_distribution_config(old[:aws_id])
|
74
|
+
end
|
75
|
+
# change a config
|
76
|
+
config[:enabled] = false
|
77
|
+
config[:cnames] << 'xxx1.myawesomesite.com'
|
78
|
+
config[:cnames] << 'xxx2.myawesomesite.com'
|
79
|
+
# set config
|
80
|
+
set_config_result = nil
|
81
|
+
assert_nothing_raised do
|
82
|
+
set_config_result = @acf.set_distribution_config(old[:aws_id], config)
|
83
|
+
end
|
84
|
+
assert set_config_result
|
85
|
+
# reget the config and check
|
86
|
+
new_config = nil
|
87
|
+
assert_nothing_raised do
|
88
|
+
new_config = @acf.get_distribution_config(old[:aws_id])
|
89
|
+
end
|
90
|
+
assert !new_config[:enabled]
|
91
|
+
assert_equal new_config[:cnames].sort, ['xxx1.myawesomesite.com', 'xxx2.myawesomesite.com']
|
92
|
+
assert_not_equal config[:e_tag], new_config[:e_tag]
|
93
|
+
|
94
|
+
# try to update the old config again (must fail because ETAG has changed)
|
95
|
+
assert_raise(Rightscale::AwsError) do
|
96
|
+
@acf.set_distribution_config(old[:aws_id], config)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_08_delete_distribution
|
101
|
+
# we need ETAG so use get_distribution
|
102
|
+
distribution = @acf.get_distribution(get_test_distribution[:aws_id])
|
103
|
+
# try to delete a distribution
|
104
|
+
# should fail because
|
105
|
+
if distribution[:status] == 'InProgress'
|
106
|
+
# should fail because the distribution is not deployed yet
|
107
|
+
assert_raise(Rightscale::AwsError) do
|
108
|
+
@acf.delete_distribution(distribution[:aws_id], distribution[:e_tag])
|
109
|
+
end
|
110
|
+
# wait for a deployed state
|
111
|
+
print "waiting up to 5 min while the distribution is being deployed: "
|
112
|
+
100.times do
|
113
|
+
print '.'
|
114
|
+
distribution = @acf.get_distribution(distribution[:aws_id])
|
115
|
+
if distribution[:status] == 'Deployed'
|
116
|
+
print ' done'
|
117
|
+
break
|
118
|
+
end
|
119
|
+
sleep 3
|
120
|
+
end
|
121
|
+
puts
|
122
|
+
end
|
123
|
+
|
124
|
+
# only disabled and deployed distribution can be deleted
|
125
|
+
assert_equal 'Deployed', distribution[:status]
|
126
|
+
assert !distribution[:enabled]
|
127
|
+
|
128
|
+
# delete the distribution
|
129
|
+
assert_nothing_raised do
|
130
|
+
@acf.delete_distribution(distribution[:aws_id], distribution[:e_tag])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_09_drop_bucket
|
135
|
+
assert @s3.bucket(@bucket_name).delete
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestEc2 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# Some of RightEc2 instance methods concerning instance launching and image registration
|
6
|
+
# are not tested here due to their potentially risk.
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@ec2 = Rightscale::Ec2.new(TestCredentials.aws_access_key_id,
|
10
|
+
TestCredentials.aws_secret_access_key)
|
11
|
+
@key = 'right_ec2_awesome_test_key'
|
12
|
+
@group = 'right_ec2_awesome_test_security_group'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_01_create_describe_key_pairs
|
16
|
+
new_key = @ec2.create_key_pair(@key)
|
17
|
+
assert new_key[:aws_material][/BEGIN RSA PRIVATE KEY/], "New key material is absent"
|
18
|
+
keys = @ec2.describe_key_pairs
|
19
|
+
assert keys.map{|key| key[:aws_key_name] }.include?(@key), "#{@key} must exist"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_02_create_security_group
|
23
|
+
assert @ec2.create_security_group(@group,'My awesone test group'), 'Create_security_group fail'
|
24
|
+
group = @ec2.describe_security_groups([@group])[0]
|
25
|
+
assert_equal @group, group[:aws_group_name], 'Group must be created but does not exist'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_03_perms_add
|
29
|
+
assert @ec2.authorize_security_group_named_ingress(@group, TestCredentials.account_number, 'default')
|
30
|
+
assert @ec2.authorize_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_04_check_new_perms_exist
|
34
|
+
assert_equal 2, @ec2.describe_security_groups([@group])[0][:aws_perms].size
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_05_perms_remove
|
38
|
+
assert @ec2.revoke_security_group_IP_ingress(@group, 80,80,'udp','192.168.1.0/8')
|
39
|
+
assert @ec2.revoke_security_group_named_ingress(@group,
|
40
|
+
TestCredentials.account_number, 'default')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_06_describe_images
|
44
|
+
images = @ec2.describe_images
|
45
|
+
assert images.size>0, 'Amazon must have at least some public images'
|
46
|
+
# unknown image
|
47
|
+
assert_raise(Rightscale::AwsError){ @ec2.describe_images(['ami-ABCDEFGH'])}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_07_describe_instanses
|
51
|
+
assert @ec2.describe_instances
|
52
|
+
# unknown image
|
53
|
+
assert_raise(Rightscale::AwsError){ @ec2.describe_instances(['i-ABCDEFGH'])}
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_08_delete_security_group
|
57
|
+
assert @ec2.delete_security_group(@group), 'Delete_security_group fail'
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_09_delete_key_pair
|
61
|
+
assert @ec2.delete_key_pair(@key), 'Delete_key_pair fail'
|
62
|
+
## Hmmm... Amazon does not through the exception any more. It now just returns a 'true' if the key does not exist any more...
|
63
|
+
## # key must be deleted already
|
64
|
+
## assert_raise(Rightscale::AwsError) { @ec2.delete_key_pair(@key) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_10_signature_version_0
|
68
|
+
ec2 = Rightscale::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :signature_version => '0')
|
69
|
+
images = ec2.describe_images
|
70
|
+
assert images.size>0, 'Amazon must have at least some public images'
|
71
|
+
# check that the request has correct signature version
|
72
|
+
assert ec2.last_request.path.include?('SignatureVersion=0')
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_11_regions
|
76
|
+
regions = nil
|
77
|
+
assert_nothing_raised do
|
78
|
+
regions = @ec2.describe_regions
|
79
|
+
end
|
80
|
+
# check we got more that 0 regions
|
81
|
+
assert regions.size > 0
|
82
|
+
# check an access to regions
|
83
|
+
regions.each do |region|
|
84
|
+
regional_ec2 = Rightscale::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :region => region)
|
85
|
+
# do we have a correct endpoint server?
|
86
|
+
assert_equal "#{region}.ec2.amazonaws.com", regional_ec2.params[:server]
|
87
|
+
# get a list of images from every region
|
88
|
+
images = nil
|
89
|
+
assert_nothing_raised do
|
90
|
+
images = regional_ec2.describe_regions
|
91
|
+
end
|
92
|
+
# every region must have images
|
93
|
+
assert images.size > 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_12_endpoint_url
|
98
|
+
ec2 = Rightscale::Ec2.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :endpoint_url => 'a://b.c:0/d/', :region => 'z')
|
99
|
+
# :endpoint_url has a priority hence :region should be ommitted
|
100
|
+
assert_equal 'a', ec2.params[:protocol]
|
101
|
+
assert_equal 'b.c', ec2.params[:server]
|
102
|
+
assert_equal '/d/', ec2.params[:service]
|
103
|
+
assert_equal 0, ec2.params[:port]
|
104
|
+
assert_nil ec2.params[:region]
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -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
|