wrap AwsHaRelease class in AwsMissingTools module
This commit is contained in:
parent
29aeb75ca3
commit
f6f07ec0fc
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'aws-missing-tools'
|
require 'aws-missing-tools'
|
||||||
AwsHaRelease.new(ARGV.dup).execute!
|
AwsMissingTools::AwsHaRelease.new(ARGV.dup).execute!
|
||||||
|
|
|
@ -2,6 +2,5 @@ require 'aws-missing-tools/version'
|
||||||
|
|
||||||
module AwsMissingTools
|
module AwsMissingTools
|
||||||
require 'aws-sdk'
|
require 'aws-sdk'
|
||||||
|
|
||||||
require 'aws-missing-tools/aws-ha-release/aws-ha-release'
|
require 'aws-missing-tools/aws-ha-release/aws-ha-release'
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
require 'timeout'
|
require 'timeout'
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
|
|
||||||
class AwsHaRelease
|
module AwsMissingTools
|
||||||
|
class AwsHaRelease
|
||||||
attr_reader :group
|
attr_reader :group
|
||||||
|
|
||||||
def initialize(argv)
|
def initialize(argv)
|
||||||
|
@ -162,4 +163,5 @@ class AwsHaRelease
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,26 +19,26 @@ describe 'aws-ha-release' do
|
||||||
as.groups.create opts[1]
|
as.groups.create opts[1]
|
||||||
|
|
||||||
AWS.should_receive(:config).with(access_key_id: 'testaccesskey', secret_access_key: 'testsecretkey', region: 'test_region')
|
AWS.should_receive(:config).with(access_key_id: 'testaccesskey', secret_access_key: 'testsecretkey', region: 'test_region')
|
||||||
AwsHaRelease.new(opts)
|
AwsMissingTools::AwsHaRelease.new(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ensures the as group exists' do
|
it 'ensures the as group exists' do
|
||||||
lambda {
|
lambda {
|
||||||
opts[1] = 'fake_group'
|
opts[1] = 'fake_group'
|
||||||
AwsHaRelease.new(opts)
|
AwsMissingTools::AwsHaRelease.new(opts)
|
||||||
}.should raise_error
|
}.should raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#parse_options' do
|
describe '#parse_options' do
|
||||||
it 'requires the autoscaling group name to be passed in' do
|
it 'requires the autoscaling group name to be passed in' do
|
||||||
expect{ AwsHaRelease.parse_options([]) }.to raise_error OptionParser::MissingArgument
|
expect{ AwsMissingTools::AwsHaRelease.parse_options([]) }.to raise_error OptionParser::MissingArgument
|
||||||
expect(AwsHaRelease.parse_options(%w(-a test_group))[:as_group_name]).to eq 'test_group'
|
expect(AwsMissingTools::AwsHaRelease.parse_options(%w(-a test_group))[:as_group_name]).to eq 'test_group'
|
||||||
expect(AwsHaRelease.parse_options(%w(--as-group-name test_group))[:as_group_name]).to eq 'test_group'
|
expect(AwsMissingTools::AwsHaRelease.parse_options(%w(--as-group-name test_group))[:as_group_name]).to eq 'test_group'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets default options' do
|
it 'sets default options' do
|
||||||
options = AwsHaRelease.parse_options(%w(-a test_group))
|
options = AwsMissingTools::AwsHaRelease.parse_options(%w(-a test_group))
|
||||||
expect(options[:elb_timeout]).not_to be_nil
|
expect(options[:elb_timeout]).not_to be_nil
|
||||||
expect(options[:region]).not_to be_nil
|
expect(options[:region]).not_to be_nil
|
||||||
expect(options[:inservice_time_allowed]).not_to be_nil
|
expect(options[:inservice_time_allowed]).not_to be_nil
|
||||||
|
@ -49,27 +49,27 @@ describe 'aws-ha-release' do
|
||||||
context 'optional params' do
|
context 'optional params' do
|
||||||
it 'ELB timeout' do
|
it 'ELB timeout' do
|
||||||
[%w(-a test_group -t 10), %w(-a test_group --elb-timeout 10)].each do |options|
|
[%w(-a test_group -t 10), %w(-a test_group --elb-timeout 10)].each do |options|
|
||||||
expect(AwsHaRelease.parse_options(options)[:elb_timeout]).to eq 10
|
expect(AwsMissingTools::AwsHaRelease.parse_options(options)[:elb_timeout]).to eq 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'region' do
|
it 'region' do
|
||||||
[%w(-a test_group -r test_region), %w(-a test_group --region test_region)].each do |options|
|
[%w(-a test_group -r test_region), %w(-a test_group --region test_region)].each do |options|
|
||||||
expect(AwsHaRelease.parse_options(options)[:region]).to eq 'test_region'
|
expect(AwsMissingTools::AwsHaRelease.parse_options(options)[:region]).to eq 'test_region'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'inservice time allowed' do
|
it 'inservice time allowed' do
|
||||||
[%w(-a test_group -i 300), %w(-a test_group --inservice-time-allowed 300)].each do |options|
|
[%w(-a test_group -i 300), %w(-a test_group --inservice-time-allowed 300)].each do |options|
|
||||||
expect(AwsHaRelease.parse_options(options)[:inservice_time_allowed]).to eq 300
|
expect(AwsMissingTools::AwsHaRelease.parse_options(options)[:inservice_time_allowed]).to eq 300
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'aws_access_key and aws_secret_key' do
|
it 'aws_access_key and aws_secret_key' do
|
||||||
expect{ AwsHaRelease.parse_options(%w(-a test_group -o testkey)) }.to raise_error OptionParser::MissingArgument
|
expect{ AwsMissingTools::AwsHaRelease.parse_options(%w(-a test_group -o testkey)) }.to raise_error OptionParser::MissingArgument
|
||||||
expect{ AwsHaRelease.parse_options(%w(-a test_group -s testsecretkey)) }.to raise_error OptionParser::MissingArgument
|
expect{ AwsMissingTools::AwsHaRelease.parse_options(%w(-a test_group -s testsecretkey)) }.to raise_error OptionParser::MissingArgument
|
||||||
|
|
||||||
options = AwsHaRelease.parse_options(%w(-a test_group -o testkey -s testsecretkey))
|
options = AwsMissingTools::AwsHaRelease.parse_options(%w(-a test_group -o testkey -s testsecretkey))
|
||||||
expect(options[:aws_access_key]).to eq 'testkey'
|
expect(options[:aws_access_key]).to eq 'testkey'
|
||||||
expect(options[:aws_secret_key]).to eq 'testsecretkey'
|
expect(options[:aws_secret_key]).to eq 'testsecretkey'
|
||||||
end
|
end
|
||||||
|
@ -79,7 +79,7 @@ describe 'aws-ha-release' do
|
||||||
describe '#execute!' do
|
describe '#execute!' do
|
||||||
before do
|
before do
|
||||||
@group = as.groups.create opts[1]
|
@group = as.groups.create opts[1]
|
||||||
@aws_ha_release = AwsHaRelease.new(opts)
|
@aws_ha_release = AwsMissingTools::AwsHaRelease.new(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'suspends certain autoscaling processes' do
|
it 'suspends certain autoscaling processes' do
|
||||||
|
@ -114,7 +114,7 @@ describe 'aws-ha-release' do
|
||||||
before do
|
before do
|
||||||
@group = as.groups.create opts[1]
|
@group = as.groups.create opts[1]
|
||||||
@group.update(desired_capacity: 2)
|
@group.update(desired_capacity: 2)
|
||||||
@aws_ha_release = AwsHaRelease.new(opts)
|
@aws_ha_release = AwsMissingTools::AwsHaRelease.new(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'checks all instances across a given load balancer' do
|
it 'checks all instances across a given load balancer' do
|
||||||
|
@ -194,7 +194,7 @@ describe 'aws-ha-release' do
|
||||||
describe '#deregister_instance' do
|
describe '#deregister_instance' do
|
||||||
before do
|
before do
|
||||||
@group = as.groups.create opts[1]
|
@group = as.groups.create opts[1]
|
||||||
@aws_ha_release = AwsHaRelease.new(opts)
|
@aws_ha_release = AwsMissingTools::AwsHaRelease.new(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deregisters an instance across all load balancers' do
|
it 'deregisters an instance across all load balancers' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user