Fix random failure related to ports

This commit is contained in:
Julien Duponchelle 2015-01-21 22:21:01 +01:00
parent 8d9da999e6
commit f3e07d5ad9
4 changed files with 6 additions and 23 deletions

View File

@ -167,4 +167,3 @@ class VPCSHandler:
vm = vpcs_manager.get_vm(request.match_info["uuid"])
nio = vm.port_remove_nio_binding(int(request.match_info["port_id"]))
response.set_status(204)

View File

@ -45,24 +45,6 @@ class PortManager:
else:
self._console_host = host
@classmethod
def instance(cls):
"""
Singleton to return only one instance of BaseManager.
:returns: instance of Manager
"""
if not hasattr(cls, "_instance") or cls._instance is None:
cls._instance = cls()
return cls._instance
@classmethod
@asyncio.coroutine # FIXME: why coroutine?
def destroy(cls):
cls._instance = None
@property
def console_host(self):

View File

@ -21,7 +21,7 @@ from gns3server.modules.port_manager import PortManager
def test_reserve_console_port():
pm = PortManager.instance()
pm = PortManager()
pm.reserve_console_port(4242)
with pytest.raises(aiohttp.web.HTTPConflict):
pm.reserve_console_port(4242)

View File

@ -31,9 +31,9 @@ from gns3server.modules.port_manager import PortManager
@pytest.fixture(scope="module")
def manager():
def manager(port_manager):
m = VPCS.instance()
m.port_manager = PortManager("127.0.0.1", False)
m.port_manager = port_manager
return m
@ -143,10 +143,12 @@ def test_change_console_port(vm, port_manager):
port2 = port_manager.get_free_console_port()
port_manager.release_console_port(port1)
port_manager.release_console_port(port2)
print(vm.console)
print(port1)
vm.console = port1
vm.console = port2
assert vm.console == port2
PortManager.instance().reserve_console_port(port1)
port_manager.reserve_console_port(port1)
def test_change_name(vm, tmpdir):