mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Drop Windows support
This commit is contained in:
1 parent
4fb0cd9321
commit
74c675d5b0
47 files changed
+223
-1004
No files matched your search
@@ -29,7 +29,6 @@ from gns3server.utils.path import get_default_project_directory
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
async def test_get(app: FastAPI, compute_client: AsyncClient, windows_platform) -> None:
|
||||
|
||||
response = await compute_client.get(app.url_path_for("compute:get_capabilities"))
|
||||
@@ -43,7 +42,6 @@ async def test_get(app: FastAPI, compute_client: AsyncClient, windows_platform)
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
async def test_get_on_gns3vm(app: FastAPI, compute_client: AsyncClient, on_gns3vm) -> None:
|
||||
|
||||
response = await compute_client.get(app.url_path_for("compute:get_capabilities"))
|
||||
|
||||
@@ -25,8 +25,7 @@ from unittest.mock import patch
|
||||
|
||||
from gns3server.compute.project import Project
|
||||
|
||||
pytestmark = [pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows"),
|
||||
pytest.mark.asyncio]
|
||||
pytestmark = [pytest.mark.asyncio]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -209,7 +209,7 @@ async def test_download_image_forbidden(app: FastAPI, compute_client: AsyncClien
|
||||
assert response.status_code == status.HTTP_403_FORBIDDEN
|
||||
|
||||
|
||||
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any image")
|
||||
@pytest.mark.skipif(os.getuid() == 0, reason="Root can delete any image")
|
||||
async def test_upload_image_permission_denied(app: FastAPI, compute_client: AsyncClient, images_dir: str) -> None:
|
||||
|
||||
os.makedirs(os.path.join(images_dir, "IOS"), exist_ok=True)
|
||||
|
||||
@@ -28,8 +28,7 @@ from unittest.mock import patch
|
||||
|
||||
from gns3server.compute.project import Project
|
||||
|
||||
pytestmark = [pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows"),
|
||||
pytest.mark.asyncio]
|
||||
pytestmark = [pytest.mark.asyncio]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -34,11 +34,7 @@ pytestmark = pytest.mark.asyncio
|
||||
def fake_qemu_bin(monkeypatch, tmpdir) -> str:
|
||||
|
||||
monkeypatch.setenv("PATH", str(tmpdir))
|
||||
if sys.platform.startswith("win"):
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.exe")
|
||||
else:
|
||||
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64")
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64")
|
||||
with open(bin_path, "w+") as f:
|
||||
f.write("1")
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
@@ -120,7 +116,6 @@ async def test_qemu_create_with_params(app: FastAPI,
|
||||
assert response.json()["hda_disk_image_md5sum"] == "c4ca4238a0b923820dcc509a6f75849b"
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
async def test_qemu_create_with_project_file(app: FastAPI,
|
||||
compute_client: AsyncClient,
|
||||
compute_project: Project,
|
||||
@@ -411,7 +406,7 @@ async def test_download_image_forbidden_location(app: FastAPI, compute_client: A
|
||||
assert response.status_code == status.HTTP_403_FORBIDDEN
|
||||
|
||||
|
||||
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any image")
|
||||
@pytest.mark.skipif(os.getuid() == 0, reason="Root can delete any image")
|
||||
async def test_upload_image_permission_denied(app: FastAPI, compute_client: AsyncClient, images_dir: str) -> None:
|
||||
|
||||
with open(os.path.join(images_dir, "QEMU", "test2.tmp"), "w+") as f:
|
||||
|
||||
@@ -1401,7 +1401,6 @@ async def test_get_image_information(compute_project, manager):
|
||||
mock.assert_called_with("GET", "images/ubuntu:latest/json")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_mount_binds(vm):
|
||||
|
||||
@@ -1476,7 +1475,6 @@ async def test_create_network_interfaces(vm):
|
||||
assert "eth5" not in content
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_fix_permission(vm):
|
||||
|
||||
@@ -1489,7 +1487,6 @@ async def test_fix_permission(vm):
|
||||
assert process.wait.called
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_fix_permission_not_running(vm):
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ def test_vm_invalid_dynamips_path(manager, config):
|
||||
manager.find_dynamips()
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported by Windows")
|
||||
def test_vm_non_executable_dynamips_path(manager, config):
|
||||
|
||||
tmpfile = tempfile.NamedTemporaryFile()
|
||||
|
||||
@@ -26,14 +26,10 @@ import shutil
|
||||
|
||||
from tests.utils import asyncio_patch, AsyncioMagicMock
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
pytestmark = pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
|
||||
if not sys.platform.startswith("win"):
|
||||
from gns3server.compute.iou.iou_vm import IOUVM
|
||||
from gns3server.compute.iou.iou_error import IOUError
|
||||
from gns3server.compute.iou import IOU
|
||||
from unittest.mock import MagicMock
|
||||
from gns3server.compute.iou.iou_vm import IOUVM
|
||||
from gns3server.compute.iou.iou_error import IOUError
|
||||
from gns3server.compute.iou import IOU
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -43,10 +43,7 @@ async def test_get_qemu_version():
|
||||
|
||||
with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard"):
|
||||
version = await Qemu.get_qemu_version("/tmp/qemu-test")
|
||||
if sys.platform.startswith("win"):
|
||||
assert version == ""
|
||||
else:
|
||||
assert version == "2.2.0"
|
||||
assert version == "2.2.0"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -62,10 +59,7 @@ async def test_binary_list(monkeypatch, tmpdir):
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
|
||||
if sys.platform.startswith("win"):
|
||||
version = ""
|
||||
else:
|
||||
version = "2.2.0"
|
||||
version = "2.2.0"
|
||||
|
||||
qemus = await Qemu.binary_list()
|
||||
|
||||
|
||||
@@ -57,10 +57,7 @@ def fake_qemu_img_binary(monkeypatch, tmpdir):
|
||||
def fake_qemu_binary(monkeypatch, tmpdir):
|
||||
|
||||
monkeypatch.setenv("PATH", str(tmpdir))
|
||||
if sys.platform.startswith("win"):
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.exe")
|
||||
else:
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64")
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64")
|
||||
with open(bin_path, "w+") as f:
|
||||
f.write("1")
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
@@ -190,7 +187,6 @@ async def test_termination_callback(vm):
|
||||
assert event == vm
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_termination_callback_error(vm, tmpdir):
|
||||
|
||||
@@ -276,10 +272,7 @@ def test_set_qemu_path(vm, tmpdir, fake_qemu_binary):
|
||||
vm.qemu_path = None
|
||||
|
||||
# Should not crash with unicode characters
|
||||
if sys.platform.startswith("win"):
|
||||
path = str(tmpdir / "\u62FF" / "qemu-system-mipsw.exe")
|
||||
else:
|
||||
path = str(tmpdir / "\u62FF" / "qemu-system-mips")
|
||||
path = str(tmpdir / "\u62FF" / "qemu-system-mips")
|
||||
|
||||
os.makedirs(str(tmpdir / "\u62FF"))
|
||||
|
||||
@@ -291,10 +284,9 @@ def test_set_qemu_path(vm, tmpdir, fake_qemu_binary):
|
||||
f.write("1")
|
||||
|
||||
# Raise because file is not executable
|
||||
if not sys.platform.startswith("win"):
|
||||
with pytest.raises(QemuError):
|
||||
vm.qemu_path = path
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
with pytest.raises(QemuError):
|
||||
vm.qemu_path = path
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
vm.qemu_path = path
|
||||
assert vm.qemu_path == path
|
||||
@@ -314,8 +306,7 @@ def test_set_qemu_path_windows(vm):
|
||||
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.EXE")
|
||||
open(bin_path, "w+").close()
|
||||
if not sys.platform.startswith("win"):
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
vm.qemu_path = bin_path
|
||||
|
||||
@@ -327,8 +318,7 @@ def test_set_qemu_path_old_windows(vm):
|
||||
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu.exe")
|
||||
open(bin_path, "w+").close()
|
||||
if not sys.platform.startswith("win"):
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
os.chmod(bin_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
vm.qemu_path = bin_path
|
||||
|
||||
@@ -336,7 +326,6 @@ def test_set_qemu_path_old_windows(vm):
|
||||
assert vm.platform == "i386"
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
def test_set_qemu_path_kvm_binary(vm, fake_qemu_binary):
|
||||
|
||||
bin_path = os.path.join(os.environ["PATH"], "qemu-kvm")
|
||||
@@ -358,10 +347,7 @@ async def test_set_platform(compute_project, manager):
|
||||
with patch("shutil.which", return_value="/bin/qemu-system-x86_64") as which_mock:
|
||||
with patch("gns3server.compute.qemu.QemuVM._check_qemu_path"):
|
||||
vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, platform="x86_64")
|
||||
if sys.platform.startswith("win"):
|
||||
which_mock.assert_called_with("qemu-system-x86_64w.exe", path=mock.ANY)
|
||||
else:
|
||||
which_mock.assert_called_with("qemu-system-x86_64", path=mock.ANY)
|
||||
which_mock.assert_called_with("qemu-system-x86_64", path=mock.ANY)
|
||||
assert vm.platform == "x86_64"
|
||||
assert vm.qemu_path == "/bin/qemu-system-x86_64"
|
||||
|
||||
@@ -447,7 +433,6 @@ async def test_disk_options_multiple_disk(vm, tmpdir, fake_qemu_img_binary):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_process_priority(vm, fake_qemu_img_binary):
|
||||
|
||||
@@ -461,7 +446,6 @@ async def test_set_process_priority(vm, fake_qemu_img_binary):
|
||||
assert args == ("renice", "-n", "5", "-p", "42")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_process_priority_normal(vm, fake_qemu_img_binary):
|
||||
|
||||
@@ -634,7 +618,6 @@ async def test_build_command_kvm_2_4(linux_platform, vm, fake_qemu_binary):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_command_without_display(vm):
|
||||
|
||||
@@ -757,7 +740,6 @@ async def test_build_command_large_number_of_adapters(vm):
|
||||
await vm._build_command()
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_build_command_with_invalid_options(vm):
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ async def test_project_delete():
|
||||
assert os.path.exists(directory) is False
|
||||
|
||||
|
||||
@pytest.mark.skipif(not sys.platform.startswith("win") and os.getuid() == 0, reason="Root can delete any project")
|
||||
@pytest.mark.skipif(os.getuid() == 0, reason="Root can delete any project")
|
||||
@pytest.mark.asyncio
|
||||
async def test_project_delete_permission_issue():
|
||||
|
||||
|
||||
@@ -190,10 +190,7 @@ async def test_stop(vm):
|
||||
await vm.stop()
|
||||
assert vm.is_running() is False
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
process.send_signal.assert_called_with(1)
|
||||
else:
|
||||
process.terminate.assert_called_with()
|
||||
process.terminate.assert_called_with()
|
||||
|
||||
await queue.get(1) # Ping
|
||||
await queue.get(1) # Started
|
||||
@@ -226,10 +223,7 @@ async def test_reload(vm):
|
||||
await vm.reload()
|
||||
assert vm.is_running() is True
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
process.send_signal.assert_called_with(1)
|
||||
else:
|
||||
process.terminate.assert_called_with()
|
||||
process.terminate.assert_called_with()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -240,7 +234,6 @@ async def test_add_nio_binding_udp(vm):
|
||||
assert nio.lport == 4242
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_nio_binding_tap(vm, ethernet_device):
|
||||
|
||||
|
||||
@@ -32,20 +32,6 @@ sys._called_from_test = True
|
||||
sys.original_platform = sys.platform
|
||||
|
||||
|
||||
if sys.platform.startswith("win") and sys.version_info < (3, 8):
|
||||
@pytest.fixture(scope="session")
|
||||
def event_loop(request):
|
||||
"""
|
||||
Overwrite pytest_asyncio event loop on Windows for Python < 3.8
|
||||
As of Python 3.8, the default event loop on Windows is Proactor
|
||||
"""
|
||||
|
||||
loop = asyncio.ProactorEventLoop()
|
||||
asyncio.set_event_loop(loop)
|
||||
yield loop
|
||||
asyncio.set_event_loop(None)
|
||||
|
||||
|
||||
# https://github.com/pytest-dev/pytest-asyncio/issues/68
|
||||
# this event_loop is used by pytest-asyncio, and redefining it
|
||||
# is currently the only way of changing the scope of this fixture
|
||||
|
||||
@@ -69,7 +69,6 @@ async def test_json(controller):
|
||||
assert vm.asdict() == vm._settings
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not working well on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_settings(controller):
|
||||
|
||||
@@ -88,7 +87,6 @@ async def test_update_settings(controller):
|
||||
assert "vm" not in controller.computes
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not working well on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_auto_start(controller, dummy_gns3vm, dummy_engine):
|
||||
"""
|
||||
@@ -106,7 +104,6 @@ async def test_auto_start(controller, dummy_gns3vm, dummy_engine):
|
||||
assert controller.computes["vm"].password.get_secret_value() == "world"
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not working well on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_auto_start_with_error(controller, dummy_gns3vm, dummy_engine):
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ async def test_init_path(tmpdir):
|
||||
assert p.path == str(tmpdir)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_changing_path_with_quote_not_allowed(tmpdir):
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ async def test_exception_wait_run_in_executor():
|
||||
await wait_run_in_executor(raise_exception)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_subprocess_check_output(tmpdir):
|
||||
|
||||
|
||||
@@ -33,18 +33,13 @@ def test_interfaces():
|
||||
assert "name" in interface
|
||||
assert "ip_address" in interface
|
||||
assert "mac_address" in interface
|
||||
if sys.platform.startswith("win"):
|
||||
assert "netcard" in interface
|
||||
assert "type" in interface
|
||||
assert "netmask" in interface
|
||||
|
||||
|
||||
def test_has_netmask(config):
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
# No loopback
|
||||
pass
|
||||
elif sys.platform.startswith("darwin"):
|
||||
if sys.platform.startswith("darwin"):
|
||||
assert has_netmask("lo0") is True
|
||||
else:
|
||||
assert has_netmask("lo") is True
|
||||
@@ -52,10 +47,7 @@ def test_has_netmask(config):
|
||||
|
||||
def test_is_interface_up():
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
# is_interface_up() always returns True on Windows
|
||||
pass
|
||||
elif sys.platform.startswith("darwin"):
|
||||
if sys.platform.startswith("darwin"):
|
||||
assert is_interface_up("lo0") is True
|
||||
else:
|
||||
assert is_interface_up("lo") is True
|
||||
|
||||
Reference in new issue
Block a user