Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/base_node.py
#	gns3server/compute/docker/__init__.py
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/controller/compute.py
#	gns3server/controller/gns3vm/virtualbox_gns3_vm.py
#	gns3server/controller/node.py
#	gns3server/controller/project.py
#	gns3server/crash_report.py
#	gns3server/handlers/api/controller/template_handler.py
#	gns3server/static/web-ui/index.html
#	gns3server/static/web-ui/main.8448c96e4facbe79a613.js
#	gns3server/version.py
#	tests/compute/iou/test_iou_vm.py
#	tests/compute/qemu/test_qemu_vm.py
#	tests/handlers/api/controller/test_template.py
This commit is contained in:
grossmj committed 2023-06-20 16:06:53 +09:30
commit 1ff23348d3
23 files changed
+763 -138

No files matched your search

+2 -3
View File
@@ -1350,8 +1350,7 @@ async def test_close(vm, port_manager):
async def test_close_vnc(vm):
vm._console_type = "vnc"
vm._x11vnc_process = MagicMock()
vm._xvfb_process = MagicMock()
vm._vnc_process = MagicMock()
with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
@@ -1359,7 +1358,7 @@ async def test_close_vnc(vm):
mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1, "v": 1})
assert vm._closed is True
assert vm._xvfb_process.terminate.called
assert vm._vnc_process.terminate.called
@pytest.mark.asyncio
+9 -2
View File
@@ -98,6 +98,7 @@ async def test_start(vm):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=mock_process) as mock_exec:
mock_process.returncode = None
mock_process.communicate = AsyncioMagicMock(return_value=(None, None))
await vm.start()
assert vm.is_running()
assert vm.command_line == ' '.join(mock_exec.call_args[0])
@@ -127,6 +128,7 @@ async def test_start_with_iourc(vm, tmpdir, config):
config.settings.IOU.iourc_path = fake_file
with asyncio_patch("asyncio.create_subprocess_exec", return_value=mock_process) as exec_mock:
mock_process.returncode = None
mock_process.communicate = AsyncioMagicMock(return_value=(None, None))
await vm.start()
assert vm.is_running()
arsgs, kwargs = exec_mock.call_args
@@ -164,11 +166,12 @@ async def test_stop(vm):
future = asyncio.Future()
future.set_result(True)
process.wait.return_value = future
process.returncode = None
process.communicate = AsyncioMagicMock(return_value=(None, None))
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
await vm.start()
process.returncode = None
assert vm.is_running()
await vm.stop()
assert vm.is_running() is False
@@ -190,6 +193,7 @@ async def test_reload(vm, fake_iou_bin):
future.set_result(True)
process.wait.return_value = future
process.returncode = None
process.communicate = AsyncioMagicMock(return_value=(None, None))
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
@@ -203,10 +207,13 @@ async def test_reload(vm, fake_iou_bin):
@pytest.mark.asyncio
async def test_close(vm, port_manager):
process = MagicMock()
process.returncode = None
process.communicate = AsyncioMagicMock(return_value=(None, None))
vm._start_ubridge = AsyncioMagicMock(return_value=True)
vm._ubridge_send = AsyncioMagicMock()
with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
await vm.start()
port = vm.console
await vm.close()
+14
View File
@@ -751,6 +751,20 @@ async def test_build_command_large_number_of_adapters(vm):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
await vm._build_command()
@pytest.mark.asyncio
async def test_build_command_with_virtio_net_pci_adapter(vm):
"""
Test virtio-net-pci adapter which has parameters speed=1000 & duplex=full hard-coded
"""
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.4.0")
vm.adapters = 1
vm.mac_address = "00:00:ab:0e:0f:09"
vm._adapter_type = "virtio-net-pci"
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
cmd = await vm._build_command()
assert "virtio-net-pci,mac=00:00:ab:0e:0f:09,speed=10000,duplex=full,netdev=gns3-0" in cmd
@pytest.mark.asyncio
async def test_build_command_with_invalid_options(vm):