From 80fd85765883b0b108f8581eed21e440fe97b861 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 3 Mar 2015 14:37:34 +0100 Subject: [PATCH] Fix tests --- gns3server/modules/port_manager.py | 2 +- tests/handlers/api/test_qemu.py | 3 +++ tests/modules/qemu/test_qemu_vm.py | 15 ++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gns3server/modules/port_manager.py b/gns3server/modules/port_manager.py index 79b8b6eb..f38e2ea3 100644 --- a/gns3server/modules/port_manager.py +++ b/gns3server/modules/port_manager.py @@ -80,7 +80,7 @@ class PortManager: return self._console_host @console_host.setter - def host(self, new_host): + def console_host(self, new_host): self._console_host = new_host diff --git a/tests/handlers/api/test_qemu.py b/tests/handlers/api/test_qemu.py index b32cd945..12a72e87 100644 --- a/tests/handlers/api/test_qemu.py +++ b/tests/handlers/api/test_qemu.py @@ -133,6 +133,7 @@ def test_qemu_update(server, vm, tmpdir, free_console_port, project): def test_qemu_nio_create_udp(server, vm): + server.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2}) response = server.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_udp", "lport": 4242, "rport": 4343, @@ -144,6 +145,7 @@ def test_qemu_nio_create_udp(server, vm): def test_qemu_nio_create_ethernet(server, vm): + server.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2}) response = server.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet", "ethernet_device": "eth0", }, @@ -155,6 +157,7 @@ def test_qemu_nio_create_ethernet(server, vm): def test_qemu_delete_nio(server, vm): + server.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2}) server.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_udp", "lport": 4242, "rport": 4343, diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index 76b4a97c..c0b6d1ee 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -59,6 +59,7 @@ def fake_qemu_binary(): @pytest.fixture(scope="function") def vm(project, manager, fake_qemu_binary, fake_qemu_img_binary): + manager.port_manager.console_host = "127.0.0.1" return QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, qemu_path=fake_qemu_binary) @@ -252,7 +253,7 @@ def test_control_vm_expect_text(vm, loop, running_subprocess_mock): assert res == "epic product" -def test_build_command(vm, loop, fake_qemu_binary): +def test_build_command(vm, loop, fake_qemu_binary, port_manager): os.environ["DISPLAY"] = "0:0" with patch("gns3server.modules.qemu.qemu_vm.QemuVM._get_random_mac", return_value="00:00:ab:7e:b5:00"): @@ -267,13 +268,13 @@ def test_build_command(vm, loop, fake_qemu_binary): "-hda", os.path.join(vm.working_dir, "flash.qcow2"), "-serial", - "telnet:0.0.0.0:{},server,nowait".format(vm.console), + "telnet:127.0.0.1:{},server,nowait".format(vm.console), "-monitor", - "telnet:0.0.0.0:{},server,nowait".format(vm.monitor), - "-net", - "nic,vlan=0,macaddr=00:00:ab:7e:b5:00,model=e1000", - "-net", - "user,vlan=0,name=gns3-0" + "telnet:127.0.0.1:{},server,nowait".format(vm.monitor), + "-device", + "e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0", + "-netdev", + "user,id=gns3-0" ]