loop through each instance, wait for a new one to come up, then deregister and terminate the old one
This commit is contained in:
@@ -13,7 +13,6 @@ describe 'aws-ha-release' do
|
||||
let(:as) { AWS::FakeAutoScaling.new }
|
||||
|
||||
before do
|
||||
AWS.stub(:config)
|
||||
AWS::AutoScaling.stub(:new).and_return(as)
|
||||
end
|
||||
|
||||
@@ -101,4 +100,30 @@ describe 'aws-ha-release' do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#deregister_instance' do
|
||||
before do
|
||||
@group = as.groups.create opts[:as_group_name]
|
||||
@aws_ha_release = AwsHaRelease.new(opts)
|
||||
end
|
||||
|
||||
it 'deregisters an instance across all load balancers' do
|
||||
instance_one = AWS::FakeEC2::Instance.new
|
||||
instance_two = AWS::FakeEC2::Instance.new
|
||||
|
||||
elb_one = AWS::FakeELB::LoadBalancer.new 'test_load_balancer_01'
|
||||
elb_two = AWS::FakeELB::LoadBalancer.new 'test_load_balancer_02'
|
||||
|
||||
elb_one.instances.register instance_one
|
||||
elb_one.instances.register instance_two
|
||||
|
||||
elb_two.instances.register instance_one
|
||||
elb_two.instances.register instance_two
|
||||
|
||||
@aws_ha_release.deregister_instance instance_one, [elb_one, elb_two]
|
||||
|
||||
expect(elb_one.instances).not_to include instance_one
|
||||
expect(elb_two.instances).not_to include instance_one
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,4 +5,8 @@ Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.order = 'random'
|
||||
|
||||
config.before do
|
||||
AWS.stub!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,6 +42,10 @@ module AWS
|
||||
self.instance_variable_set "@#{key}", value
|
||||
end
|
||||
end
|
||||
|
||||
def ec2_instances
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,10 +12,20 @@ module AWS
|
||||
end
|
||||
end
|
||||
|
||||
class InstanceCollection
|
||||
class InstanceCollection < Array
|
||||
def initialize
|
||||
end
|
||||
|
||||
def register(*instances)
|
||||
self.concat instances
|
||||
end
|
||||
|
||||
def deregister(*instances)
|
||||
instances.each do |i|
|
||||
self.delete i
|
||||
end
|
||||
end
|
||||
|
||||
def health
|
||||
@health ||= [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user