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