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