Skip to content

Commit

Permalink
add a true and false test and fix the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fearoffish committed Sep 2, 2016
1 parent 7f32371 commit 10fd76b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bosh_aws_cpi/lib/cloud/aws/instance_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create(agent_id, stemcell_id, resource_pool, networks_spec, disk_locality, e
instance.wait_for_running
instance.attach_to_load_balancers(resource_pool['elbs'] || [])
instance.update_routing_tables(resource_pool['advertised_routes'] || [])
instance.source_dest_check = resource_pool['source_dest_check'] || true
instance.source_dest_check = resource_pool.fetch('source_dest_check', true)
rescue => e
@logger.warn("Failed to configure instance '#{instance.id}': #{e.inspect}")
begin
Expand Down
4 changes: 2 additions & 2 deletions src/bosh_aws_cpi/spec/unit/instance_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module Bosh::AwsCloud
it 'should ask AWS to create an instance in the given region, with parameters built up from the given arguments' do
instance_manager = InstanceManager.new(ec2, registry, elb, param_mapper, block_device_manager, logger)
allow(instance_manager).to receive(:get_created_instance_id).with("run-instances-response").and_return('i-12345678')
allow(aws_instance).to receive(:source_dest_check=).with(true)
allow(aws_instance).to receive(:source_dest_check=).with(false)

expect(aws_client).to receive(:run_instances).with({ fake: 'instance-params', min_count: 1, max_count: 1 }).and_return("run-instances-response")
instance_manager.create(
Expand Down Expand Up @@ -238,7 +238,7 @@ module Bosh::AwsCloud
expect(aws_client).to receive(:run_instances).with({ fake: 'instance-params', min_count: 1, max_count: 1 }).and_return("run-instances-response")

allow(ResourceWait).to receive(:for_instance).with(instance: aws_instance, state: :running)
allow(aws_instance).to receive(:source_dest_check=).with(true)
allow(aws_instance).to receive(:source_dest_check=).with(false)
expect(logger).to receive(:warn).with(/IP address was in use/).once

instance_manager.create(
Expand Down
7 changes: 6 additions & 1 deletion src/bosh_aws_cpi/spec/unit/instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ module Bosh::AwsCloud
end

describe '#source_dest_check=' do
it 'propagates source_dest_check=' do
it 'propagates source_dest_check= true' do
expect(aws_instance).to receive(:source_dest_check=).with(false)
instance.source_dest_check = false
end

it 'propagates source_dest_check= false' do
expect(aws_instance).to receive(:source_dest_check=).with(true)
instance.source_dest_check = true
end
end

describe '#attach_to_load_balancers' do
Expand Down

0 comments on commit 10fd76b

Please sign in to comment.