ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 1 | """These tests fall under Conformance Test-Suite (OF-SWITCH-1.0.0 TestCases). |
| 2 | Refer Documentation -- Detailed testing methodology |
| 3 | <Some of test-cases are directly taken from oftest> """ |
| 4 | |
| 5 | "Test Suite 5 --> Counters" |
| 6 | |
| 7 | import logging |
| 8 | |
| 9 | import unittest |
| 10 | import random |
| 11 | |
| 12 | from oftest import config |
| 13 | import oftest.controller as controller |
| 14 | import oftest.cstruct as ofp |
| 15 | import oftest.message as message |
| 16 | import oftest.dataplane as dataplane |
| 17 | import oftest.action as action |
| 18 | import oftest.parse as parse |
| 19 | import oftest.base_tests as base_tests |
| 20 | import time |
| 21 | |
| 22 | from oftest.testutils import * |
| 23 | from time import sleep |
| 24 | from FuncUtils import* |
| 25 | |
| 26 | |
| 27 | def portQueuesGet(self, queue_stats, port_num): |
| 28 | result = [] |
| 29 | for qs in queue_stats.stats: |
| 30 | if qs.port_no != port_num: |
| 31 | continue |
| 32 | result.append(qs.queue_id) |
| 33 | return result |
| 34 | |
| 35 | |
| 36 | class FlowCounter1(base_tests.SimpleDataPlane): |
| 37 | |
| 38 | """Verify Packet and Byte counters per flow are |
| 39 | incremented by no. of packets/bytes received for that flow""" |
| 40 | |
| 41 | def runTest(self): |
| 42 | |
| 43 | logging.info("Running Flow_Counter_1 test") |
| 44 | |
| 45 | of_ports = config["port_map"].keys() |
| 46 | of_ports.sort() |
| 47 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 48 | |
| 49 | #Clear switch state |
| 50 | rv = delete_all_flows(self.controller) |
| 51 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 52 | |
| 53 | logging.info("Insert any flow") |
| 54 | logging.info("Sending N Packets matching the flow") |
| 55 | logging.info("Verify packet/byte counters increment in accordance") |
| 56 | |
| 57 | #Create a Match on Ingress flow |
| 58 | (pkt,match) = Wildcard_All_Except_Ingress(self,of_ports) |
| 59 | |
| 60 | #Send Packets matching the flow |
| 61 | num_pkts = 5 |
| 62 | byte_count = num_pkts*len(str(pkt)) |
| 63 | for pkt_cnt in range(num_pkts): |
| 64 | self.dataplane.send(of_ports[0],str(pkt)) |
| 65 | |
| 66 | #Verify Recieved Packets/Bytes Per Flow |
| 67 | Verify_FlowStats(self,match,byte_count=byte_count,packet_count=num_pkts) |
| 68 | |
| 69 | |
| 70 | class FlowCounter2(base_tests.SimpleDataPlane): |
| 71 | |
| 72 | """Verify Duration_sec and Duration_nsec counters per flow varies in accordance with the amount of |
| 73 | time the flow was alive""" |
| 74 | |
| 75 | def runTest(self): |
| 76 | |
| 77 | logging.info("Running Flow_Counter_2 test") |
| 78 | |
| 79 | of_ports = config["port_map"].keys() |
| 80 | of_ports.sort() |
| 81 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 82 | |
| 83 | #Clear switch state |
| 84 | rc = delete_all_flows(self.controller) |
| 85 | self.assertEqual(rc, 0, "Failed to delete all flows") |
| 86 | |
| 87 | logging.info("Insert any flow") |
| 88 | logging.info("Send Flow_stats request after n sec intervals") |
| 89 | logging.info("Verify duration_sec and nsec counters are incrementing in accordance with the life of flow") |
| 90 | |
| 91 | #Create a flow with match on ingress_port |
| 92 | pkt = simple_tcp_packet() |
| 93 | match = parse.packet_to_flow_match(pkt) |
| 94 | match.wildcards &= ~ofp.OFPFW_IN_PORT |
| 95 | self.assertTrue(match is not None, |
| 96 | "Could not generate flow match from pkt") |
| 97 | match.in_port = of_ports[0] |
| 98 | flow_mod_msg = message.flow_mod() |
| 99 | flow_mod_msg.match = match |
| 100 | flow_mod_msg.cookie = random.randint(0,9007199254740992) |
| 101 | flow_mod_msg.buffer_id = 0xffffffff |
| 102 | flow_mod_msg.idle_timeout = 0 |
| 103 | flow_mod_msg.hard_timeout = 0 |
| 104 | act = action.action_output() |
| 105 | act.port = of_ports[1] |
| 106 | self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action") |
| 107 | rv = self.controller.message_send(flow_mod_msg) |
| 108 | self.assertTrue(rv != -1, "Error installing flow mod") |
| 109 | self.assertEqual(do_barrier(self.controller), 0, "Barrier failed") |
| 110 | |
| 111 | #Create flow_stats request |
| 112 | test_timeout = 30 |
| 113 | stat_req = message.flow_stats_request() |
| 114 | stat_req.match= match |
| 115 | stat_req.out_port = of_ports[1] |
| 116 | |
| 117 | flow_stats_gen_ts = range (10,test_timeout,10) |
| 118 | |
| 119 | for ts in range(0,test_timeout): |
| 120 | if ts in flow_stats_gen_ts: |
| 121 | response, pkt = self.controller.transact(stat_req) |
| 122 | |
| 123 | self.assertTrue(response is not None,"No response to stats request") |
| 124 | self.assertTrue(len(response.stats) == 1,"Did not receive flow stats reply") |
| 125 | |
| 126 | stat = response.stats[0] |
| 127 | self.assertTrue(stat.duration_sec == ts,"Flow stats reply incorrect") |
| 128 | logging.info("Duration of flow is " + str(stat.duration_sec) + str(stat.duration_nsec)) |
| 129 | |
| 130 | sleep(1) |
| 131 | |
| 132 | |
| 133 | |
| 134 | class PortCounter1(base_tests.SimpleDataPlane): |
| 135 | |
| 136 | """Verify that rx_packets counter in the Port_Stats reply , increments when packets are received on a port""" |
| 137 | |
| 138 | def runTest(self): |
| 139 | |
| 140 | logging.info("Running Port_Counter_1 test") |
| 141 | |
| 142 | of_ports = config["port_map"].keys() |
| 143 | of_ports.sort() |
| 144 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 145 | |
| 146 | # Clear Switch State |
| 147 | rv = delete_all_flows(self.controller) |
| 148 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 149 | |
| 150 | logging.info("Insert a flow with match on ingress_port") |
| 151 | logging.info("Send N Packets on an ingress_port P ") |
| 152 | logging.info("Send Port_Stats Request for Port P , verify recieved packets counters are incrementing in accordance") |
| 153 | |
| 154 | #Insert a flow with match on all ingress port |
| 155 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 156 | |
| 157 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 158 | port_stats_req = message.port_stats_request() |
| 159 | port_stats_req.port_no = of_ports[0] |
| 160 | response,pkt = self.controller.transact(port_stats_req) |
| 161 | self.assertTrue(response is not None,"No response received for port stats request") |
| 162 | current_counter=0 |
| 163 | |
| 164 | for obj in response.stats: |
| 165 | current_counter += obj.rx_packets |
| 166 | |
| 167 | #Send packets matching the flow |
| 168 | num_pkts = 5 |
| 169 | for pkt_cnt in range(num_pkts): |
| 170 | self.dataplane.send(of_ports[0],str(pkt)) |
| 171 | |
| 172 | #Verify recieved packet counters |
| 173 | Verify_PortStats1(self,of_ports[0],current_counter,num_pkts) |
| 174 | |
| 175 | |
| 176 | class PortCounter2(base_tests.SimpleDataPlane): |
| 177 | |
| 178 | """Verify that tx_packets counter in the Port_Stats reply , increments when packets are transmitted by a port""" |
| 179 | |
| 180 | def runTest(self): |
| 181 | |
| 182 | logging.info("Running Port_Counter_2 test") |
| 183 | |
| 184 | of_ports = config["port_map"].keys() |
| 185 | of_ports.sort() |
| 186 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 187 | |
| 188 | #Clear switch state |
| 189 | rv = delete_all_flows(self.controller) |
| 190 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 191 | |
| 192 | |
| 193 | logging.info("Insert any flow matching on in_port=ingress_port, action output to egress_port T ") |
| 194 | logging.info("Send N Packets matching the flow on ingress_port P ") |
| 195 | logging.info("Send Port_Stats Request for Port P , verify transmitted packets counters are incrementing in accordance") |
| 196 | |
| 197 | #Insert a flow with match on all ingress port |
| 198 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 199 | |
| 200 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 201 | port_stats_req = message.port_stats_request() |
Rich Lane | a563e40 | 2012-10-26 14:25:30 -0700 | [diff] [blame^] | 202 | port_stats_req.port_no = of_ports[1] |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 203 | response,pkt = self.controller.transact(port_stats_req) |
| 204 | self.assertTrue(response is not None,"No response received for port stats request") |
| 205 | current_counter=0 |
| 206 | |
| 207 | for obj in response.stats: |
| 208 | current_counter += obj.tx_packets |
| 209 | |
| 210 | #Send packets matching the flow |
| 211 | num_pkts = 5 |
| 212 | for pkt_cnt in range(num_pkts): |
| 213 | self.dataplane.send(of_ports[0],str(pkt)) |
| 214 | |
| 215 | #Verify transmitted_packet counters |
Rich Lane | a563e40 | 2012-10-26 14:25:30 -0700 | [diff] [blame^] | 216 | Verify_PortStats2(self,of_ports[1],current_counter,num_pkts) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 217 | |
| 218 | |
| 219 | class PortCounter3(base_tests.SimpleDataPlane): |
| 220 | |
| 221 | """Verify that recieved bytes counter in the Port_Stats reply , increments in accordance with the bytes recieved on a port""" |
| 222 | |
| 223 | def runTest(self): |
| 224 | |
| 225 | logging.info("Running Port_Counter_3 test") |
| 226 | |
| 227 | of_ports = config["port_map"].keys() |
| 228 | of_ports.sort() |
| 229 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 230 | |
| 231 | #Clear switch State |
| 232 | rv = delete_all_flows(self.controller) |
| 233 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 234 | |
| 235 | logging.info("Insert any flow matching on in_port=ingress_port") |
| 236 | logging.info("Send N Packets matching the flow on ingress_port P ") |
| 237 | logging.info("Send Port_Stats Request for Port P , verify recieved bytes counters are incrementing in accordance") |
| 238 | |
| 239 | #Insert a flow with match on all ingress port |
| 240 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 241 | |
| 242 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 243 | port_stats_req = message.port_stats_request() |
| 244 | port_stats_req.port_no = of_ports[0] |
| 245 | response,pkt = self.controller.transact(port_stats_req) |
| 246 | self.assertTrue(response is not None,"No response received for port stats request") |
| 247 | current_counter=0 |
| 248 | |
| 249 | for obj in response.stats: |
| 250 | current_counter += obj.rx_bytes |
| 251 | |
| 252 | #Send packets matching the flow. |
| 253 | num_pkts = 5 |
| 254 | byte_count = num_pkts*len(str(pkt)) |
| 255 | for pkt_cnt in range(num_pkts): |
| 256 | self.dataplane.send(of_ports[0],str(pkt)) |
| 257 | |
| 258 | |
| 259 | #Verify recieved_bytes counters |
| 260 | Verify_PortStats3(self,of_ports[0],current_counter,byte_count) |
| 261 | |
| 262 | |
| 263 | class PortCounter4(base_tests.SimpleDataPlane): |
| 264 | |
| 265 | """Verify that trasnsmitted bytes counter in the Port_Stats reply , increments in accordance with the bytes trasmitted by a port""" |
| 266 | |
| 267 | def runTest(self): |
| 268 | |
| 269 | logging.info("Running Port_Counter_4 test") |
| 270 | |
| 271 | of_ports = config["port_map"].keys() |
| 272 | of_ports.sort() |
| 273 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 274 | |
| 275 | #Clear switch State |
| 276 | rv = delete_all_flows(self.controller) |
| 277 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 278 | |
| 279 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port") |
| 280 | logging.info("Send N Packets matching the flow on ingress_port P ") |
| 281 | logging.info("Send Port_Stats Request for Port P , verify trasmitted bytes counters are incrementing in accordance") |
| 282 | |
| 283 | #Insert a flow with match on all ingress port |
| 284 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 285 | |
| 286 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 287 | port_stats_req = message.port_stats_request() |
Rich Lane | a563e40 | 2012-10-26 14:25:30 -0700 | [diff] [blame^] | 288 | port_stats_req.port_no = of_ports[1] |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 289 | response,pkt = self.controller.transact(port_stats_req) |
| 290 | self.assertTrue(response is not None,"No response received for port stats request") |
| 291 | current_counter=0 |
| 292 | |
| 293 | for obj in response.stats: |
| 294 | current_counter += obj.tx_bytes |
| 295 | |
| 296 | #Send packets matching the flow. |
| 297 | num_pkts = 5 |
| 298 | byte_count = num_pkts*len(str(pkt)) |
| 299 | for pkt_cnt in range(num_pkts): |
| 300 | self.dataplane.send(of_ports[0],str(pkt)) |
| 301 | |
| 302 | |
| 303 | #Verify trasmitted_bytes counters |
Rich Lane | a563e40 | 2012-10-26 14:25:30 -0700 | [diff] [blame^] | 304 | Verify_PortStats4(self,of_ports[1],current_counter,byte_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 305 | |
| 306 | |
| 307 | class TableCounter1(base_tests.SimpleDataPlane): |
| 308 | |
| 309 | """Verify that active_count counter in the Table_Stats reply , increments in accordance with the flows inserted in a table""" |
| 310 | |
| 311 | def runTest(self): |
| 312 | |
| 313 | logging.info("Running Table_Counter_1 test") |
| 314 | |
| 315 | of_ports = config["port_map"].keys() |
| 316 | of_ports.sort() |
| 317 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 318 | |
| 319 | #Clear Switch state |
| 320 | rv = delete_all_flows(self.controller) |
| 321 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 322 | |
| 323 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port") |
| 324 | logging.info("Send Table_Stats, verify active_count counter is incremented in accordance") |
| 325 | |
| 326 | #Insert a flow with match on all ingress port |
| 327 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 328 | |
| 329 | #Generate Table_Stats |
| 330 | Verify_TableStats(self,active_entries=1) |
| 331 | |
| 332 | |
| 333 | class TableCounter2(base_tests.SimpleDataPlane): |
| 334 | |
| 335 | """Verify that lookup_count and matched_count counter in the Table_Stats reply |
| 336 | increments in accordance with the packets looked up and matched with the flows in the table""" |
| 337 | |
| 338 | def runTest(self): |
| 339 | |
| 340 | logging.info("Running Table_Counter_1 test") |
| 341 | |
| 342 | of_ports = config["port_map"].keys() |
| 343 | of_ports.sort() |
| 344 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 345 | |
| 346 | #Clear Switch state |
| 347 | rv = delete_all_flows(self.controller) |
| 348 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 349 | |
| 350 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port") |
| 351 | logging.info("Send N packets matching the flow, N' packets not matching the flow") |
| 352 | logging.info("Send Table_Stats, verify lookup_count = N+N' & matched_count=N ") |
| 353 | |
| 354 | # Send Table_Stats reuqest (retrieve current table counters ) |
| 355 | |
| 356 | stat_req = message.table_stats_request() |
| 357 | response, pkt = self.controller.transact(stat_req, |
| 358 | timeout=5) |
| 359 | self.assertTrue(response is not None, |
| 360 | "No response to stats request") |
| 361 | current_lookedup = 0 |
| 362 | current_matched = 0 |
| 363 | |
| 364 | for obj in response.stats: |
| 365 | current_lookedup += obj.lookup_count |
| 366 | current_matched += obj.matched_count |
| 367 | |
| 368 | #Insert a flow with match on all ingress port |
| 369 | (pkt, match ) = Wildcard_All_Except_Ingress(self,of_ports) |
| 370 | |
| 371 | #send packet pkt N times (pkt matches the flow) |
| 372 | num_sends = 5 |
| 373 | for pkt_cnt in range(num_sends): |
| 374 | self.dataplane.send(of_ports[0],str(pkt)) |
| 375 | |
| 376 | #send packet pkt N' (pkt does not match the flow) |
| 377 | num_sends2 = 5 |
| 378 | for pkt_cnt in range(num_sends): |
| 379 | self.dataplane.send(of_ports[1],str(pkt)) |
| 380 | |
| 381 | #Verify lookup_count and matched_count counters. |
| 382 | Verify_TableStats1(self,current_lookedup,current_matched,num_sends+num_sends2,num_sends) |
| 383 | |
| 384 | |
| 385 | |
| 386 | class QueueCounter1(base_tests.SimpleDataPlane): |
| 387 | |
| 388 | """Verify that tx_packets in the queue_stats reply increments in accordance with the number of transmitted packets""" |
| 389 | |
| 390 | def runTest(self): |
| 391 | logging.info("Running Queue_Counter_1 test") |
| 392 | |
| 393 | of_ports = config["port_map"].keys() |
| 394 | of_ports.sort() |
| 395 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 396 | |
| 397 | # Get queue stats from switch (retrieve current state) |
| 398 | (queue_stats,p) = Get_QueueStats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
| 399 | |
| 400 | for idx in range(len(of_ports)): |
| 401 | ingress_port = of_ports[idx] |
| 402 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 403 | |
| 404 | queue_id = portQueuesGet(self,queue_stats,egress_port) |
| 405 | |
| 406 | for egress_queue_id in queue_id: |
| 407 | |
| 408 | #Clear switch state |
| 409 | rv = delete_all_flows(self.controller) |
| 410 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 411 | |
| 412 | # Get Queue stats for selected egress queue only |
| 413 | (qs_before,p) = Get_QueueStats(self,egress_port,egress_queue_id) |
| 414 | |
| 415 | #Insert a flow with enqueue action to queues configured on egress_port |
| 416 | (pkt,match) = Enqueue(self,ingress_port,egress_port,egress_queue_id) |
| 417 | |
| 418 | #Send packet on the ingress_port and verify its received on egress_port |
| 419 | SendPacket(self,pkt,ingress_port,egress_port) |
| 420 | |
| 421 | # FIXME: instead of sleeping, keep requesting queue stats until |
| 422 | # the expected queue counter increases or some large timeout is |
| 423 | # reached |
| 424 | time.sleep(2) |
| 425 | |
| 426 | # Get Queue Stats for selected egress queue after packets have been sent |
| 427 | (qs_after,p) = Get_QueueStats(self,egress_port,egress_queue_id) |
| 428 | |
| 429 | #Verify transmitted packets counter is incremented in accordance |
| 430 | self.assertEqual(qs_after.stats[0].tx_packets,qs_before.stats[0].tx_packets + 1,"tx_packet count incorrect") |
| 431 | |
| 432 | |
| 433 | class QueueCounter2(base_tests.SimpleDataPlane): |
| 434 | |
| 435 | """Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes""" |
| 436 | |
| 437 | def runTest(self): |
| 438 | logging.info("Running Queue_Counter_2 test") |
| 439 | |
| 440 | of_ports = config["port_map"].keys() |
| 441 | of_ports.sort() |
| 442 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 443 | |
| 444 | # Get queue stats from switch (retrieve current state) |
| 445 | (queue_stats,p) = Get_QueueStats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
| 446 | |
| 447 | for idx in range(len(of_ports)): |
| 448 | ingress_port = of_ports[idx] |
| 449 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 450 | |
| 451 | queue_id = portQueuesGet(self,queue_stats,egress_port) |
| 452 | |
| 453 | for egress_queue_id in queue_id: |
| 454 | |
| 455 | #Clear switch state |
| 456 | rv = delete_all_flows(self.controller) |
| 457 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 458 | |
| 459 | # Get Queue stats for selected egress queue only |
| 460 | (qs_before,p) = Get_QueueStats(self,egress_port,egress_queue_id) |
| 461 | |
| 462 | #Insert a flow with enqueue action to queues configured on egress_port |
| 463 | (pkt,match) = Enqueue(self,ingress_port,egress_port,egress_queue_id) |
| 464 | |
| 465 | #Send packet on the ingress_port and verify its received on egress_port |
| 466 | SendPacket(self,pkt,ingress_port,egress_port) |
| 467 | |
| 468 | # FIXME: instead of sleeping, keep requesting queue stats until |
| 469 | # the expected queue counter increases or some large timeout is |
| 470 | # reached |
| 471 | time.sleep(2) |
| 472 | |
| 473 | # Get Queue Stats for selected egress queue after packets have been sent |
| 474 | (qs_after,p) = Get_QueueStats(self,egress_port,egress_queue_id) |
| 475 | |
| 476 | #Verify transmitted packets counter is incremented in accordance |
Rich Lane | 05937a5 | 2012-10-26 14:23:53 -0700 | [diff] [blame] | 477 | self.assertEqual(qs_after.stats[0].tx_bytes,qs_before.stats[0].tx_bytes + len(str(pkt)),"tx_bytes count incorrect") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 478 | |
| 479 | |
| 480 | |
| 481 | class RxDrops(base_tests.SimpleDataPlane): |
| 482 | |
| 483 | """Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX""" |
| 484 | |
| 485 | def runTest(self): |
| 486 | |
| 487 | logging.info("Running Rx_Drops test") |
| 488 | |
| 489 | of_ports = config["port_map"].keys() |
| 490 | of_ports.sort() |
| 491 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 492 | |
| 493 | #Clear switch State |
| 494 | rv = delete_all_flows(self.controller) |
| 495 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 496 | |
| 497 | logging.info("Send Port_Stats Request") |
| 498 | logging.info("Verify reply has rx_dropped count ") |
| 499 | |
| 500 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 501 | port_stats_req = message.port_stats_request() |
| 502 | port_stats_req.port_no = of_ports[0] |
| 503 | response,pkt = self.controller.transact(port_stats_req) |
| 504 | self.assertTrue(response is not None,"No response received for port stats request") |
| 505 | current_counter=0 |
| 506 | |
| 507 | for obj in response.stats: |
| 508 | current_counter += obj.rx_dropped |
| 509 | |
| 510 | logging.info("recieved dropped count is :" + str(current_counter)) |
| 511 | |
| 512 | |
| 513 | |
| 514 | class TxDrops(base_tests.SimpleDataPlane): |
| 515 | |
| 516 | """Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX""" |
| 517 | |
| 518 | def runTest(self): |
| 519 | |
| 520 | logging.info("Running Tx_Drops test") |
| 521 | |
| 522 | of_ports = config["port_map"].keys() |
| 523 | of_ports.sort() |
| 524 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 525 | |
| 526 | #Clear switch State |
| 527 | rv = delete_all_flows(self.controller) |
| 528 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 529 | |
| 530 | logging.info("Send Port_Stats Request") |
| 531 | logging.info("Verify reply has tx_dropped count ") |
| 532 | |
| 533 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 534 | port_stats_req = message.port_stats_request() |
| 535 | port_stats_req.port_no = of_ports[0] |
| 536 | response,pkt = self.controller.transact(port_stats_req) |
| 537 | self.assertTrue(response is not None,"No response received for port stats request") |
| 538 | current_counter=0 |
| 539 | |
| 540 | for obj in response.stats: |
| 541 | current_counter += obj.tx_dropped |
| 542 | |
| 543 | logging.info("Transmitted dropped count is :" + str(current_counter)) |
| 544 | |
| 545 | |
| 546 | class RxErrors(base_tests.SimpleDataPlane): |
| 547 | |
| 548 | """Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error |
| 549 | This is a super-set of more specific receive errors and should be greater than or equal to the sum of all |
| 550 | rx_*_err values""" |
| 551 | |
| 552 | def runTest(self): |
| 553 | |
| 554 | logging.info("Running Rx_Errors test") |
| 555 | |
| 556 | of_ports = config["port_map"].keys() |
| 557 | of_ports.sort() |
| 558 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 559 | |
| 560 | #Clear switch State |
| 561 | rv = delete_all_flows(self.controller) |
| 562 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 563 | |
| 564 | logging.info("Send Port_Stats Request") |
| 565 | logging.info("Verify reply has rx_errors count ") |
| 566 | |
| 567 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 568 | port_stats_req = message.port_stats_request() |
| 569 | port_stats_req.port_no = of_ports[0] |
| 570 | response,pkt = self.controller.transact(port_stats_req) |
| 571 | self.assertTrue(response is not None,"No response received for port stats request") |
| 572 | current_counter=0 |
| 573 | |
| 574 | for obj in response.stats: |
| 575 | current_counter += obj.rx_errors |
| 576 | |
| 577 | logging.info("Recieve Errors count is :" + str(current_counter)) |
| 578 | |
| 579 | |
| 580 | class TxErrors(base_tests.SimpleDataPlane): |
| 581 | |
| 582 | """Verify that Tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit error""" |
| 583 | |
| 584 | def runTest(self): |
| 585 | |
| 586 | logging.info("Running Tx_Errors test") |
| 587 | |
| 588 | of_ports = config["port_map"].keys() |
| 589 | of_ports.sort() |
| 590 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 591 | |
| 592 | #Clear switch State |
| 593 | rv = delete_all_flows(self.controller) |
| 594 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 595 | |
| 596 | logging.info("Send Port_Stats Request") |
| 597 | logging.info("Verify reply has Tx_errors count ") |
| 598 | |
| 599 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 600 | port_stats_req = message.port_stats_request() |
| 601 | port_stats_req.port_no = of_ports[0] |
| 602 | response,pkt = self.controller.transact(port_stats_req) |
| 603 | self.assertTrue(response is not None,"No response received for port stats request") |
| 604 | current_counter=0 |
| 605 | |
| 606 | for obj in response.stats: |
| 607 | current_counter += obj.tx_errors |
| 608 | |
| 609 | logging.info("Trasmit Error count is :" + str(current_counter)) |
| 610 | |
| 611 | |
| 612 | class RxFrameErr(base_tests.SimpleDataPlane): |
| 613 | |
| 614 | """Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors""" |
| 615 | |
| 616 | def runTest(self): |
| 617 | |
| 618 | logging.info("Running Rx_Frame_Err test") |
| 619 | |
| 620 | of_ports = config["port_map"].keys() |
| 621 | of_ports.sort() |
| 622 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 623 | |
| 624 | #Clear switch State |
| 625 | rv = delete_all_flows(self.controller) |
| 626 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 627 | |
| 628 | logging.info("Send Port_Stats Request") |
| 629 | logging.info("Verify reply has rx_frame_err count ") |
| 630 | |
| 631 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 632 | port_stats_req = message.port_stats_request() |
| 633 | port_stats_req.port_no = of_ports[0] |
| 634 | response,pkt = self.controller.transact(port_stats_req) |
| 635 | self.assertTrue(response is not None,"No response received for port stats request") |
| 636 | current_counter=0 |
| 637 | |
| 638 | for obj in response.stats: |
| 639 | current_counter += obj.rx_frame_err |
| 640 | |
| 641 | logging.info("Recieve Frame Errors count is :" + str(current_counter)) |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | class RxOErr(base_tests.SimpleDataPlane): |
| 648 | |
| 649 | """Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun""" |
| 650 | |
| 651 | def runTest(self): |
| 652 | |
| 653 | logging.info("Running Rx_O_Err test") |
| 654 | |
| 655 | of_ports = config["port_map"].keys() |
| 656 | of_ports.sort() |
| 657 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 658 | |
| 659 | #Clear switch State |
| 660 | rv = delete_all_flows(self.controller) |
| 661 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 662 | |
| 663 | logging.info("Send Port_Stats Request") |
| 664 | logging.info("Verify reply has rx_over_err count ") |
| 665 | |
| 666 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 667 | port_stats_req = message.port_stats_request() |
| 668 | port_stats_req.port_no = of_ports[0] |
| 669 | response,pkt = self.controller.transact(port_stats_req) |
| 670 | self.assertTrue(response is not None,"No response received for port stats request") |
| 671 | current_counter=0 |
| 672 | |
| 673 | for obj in response.stats: |
| 674 | current_counter += obj.rx_over_err |
| 675 | |
| 676 | logging.info("Recieve Overrun Errors count is :" + str(current_counter)) |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | class RxCrcErr(base_tests.SimpleDataPlane): |
| 682 | |
| 683 | """Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors""" |
| 684 | |
| 685 | def runTest(self): |
| 686 | |
| 687 | logging.info("Running Port_Counter_9 test") |
| 688 | |
| 689 | of_ports = config["port_map"].keys() |
| 690 | of_ports.sort() |
| 691 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 692 | |
| 693 | #Clear switch State |
| 694 | rv = delete_all_flows(self.controller) |
| 695 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 696 | |
| 697 | logging.info("Send Port_Stats Request") |
| 698 | logging.info("Verify reply has rx_crc_err count ") |
| 699 | |
| 700 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 701 | port_stats_req = message.port_stats_request() |
| 702 | port_stats_req.port_no = of_ports[0] |
| 703 | response,pkt = self.controller.transact(port_stats_req) |
| 704 | self.assertTrue(response is not None,"No response received for port stats request") |
| 705 | current_counter=0 |
| 706 | |
| 707 | for obj in response.stats: |
| 708 | current_counter += obj.rx_crc_err |
| 709 | |
| 710 | logging.info("Recieve CRC Errors count is :" + str(current_counter)) |
| 711 | |
| 712 | |
| 713 | |
| 714 | class Collisions(base_tests.SimpleDataPlane): |
| 715 | |
| 716 | """Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch """ |
| 717 | |
| 718 | def runTest(self): |
| 719 | |
| 720 | logging.info("Running Collisions test") |
| 721 | |
| 722 | of_ports = config["port_map"].keys() |
| 723 | of_ports.sort() |
| 724 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 725 | |
| 726 | #Clear switch State |
| 727 | rv = delete_all_flows(self.controller) |
| 728 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 729 | |
| 730 | logging.info("Send Port_Stats Request") |
| 731 | logging.info("Verify reply has Collisions count ") |
| 732 | |
| 733 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 734 | port_stats_req = message.port_stats_request() |
| 735 | port_stats_req.port_no = of_ports[0] |
| 736 | response,pkt = self.controller.transact(port_stats_req) |
| 737 | self.assertTrue(response is not None,"No response received for port stats request") |
| 738 | current_counter=0 |
| 739 | |
| 740 | for obj in response.stats: |
| 741 | current_counter += obj.collisions |
| 742 | |
| 743 | logging.info("collisions count is :" + str(current_counter)) |
| 744 | |
| 745 | |
| 746 | |
| 747 | |
| 748 | class QueueCounter3(base_tests.SimpleDataPlane): |
| 749 | |
| 750 | """Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun """ |
| 751 | |
| 752 | def runTest(self): |
| 753 | |
| 754 | logging.info("Running Queue_Counter_3 test") |
| 755 | |
| 756 | of_ports = config["port_map"].keys() |
| 757 | of_ports.sort() |
| 758 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 759 | |
| 760 | #Clear switch State |
| 761 | rv = delete_all_flows(self.controller) |
| 762 | self.assertEqual(rv, 0, "Failed to delete all flows") |
| 763 | |
| 764 | logging.info("Send Queue_Stats Request") |
| 765 | logging.info("Verify reply has Tramitted Overrun errors count ") |
| 766 | |
| 767 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
| 768 | port_stats_req = message.port_stats_request() |
| 769 | port_stats_req.port_no = of_ports[0] |
| 770 | response,pkt = self.controller.transact(port_stats_req) |
| 771 | self.assertTrue(response is not None,"No response received for port stats request") |
| 772 | current_counter=0 |
| 773 | |
| 774 | for obj in response.stats: |
| 775 | current_counter += obj.tx_errors |
| 776 | |
| 777 | logging.info("Transmit Overrun Error count is :" + str(current_counter)) |
| 778 | |
| 779 | |