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 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 27 | def port_queues_get(self, queue_stats, port_num): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 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 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 36 | class PktPerFlow(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 37 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 38 | """Verify Packet counters per flow are |
| 39 | incremented by no. of packets received for that flow""" |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 40 | |
| 41 | def runTest(self): |
| 42 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 43 | logging.info("Running PktPerFlow test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 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 |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 50 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 51 | |
| 52 | logging.info("Insert any flow") |
| 53 | logging.info("Sending N Packets matching the flow") |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 54 | logging.info("Verify packet counters increment in accordance") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 55 | |
| 56 | #Create a Match on Ingress flow |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 57 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
| 58 | |
| 59 | #Send Packets matching the flow |
| 60 | num_pkts = 5 |
| 61 | for pkt_cnt in range(num_pkts): |
| 62 | self.dataplane.send(of_ports[0],str(pkt)) |
| 63 | |
| 64 | #Verify Recieved Packets/Bytes Per Flow |
| 65 | verify_flowstats(self,match,packet_count=num_pkts) |
| 66 | |
| 67 | |
| 68 | class BytPerFlow(base_tests.SimpleDataPlane): |
| 69 | |
| 70 | """Verify Byte counters per flow are |
| 71 | incremented by no. of bytes received for that flow""" |
| 72 | |
| 73 | def runTest(self): |
| 74 | |
| 75 | logging.info("Running BytPerFlow test") |
| 76 | |
| 77 | of_ports = config["port_map"].keys() |
| 78 | of_ports.sort() |
| 79 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 80 | |
| 81 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 82 | delete_all_flows(self.controller) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 83 | |
| 84 | logging.info("Insert any flow") |
| 85 | logging.info("Sending N Packets matching the flow") |
| 86 | logging.info("Verify byte counters increment in accordance") |
| 87 | |
| 88 | #Create a Match on Ingress flow |
| 89 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 90 | |
| 91 | #Send Packets matching the flow |
| 92 | num_pkts = 5 |
| 93 | byte_count = num_pkts*len(str(pkt)) |
| 94 | for pkt_cnt in range(num_pkts): |
| 95 | self.dataplane.send(of_ports[0],str(pkt)) |
| 96 | |
| 97 | #Verify Recieved Packets/Bytes Per Flow |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 98 | verify_flowstats(self,match,byte_count=byte_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 99 | |
| 100 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 101 | class DurationPerFlow(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 102 | |
| 103 | """Verify Duration_sec and Duration_nsec counters per flow varies in accordance with the amount of |
| 104 | time the flow was alive""" |
| 105 | |
| 106 | def runTest(self): |
| 107 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 108 | logging.info("Running DurationPerFlow test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 109 | |
| 110 | of_ports = config["port_map"].keys() |
| 111 | of_ports.sort() |
| 112 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 113 | |
| 114 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 115 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 116 | |
| 117 | logging.info("Insert any flow") |
| 118 | logging.info("Send Flow_stats request after n sec intervals") |
| 119 | logging.info("Verify duration_sec and nsec counters are incrementing in accordance with the life of flow") |
| 120 | |
| 121 | #Create a flow with match on ingress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 122 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
| 123 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 124 | #Create flow_stats request |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 125 | stat_req = message.flow_stats_request() |
| 126 | stat_req.match= match |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 127 | stat_req.table_id = 0xff |
| 128 | stat_req.out_port = ofp.OFPP_NONE |
Rich Lane | 0b04b6c | 2012-12-31 10:12:23 -0800 | [diff] [blame] | 129 | |
| 130 | expected_duration = 3 |
| 131 | sleep(expected_duration) |
| 132 | |
| 133 | response, pkt = self.controller.transact(stat_req) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 134 | |
Rich Lane | 0b04b6c | 2012-12-31 10:12:23 -0800 | [diff] [blame] | 135 | self.assertTrue(response is not None,"No response to stats request") |
| 136 | self.assertTrue(len(response.stats) == 1,"Did not receive flow stats reply") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 137 | |
Rich Lane | 0b04b6c | 2012-12-31 10:12:23 -0800 | [diff] [blame] | 138 | stat = response.stats[0] |
| 139 | logging.info("Duration of flow is %d s %d ns", stat.duration_sec, stat.duration_nsec) |
| 140 | self.assertTrue(stat.duration_sec == expected_duration, "Flow stats reply incorrect") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 141 | |
| 142 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 143 | class RxPktPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 144 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 145 | """Verify that rx_packets counter in the Port_Stats reply |
| 146 | increments when packets are received on a port""" |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 147 | |
| 148 | def runTest(self): |
| 149 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 150 | logging.info("Running RxPktPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 151 | |
| 152 | of_ports = config["port_map"].keys() |
| 153 | of_ports.sort() |
| 154 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 155 | |
| 156 | # Clear Switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 157 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 158 | |
| 159 | logging.info("Insert a flow with match on ingress_port") |
| 160 | logging.info("Send N Packets on an ingress_port P ") |
| 161 | logging.info("Send Port_Stats Request for Port P , verify recieved packets counters are incrementing in accordance") |
| 162 | |
| 163 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 164 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 165 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 166 | # Send Port_Stats request for the ingress port (retrieve old counter state) |
| 167 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 168 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 169 | # Send packets matching the flow |
| 170 | num_pkts = 5 |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 171 | for pkt_cnt in range(num_pkts): |
| 172 | self.dataplane.send(of_ports[0],str(pkt)) |
Rich Lane | 47d0ec0 | 2012-10-26 14:28:19 -0700 | [diff] [blame] | 173 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 174 | pkts = num_pkts+counter[0] |
| 175 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 176 | #Verify recieved packet counters |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 177 | verify_portstats(self,of_ports[0],rx_packets=pkts) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 178 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 179 | class TxPktPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 180 | |
| 181 | """Verify that tx_packets counter in the Port_Stats reply , increments when packets are transmitted by a port""" |
| 182 | |
| 183 | def runTest(self): |
| 184 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 185 | logging.info("Running TxPktPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 186 | |
| 187 | of_ports = config["port_map"].keys() |
| 188 | of_ports.sort() |
| 189 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 190 | |
| 191 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 192 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 193 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 194 | logging.info("Insert any flow matching on in_port=ingress_port, action output to egress_port T ") |
| 195 | logging.info("Send N Packets matching the flow on ingress_port P ") |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 196 | logging.info("Send Port_Stats Request for Port T , verify transmitted packets counters are incrementing in accordance") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 197 | |
| 198 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 199 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 200 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 201 | # Send Port_Stats request for the ingress port (retrieve old counter state) |
| 202 | (counter) = get_portstats(self,of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 203 | |
| 204 | #Send packets matching the flow |
| 205 | num_pkts = 5 |
| 206 | for pkt_cnt in range(num_pkts): |
| 207 | self.dataplane.send(of_ports[0],str(pkt)) |
Rich Lane | 47d0ec0 | 2012-10-26 14:28:19 -0700 | [diff] [blame] | 208 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 209 | pkts = num_pkts+counter[1] |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 210 | |
| 211 | #Verify transmitted_packet counters |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 212 | verify_portstats(self,of_ports[1],tx_packets=pkts) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 213 | |
| 214 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 215 | |
| 216 | class RxBytPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 217 | |
| 218 | """Verify that recieved bytes counter in the Port_Stats reply , increments in accordance with the bytes recieved on a port""" |
| 219 | |
| 220 | def runTest(self): |
| 221 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 222 | logging.info("Running RxBytPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 223 | |
| 224 | of_ports = config["port_map"].keys() |
| 225 | of_ports.sort() |
| 226 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 227 | |
| 228 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 229 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 230 | |
| 231 | logging.info("Insert any flow matching on in_port=ingress_port") |
| 232 | logging.info("Send N Packets matching the flow on ingress_port P ") |
| 233 | logging.info("Send Port_Stats Request for Port P , verify recieved bytes counters are incrementing in accordance") |
| 234 | |
| 235 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 236 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 237 | |
| 238 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 239 | (counter) = get_portstats(self,of_ports[0]) |
| 240 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 241 | #Send packets matching the flow. |
| 242 | num_pkts = 5 |
| 243 | byte_count = num_pkts*len(str(pkt)) |
| 244 | for pkt_cnt in range(num_pkts): |
| 245 | self.dataplane.send(of_ports[0],str(pkt)) |
| 246 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 247 | byt_count = byte_count+counter[2] |
Rich Lane | 47d0ec0 | 2012-10-26 14:28:19 -0700 | [diff] [blame] | 248 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 249 | #Verify recieved_bytes counters |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 250 | verify_portstats(self,of_ports[0],rx_byte=byt_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 251 | |
| 252 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 253 | class TxBytPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 254 | |
| 255 | """Verify that trasnsmitted bytes counter in the Port_Stats reply , increments in accordance with the bytes trasmitted by a port""" |
| 256 | |
| 257 | def runTest(self): |
| 258 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 259 | logging.info("Running TxBytPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 260 | |
| 261 | of_ports = config["port_map"].keys() |
| 262 | of_ports.sort() |
| 263 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 264 | |
| 265 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 266 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 267 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 268 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 269 | logging.info("Send N Packets matching the flow on ingress_port P ") |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 270 | logging.info("Send Port_Stats Request for Port T , verify trasmitted bytes counters are incrementing in accordance") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 271 | |
| 272 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 273 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 274 | |
| 275 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 276 | (counter) = get_portstats(self,of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 277 | |
| 278 | #Send packets matching the flow. |
| 279 | num_pkts = 5 |
| 280 | byte_count = num_pkts*len(str(pkt)) |
| 281 | for pkt_cnt in range(num_pkts): |
| 282 | self.dataplane.send(of_ports[0],str(pkt)) |
| 283 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 284 | byt_count = byte_count+counter[3] |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 285 | |
| 286 | #Verify trasmitted_bytes counters |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 287 | verify_portstats(self,of_ports[1],tx_byte=byt_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 288 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 289 | class ActiveCount(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 290 | |
| 291 | """Verify that active_count counter in the Table_Stats reply , increments in accordance with the flows inserted in a table""" |
| 292 | |
| 293 | def runTest(self): |
| 294 | |
| 295 | logging.info("Running Table_Counter_1 test") |
| 296 | |
| 297 | of_ports = config["port_map"].keys() |
| 298 | of_ports.sort() |
| 299 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 300 | |
| 301 | #Clear Switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 302 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 303 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 304 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T ") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 305 | logging.info("Send Table_Stats, verify active_count counter is incremented in accordance") |
| 306 | |
| 307 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 308 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 309 | |
| 310 | #Generate Table_Stats |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 311 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 312 | |
| 313 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 314 | class LookupMatchedCount(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 315 | |
| 316 | """Verify that lookup_count and matched_count counter in the Table_Stats reply |
| 317 | increments in accordance with the packets looked up and matched with the flows in the table""" |
| 318 | |
| 319 | def runTest(self): |
| 320 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 321 | logging.info("Running LookupMatchedCount test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 322 | |
| 323 | of_ports = config["port_map"].keys() |
| 324 | of_ports.sort() |
| 325 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 326 | |
| 327 | #Clear Switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 328 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 329 | |
| 330 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port") |
| 331 | logging.info("Send N packets matching the flow, N' packets not matching the flow") |
| 332 | logging.info("Send Table_Stats, verify lookup_count = N+N' & matched_count=N ") |
| 333 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 334 | #Get Current Table Stats |
| 335 | (current_lookedup,current_matched,current_active) = get_tablestats(self) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 336 | |
| 337 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 338 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 339 | |
| 340 | #send packet pkt N times (pkt matches the flow) |
| 341 | num_sends = 5 |
| 342 | for pkt_cnt in range(num_sends): |
| 343 | self.dataplane.send(of_ports[0],str(pkt)) |
| 344 | |
| 345 | #send packet pkt N' (pkt does not match the flow) |
| 346 | num_sends2 = 5 |
| 347 | for pkt_cnt in range(num_sends): |
| 348 | self.dataplane.send(of_ports[1],str(pkt)) |
| 349 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 350 | new_lookup = num_sends+num_sends2+current_lookedup |
| 351 | new_matched = num_sends+current_matched |
Rich Lane | 47d0ec0 | 2012-10-26 14:28:19 -0700 | [diff] [blame] | 352 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 353 | #Verify lookup_count and matched_count counters. |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 354 | verify_tablestats(self,expect_lookup=new_lookup,expect_match=new_matched) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 355 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 356 | class TxPktPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 357 | |
| 358 | """Verify that tx_packets in the queue_stats reply increments in accordance with the number of transmitted packets""" |
| 359 | |
| 360 | def runTest(self): |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 361 | logging.info("Running TxPktPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 362 | |
| 363 | of_ports = config["port_map"].keys() |
| 364 | of_ports.sort() |
| 365 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 366 | |
| 367 | # Get queue stats from switch (retrieve current state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 368 | (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 369 | |
| 370 | for idx in range(len(of_ports)): |
| 371 | ingress_port = of_ports[idx] |
| 372 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 373 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 374 | queue_id = port_queues_get(self,queue_stats,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 375 | |
| 376 | for egress_queue_id in queue_id: |
| 377 | |
| 378 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 379 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 380 | |
| 381 | # Get Queue stats for selected egress queue only |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 382 | (qs_before,p) = get_queuestats(self,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 383 | |
| 384 | #Insert a flow with enqueue action to queues configured on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 385 | (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 386 | |
| 387 | #Send packet on the ingress_port and verify its received on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 388 | send_packet(self,pkt,ingress_port,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 389 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 390 | expected_packets = qs_before.stats[0].tx_packets+1 |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 391 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 392 | verify_queuestats(self,egress_port,egress_queue_id,expect_packet=expected_packets) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 393 | |
| 394 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 395 | class TxBytPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 396 | |
| 397 | """Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes""" |
| 398 | |
| 399 | def runTest(self): |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 400 | logging.info("Running TxBytPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 401 | |
| 402 | of_ports = config["port_map"].keys() |
| 403 | of_ports.sort() |
| 404 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 405 | |
| 406 | # Get queue stats from switch (retrieve current state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 407 | (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 408 | |
| 409 | for idx in range(len(of_ports)): |
| 410 | ingress_port = of_ports[idx] |
| 411 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 412 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 413 | queue_id = port_queues_get(self,queue_stats,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 414 | |
| 415 | for egress_queue_id in queue_id: |
| 416 | |
| 417 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 418 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 419 | |
| 420 | # Get Queue stats for selected egress queue only |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 421 | (qs_before,p) = get_queuestats(self,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 422 | |
| 423 | #Insert a flow with enqueue action to queues configured on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 424 | (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 425 | |
| 426 | #Send packet on the ingress_port and verify its received on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 427 | send_packet(self,pkt,ingress_port,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 428 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 429 | expected_bytes = qs_before.stats[0].tx_bytes+len(str(pkt)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 430 | |
ShreyaPandita | 8793204 | 2012-11-05 18:48:39 -0500 | [diff] [blame] | 431 | verify_queuestats(self,egress_port,egress_queue_id,expect_byte=expected_bytes) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 432 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 433 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 434 | class RxDrops(base_tests.SimpleDataPlane): |
| 435 | |
| 436 | """Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX""" |
| 437 | |
| 438 | def runTest(self): |
| 439 | |
| 440 | logging.info("Running Rx_Drops test") |
| 441 | |
| 442 | of_ports = config["port_map"].keys() |
| 443 | of_ports.sort() |
| 444 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 445 | |
| 446 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 447 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 448 | |
| 449 | logging.info("Send Port_Stats Request") |
| 450 | logging.info("Verify reply has rx_dropped count ") |
| 451 | |
| 452 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 453 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 454 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 455 | rx_drp = counter[4] |
| 456 | logging.info("recieved dropped count is :" + str(rx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 457 | |
| 458 | |
| 459 | |
| 460 | class TxDrops(base_tests.SimpleDataPlane): |
| 461 | |
| 462 | """Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX""" |
| 463 | |
| 464 | def runTest(self): |
| 465 | |
| 466 | logging.info("Running Tx_Drops test") |
| 467 | |
| 468 | of_ports = config["port_map"].keys() |
| 469 | of_ports.sort() |
| 470 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 471 | |
| 472 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 473 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 474 | |
| 475 | logging.info("Send Port_Stats Request") |
| 476 | logging.info("Verify reply has tx_dropped count ") |
| 477 | |
| 478 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 479 | (counter) = get_portstats(self,of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 480 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 481 | tx_drp = counter[5] |
| 482 | logging.info("Transmitted dropped count is :" + str(tx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 483 | |
| 484 | |
| 485 | class RxErrors(base_tests.SimpleDataPlane): |
| 486 | |
| 487 | """Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error |
| 488 | This is a super-set of more specific receive errors and should be greater than or equal to the sum of all |
| 489 | rx_*_err values""" |
| 490 | |
| 491 | def runTest(self): |
| 492 | |
| 493 | logging.info("Running Rx_Errors test") |
| 494 | |
| 495 | of_ports = config["port_map"].keys() |
| 496 | of_ports.sort() |
| 497 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 498 | |
| 499 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 500 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 501 | |
| 502 | logging.info("Send Port_Stats Request") |
| 503 | logging.info("Verify reply has rx_errors count ") |
| 504 | |
| 505 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 506 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 507 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 508 | rx_err = counter[6] |
| 509 | logging.info("Recieve Errors count is :" + str(rx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 510 | |
| 511 | |
| 512 | class TxErrors(base_tests.SimpleDataPlane): |
| 513 | |
| 514 | """Verify that Tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit error""" |
| 515 | |
| 516 | def runTest(self): |
| 517 | |
| 518 | logging.info("Running Tx_Errors test") |
| 519 | |
| 520 | of_ports = config["port_map"].keys() |
| 521 | of_ports.sort() |
| 522 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 523 | |
| 524 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 525 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 526 | |
| 527 | logging.info("Send Port_Stats Request") |
| 528 | logging.info("Verify reply has Tx_errors count ") |
| 529 | |
| 530 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 531 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 532 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 533 | tx_err = counter[7] |
| 534 | logging.info("Trasmit Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 535 | |
| 536 | |
| 537 | class RxFrameErr(base_tests.SimpleDataPlane): |
| 538 | |
| 539 | """Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors""" |
| 540 | |
| 541 | def runTest(self): |
| 542 | |
| 543 | logging.info("Running Rx_Frame_Err test") |
| 544 | |
| 545 | of_ports = config["port_map"].keys() |
| 546 | of_ports.sort() |
| 547 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 548 | |
| 549 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 550 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 551 | |
| 552 | logging.info("Send Port_Stats Request") |
| 553 | logging.info("Verify reply has rx_frame_err count ") |
| 554 | |
| 555 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 556 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 557 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 558 | rx_fr_err = counter[8] |
| 559 | logging.info("Recieve Frame Errors count is :" + str(rx_fr_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 560 | |
| 561 | |
| 562 | |
| 563 | class RxOErr(base_tests.SimpleDataPlane): |
| 564 | |
| 565 | """Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun""" |
| 566 | |
| 567 | def runTest(self): |
| 568 | |
| 569 | logging.info("Running Rx_O_Err test") |
| 570 | |
| 571 | of_ports = config["port_map"].keys() |
| 572 | of_ports.sort() |
| 573 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 574 | |
| 575 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 576 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 577 | |
| 578 | logging.info("Send Port_Stats Request") |
| 579 | logging.info("Verify reply has rx_over_err count ") |
| 580 | |
| 581 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 582 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 583 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 584 | rx_over_err = counter[9] |
| 585 | logging.info("Recieve Overrun Errors count is :" + str(rx_over_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | class RxCrcErr(base_tests.SimpleDataPlane): |
| 591 | |
| 592 | """Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors""" |
| 593 | |
| 594 | def runTest(self): |
| 595 | |
| 596 | logging.info("Running Port_Counter_9 test") |
| 597 | |
| 598 | of_ports = config["port_map"].keys() |
| 599 | of_ports.sort() |
| 600 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 601 | |
| 602 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 603 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 604 | |
| 605 | logging.info("Send Port_Stats Request") |
| 606 | logging.info("Verify reply has rx_crc_err count ") |
| 607 | |
| 608 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 609 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 610 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 611 | rx_crc_err = counter[10] |
| 612 | logging.info("Recieve CRC Errors count is :" + str(rx_crc_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 613 | |
| 614 | |
| 615 | |
| 616 | class Collisions(base_tests.SimpleDataPlane): |
| 617 | |
| 618 | """Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch """ |
| 619 | |
| 620 | def runTest(self): |
| 621 | |
| 622 | logging.info("Running Collisions test") |
| 623 | |
| 624 | of_ports = config["port_map"].keys() |
| 625 | of_ports.sort() |
| 626 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 627 | |
| 628 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 629 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 630 | |
| 631 | logging.info("Send Port_Stats Request") |
| 632 | logging.info("Verify reply has Collisions count ") |
| 633 | |
| 634 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 635 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 636 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 637 | collisions = counter[11] |
| 638 | logging.info("collisions count is :" + str(collisions)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 639 | |
| 640 | |
| 641 | |
| 642 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 643 | class TxErrorPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 644 | |
| 645 | """Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun """ |
| 646 | |
| 647 | def runTest(self): |
| 648 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 649 | logging.info("Running TxErrorPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 650 | |
| 651 | of_ports = config["port_map"].keys() |
| 652 | of_ports.sort() |
| 653 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 654 | |
| 655 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 656 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 657 | |
| 658 | logging.info("Send Queue_Stats Request") |
| 659 | logging.info("Verify reply has Tramitted Overrun errors count ") |
| 660 | |
| 661 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 662 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 663 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 664 | tx_err = counter[12] |
| 665 | logging.info("Transmit Overrun Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 666 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 667 | |
| 668 | |