mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Fix test suite after VPCS changes for using ubridge
This commit is contained in:
parent
852d8e411e
commit
4c3bfde97e
@ -108,6 +108,9 @@ class VPCSVM(BaseNode):
|
|||||||
if not path:
|
if not path:
|
||||||
raise VPCSError("No path to a VPCS executable has been set")
|
raise VPCSError("No path to a VPCS executable has been set")
|
||||||
|
|
||||||
|
# This raise an error if ubridge is not available
|
||||||
|
ubridge_path = self.ubridge_path
|
||||||
|
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
raise VPCSError("VPCS program '{}' is not accessible".format(path))
|
raise VPCSError("VPCS program '{}' is not accessible".format(path))
|
||||||
|
|
||||||
|
@ -104,4 +104,3 @@ class DrawingHandler:
|
|||||||
project = controller.get_project(request.match_info["project_id"])
|
project = controller.get_project(request.match_info["project_id"])
|
||||||
yield from project.delete_drawing(request.match_info["drawing_id"])
|
yield from project.delete_drawing(request.match_info["drawing_id"])
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from tests.utils import asyncio_patch
|
from tests.utils import asyncio_patch, AsyncioMagicMock
|
||||||
from gns3server.utils import parse_version
|
from gns3server.utils import parse_version
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock, ANY
|
||||||
|
|
||||||
from gns3server.compute.vpcs.vpcs_vm import VPCSVM
|
from gns3server.compute.vpcs.vpcs_vm import VPCSVM
|
||||||
from gns3server.compute.vpcs.vpcs_error import VPCSError
|
from gns3server.compute.vpcs.vpcs_error import VPCSError
|
||||||
@ -39,9 +39,10 @@ def manager(port_manager):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def vm(project, manager):
|
def vm(project, manager, ubridge_path):
|
||||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||||
vm._vpcs_version = parse_version("0.9")
|
vm._vpcs_version = parse_version("0.9")
|
||||||
|
vm._start_ubridge = AsyncioMagicMock()
|
||||||
return vm
|
return vm
|
||||||
|
|
||||||
|
|
||||||
@ -104,9 +105,9 @@ def test_start(loop, vm, async_run):
|
|||||||
'-F',
|
'-F',
|
||||||
'-R',
|
'-R',
|
||||||
'-s',
|
'-s',
|
||||||
'4242',
|
ANY,
|
||||||
'-c',
|
'-c',
|
||||||
'4243',
|
ANY,
|
||||||
'-t',
|
'-t',
|
||||||
'127.0.0.1')
|
'127.0.0.1')
|
||||||
assert vm.is_running()
|
assert vm.is_running()
|
||||||
@ -138,9 +139,9 @@ def test_start_0_6_1(loop, vm):
|
|||||||
'1',
|
'1',
|
||||||
'-F',
|
'-F',
|
||||||
'-s',
|
'-s',
|
||||||
'4242',
|
ANY,
|
||||||
'-c',
|
'-c',
|
||||||
'4243',
|
ANY,
|
||||||
'-t',
|
'-t',
|
||||||
'127.0.0.1')
|
'127.0.0.1')
|
||||||
assert vm.is_running()
|
assert vm.is_running()
|
||||||
|
@ -205,6 +205,7 @@ def run_around_tests(monkeypatch, port_manager, controller, config):
|
|||||||
os.makedirs(os.path.join(tmppath, 'projects'))
|
os.makedirs(os.path.join(tmppath, 'projects'))
|
||||||
config.set("Server", "projects_path", os.path.join(tmppath, 'projects'))
|
config.set("Server", "projects_path", os.path.join(tmppath, 'projects'))
|
||||||
config.set("Server", "images_path", os.path.join(tmppath, 'images'))
|
config.set("Server", "images_path", os.path.join(tmppath, 'images'))
|
||||||
|
config.set("Server", "ubridge_path", os.path.join(tmppath, 'bin', 'ubridge'))
|
||||||
config.set("Server", "auth", False)
|
config.set("Server", "auth", False)
|
||||||
config.set("Server", "controller", True)
|
config.set("Server", "controller", True)
|
||||||
|
|
||||||
@ -252,6 +253,17 @@ def projects_dir(config):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def ubridge_path(config):
|
||||||
|
"""
|
||||||
|
Get the location of a fake ubridge
|
||||||
|
"""
|
||||||
|
path = config.get_section_config("Server").get("ubridge_path")
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
open(path, 'w+').close()
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def darwin_platform():
|
def darwin_platform():
|
||||||
"""
|
"""
|
||||||
|
@ -123,10 +123,6 @@ def test_choose_capture_side(async_run, project):
|
|||||||
async_run(link.add_node(node_vpcs, 0, 4))
|
async_run(link.add_node(node_vpcs, 0, 4))
|
||||||
async_run(link.add_node(node_vpcs2, 3, 1))
|
async_run(link.add_node(node_vpcs2, 3, 1))
|
||||||
|
|
||||||
# VPCS doesn't support capture
|
|
||||||
with pytest.raises(aiohttp.web.HTTPConflict):
|
|
||||||
link._choose_capture_side()["node"]
|
|
||||||
|
|
||||||
# Capture should run on the local node
|
# Capture should run on the local node
|
||||||
node_iou = Node(project, compute1, "node1", node_type="iou")
|
node_iou = Node(project, compute1, "node1", node_type="iou")
|
||||||
node_iou2 = Node(project, compute2, "node2", node_type="iou")
|
node_iou2 = Node(project, compute2, "node2", node_type="iou")
|
||||||
@ -151,7 +147,7 @@ def test_capture(async_run, project):
|
|||||||
capture = async_run(link.start_capture())
|
capture = async_run(link.start_capture())
|
||||||
assert link.capturing
|
assert link.capturing
|
||||||
|
|
||||||
compute1.post.assert_any_call("/projects/{}/iou/nodes/{}/adapters/3/ports/1/start_capture".format(project.id, node_iou.id), data={
|
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/start_capture".format(project.id, node_vpcs.id), data={
|
||||||
"capture_file_name": link.default_capture_file_name(),
|
"capture_file_name": link.default_capture_file_name(),
|
||||||
"data_link_type": "DLT_EN10MB"
|
"data_link_type": "DLT_EN10MB"
|
||||||
})
|
})
|
||||||
@ -159,7 +155,7 @@ def test_capture(async_run, project):
|
|||||||
capture = async_run(link.stop_capture())
|
capture = async_run(link.stop_capture())
|
||||||
assert link.capturing is False
|
assert link.capturing is False
|
||||||
|
|
||||||
compute1.post.assert_any_call("/projects/{}/iou/nodes/{}/adapters/3/ports/1/stop_capture".format(project.id, node_iou.id))
|
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/stop_capture".format(project.id, node_vpcs.id))
|
||||||
|
|
||||||
|
|
||||||
def test_read_pcap_from_source(project, async_run):
|
def test_read_pcap_from_source(project, async_run):
|
||||||
|
@ -33,7 +33,6 @@ from gns3server.controller import Controller
|
|||||||
from gns3server.controller.drawing import Drawing
|
from gns3server.controller.drawing import Drawing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def project(http_controller, async_run):
|
def project(http_controller, async_run):
|
||||||
return async_run(Controller.instance().add_project())
|
return async_run(Controller.instance().add_project())
|
||||||
|
Loading…
Reference in New Issue
Block a user