Created DirectPacketQueue test, to exercise enqueue action.
diff --git a/tests/pktact.py b/tests/pktact.py
index 222317f..4598262 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -196,6 +196,14 @@
def runTest(self):
self.handleFlow()
+ def portQueuesGet(self, queue_stats, port_num):
+ result = []
+ for qs in queue_stats.stats:
+ if qs.port_no != port_num:
+ continue
+ result.append(qs.queue_id)
+ return result
+
def handleFlow(self, pkttype='TCP'):
of_ports = pa_port_map.keys()
of_ports.sort()
@@ -210,54 +218,89 @@
self.assertTrue(match is not None,
"Could not generate flow match from pkt")
- act = action.action_enqueue()
- egress_queue_id = 0 # For the time being, always queue 0
+ # Get queue stats from switch
+
+ request = message.queue_stats_request()
+ request.port_no = ofp.OFPP_ALL
+ request.queue_id = ofp.OFPQ_ALL
+ (queue_stats, pkt) = self.controller.transact(request, timeout=2)
+ self.assertNotEqual(queue_stats, None, "Queue stats request failed")
+
+ act = action.action_enqueue()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller, pa_logger)
- self.assertEqual(rv, 0, "Failed to delete all flows")
-
ingress_port = of_ports[idx]
egress_port = of_ports[(idx + 1) % len(of_ports)]
- pa_logger.info("Ingress " + str(ingress_port)
- + " to egress " + str(egress_port)
- + " queue " + str(egress_queue_id)
- )
- match.in_port = ingress_port
+ for egress_queue_id in self.portQueuesGet(queue_stats, egress_port):
+ pa_logger.info("Ingress " + str(ingress_port)
+ + " to egress " + str(egress_port)
+ + " queue " + str(egress_queue_id)
+ )
- request = message.flow_mod()
- request.match = match
+ rv = delete_all_flows(self.controller, pa_logger)
+ self.assertEqual(rv, 0, "Failed to delete all flows")
- request.buffer_id = 0xffffffff
- act.port = egress_port
- act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ match.in_port = ingress_port
+
+ request = message.flow_mod()
+ request.match = match
- pa_logger.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ request.buffer_id = 0xffffffff
+ act.port = egress_port
+ act.queue_id = egress_queue_id
+ self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Sending packet to dp port " +
- str(ingress_port))
- self.dataplane.send(ingress_port, str(pkt))
+ pa_logger.info("Inserting flow")
+ rv = self.controller.message_send(request)
+ self.assertTrue(rv != -1, "Error installing flow mod")
+ self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- exp_pkt_arg = None
- exp_port = None
- if pa_config["relax"]:
- exp_pkt_arg = pkt
- exp_port = egress_port
+ # Get current stats for selected egress queue
- (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1,
- port_number=exp_port,
- exp_pkt=exp_pkt_arg)
- self.assertTrue(rcv_pkt is not None, "Did not receive packet")
- pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
- str(rcv_port))
- self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
- self.assertEqual(str(pkt), str(rcv_pkt),
- 'Response packet does not match send packet')
+ request = message.queue_stats_request()
+ request.port_no = egress_port
+ request.queue_id = egress_queue_id
+ (qs_before, pkt) = self.controller.transact(request, timeout=2)
+ self.assertNotEqual(qs_before, None, "Queue stats request failed")
+
+ pa_logger.info("Sending packet to dp port " +
+ str(ingress_port))
+ self.dataplane.send(ingress_port, str(pkt))
+
+ exp_pkt_arg = None
+ exp_port = None
+ if pa_config["relax"]:
+ exp_pkt_arg = pkt
+ exp_port = egress_port
+
+ (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(timeout=1,
+ port_number=exp_port,
+ exp_pkt=exp_pkt_arg)
+ self.assertTrue(rcv_pkt is not None, "Did not receive packet")
+ pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
+ str(rcv_port))
+ self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
+ self.assertEqual(str(pkt), str(rcv_pkt),
+ 'Response packet does not match send packet')
+
+ # Get current stats for selected egress queue again
+
+ request = message.queue_stats_request()
+ request.port_no = egress_port
+ request.queue_id = egress_queue_id
+ (qs_after, pkt) = self.controller.transact(request, timeout=2)
+ self.assertNotEqual(qs_after, None, "Queue stats request failed")
+
+ # Make sure that tx packet counter for selected egress queue was
+ # incremented
+
+ self.assertEqual(qs_after.stats.stats[0].tx_packets, \
+ qs_before.stats.stats[0].tx_packets + 1, \
+ "Verification of egress queue tx packet count failed"
+ )
+
+
class DirectPacketICMP(DirectPacket):