testutils: add verify_packet_in and verify_no_packet_in
Checking that the controller received a packet-in message is surprisingly
complicated to do correctly. Because the switch may send unexpected packet-ins
(Linux IP stack on IVS's OFPP_LOCAL, for example) each test needs logic to
match the packet data, in_port, etc to figure out if this is the packet-in
message it's looking for.
This change adds two testutils functions that automate this, and replaces all
the other implementations in tests.
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index b30da7c..50c7eae 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -275,10 +275,7 @@
logging.info("Sending packet to dp port " + str(ingress_port) +
", expecting packet_in on control plane" )
- (response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_PACKET_IN,
- timeout=2)
- self.assertTrue(response is not None,
- 'Packet in event is not sent to the controller')
+ verify_packet_in(self, str(pkt), ingress_port, ofp.OFPR_NO_MATCH)
class Hello(base_tests.SimpleDataPlane):