Port collision type mismatches fixed. [closes GH-185]

This commit is contained in:
Mitchell Hashimoto 2010-10-09 01:21:52 -07:00
parent ebf1fa2fb1
commit 341e7916f4
5 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
## 0.6.6 (unreleased)
- Fix port collision handling with greater than two VMs. [GH-185]
- Fix potential infinite loop with root path if bad CWD is given to environment.
## 0.6.5 (October 8, 2010)

View File

@ -34,7 +34,7 @@ module Vagrant
def external_collision_check
existing = used_ports
@env.env.config.vm.forwarded_ports.each do |name, options|
if existing.include?(options[:hostport].to_s)
if existing.include?(options[:hostport].to_i)
handle_collision(name, options, existing)
end
end

View File

@ -14,7 +14,7 @@ module Vagrant
if vm.running? && vm.uuid != @env["vm"].uuid
vm.network_adapters.collect do |na|
na.nat_driver.forwarded_ports.collect do |fp|
fp.hostport.to_s
fp.hostport.to_i
end
end
end

View File

@ -64,7 +64,7 @@ class ForwardPortsHelpersVMActionTest < Test::Unit::TestCase
na.stubs(:nat_driver).returns(ne)
ne.stubs(:forwarded_ports).returns(fps)
@vms << mock_vm(:network_adapters => [na])
assert_equal %W[2222 80], @instance.used_ports
assert_equal [2222, 80], @instance.used_ports
end
end
end

View File

@ -53,12 +53,12 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
end
should "not raise any errors if no forwarded ports collide" do
@used_ports << "80"
@used_ports << 80
assert_nothing_raised { @klass.new(@app, @env) }
end
should "handle collision if it happens" do
@used_ports << "2222"
@used_ports << 2222
@klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once
assert_nothing_raised { @klass.new(@app, @env) }
end