use AutoScaling::Instance instead of EC2::Instance

This commit is contained in:
Anuj Biyani 2013-06-04 15:39:56 -07:00
parent f6f07ec0fc
commit f91dbe1c94
4 changed files with 21 additions and 25 deletions

View File

@ -86,8 +86,8 @@ module AwsMissingTools
@group.update(desired_capacity: @group.desired_capacity + 1) @group.update(desired_capacity: @group.desired_capacity + 1)
puts "The list of Instances in Auto Scaling Group #{@group.name} that will be terminated is:\n#{@group.ec2_instances.map(&:id)}" puts "The list of Instances in Auto Scaling Group #{@group.name} that will be terminated is:\n#{@group.auto_scaling_instances.map(&:id)}"
@group.ec2_instances.each do |instance| @group.auto_scaling_instances.each do |instance|
time_taken = 0 time_taken = 0
begin begin

View File

@ -5,9 +5,9 @@ describe 'aws-ha-release' do
let(:as) { AWS::FakeAutoScaling.new } let(:as) { AWS::FakeAutoScaling.new }
let(:instance_one) { AWS::FakeEC2::Instance.new } let(:instance_one) { AWS::FakeAutoScaling::Instance.new(@group) }
let(:instance_two) { AWS::FakeEC2::Instance.new } let(:instance_two) { AWS::FakeAutoScaling::Instance.new(@group) }
before do before do
AWS::AutoScaling.stub(:new).and_return(as) AWS::AutoScaling.stub(:new).and_return(as)
@ -183,7 +183,7 @@ describe 'aws-ha-release' do
expect(@aws_ha_release.instances_inservice?(load_balancer)).to eq false expect(@aws_ha_release.instances_inservice?(load_balancer)).to eq false
instance_three = AWS::FakeEC2::Instance.new instance_three = AWS::FakeAutoScaling::Instance.new(@group)
load_balancer.instances.register instance_three load_balancer.instances.register instance_three
load_balancer.instances.make_instance_healthy(instance_three) load_balancer.instances.make_instance_healthy(instance_three)

View File

@ -47,13 +47,27 @@ module AWS
end end
end end
def ec2_instances def auto_scaling_instances
@ec2_instances ||= [AWS::FakeEC2::Instance.new, AWS::FakeEC2::Instance.new] @auto_scaling_instances ||= [AWS::FakeAutoScaling::Instance.new(self), AWS::FakeAutoScaling::Instance.new(self)]
end end
def load_balancers def load_balancers
@load_balancers ||= AWS::FakeELB::LoadBalancerCollection.new @load_balancers ||= AWS::FakeELB::LoadBalancerCollection.new
end end
end end
class Instance
def initialize(group)
@group = group
end
def terminate(decrement_desired_capacity)
@group.update(desired_capacity: @group.desired_capacity - 1) if decrement_desired_capacity
end
def id
'i-test'
end
end
end end
end end

View File

@ -1,18 +0,0 @@
module AWS
class FakeEC2
def initialize
end
class Instance
def initialize
end
def terminate(decrement_desired_capacity)
end
def id
'i-test'
end
end
end
end