From 92a0fa6cd7231de3a0b08a70669e7deda9eabe01 Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Sun, 31 May 2026 00:38:03 +0800 Subject: [PATCH] Fix packet filter validation tests: use correct ubridge filter type names --- tests/api/routes/controller/test_links.py | 12 ++++++------ tests/controller/test_udp_link.py | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/api/routes/controller/test_links.py b/tests/api/routes/controller/test_links.py index 5068fc8ea..bc50e053c 100644 --- a/tests/api/routes/controller/test_links.py +++ b/tests/api/routes/controller/test_links.py @@ -63,10 +63,10 @@ class TestLinkRoutes: node1, node2 = nodes filters = { - "latency": [10], + "delay": [10, 0], "frequency_drop": [50] } - + with asyncio_patch("gns3server.controller.udp_link.UDPLink.create") as mock: response = await client.post(app.url_path_for("create_link", project_id=project.id), json={ "nodes": [ @@ -88,7 +88,7 @@ class TestLinkRoutes: ], "filters": filters }) - + assert mock.called assert response.status_code == status.HTTP_201_CREATED assert response.json()["link_id"] is not None @@ -250,10 +250,10 @@ class TestLinkRoutes: ) -> None: filters = { - "latency": [10], + "delay": [10, 0], "frequency_drop": [50] } - + node1, node2 = nodes with asyncio_patch("gns3server.controller.udp_link.UDPLink.create") as mock: response = await client.post(app.url_path_for("create_link", project_id=project.id), json={ @@ -315,7 +315,7 @@ class TestLinkRoutes: ) -> None: filters = { - "latency": [10], + "delay": [10, 0], "frequency_drop": [50] } diff --git a/tests/controller/test_udp_link.py b/tests/controller/test_udp_link.py index 22a7bb50f..fb03947c9 100644 --- a/tests/controller/test_udp_link.py +++ b/tests/controller/test_udp_link.py @@ -46,7 +46,7 @@ async def test_create(project): link = UDPLink(project) await link.add_node(node1, 0, 4) - await link.update_filters({"latency": [10]}) + await link.update_filters({"delay": [10, 0]}) async def compute1_callback(path, data={}, **kwargs): """ @@ -77,7 +77,7 @@ async def test_create(project): "rhost": "192.168.1.2", "rport": 2048, "type": "nio_udp", - "filters": {"latency": [10]}, + "filters": {"delay": [10, 0]}, "suspend": False, }, timeout=120) @@ -313,7 +313,7 @@ async def test_update(project): link = UDPLink(project) await link.add_node(node1, 0, 4) - await link.update_filters({"latency": [10]}) + await link.update_filters({"delay": [10, 0]}) async def compute1_callback(path, data={}, **kwargs): """ @@ -345,7 +345,7 @@ async def test_update(project): "rport": 2048, "type": "nio_udp", "suspend": False, - "filters": {"latency": [10]} + "filters": {"delay": [10, 0]} }, timeout=120) compute2.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/3/ports/1/nio".format(project.id, node2.id), data={ @@ -358,7 +358,7 @@ async def test_update(project): }, timeout=120) assert link.created - await link.update_filters({"drop": [5], "bpf": ["icmp[icmptype] == 8"]}) + await link.update_filters({"frequency_drop": [5], "bpf": ["icmp[icmptype] == 8"]}) compute1.put.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/nio".format(project.id, node1.id), data={ "lport": 1024, "rhost": "192.168.1.2", @@ -366,7 +366,7 @@ async def test_update(project): "type": "nio_udp", "suspend": False, "filters": { - "drop": [5], + "frequency_drop": [5], "bpf": ["icmp[icmptype] == 8"] } }, timeout=120) @@ -392,7 +392,7 @@ async def test_update_suspend(project): link = UDPLink(project) await link.add_node(node1, 0, 4) - await link.update_filters({"latency": [10]}) + await link.update_filters({"frequency_drop": [-1]}) await link.update_suspend(True) async def compute1_callback(path, data={}, **kwargs):