mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Test work without vpcs binary
This commit is contained in:
parent
0eaa7be86a
commit
984d47f9c8
@ -6,7 +6,7 @@ python:
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:gns3/ppa -y
|
||||
- sudo apt-get update -q
|
||||
- sudo apt-get install vpcs dynamips
|
||||
- sudo apt-get install dynamips
|
||||
|
||||
install:
|
||||
- python setup.py install
|
||||
|
@ -20,5 +20,5 @@ X-ROUTE: /vpcs
|
||||
"name": "PC TEST 1",
|
||||
"project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
|
||||
"script_file": null,
|
||||
"uuid": "f598eb3a-67b2-43ab-af37-3c9b1f643cdd"
|
||||
"uuid": "12171ed6-4234-4ba7-9ef5-db3631a3a2e4"
|
||||
}
|
||||
|
@ -157,7 +157,6 @@ class PortManager:
|
||||
Get an available TCP console port and reserve it
|
||||
"""
|
||||
|
||||
print("FREE")
|
||||
port = self.find_unused_port(self._console_port_range[0],
|
||||
self._console_port_range[1],
|
||||
host=self._console_host,
|
||||
|
@ -77,8 +77,6 @@ class VPCSVM(BaseVM):
|
||||
else:
|
||||
self._console = self._manager.port_manager.get_free_console_port()
|
||||
|
||||
self._check_requirements()
|
||||
|
||||
def __del__(self):
|
||||
self._kill_process()
|
||||
|
||||
@ -169,6 +167,8 @@ class VPCSVM(BaseVM):
|
||||
Starts the VPCS process.
|
||||
"""
|
||||
|
||||
self._check_requirements()
|
||||
|
||||
if not self.is_running():
|
||||
if not self._ethernet_adapter.get_nio(0):
|
||||
raise VPCSError("This VPCS instance must be connected in order to start")
|
||||
|
@ -44,21 +44,24 @@ def test_vm(project, manager):
|
||||
|
||||
|
||||
@patch("subprocess.check_output", return_value="Welcome to Virtual PC Simulator, version 0.1".encode("utf-8"))
|
||||
def test_vm_invalid_vpcs_version(project, manager):
|
||||
def test_vm_invalid_vpcs_version(project, manager, loop):
|
||||
with pytest.raises(VPCSError):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
loop.run_until_complete(asyncio.async(vm.start()))
|
||||
assert vm.name == "test"
|
||||
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
|
||||
@patch("gns3server.config.Config.get_section_config", return_value={"path": "/bin/test_fake"})
|
||||
def test_vm_invalid_vpcs_path(project, manager):
|
||||
def test_vm_invalid_vpcs_path(project, manager, loop):
|
||||
with pytest.raises(VPCSError):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
loop.run_until_complete(asyncio.async(vm.start()))
|
||||
assert vm.name == "test"
|
||||
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
|
||||
@patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True)
|
||||
def test_start(project, loop, manager):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
@ -68,6 +71,7 @@ def test_start(project, loop, manager):
|
||||
assert vm.is_running()
|
||||
|
||||
|
||||
@patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True)
|
||||
def test_stop(project, loop, manager):
|
||||
process = MagicMock()
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
|
||||
|
Loading…
Reference in New Issue
Block a user