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/src/python/oftest/controller.py b/src/python/oftest/controller.py
index b60823a..fa346c3 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -258,8 +258,7 @@
rep = echo_reply()
rep.header.xid = hdr.xid
# Ignoring additional data
- if self.message_send(rep.pack(), zero_xid=True) < 0:
- self.logger.error("Error sending echo reply")
+ self.message_send(rep.pack(), zero_xid=True)
continue
# Now check for message handlers; preference is given to
@@ -613,10 +612,7 @@
self.xid = msg.header.xid
self.xid_response = None
- if self.message_send(msg.pack()) < 0:
- self.logger.error("Error sending pkt for transaction %d" %
- msg.header.xid)
- return (None, None)
+ self.message_send(msg.pack())
self.logger.debug("Waiting for transaction %d" % msg.header.xid)
timed_wait(self.xid_cv, lambda: self.xid_response, timeout=timeout)
@@ -641,9 +637,6 @@
the XID in the header is 0, then an XID will be generated
for the message. Set zero_xid to override this behavior (and keep an
existing 0 xid)
-
- @return 0 on success
-
"""
if not self.switch_socket:
@@ -663,9 +656,9 @@
ofp_type_map.get(msg_type, "unknown (%d)" % msg_type),
msg_len)
if self.switch_socket.sendall(outpkt) is not None:
- raise Exception("unknown error on sendall")
+ raise AssertionError("failed to send message to switch")
- return 0
+ return 0 # for backwards compatibility
def __str__(self):
string = "Controller:\n"
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index de7b52a..0fc6ce0 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -43,7 +43,8 @@
msg.out_port = ofp.OFPP_NONE
msg.command = ofp.OFPFC_DELETE
msg.buffer_id = 0xffffffff
- return ctrl.message_send(msg)
+ ctrl.message_send(msg)
+ return 0
def required_wildcards(parent):
w = test_param_get('required_wildcards', default='default')
@@ -349,8 +350,8 @@
mod.config = config
mod.mask = mask
mod.advertise = reply.ports[idx].advertised
- rv = controller.message_send(mod)
- return rv
+ controller.message_send(mod)
+ return 0
def receive_pkt_check(dp, pkt, yes_ports, no_ports, assert_if):
"""
@@ -574,8 +575,7 @@
parent.assertEqual(rc, 0, "Failed to delete all flows")
logging.debug("Insert flow")
- rv = parent.controller.message_send(request)
- parent.assertTrue(rv != -1, "Error installing flow mod")
+ parent.controller.message_send(request)
parent.assertEqual(do_barrier(parent.controller), 0, "Barrier failed")
@@ -642,8 +642,7 @@
msg.actions.add(act)
logging.debug(msg.show())
- rv = parent.controller.message_send(msg)
- parent.assertTrue(rv == 0, "Error sending out message")
+ parent.controller.message_send(msg)
if exp_pkt is None:
exp_pkt = pkt
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 4d420da..ad1b1ea 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -41,8 +41,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_exactflow,match)
@@ -69,8 +68,7 @@
act.port = of_ports[2]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_exactflow,match)
@@ -98,8 +96,7 @@
act1.port = of_ports[1]
msg1.actions.add(act1)
- rv = self.controller.message_send(msg1)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg1)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_wildcardsrc,match1)
@@ -126,8 +123,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_MatchSrc,match)
@@ -153,8 +149,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchdst,match)
@@ -180,8 +175,7 @@
if priority != None :
msg2.priority = priority
- rv = self.controller.message_send(msg2)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg2)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_wildcard,match2)
@@ -214,8 +208,7 @@
if priority != None :
msg3.priority = priority
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg3)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchingress,match3)
@@ -247,8 +240,7 @@
if priority != None :
msg3.priority = priority
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg3)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchingress,match3)
@@ -275,8 +267,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchvlanid,match)
@@ -302,8 +293,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchvlanpcp,match)
@@ -330,8 +320,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_mulL2,match)
@@ -357,8 +346,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_mulL4,match)
@@ -383,8 +371,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_iptos,match)
@@ -409,8 +396,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_iptos,match)
@@ -437,8 +423,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchtSrc,match)
@@ -463,8 +448,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchdst,match)
@@ -491,8 +475,7 @@
act.port = of_ports[1]
msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt_matchtype,match)
@@ -516,8 +499,7 @@
msg5.priority = priority
# Send the flow with action A'
- rv = self.controller.message_send (msg5)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send (msg5)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
def modify_flow_action(self,of_ports,match,priority=None):
@@ -539,8 +521,7 @@
msg8.priority = priority
# Send the flow with action A'
- rv = self.controller.message_send (msg8)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send (msg8)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
def enqueue(self,ingress_port,egress_port,egress_queue_id):
@@ -562,8 +543,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
return (pkt,match)
@@ -834,8 +814,7 @@
if priority != None :
msg4.priority = priority
- rv = self.controller.message_send(msg4)
- self.assertTrue(rv!= -1, "Error installing flow mod")
+ self.controller.message_send(msg4)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -853,8 +832,7 @@
if priority != None :
msg6.priority = priority
- rv = self.controller.message_send(msg6)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg6)
self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
diff --git a/tests/actions.py b/tests/actions.py
index 330068c..62afda8 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -57,8 +57,7 @@
msg.command = ofp.OFPFC_ADD
msg.buffer_id = 0xffffffff
msg.match = match
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Sending N packets matching the flow inserted
@@ -163,8 +162,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send Packet matching the flow
@@ -217,8 +215,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send packet matching the flow
@@ -271,8 +268,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send packet matching the flow
@@ -323,8 +319,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send Packet matching the flow
@@ -375,8 +370,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send packet matching the flow
@@ -420,8 +414,7 @@
act = action.action_output()
act.port = ofp.OFPP_TABLE
pkt_out.actions.add(act)
- rv = self.controller.message_send(pkt_out)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(pkt_out)
#Verifying packet out message recieved on the expected dataplane port.
(of_port, pkt, pkt_time) = self.dataplane.poll(port_number=of_ports[1],
diff --git a/tests/basic.py b/tests/basic.py
index 84c4d63..06d4304 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -215,8 +215,7 @@
msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_port))
- rv = self.controller.message_send(msg)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(msg)
exp_pkt_arg = None
exp_port = None
@@ -273,8 +272,7 @@
msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_ports))
- rv = self.controller.message_send(msg)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(msg)
receive_pkt_check(self.dataplane, outpkt, dp_ports,
set(of_ports).difference(dp_ports),
@@ -293,8 +291,7 @@
logging.info("Running StatsGet")
logging.info("Inserting trial flow")
request = flow_mod_gen(config["port_map"], True)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Failed to insert test flow")
+ self.controller.message_send(request)
logging.info("Sending flow request")
request = message.flow_stats_request()
@@ -316,8 +313,7 @@
logging.info("Running TableStatsGet")
logging.info("Inserting trial flow")
request = flow_mod_gen(config["port_map"], True)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Failed to insert test flow")
+ self.controller.message_send(request)
logging.info("Sending table stats request")
request = message.table_stats_request()
@@ -352,8 +348,7 @@
def runTest(self):
logging.info("Running " + str(self))
request = flow_mod_gen(config["port_map"], True)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
class PortConfigMod(base_tests.SimpleProtocol):
"""
diff --git a/tests/bsn_ipmask.py b/tests/bsn_ipmask.py
index 70ca990..51f2213 100644
--- a/tests/bsn_ipmask.py
+++ b/tests/bsn_ipmask.py
@@ -52,8 +52,7 @@
m = message.vendor()
m.vendor = 0x005c16c7
m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask)
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending set IP mask command")
+ self.controller.message_send(m)
def bsn_get_ip_mask(self, index):
"""
@@ -63,8 +62,7 @@
m = message.vendor()
m.vendor = 0x005c16c7
m.data = struct.pack( "!LBBBBL", 1, index, 0, 0, 0, 0 )
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending get IP mask command")
+ self.controller.message_send(m)
m, r = self.controller.poll(ofp.OFPT_VENDOR)
self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
x = struct.unpack("!LBBBBL", m.data)
@@ -149,14 +147,12 @@
rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- rc = self.controller.message_send(flow_msg_create(
+ self.controller.message_send(flow_msg_create(
self, pkt0, ing_port=ports[0], egr_ports=[ports[1]],
wildcards=wildcards))
- self.assertNotEqual(rc, -1, "Error inserting flow entry 0")
- rc = self.controller.message_send(flow_msg_create(
+ self.controller.message_send(flow_msg_create(
self, pkt1, ing_port=ports[0], egr_ports=[ports[2]],
wildcards=wildcards))
- self.assertNotEqual(rc, -1, "Error inserting flow entry 1")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
diff --git a/tests/bsn_mirror.py b/tests/bsn_mirror.py
index fd211c8..8a713be 100644
--- a/tests/bsn_mirror.py
+++ b/tests/bsn_mirror.py
@@ -91,8 +91,7 @@
m = message.vendor()
m.vendor = 0x005c16c7
m.data = struct.pack("!LBBBB", 3, enabled, 0, 0, 0)
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending set mirroring command")
+ self.controller.message_send(m)
def bsn_get_mirroring(self):
"""
@@ -102,8 +101,7 @@
m = message.vendor()
m.vendor = 0x005c16c7
m.data = struct.pack("!LBBBB", 4, 0, 0, 0, 0)
- rc = self.controller.message_send(m)
- self.assertNotEqual(rc, -1, "Error sending get mirroring command")
+ self.controller.message_send(m)
m, r = self.controller.poll(ofp.OFPT_VENDOR, 2)
self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
x = struct.unpack("!LBBBB", m.data)
@@ -154,8 +152,7 @@
flow_mod.actions.add(act3)
self.assertEqual(delete_all_flows(self.controller), 0,
"Failed to delete all flows")
- self.assertNotEqual(self.controller.message_send(flow_mod), -1,
- "Error installing flow mod")
+ self.controller.message_send(flow_mod)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to port %s" % ports[0])
diff --git a/tests/caps.py b/tests/caps.py
index 6c48840..9f80d4b 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -58,8 +58,7 @@
# Make sure we can install at least one flow
logging.info("Inserting initial flow")
- rv = obj.controller.message_send(request)
- obj.assertTrue(rv != -1, "Error installing flow mod")
+ obj.controller.message_send(request)
obj.assertEqual(do_barrier(obj.controller, timeout=10), 0, "Barrier failed")
flow_count = 1
@@ -68,7 +67,7 @@
while True:
request.match.nw_src += 1
- rv = obj.controller.message_send(request)
+ obj.controller.message_send(request)
flow_count += 1
if flow_count % count_check == 0:
obj.assertEqual(do_barrier(obj.controller, timeout=10), 0, "Barrier failed")
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index 25fc683..3ca0038 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -65,9 +65,7 @@
act3 = action.action_output()
act3.port = of_ports[1]
msg3.actions.add(act3)
- msg3.actions.add(1)
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg3)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Verify Flow does not get inserted
@@ -193,8 +191,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Flow addition did not fail.")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -241,8 +238,7 @@
request.actions.add(act3)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify the flow gets added i.e. active_count= 1
@@ -457,8 +453,7 @@
act.port = of_ports[1]
request.actions.add(act)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Flow addition failed.")
+ self.controller.message_send(request)
# Delete the emergency flow
@@ -590,8 +585,7 @@
msg7.buffer_id = 0xffffffff
msg7.match = match
- rv = self.controller.message_send(msg7)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg7)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Verify flow will not get deleted, active_entries in table_stats_request = 1
@@ -607,8 +601,7 @@
msg7.buffer_id = 0xffffffff
msg7.match = match
- rv = self.controller.message_send(msg7)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg7)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify flow gets deleted.
@@ -783,8 +776,7 @@
act3.port = of_ports[1]
msg3.actions.add(act3)
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(msg3)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Verify no flow removed message is generated
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index 93df5f8..705cab0 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -68,8 +68,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 13c82c3..b205101 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -1330,8 +1330,7 @@
request.match = query_match
request.table_id = 0xff
request.out_port = ofp.OFPP_NONE;
- if self.controller.message_send(request) == -1:
- return False
+ self.controller.message_send(request)
# <TBD>
# Glue together successive reponse messages for stats reply.
# Looking at the "more" flag and performing re-assembly
@@ -1367,7 +1366,8 @@
logging.info("Sending flow_mod(add), xid=%d"
% (flow_mod_msg.header.xid)
)
- return (self.controller.message_send(flow_mod_msg) != -1)
+ self.controller.message_send(flow_mod_msg)
+ return True
def flow_mod(self, flow_cfg, strictf):
flow_mod_msg = message.flow_mod()
@@ -1379,7 +1379,8 @@
logging.info("Sending flow_mod(mod), xid=%d"
% (flow_mod_msg.header.xid)
)
- return (self.controller.message_send(flow_mod_msg) != -1)
+ self.controller.message_send(flow_mod_msg)
+ return True
def flow_del(self, flow_cfg, strictf):
flow_mod_msg = message.flow_mod()
@@ -1393,7 +1394,8 @@
logging.info("Sending flow_mod(del), xid=%d"
% (flow_mod_msg.header.xid)
)
- return (self.controller.message_send(flow_mod_msg) != -1)
+ self.controller.message_send(flow_mod_msg)
+ return True
def barrier(self):
barrier = message.barrier_request()
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
diff --git a/tests/load.py b/tests/load.py
index b35abc1..d3d3ca6 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -75,8 +75,7 @@
act.port = ofp.OFPP_CONTROLLER
request.actions.add(act)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Create packet out and send to port lb_port + 1
@@ -89,8 +88,7 @@
logging.info("Sleeping before starting storm")
time.sleep(1) # Root causing issue with fast disconnects
logging.info("Sending packet out to %d" % (lb_port + 1))
- rv = self.controller.message_send(msg)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(msg)
for idx in range(0, barrier_count):
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -186,8 +184,7 @@
for count in range(100):
msg.xid = xid
xid += 1
- rv = self.controller.message_send(msg)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(msg)
out_count += 1
exp_pkt_arg = None
diff --git a/tests/message_types.py b/tests/message_types.py
index 2beaaab..0a72acd 100644
--- a/tests/message_types.py
+++ b/tests/message_types.py
@@ -38,8 +38,7 @@
logging.info("Sending Hello...")
request = message.hello()
request.data = 'OpenFlow Will Rule The World'
- rv=self.controller.message_send(request)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(request)
#Verify Hello message in response
logging.info("Waiting for a Hello on the control plane with same xid,version--1.0.0 and data field empty")
@@ -64,8 +63,7 @@
logging.info("Sending Echo With Data ...")
request = message.echo_request()
request.data = 'OpenFlow Will Rule The World'
- rv=self.controller.message_send(request)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(request)
#Verify Echo Reply is recieved
logging.info("Waiting for Echo Reply with data field copied from Echo Request")
@@ -100,8 +98,7 @@
logging.info("Sending a Echo request with a version which is not supported by the switch")
request=message.echo_request()
request.header.version=0
- rv=self.controller.message_send(request)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(request)
logging.info("Waiting for a OFPT_ERROR msg on the control plane...")
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,
@@ -273,8 +270,7 @@
req.flags = old_flags+1
new_flags = req.flags
- rv=self.controller.message_send(req)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(req)
#Send get_config_request -- verify change came into effect
logging.info("Sending Get Config Request...")
@@ -310,8 +306,7 @@
for bytes in miss_send_len :
req = message.set_config()
req.miss_send_len = bytes
- rv=self.controller.message_send(req)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(req)
sleep(1)
# Send packet to trigger packet_in event
@@ -375,8 +370,7 @@
request.actions.add(act)
logging.info("Inserting flow....")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send packet matching the flow
@@ -417,8 +411,7 @@
logging.info("Sending set_config_request to set miss_send_len... ")
req = message.set_config()
req.miss_send_len = 65535
- rv=self.controller.message_send(req)
- self.assertTrue(rv is not None,"Unable to send the message")
+ self.controller.message_send(req)
sleep(1)
# Send packet to trigger packet_in event
@@ -477,8 +470,7 @@
request.actions.add(act)
logging.info("Inserting flow....")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
#Send packet matching the flow
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index 2d57978..037209d 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -43,8 +43,7 @@
logging.info("Expecting Features_Reply")
request = message.features_request()
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Not able to send features request.")
+ self.controller.message_send(request)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FEATURES_REPLY,
timeout=2)
@@ -73,8 +72,7 @@
logging.info("Expecting OFPT_GET_CONFIG_REPLY ")
request = message.get_config_request()
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, " Not able to send get_config request.")
+ self.controller.message_send(request)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_GET_CONFIG_REPLY,
timeout=2)
@@ -235,8 +233,7 @@
msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_port))
- rv = self.controller.message_send(msg)
- self.assertTrue(rv == 0, "Error sending out message")
+ self.controller.message_send(msg)
exp_pkt_arg = None
exp_port = None
diff --git a/tests/pktact.py b/tests/pktact.py
index 5a1bedf..4a9f7cc 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -125,8 +125,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " +
@@ -191,8 +190,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " +
@@ -280,8 +278,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Get current stats for selected egress queue
@@ -411,8 +408,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Get current stats for selected egress queue
@@ -533,8 +529,7 @@
# logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " +
@@ -589,8 +584,7 @@
logging.debug(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -643,8 +637,7 @@
# logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -688,8 +681,7 @@
logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -738,8 +730,7 @@
logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -783,8 +774,7 @@
logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -833,8 +823,7 @@
logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -892,8 +881,7 @@
logging.info(request.show())
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -1802,8 +1790,7 @@
# Install the first set of flows
for f_idx in range(flow_count):
- rv = self.controller.message_send(flows[0][f_idx])
- self.assertTrue(rv != -1, "Error installing flow %d" % f_idx)
+ self.controller.message_send(flows[0][f_idx])
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
logging.info("Installed %d flows" % flow_count)
@@ -1822,10 +1809,8 @@
for toggle in range(2):
t_idx = 1 - toggle
for f_idx in range(flow_count):
- rv = self.controller.message_send(flows[t_idx][f_idx])
+ self.controller.message_send(flows[t_idx][f_idx])
updates += 1
- self.assertTrue(rv != -1, "Error modifying flow %d" %
- f_idx)
self.assertEqual(do_barrier(self.controller), 0,
"Barrier failed")
@@ -2104,8 +2089,7 @@
request.actions.add(act)
logging.info("Inserting flow")
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request)
# This flow speeds up negative tests
logging.info("Inserting catch-all flow")
@@ -2115,8 +2099,7 @@
act = action.action_output()
act.port = ofp.OFPP_IN_PORT
request2.actions.add(act)
- rv = self.controller.message_send(request2)
- self.assertTrue(rv != -1, "Error installing flow mod")
+ self.controller.message_send(request2)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
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)