forked from flexera-public/right_aws
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. Tests for some of the existing functionality in Route 53. 3. Specify source in Gemfile to make it work with more versions of bundler. 4. Tests for existing ELB functionality. 5. README for developers. 6. Updated ELB to API version 2011-04-05 to display CanonicalHostedZoneNameID. Ignore SourceSecurityGroup for now. 7. Updated Route 53 to API version 2011-05-05 which handles A(Alias) records.
- Loading branch information
Showing
12 changed files
with
308 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Notes and tips for developers | ||
|
||
## Setting up credentials for testing | ||
|
||
Before you can run any tests, you need to set up credentials (API key and secret) that | ||
will be used when talking to AWS. The credentials are loaded in `test/test_credentials.rb` | ||
and are expected to be found in `~/.rightscale/testcredentials.rb` and look like this: | ||
|
||
TestCredentials.aws_access_key_id= 'AAAAAAAAAAAAAAAAAAAA' | ||
TestCredentials.aws_secret_access_key= 'asdfasdfsadf' | ||
TestCredentials.account_number= '???' | ||
|
||
If you prefer to store your secret key in the OS X keychain, you can do this: | ||
|
||
def secret_access_key_from_keychain (key_id) | ||
dump = `security -q find-generic-password -a "#{key_id}" -g 2>&1` | ||
dump[/password: "(.*)"/, 1] | ||
end | ||
|
||
TestCredentials.aws_access_key_id= 'AAAAAAAAAAAAAAAAAAAA' | ||
TestCredentials.aws_secret_access_key= secret_access_key_from_keychain(TestCredentials.aws_access_key_id) | ||
TestCredentials.account_number= '???' | ||
|
||
## Running tests | ||
|
||
There is no test suite that runs all tests. Each module is tested separately. E.g., | ||
to run the Load Balancer tests, run `rake testelb`. Run `rake -T` for a full list. | ||
|
||
Some tests need to launch services on AWS to have something to test. This means two things: | ||
|
||
1. Running all the tests will cost you money. | ||
2. You will need to shut down some services separately once you are done, or things | ||
will keep running and cost you money. | ||
|
||
As an example, the ELB and Route 53 tests need a load balancer for testing. Starting a load balancer | ||
for every test would make every test case cost as much as running the LB for one hour, so it makes | ||
more sense to leave it running until it's no longer needed. | ||
|
||
The ELB tests contain instructions for shutting down the load balancer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'test/unit' | ||
require File.dirname(__FILE__) + '/../../lib/right_aws' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require File.dirname(__FILE__) + '/test_helper.rb' | ||
|
||
class TestElb < Test::Unit::TestCase | ||
|
||
STDOUT.sync = true | ||
BALANCER_NAME = 'right-aws-test-lb' | ||
|
||
def setup | ||
@elb = Rightscale::ElbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null')) | ||
|
||
unless @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME } | ||
@elb.create_load_balancer(BALANCER_NAME, %w[us-east-1b], []) | ||
end | ||
@lb = @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME } | ||
end | ||
|
||
# At the end of the day when you want to shut down the test balancer: | ||
# * Uncomment this method. | ||
# * Comment out all test except one. | ||
# * Run this test file. | ||
# | ||
# def teardown | ||
# @elb.delete_load_balancer BALANCER_NAME | ||
# end | ||
|
||
def test_00_describe_load_balancers | ||
items = @elb.describe_load_balancers | ||
assert items.is_a?(Array) | ||
end | ||
|
||
def test_description | ||
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:dns_name] | ||
end | ||
|
||
def test_description_has_canonical_hosted_zone_name | ||
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:canonical_hosted_zone_name] | ||
end | ||
|
||
def test_description_has_canonical_hosted_zone_name_id | ||
assert_match /^[A-Z0-9]+$/, @lb[:canonical_hosted_zone_name_id] | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/"> | ||
<ChangeBatch> | ||
<Changes> | ||
<Change> | ||
<Action>CREATE</Action> | ||
<ResourceRecordSet> | ||
<Name>host.right-aws.example.com.</Name> | ||
<Type>A</Type> | ||
<TTL>600</TTL> | ||
<ResourceRecords> | ||
<ResourceRecord><Value>10.0.0.1</Value></ResourceRecord> | ||
</ResourceRecords> | ||
</ResourceRecordSet> | ||
</Change> | ||
</Changes> | ||
</ChangeBatch> | ||
</ChangeResourceRecordSetsRequest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/"> | ||
<ChangeBatch> | ||
<Changes> | ||
<Change> | ||
<Action>CREATE</Action> | ||
<ResourceRecordSet> | ||
<Name>right-aws.example.com.</Name> | ||
<Type>A</Type> | ||
<AliasTarget> | ||
<HostedZoneId>Z1234567890123</HostedZoneId> | ||
<DNSName>example-load-balancer-1111111111.us-east-1.elb.amazonaws.com.</DNSName> | ||
</AliasTarget> | ||
</ResourceRecordSet> | ||
</Change> | ||
</Changes> | ||
</ChangeBatch> | ||
</ChangeResourceRecordSetsRequest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'test/unit' | ||
require File.dirname(__FILE__) + '/../../lib/right_aws' |
Oops, something went wrong.