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)) |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 63 | |
| 64 | # Verify the packet counter was updated |
| 65 | verify_flow_stats(self, match, pkts=num_pkts) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 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)) |
Rich Lane | ae3428c | 2013-03-07 14:37:42 -0800 | [diff] [blame] | 96 | |
| 97 | # Verify the byte counter was updated |
| 98 | verify_flow_stats(self, match, bytes=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) |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 167 | initial_stats = get_port_stats(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 | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 174 | #Verify recieved packet counters |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 175 | verify_port_stats(self, of_ports[0], initial=initial_stats, rx_pkts=num_pkts) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 176 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 177 | class TxPktPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 178 | |
| 179 | """Verify that tx_packets counter in the Port_Stats reply , increments when packets are transmitted by a port""" |
| 180 | |
| 181 | def runTest(self): |
| 182 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 183 | logging.info("Running TxPktPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 184 | |
| 185 | of_ports = config["port_map"].keys() |
| 186 | of_ports.sort() |
| 187 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 188 | |
| 189 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 190 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 191 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 192 | logging.info("Insert any flow matching on in_port=ingress_port, action output to egress_port T ") |
| 193 | logging.info("Send N Packets matching the flow on ingress_port P ") |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 194 | 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] | 195 | |
| 196 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 197 | (pkt,match) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 198 | |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 199 | # Send Port_Stats request for the egress port (retrieve old counter state) |
| 200 | initial_stats = get_port_stats(self, of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 201 | |
| 202 | #Send packets matching the flow |
| 203 | num_pkts = 5 |
| 204 | for pkt_cnt in range(num_pkts): |
| 205 | self.dataplane.send(of_ports[0],str(pkt)) |
| 206 | |
| 207 | #Verify transmitted_packet counters |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 208 | verify_port_stats(self, of_ports[1], initial=initial_stats, |
| 209 | tx_pkts=num_pkts) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 210 | |
| 211 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 212 | |
| 213 | class RxBytPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 214 | |
| 215 | """Verify that recieved bytes counter in the Port_Stats reply , increments in accordance with the bytes recieved on a port""" |
| 216 | |
| 217 | def runTest(self): |
| 218 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 219 | logging.info("Running RxBytPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 220 | |
| 221 | of_ports = config["port_map"].keys() |
| 222 | of_ports.sort() |
| 223 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 224 | |
| 225 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 226 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 227 | |
| 228 | logging.info("Insert any flow matching on in_port=ingress_port") |
| 229 | logging.info("Send N Packets matching the flow on ingress_port P ") |
| 230 | logging.info("Send Port_Stats Request for Port P , verify recieved bytes counters are incrementing in accordance") |
| 231 | |
| 232 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 233 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 234 | |
| 235 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 236 | initial_stats = get_port_stats(self, of_ports[0]) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 237 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 238 | #Send packets matching the flow. |
| 239 | num_pkts = 5 |
| 240 | byte_count = num_pkts*len(str(pkt)) |
| 241 | for pkt_cnt in range(num_pkts): |
| 242 | self.dataplane.send(of_ports[0],str(pkt)) |
| 243 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 244 | #Verify recieved_bytes counters |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 245 | verify_port_stats(self, of_ports[0], initial=initial_stats, |
| 246 | rx_bytes=byte_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 247 | |
| 248 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 249 | class TxBytPerPort(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 250 | |
| 251 | """Verify that trasnsmitted bytes counter in the Port_Stats reply , increments in accordance with the bytes trasmitted by a port""" |
| 252 | |
| 253 | def runTest(self): |
| 254 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 255 | logging.info("Running TxBytPerPort test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 256 | |
| 257 | of_ports = config["port_map"].keys() |
| 258 | of_ports.sort() |
| 259 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 260 | |
| 261 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 262 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 263 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 264 | 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] | 265 | logging.info("Send N Packets matching the flow on ingress_port P ") |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 266 | 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] | 267 | |
| 268 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 269 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 270 | |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 271 | # Send Port_Stats request for the egress port (retrieve current counter state) |
| 272 | initial_stats = get_port_stats(self, of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 273 | |
| 274 | #Send packets matching the flow. |
| 275 | num_pkts = 5 |
| 276 | byte_count = num_pkts*len(str(pkt)) |
| 277 | for pkt_cnt in range(num_pkts): |
| 278 | self.dataplane.send(of_ports[0],str(pkt)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 279 | |
| 280 | #Verify trasmitted_bytes counters |
Rich Lane | 968b619 | 2013-03-07 15:34:43 -0800 | [diff] [blame] | 281 | verify_port_stats(self, of_ports[1], initial=initial_stats, |
| 282 | tx_bytes=byte_count) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 283 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 284 | class ActiveCount(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 285 | |
| 286 | """Verify that active_count counter in the Table_Stats reply , increments in accordance with the flows inserted in a table""" |
| 287 | |
| 288 | def runTest(self): |
| 289 | |
| 290 | logging.info("Running Table_Counter_1 test") |
| 291 | |
| 292 | of_ports = config["port_map"].keys() |
| 293 | of_ports.sort() |
| 294 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 295 | |
| 296 | #Clear Switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 297 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 298 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 299 | 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] | 300 | logging.info("Send Table_Stats, verify active_count counter is incremented in accordance") |
| 301 | |
| 302 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 303 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 304 | |
| 305 | #Generate Table_Stats |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 306 | verify_tablestats(self,expect_active=1) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 307 | |
| 308 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 309 | class LookupMatchedCount(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 310 | |
| 311 | """Verify that lookup_count and matched_count counter in the Table_Stats reply |
| 312 | increments in accordance with the packets looked up and matched with the flows in the table""" |
| 313 | |
| 314 | def runTest(self): |
| 315 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 316 | logging.info("Running LookupMatchedCount test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 317 | |
| 318 | of_ports = config["port_map"].keys() |
| 319 | of_ports.sort() |
| 320 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 321 | |
| 322 | #Clear Switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 323 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 324 | |
| 325 | logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port") |
| 326 | logging.info("Send N packets matching the flow, N' packets not matching the flow") |
| 327 | logging.info("Send Table_Stats, verify lookup_count = N+N' & matched_count=N ") |
| 328 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 329 | #Get Current Table Stats |
| 330 | (current_lookedup,current_matched,current_active) = get_tablestats(self) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 331 | |
| 332 | #Insert a flow with match on all ingress port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 333 | (pkt, match ) = wildcard_all_except_ingress(self,of_ports) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 334 | |
| 335 | #send packet pkt N times (pkt matches the flow) |
| 336 | num_sends = 5 |
| 337 | for pkt_cnt in range(num_sends): |
| 338 | self.dataplane.send(of_ports[0],str(pkt)) |
| 339 | |
| 340 | #send packet pkt N' (pkt does not match the flow) |
| 341 | num_sends2 = 5 |
| 342 | for pkt_cnt in range(num_sends): |
| 343 | self.dataplane.send(of_ports[1],str(pkt)) |
| 344 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 345 | new_lookup = num_sends+num_sends2+current_lookedup |
| 346 | new_matched = num_sends+current_matched |
Rich Lane | 47d0ec0 | 2012-10-26 14:28:19 -0700 | [diff] [blame] | 347 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 348 | #Verify lookup_count and matched_count counters. |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 349 | verify_tablestats(self,expect_lookup=new_lookup,expect_match=new_matched) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 350 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 351 | class TxPktPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 352 | |
| 353 | """Verify that tx_packets in the queue_stats reply increments in accordance with the number of transmitted packets""" |
| 354 | |
| 355 | def runTest(self): |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 356 | logging.info("Running TxPktPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 357 | |
| 358 | of_ports = config["port_map"].keys() |
| 359 | of_ports.sort() |
| 360 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 361 | |
| 362 | # Get queue stats from switch (retrieve current state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 363 | (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 364 | |
| 365 | for idx in range(len(of_ports)): |
| 366 | ingress_port = of_ports[idx] |
| 367 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 368 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 369 | queue_id = port_queues_get(self,queue_stats,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 370 | |
| 371 | for egress_queue_id in queue_id: |
| 372 | |
| 373 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 374 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 375 | |
| 376 | # Get Queue stats for selected egress queue only |
Rich Lane | 6a33492 | 2013-03-07 16:14:52 -0800 | [diff] [blame^] | 377 | initial_stats = get_queue_stats(self, egress_port, egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 378 | |
| 379 | #Insert a flow with enqueue action to queues configured on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 380 | (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 381 | |
| 382 | #Send packet on the ingress_port and verify its received on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 383 | send_packet(self,pkt,ingress_port,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 384 | |
Rich Lane | 6a33492 | 2013-03-07 16:14:52 -0800 | [diff] [blame^] | 385 | verify_queue_stats(self, egress_port, egress_queue_id, |
| 386 | initial=initial_stats, pkts=1) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 387 | |
| 388 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 389 | class TxBytPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 390 | |
| 391 | """Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes""" |
| 392 | |
| 393 | def runTest(self): |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 394 | logging.info("Running TxBytPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 395 | |
| 396 | of_ports = config["port_map"].keys() |
| 397 | of_ports.sort() |
| 398 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 399 | |
| 400 | # Get queue stats from switch (retrieve current state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 401 | (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 402 | |
| 403 | for idx in range(len(of_ports)): |
| 404 | ingress_port = of_ports[idx] |
| 405 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 406 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 407 | queue_id = port_queues_get(self,queue_stats,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 408 | |
| 409 | for egress_queue_id in queue_id: |
| 410 | |
| 411 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 412 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 413 | |
| 414 | # Get Queue stats for selected egress queue only |
Rich Lane | 6a33492 | 2013-03-07 16:14:52 -0800 | [diff] [blame^] | 415 | initial_stats = get_queue_stats(self, egress_port, egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 416 | |
| 417 | #Insert a flow with enqueue action to queues configured on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 418 | (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 419 | |
| 420 | #Send packet on the ingress_port and verify its received on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 421 | send_packet(self,pkt,ingress_port,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 422 | |
Rich Lane | 6a33492 | 2013-03-07 16:14:52 -0800 | [diff] [blame^] | 423 | verify_queue_stats(self, egress_port, egress_queue_id, |
| 424 | initial=initial_stats, |
| 425 | bytes=len(str(pkt))) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 426 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 427 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 428 | class RxDrops(base_tests.SimpleDataPlane): |
| 429 | |
| 430 | """Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX""" |
| 431 | |
| 432 | def runTest(self): |
| 433 | |
| 434 | logging.info("Running Rx_Drops test") |
| 435 | |
| 436 | of_ports = config["port_map"].keys() |
| 437 | of_ports.sort() |
| 438 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 439 | |
| 440 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 441 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 442 | |
| 443 | logging.info("Send Port_Stats Request") |
| 444 | logging.info("Verify reply has rx_dropped count ") |
| 445 | |
| 446 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 447 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 448 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 449 | rx_drp = counter[4] |
| 450 | logging.info("recieved dropped count is :" + str(rx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 451 | |
| 452 | |
| 453 | |
| 454 | class TxDrops(base_tests.SimpleDataPlane): |
| 455 | |
| 456 | """Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX""" |
| 457 | |
| 458 | def runTest(self): |
| 459 | |
| 460 | logging.info("Running Tx_Drops test") |
| 461 | |
| 462 | of_ports = config["port_map"].keys() |
| 463 | of_ports.sort() |
| 464 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 465 | |
| 466 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 467 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 468 | |
| 469 | logging.info("Send Port_Stats Request") |
| 470 | logging.info("Verify reply has tx_dropped count ") |
| 471 | |
| 472 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 473 | (counter) = get_portstats(self,of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 474 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 475 | tx_drp = counter[5] |
| 476 | logging.info("Transmitted dropped count is :" + str(tx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 477 | |
| 478 | |
| 479 | class RxErrors(base_tests.SimpleDataPlane): |
| 480 | |
| 481 | """Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error |
| 482 | This is a super-set of more specific receive errors and should be greater than or equal to the sum of all |
| 483 | rx_*_err values""" |
| 484 | |
| 485 | def runTest(self): |
| 486 | |
| 487 | logging.info("Running Rx_Errors 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 |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 494 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 495 | |
| 496 | logging.info("Send Port_Stats Request") |
| 497 | logging.info("Verify reply has rx_errors count ") |
| 498 | |
| 499 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 500 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 501 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 502 | rx_err = counter[6] |
| 503 | logging.info("Recieve Errors count is :" + str(rx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 504 | |
| 505 | |
| 506 | class TxErrors(base_tests.SimpleDataPlane): |
| 507 | |
| 508 | """Verify that Tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit error""" |
| 509 | |
| 510 | def runTest(self): |
| 511 | |
| 512 | logging.info("Running Tx_Errors test") |
| 513 | |
| 514 | of_ports = config["port_map"].keys() |
| 515 | of_ports.sort() |
| 516 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 517 | |
| 518 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 519 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 520 | |
| 521 | logging.info("Send Port_Stats Request") |
| 522 | logging.info("Verify reply has Tx_errors count ") |
| 523 | |
| 524 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 525 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 526 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 527 | tx_err = counter[7] |
| 528 | logging.info("Trasmit Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 529 | |
| 530 | |
| 531 | class RxFrameErr(base_tests.SimpleDataPlane): |
| 532 | |
| 533 | """Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors""" |
| 534 | |
| 535 | def runTest(self): |
| 536 | |
| 537 | logging.info("Running Rx_Frame_Err test") |
| 538 | |
| 539 | of_ports = config["port_map"].keys() |
| 540 | of_ports.sort() |
| 541 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 542 | |
| 543 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 544 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 545 | |
| 546 | logging.info("Send Port_Stats Request") |
| 547 | logging.info("Verify reply has rx_frame_err count ") |
| 548 | |
| 549 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 550 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 551 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 552 | rx_fr_err = counter[8] |
| 553 | logging.info("Recieve Frame Errors count is :" + str(rx_fr_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 554 | |
| 555 | |
| 556 | |
| 557 | class RxOErr(base_tests.SimpleDataPlane): |
| 558 | |
| 559 | """Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun""" |
| 560 | |
| 561 | def runTest(self): |
| 562 | |
| 563 | logging.info("Running Rx_O_Err test") |
| 564 | |
| 565 | of_ports = config["port_map"].keys() |
| 566 | of_ports.sort() |
| 567 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 568 | |
| 569 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 570 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 571 | |
| 572 | logging.info("Send Port_Stats Request") |
| 573 | logging.info("Verify reply has rx_over_err count ") |
| 574 | |
| 575 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 576 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 577 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 578 | rx_over_err = counter[9] |
| 579 | logging.info("Recieve Overrun Errors count is :" + str(rx_over_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | class RxCrcErr(base_tests.SimpleDataPlane): |
| 585 | |
| 586 | """Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors""" |
| 587 | |
| 588 | def runTest(self): |
| 589 | |
| 590 | logging.info("Running Port_Counter_9 test") |
| 591 | |
| 592 | of_ports = config["port_map"].keys() |
| 593 | of_ports.sort() |
| 594 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 595 | |
| 596 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 597 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 598 | |
| 599 | logging.info("Send Port_Stats Request") |
| 600 | logging.info("Verify reply has rx_crc_err count ") |
| 601 | |
| 602 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 603 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 604 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 605 | rx_crc_err = counter[10] |
| 606 | logging.info("Recieve CRC Errors count is :" + str(rx_crc_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 607 | |
| 608 | |
| 609 | |
| 610 | class Collisions(base_tests.SimpleDataPlane): |
| 611 | |
| 612 | """Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch """ |
| 613 | |
| 614 | def runTest(self): |
| 615 | |
| 616 | logging.info("Running Collisions 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 |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 623 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 624 | |
| 625 | logging.info("Send Port_Stats Request") |
| 626 | logging.info("Verify reply has Collisions count ") |
| 627 | |
| 628 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 629 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 630 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 631 | collisions = counter[11] |
| 632 | logging.info("collisions count is :" + str(collisions)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 633 | |
| 634 | |
| 635 | |
| 636 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 637 | class TxErrorPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 638 | |
| 639 | """Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun """ |
| 640 | |
| 641 | def runTest(self): |
| 642 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 643 | logging.info("Running TxErrorPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 644 | |
| 645 | of_ports = config["port_map"].keys() |
| 646 | of_ports.sort() |
| 647 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 648 | |
| 649 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 650 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 651 | |
| 652 | logging.info("Send Queue_Stats Request") |
| 653 | logging.info("Verify reply has Tramitted Overrun errors count ") |
| 654 | |
| 655 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 656 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 657 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 658 | tx_err = counter[12] |
| 659 | logging.info("Transmit Overrun Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 660 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 661 | |
| 662 | |