Stream pcap from compute to controller to client

This commit is contained in:
Julien Duponchelle committed 2016-04-22 16:22:03 +02:00
1 parent 48e71617d6
commit 1ce576c020
15 files changed
+172 -124

No files matched your search

+8
View File
@@ -179,3 +179,11 @@ def test_json(compute):
"user": "test",
"connected": True
}
def test_streamFile(project, async_run, compute):
response = MagicMock()
response.status = 200
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
async_run(compute.streamFile(project, "test/titi"))
mock.assert_called_with("GET", "https://example.com:84/v2/compute/projects/{}/stream/test/titi".format(project.id), auth=None)
+1
View File
@@ -18,6 +18,7 @@
import pytest
from unittest.mock import MagicMock
from gns3server.controller.link import Link
from gns3server.controller.vm import VM
from gns3server.controller.compute import Compute
+15
View File
@@ -19,6 +19,7 @@ import pytest
import asyncio
import aiohttp
from unittest.mock import MagicMock
from tests.utils import asyncio_patch
from gns3server.controller.project import Project
from gns3server.controller.compute import Compute
@@ -160,3 +161,17 @@ def test_capture(async_run, project):
assert link.capturing is False
compute1.post.assert_any_call("/projects/{}/iou/vms/{}/adapters/3/ports/1/stop_capture".format(project.id, vm_iou.id))
def test_read_pcap(project, async_run):
compute1 = MagicMock()
link = UDPLink(project)
async_run(link.addVM(compute1, 0, 4))
async_run(link.addVM(compute1, 3, 1))
capture = async_run(link.start_capture())
assert link._capture_vm is not None
async_run(link.read_pcap())
link._capture_vm["vm"].compute.streamFile.assert_called_with(project, "tmp/captures/" + link.capture_file_name())