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