Improve VPCS port change test

This commit is contained in:
Julien Duponchelle 2015-01-21 22:06:25 +01:00
parent 7ce1cf3f84
commit ef4ecbfb6a
2 changed files with 12 additions and 5 deletions

View File

@ -130,6 +130,9 @@ class VPCSVM(BaseVM):
:params console: Console port (integer)
"""
if console == self._console:
return
if self._console:
self._manager.port_manager.release_console_port(self._console)
self._console = self._manager.port_manager.reserve_console_port(console)

View File

@ -138,11 +138,15 @@ def test_get_startup_script(vm):
assert vm.startup_script == content
def test_change_console_port(vm, free_console_port):
vm.console = free_console_port
vm.console = free_console_port + 1
assert vm.console == free_console_port
PortManager.instance().reserve_console_port(free_console_port + 1)
def test_change_console_port(vm, port_manager):
port1 = port_manager.get_free_console_port()
port2 = port_manager.get_free_console_port()
port_manager.release_console_port(port1)
port_manager.release_console_port(port2)
vm.console = port1
vm.console = port2
assert vm.console == port2
PortManager.instance().reserve_console_port(port1)
def test_change_name(vm, tmpdir):