throw AssertionError if controller.message_send fails
Unlike other types of exception an AssertionError will cause the test to "fail"
instead of "error". Using an exception instead of checking return values
removes a lot of boilerplate code that wasn't always present (or correct). It
may also help disabuse test writers of the dangerous notion that succeeding in
writing a message to the TCP socket means anything.
diff --git a/tests/port_stats.py b/tests/port_stats.py
index eb7e612..bacf1d8 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -176,8 +176,7 @@
# send flow
logging.info("Inserting flow")
- rv = self.controller.message_send(flow_mod_msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(flow_mod_msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# get initial port stats count
@@ -247,11 +246,9 @@
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
logging.info("Inserting flow1")
- rv = self.controller.message_send(flow_mod_msg1)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(flow_mod_msg1)
logging.info("Inserting flow2")
- rv = self.controller.message_send(flow_mod_msg2)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(flow_mod_msg2)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# get initial port stats count
@@ -325,11 +322,9 @@
flow_mod_msg2 = self.buildFlowModMsg(pkt2, port0, port2)
logging.info("Inserting flow1")
- rv = self.controller.message_send(flow_mod_msg1)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(flow_mod_msg1)
logging.info("Inserting flow2")
- rv = self.controller.message_send(flow_mod_msg2)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(flow_mod_msg2)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
num_pkt1s = random.randint(5,10)