|
@@ 215-240 (lines=26) @@
|
| 212 |
|
json_response = json.loads(response.data) |
| 213 |
|
assert len(json_response) == 0 |
| 214 |
|
|
| 215 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 216 |
|
def test_bytes_count_per_flow(self, mock_from_flow): |
| 217 |
|
"""Test bytes_count_per_flow rest call.""" |
| 218 |
|
flow_info = { |
| 219 |
|
"byte_count": 10, |
| 220 |
|
"duration_sec": 20, |
| 221 |
|
"duration_nsec": 30, |
| 222 |
|
"packet_count": 40, |
| 223 |
|
"cookie": 12310228866111668291, |
| 224 |
|
"match": {"in_port": 1}, |
| 225 |
|
"priority": 32768 |
| 226 |
|
} |
| 227 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 228 |
|
flow_stats_dict_mock = {flow_id: flow_info} |
| 229 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 230 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 231 |
|
mock_from_flow.return_value = flow_by_sw |
| 232 |
|
|
| 233 |
|
rest_name = "bytes_count/per_flow" |
| 234 |
|
self._patch_switch_flow(flow_id) |
| 235 |
|
|
| 236 |
|
response = self._get_rest_response(rest_name, dpid_id) |
| 237 |
|
json_response = json.loads(response.data) |
| 238 |
|
assert json_response[0]["flow_id"] == flow_id |
| 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): |
|
@@ 181-205 (lines=25) @@
|
| 178 |
|
json_response = json.loads(response.data) |
| 179 |
|
assert len(json_response) == 0 |
| 180 |
|
|
| 181 |
|
@patch("napps.amlight.flow_stats.main.Main.flow_stats_by_dpid_flow_id") |
| 182 |
|
def test_packet_count_per_flow(self, mock_from_flow): |
| 183 |
|
"""Test packet_count_per_flow rest call.""" |
| 184 |
|
flow_info = { |
| 185 |
|
"byte_count": 10, |
| 186 |
|
"duration_sec": 20, |
| 187 |
|
"duration_nsec": 30, |
| 188 |
|
"packet_count": 40, |
| 189 |
|
"cookie": 12310228866111668291, |
| 190 |
|
"match": {"in_port": 1}, |
| 191 |
|
"priority": 32768 |
| 192 |
|
} |
| 193 |
|
flow_id = '6055f13593fad45e0b4699f49d56b105' |
| 194 |
|
flow_stats_dict_mock = {flow_id: flow_info} |
| 195 |
|
dpid_id = "00:00:00:00:00:00:00:01" |
| 196 |
|
flow_by_sw = {dpid_id: flow_stats_dict_mock} |
| 197 |
|
mock_from_flow.return_value = flow_by_sw |
| 198 |
|
|
| 199 |
|
rest_name = "packet_count/per_flow" |
| 200 |
|
self._patch_switch_flow(flow_id) |
| 201 |
|
response = self._get_rest_response(rest_name, dpid_id) |
| 202 |
|
json_response = json.loads(response.data) |
| 203 |
|
assert json_response[0]["flow_id"] == flow_id |
| 204 |
|
assert json_response[0]["packet_counter"] == 40 |
| 205 |
|
assert json_response[0]["packet_per_second"] == 2.0 |
| 206 |
|
|
| 207 |
|
def test_bytes_count_per_flow__empty(self): |
| 208 |
|
"""Test bytes_count rest call with a flow that does not exist .""" |