use AutoScaling::Instance instead of EC2::Instance
This commit is contained in:
		
							parent
							
								
									f6f07ec0fc
								
							
						
					
					
						commit
						f91dbe1c94
					
				@ -86,8 +86,8 @@ module AwsMissingTools
 | 
			
		||||
 | 
			
		||||
      @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)}"
 | 
			
		||||
      @group.ec2_instances.each do |instance|
 | 
			
		||||
      puts "The list of Instances in Auto Scaling Group #{@group.name} that will be terminated is:\n#{@group.auto_scaling_instances.map(&:id)}"
 | 
			
		||||
      @group.auto_scaling_instances.each do |instance|
 | 
			
		||||
        time_taken = 0
 | 
			
		||||
 | 
			
		||||
        begin
 | 
			
		||||
 | 
			
		||||
@ -5,9 +5,9 @@ describe 'aws-ha-release' do
 | 
			
		||||
 | 
			
		||||
  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
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
      instance_three = AWS::FakeEC2::Instance.new
 | 
			
		||||
      instance_three = AWS::FakeAutoScaling::Instance.new(@group)
 | 
			
		||||
      load_balancer.instances.register instance_three
 | 
			
		||||
      load_balancer.instances.make_instance_healthy(instance_three)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -47,13 +47,27 @@ module AWS
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def ec2_instances
 | 
			
		||||
        @ec2_instances ||= [AWS::FakeEC2::Instance.new, AWS::FakeEC2::Instance.new]
 | 
			
		||||
      def auto_scaling_instances
 | 
			
		||||
        @auto_scaling_instances ||= [AWS::FakeAutoScaling::Instance.new(self), AWS::FakeAutoScaling::Instance.new(self)]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def load_balancers
 | 
			
		||||
        @load_balancers ||= AWS::FakeELB::LoadBalancerCollection.new
 | 
			
		||||
      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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user