mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 06:07:51 +00:00
Add a test of cloud raw ethernet interface
Before touching it for the bridge support a test to prevent regressions. Ref #761
This commit is contained in:
parent
74695efe90
commit
1b3e47ce83
@ -41,10 +41,13 @@ class Cloud(BaseNode):
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
"""
|
||||
_cloud_id = 0
|
||||
|
||||
def __init__(self, name, node_id, project, manager, ports=[]):
|
||||
|
||||
super().__init__(name, node_id, project, manager)
|
||||
Cloud._cloud_id += 1
|
||||
|
||||
self._nios = {}
|
||||
# If the cloud is not configured we fill it with host interfaces
|
||||
if not ports or len(ports) == 0:
|
||||
|
@ -17,9 +17,16 @@
|
||||
|
||||
import uuid
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch, call
|
||||
|
||||
from gns3server.compute.builtin.nodes.cloud import Cloud
|
||||
from gns3server.compute.nios.nio_udp import NIOUDP
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def nio():
|
||||
return NIOUDP(4242, "127.0.0.1", 4343)
|
||||
|
||||
|
||||
def test_json_with_ports(on_gns3vm, project):
|
||||
@ -122,3 +129,26 @@ def test_update_port_mappings(on_gns3vm, project):
|
||||
]
|
||||
cloud = Cloud("cloud2", str(uuid.uuid4()), project, MagicMock(), ports=ports2)
|
||||
assert cloud.ports_mapping == ports1
|
||||
|
||||
|
||||
def test_linux_ethernet_raw_add_nio(linux_platform, project, async_run, nio):
|
||||
ports = [
|
||||
{
|
||||
"interface": "eth0",
|
||||
"name": "eth0",
|
||||
"port_number": 0,
|
||||
"type": "ethernet"
|
||||
}
|
||||
]
|
||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
||||
|
||||
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._ubridge_send") as ubridge_mock:
|
||||
with patch("gns3server.compute.builtin.nodes.cloud.Cloud._interfaces", return_value=[{"name": "eth0"}]):
|
||||
async_run(cloud.add_nio(nio, 0))
|
||||
|
||||
ubridge_mock.assert_has_calls([
|
||||
call("bridge create {}-0".format(cloud._id)),
|
||||
call("bridge add_nio_udp {}-0 4242 127.0.0.1 4343".format(cloud._id)),
|
||||
call("bridge add_nio_linux_raw {}-0 \"eth0\"".format(cloud._id)),
|
||||
call("bridge start {}-0".format(cloud._id)),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user