mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-20 05:05:14 +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
@@ -230,6 +230,7 @@ def test_json(async_run, project, compute, link):
|
||||
}
|
||||
}
|
||||
],
|
||||
"filters": {},
|
||||
"link_type": "ethernet",
|
||||
"capturing": False,
|
||||
"capture_file_name": None,
|
||||
@@ -262,7 +263,8 @@ def test_json(async_run, project, compute, link):
|
||||
'style': 'font-size: 10; font-style: Verdana'
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"filters": {}
|
||||
}
|
||||
|
||||
|
||||
@@ -348,3 +350,49 @@ def test_delete(async_run, project, compute):
|
||||
|
||||
async_run(link.delete())
|
||||
assert link not in node2.link
|
||||
|
||||
|
||||
def test_update_filters(async_run, project, compute):
|
||||
node1 = Node(project, compute, "node1", node_type="qemu")
|
||||
node1._ports = [EthernetPort("E0", 0, 0, 4)]
|
||||
|
||||
link = Link(project)
|
||||
link.create = AsyncioMagicMock()
|
||||
link._project.controller.notification.emit = MagicMock()
|
||||
project.dump = AsyncioMagicMock()
|
||||
async_run(link.add_node(node1, 0, 4))
|
||||
|
||||
node2 = Node(project, compute, "node2", node_type="qemu")
|
||||
node2._ports = [EthernetPort("E0", 0, 0, 4)]
|
||||
async_run(link.add_node(node2, 0, 4))
|
||||
|
||||
link.update = AsyncioMagicMock()
|
||||
assert link._created
|
||||
async_run(link.update_filters({
|
||||
"packet_loss": ["10"],
|
||||
"delay": ["50", "10"],
|
||||
"frequency_drop": ["0"]
|
||||
}))
|
||||
assert link.filters == {
|
||||
"packet_loss": [10],
|
||||
"delay": [50, 10]
|
||||
}
|
||||
assert link.update.called
|
||||
|
||||
|
||||
def test_available_filters(async_run, project, compute):
|
||||
node1 = Node(project, compute, "node1", node_type="qemu")
|
||||
node1._ports = [EthernetPort("E0", 0, 0, 4)]
|
||||
|
||||
link = Link(project)
|
||||
link.create = AsyncioMagicMock()
|
||||
assert link.available_filters() == []
|
||||
|
||||
# Qemu is not supported should return 0 filters
|
||||
async_run(link.add_node(node1, 0, 4))
|
||||
assert link.available_filters() == []
|
||||
|
||||
node2 = Node(project, compute, "node2", node_type="vpcs")
|
||||
node2._ports = [EthernetPort("E0", 0, 0, 4)]
|
||||
async_run(link.add_node(node2, 0, 4))
|
||||
assert len(link.available_filters()) > 0
|
||||
Reference in new issue
Block a user