mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Support packet filtering for VPCS
https://github.com/GNS3/gns3-gui/issues/765
This commit is contained in:
25 files changed
+526
-269
No files matched your search
@@ -26,7 +26,7 @@ from tests.utils import asyncio_patch
|
||||
|
||||
@pytest.fixture
|
||||
def nio():
|
||||
return NIOUDP(4242, "127.0.0.1", 4343)
|
||||
return NIOUDP(4242, "127.0.0.1", 4343, [])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -24,9 +24,9 @@ def test_arp_command(async_run):
|
||||
node = AsyncioMagicMock()
|
||||
node.name = "Test"
|
||||
node.nios = {}
|
||||
node.nios[0] = NIOUDP(55, "127.0.0.1", 56)
|
||||
node.nios[0] = NIOUDP(55, "127.0.0.1", 56, [])
|
||||
node.nios[0].name = "Ethernet0"
|
||||
node.nios[1] = NIOUDP(55, "127.0.0.1", 56)
|
||||
node.nios[1] = NIOUDP(55, "127.0.0.1", 56, [])
|
||||
node.nios[1].name = "Ethernet1"
|
||||
node._hypervisor.send = AsyncioMagicMock(return_value=["0050.7966.6801 1 Ethernet0", "0050.7966.6802 1 Ethernet1"])
|
||||
console = EthernetSwitchConsole(node)
|
||||
|
||||
@@ -19,7 +19,7 @@ import pytest
|
||||
import aiohttp
|
||||
import asyncio
|
||||
import os
|
||||
from tests.utils import asyncio_patch
|
||||
from tests.utils import asyncio_patch, AsyncioMagicMock
|
||||
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
@@ -28,6 +28,7 @@ from gns3server.compute.docker.docker_vm import DockerVM
|
||||
from gns3server.compute.vpcs.vpcs_error import VPCSError
|
||||
from gns3server.compute.error import NodeError
|
||||
from gns3server.compute.vpcs import VPCS
|
||||
from gns3server.compute.nios.nio_udp import NIOUDP
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
@@ -121,3 +122,26 @@ def test_change_aux_port(node, port_manager):
|
||||
node.aux = port2
|
||||
assert node.aux == port2
|
||||
port_manager.reserve_tcp_port(port1, node.project)
|
||||
|
||||
|
||||
def test_update_ubridge_udp_connection(node, async_run):
|
||||
filters = [{
|
||||
"type": "latency",
|
||||
"value": 10
|
||||
}]
|
||||
|
||||
snio = NIOUDP(1245, "localhost", 1246, [])
|
||||
dnio = NIOUDP(1245, "localhost", 1244, filters)
|
||||
with asyncio_patch("gns3server.compute.base_node.BaseNode._ubridge_apply_filters") as mock:
|
||||
async_run(node._update_ubridge_udp_connection('VPCS-10', snio, dnio))
|
||||
mock.assert_called_with("VPCS-10", filters)
|
||||
|
||||
|
||||
def test_ubridge_apply_filters(node, async_run):
|
||||
filters = {
|
||||
"latency": [10]
|
||||
}
|
||||
node._ubridge_send = AsyncioMagicMock()
|
||||
async_run(node._ubridge_apply_filters("VPCS-10", filters))
|
||||
node._ubridge_send.assert_any_call("bridge reset_packet_filters VPCS-10")
|
||||
node._ubridge_send.assert_any_call("bridge add_packet_filter VPCS-10 filter0 latency 10")
|
||||
Reference in new issue
Block a user