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/flow_stats.py b/tests/flow_stats.py
index da12071..e8322fd 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -148,8 +148,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")
# no packets sent, so zero packet count
@@ -270,11 +269,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")
num_pkt1s = random.randint(10,30)
@@ -384,11 +381,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")
num_pkt1s = random.randint(10,30)
@@ -508,8 +503,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")
# send packet N times