|
@@ 265-286 (lines=22) @@
|
| 262 |
|
json_response = response.json |
| 263 |
|
assert len(json_response) == 1 |
| 264 |
|
|
| 265 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 266 |
|
def test_flows_counters_bytes(self, mock_from_flow): |
| 267 |
|
"""Test flows_counters function for bytes""" |
| 268 |
|
flow_info = { |
| 269 |
|
"byte_count": 10, |
| 270 |
|
"duration_sec": 20, |
| 271 |
|
"duration_nsec": 30, |
| 272 |
|
"packet_count": 40, |
| 273 |
|
"cookie": 12310228866111668291, |
| 274 |
|
"match": {"in_port": 1}, |
| 275 |
|
"priority": 32768 |
| 276 |
|
} |
| 277 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 278 |
|
flow_stats_dict_mock = {flow_id: flow_info} |
| 279 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 280 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 281 |
|
mock_from_flow.return_value = flow_by_sw |
| 282 |
|
|
| 283 |
|
with get_controller_mock().api_server.app.app_context(): |
| 284 |
|
response = self.napp.flows_counters('byte_count', dpid_id) |
| 285 |
|
json_response = response.json |
| 286 |
|
assert len(json_response) == 1 |
| 287 |
|
|
| 288 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 289 |
|
def test_flow_stats_by_dpid_flow_id(self, mock_from_flow): |
|
@@ 242-263 (lines=22) @@
|
| 239 |
|
assert json_response[0]["bytes_counter"] == 10 |
| 240 |
|
assert json_response[0]["bits_per_second"] == 4.0 |
| 241 |
|
|
| 242 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 243 |
|
def test_flows_counters_packet(self, mock_from_flow): |
| 244 |
|
"""Test flows_counters function for packet""" |
| 245 |
|
flow_info = { |
| 246 |
|
"byte_count": 10, |
| 247 |
|
"duration_sec": 20, |
| 248 |
|
"duration_nsec": 30, |
| 249 |
|
"packet_count": 40, |
| 250 |
|
"cookie": 12310228866111668291, |
| 251 |
|
"match": {"in_port": 1}, |
| 252 |
|
"priority": 32768 |
| 253 |
|
} |
| 254 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 255 |
|
flow_stats_dict_mock = {flow_id: flow_info} |
| 256 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 257 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 258 |
|
mock_from_flow.return_value = flow_by_sw |
| 259 |
|
|
| 260 |
|
with get_controller_mock().api_server.app.app_context(): |
| 261 |
|
response = self.napp.flows_counters('packet_count', dpid_id) |
| 262 |
|
json_response = response.json |
| 263 |
|
assert len(json_response) == 1 |
| 264 |
|
|
| 265 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 266 |
|
def test_flows_counters_bytes(self, mock_from_flow): |