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 |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 377 | (qs_before,p) = get_queuestats(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 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 385 | expected_packets = qs_before.stats[0].tx_packets+1 |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 386 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 387 | verify_queuestats(self,egress_port,egress_queue_id,expect_packet=expected_packets) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 388 | |
| 389 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 390 | class TxBytPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 391 | |
| 392 | """Verify that tx_bytes in the queue_stats reply increments in accordance with the number of transmitted bytes""" |
| 393 | |
| 394 | def runTest(self): |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 395 | logging.info("Running TxBytPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 396 | |
| 397 | of_ports = config["port_map"].keys() |
| 398 | of_ports.sort() |
| 399 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 400 | |
| 401 | # Get queue stats from switch (retrieve current state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 402 | (queue_stats,p) = get_queuestats(self,ofp.OFPP_ALL,ofp.OFPQ_ALL) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 403 | |
| 404 | for idx in range(len(of_ports)): |
| 405 | ingress_port = of_ports[idx] |
| 406 | egress_port = of_ports[(idx + 1) % len(of_ports)] |
| 407 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 408 | queue_id = port_queues_get(self,queue_stats,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 409 | |
| 410 | for egress_queue_id in queue_id: |
| 411 | |
| 412 | #Clear switch state |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 413 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 414 | |
| 415 | # Get Queue stats for selected egress queue only |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 416 | (qs_before,p) = get_queuestats(self,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 417 | |
| 418 | #Insert a flow with enqueue action to queues configured on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 419 | (pkt,match) = enqueue(self,ingress_port,egress_port,egress_queue_id) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 420 | |
| 421 | #Send packet on the ingress_port and verify its received on egress_port |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 422 | send_packet(self,pkt,ingress_port,egress_port) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 423 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 424 | expected_bytes = qs_before.stats[0].tx_bytes+len(str(pkt)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 425 | |
ShreyaPandita | 8793204 | 2012-11-05 18:48:39 -0500 | [diff] [blame] | 426 | verify_queuestats(self,egress_port,egress_queue_id,expect_byte=expected_bytes) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 427 | |
ShreyaPandita | ed20996 | 2012-11-04 02:16:48 -0500 | [diff] [blame] | 428 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 429 | class RxDrops(base_tests.SimpleDataPlane): |
| 430 | |
| 431 | """Verify that rx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by RX""" |
| 432 | |
| 433 | def runTest(self): |
| 434 | |
| 435 | logging.info("Running Rx_Drops test") |
| 436 | |
| 437 | of_ports = config["port_map"].keys() |
| 438 | of_ports.sort() |
| 439 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 440 | |
| 441 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 442 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 443 | |
| 444 | logging.info("Send Port_Stats Request") |
| 445 | logging.info("Verify reply has rx_dropped count ") |
| 446 | |
| 447 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 448 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 449 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 450 | rx_drp = counter[4] |
| 451 | logging.info("recieved dropped count is :" + str(rx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 452 | |
| 453 | |
| 454 | |
| 455 | class TxDrops(base_tests.SimpleDataPlane): |
| 456 | |
| 457 | """Verify that tx_dropped counters in the Port_Stats reply increments in accordance with the packets dropped by TX""" |
| 458 | |
| 459 | def runTest(self): |
| 460 | |
| 461 | logging.info("Running Tx_Drops test") |
| 462 | |
| 463 | of_ports = config["port_map"].keys() |
| 464 | of_ports.sort() |
| 465 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 466 | |
| 467 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 468 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 469 | |
| 470 | logging.info("Send Port_Stats Request") |
| 471 | logging.info("Verify reply has tx_dropped count ") |
| 472 | |
| 473 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 474 | (counter) = get_portstats(self,of_ports[1]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 475 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 476 | tx_drp = counter[5] |
| 477 | logging.info("Transmitted dropped count is :" + str(tx_drp)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 478 | |
| 479 | |
| 480 | class RxErrors(base_tests.SimpleDataPlane): |
| 481 | |
| 482 | """Verify that rx_errors counters in the Port_Stats reply increments in accordance with number of recieved error |
| 483 | This is a super-set of more specific receive errors and should be greater than or equal to the sum of all |
| 484 | rx_*_err values""" |
| 485 | |
| 486 | def runTest(self): |
| 487 | |
| 488 | logging.info("Running Rx_Errors test") |
| 489 | |
| 490 | of_ports = config["port_map"].keys() |
| 491 | of_ports.sort() |
| 492 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 493 | |
| 494 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 495 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 496 | |
| 497 | logging.info("Send Port_Stats Request") |
| 498 | logging.info("Verify reply has rx_errors count ") |
| 499 | |
| 500 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 501 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 502 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 503 | rx_err = counter[6] |
| 504 | logging.info("Recieve Errors count is :" + str(rx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 505 | |
| 506 | |
| 507 | class TxErrors(base_tests.SimpleDataPlane): |
| 508 | |
| 509 | """Verify that Tx_errors counters in the Port_Stats reply increments in accordance with number of trasmit error""" |
| 510 | |
| 511 | def runTest(self): |
| 512 | |
| 513 | logging.info("Running Tx_Errors test") |
| 514 | |
| 515 | of_ports = config["port_map"].keys() |
| 516 | of_ports.sort() |
| 517 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 518 | |
| 519 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 520 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 521 | |
| 522 | logging.info("Send Port_Stats Request") |
| 523 | logging.info("Verify reply has Tx_errors count ") |
| 524 | |
| 525 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 526 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 527 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 528 | tx_err = counter[7] |
| 529 | logging.info("Trasmit Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 530 | |
| 531 | |
| 532 | class RxFrameErr(base_tests.SimpleDataPlane): |
| 533 | |
| 534 | """Verify that rx_frm_err counters in the Port_Stats reply increments in accordance with the number of frame alignment errors""" |
| 535 | |
| 536 | def runTest(self): |
| 537 | |
| 538 | logging.info("Running Rx_Frame_Err test") |
| 539 | |
| 540 | of_ports = config["port_map"].keys() |
| 541 | of_ports.sort() |
| 542 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 543 | |
| 544 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 545 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 546 | |
| 547 | logging.info("Send Port_Stats Request") |
| 548 | logging.info("Verify reply has rx_frame_err count ") |
| 549 | |
| 550 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 551 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 552 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 553 | rx_fr_err = counter[8] |
| 554 | logging.info("Recieve Frame Errors count is :" + str(rx_fr_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 555 | |
| 556 | |
| 557 | |
| 558 | class RxOErr(base_tests.SimpleDataPlane): |
| 559 | |
| 560 | """Verify that rx_over_err counters in the Port_Stats reply increments in accordance with the number of with RX overrun""" |
| 561 | |
| 562 | def runTest(self): |
| 563 | |
| 564 | logging.info("Running Rx_O_Err test") |
| 565 | |
| 566 | of_ports = config["port_map"].keys() |
| 567 | of_ports.sort() |
| 568 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 569 | |
| 570 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 571 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 572 | |
| 573 | logging.info("Send Port_Stats Request") |
| 574 | logging.info("Verify reply has rx_over_err count ") |
| 575 | |
| 576 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 577 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 578 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 579 | rx_over_err = counter[9] |
| 580 | logging.info("Recieve Overrun Errors count is :" + str(rx_over_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | class RxCrcErr(base_tests.SimpleDataPlane): |
| 586 | |
| 587 | """Verify that rx_crc_err counters in the Port_Stats reply increments in accordance with the number of crc errors""" |
| 588 | |
| 589 | def runTest(self): |
| 590 | |
| 591 | logging.info("Running Port_Counter_9 test") |
| 592 | |
| 593 | of_ports = config["port_map"].keys() |
| 594 | of_ports.sort() |
| 595 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 596 | |
| 597 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 598 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 599 | |
| 600 | logging.info("Send Port_Stats Request") |
| 601 | logging.info("Verify reply has rx_crc_err count ") |
| 602 | |
| 603 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 604 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 605 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 606 | rx_crc_err = counter[10] |
| 607 | logging.info("Recieve CRC Errors count is :" + str(rx_crc_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 608 | |
| 609 | |
| 610 | |
| 611 | class Collisions(base_tests.SimpleDataPlane): |
| 612 | |
| 613 | """Verify that collisons counters in the Port_Stats reply increments in accordance with the collisions encountered by the switch """ |
| 614 | |
| 615 | def runTest(self): |
| 616 | |
| 617 | logging.info("Running Collisions test") |
| 618 | |
| 619 | of_ports = config["port_map"].keys() |
| 620 | of_ports.sort() |
| 621 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 622 | |
| 623 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 624 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 625 | |
| 626 | logging.info("Send Port_Stats Request") |
| 627 | logging.info("Verify reply has Collisions count ") |
| 628 | |
| 629 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 630 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 631 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 632 | collisions = counter[11] |
| 633 | logging.info("collisions count is :" + str(collisions)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 634 | |
| 635 | |
| 636 | |
| 637 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 638 | class TxErrorPerQueue(base_tests.SimpleDataPlane): |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 639 | |
| 640 | """Verify that tx_errors in the queue_stats reply increments in accordance with the number of packets dropped due to overrun """ |
| 641 | |
| 642 | def runTest(self): |
| 643 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 644 | logging.info("Running TxErrorPerQueue test") |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 645 | |
| 646 | of_ports = config["port_map"].keys() |
| 647 | of_ports.sort() |
| 648 | self.assertTrue(len(of_ports) > 1, "Not enough ports for test") |
| 649 | |
| 650 | #Clear switch State |
Rich Lane | 32bf948 | 2013-01-03 17:26:30 -0800 | [diff] [blame] | 651 | delete_all_flows(self.controller) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 652 | |
| 653 | logging.info("Send Queue_Stats Request") |
| 654 | logging.info("Verify reply has Tramitted Overrun errors count ") |
| 655 | |
| 656 | # Send Port_Stats request for the ingress port (retrieve current counter state) |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 657 | (counter) = get_portstats(self,of_ports[0]) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 658 | |
ShreyaPandita | e807dfb | 2012-11-02 19:01:19 -0400 | [diff] [blame] | 659 | tx_err = counter[12] |
| 660 | logging.info("Transmit Overrun Error count is :" + str(tx_err)) |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 661 | |
ShreyaPandita | 66de26f | 2012-10-26 14:44:24 -0400 | [diff] [blame] | 662 | |
| 663 | |