Merge branch 'annotations'
Conflicts:
oft
diff --git a/oft b/oft
index fc62193..7205505 100755
--- a/oft
+++ b/oft
@@ -468,8 +468,7 @@
print "Test List:"
for (modname, (mod, tests)) in test_modules.items():
mod_count += 1
- desc = (mod.__doc__ or "").strip()
- desc = desc.split('\n')[0]
+ desc = (mod.__doc__ or "No description").strip().split('\n')[0]
start_str = " Module " + mod.__name__ + ": "
print start_str + _space_to(22, start_str) + desc
for (testname, test) in tests.items():
diff --git a/src/python/oftest/action_list.py b/src/python/oftest/action_list.py
index 628e067..fbbddea 100644
--- a/src/python/oftest/action_list.py
+++ b/src/python/oftest/action_list.py
@@ -54,8 +54,10 @@
"""
- def __init__(self):
- self.actions = []
+ def __init__(self, actions=None):
+ if actions == None:
+ actions = []
+ self.actions = actions
def pack(self):
"""
@@ -112,14 +114,11 @@
@param action The action to add
- @return True if successful, False if not an action object
-
"""
- if isinstance(action, action_class_list):
- tmp = copy.deepcopy(action)
- self.actions.append(tmp)
- return True
- return False
+ if not isinstance(action, action_class_list):
+ raise ValueError("%s is not an action" % type(action))
+ self.actions.append(copy.deepcopy(action))
+ return True # for backwards compatibility
def remove_type(self, type):
"""
@@ -163,9 +162,8 @@
"""
for act in other.actions:
- if not self.add(act):
- return False
- return True
+ self.add(act)
+ return True # for backwards compatibility
def __len__(self):
length = 0
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/dataplane.py b/src/python/oftest/dataplane.py
index a5b4e26..78089e3 100644
--- a/src/python/oftest/dataplane.py
+++ b/src/python/oftest/dataplane.py
@@ -24,7 +24,6 @@
from threading import Condition
import select
import logging
-from oft_assert import oft_assert
from ofutils import *
have_pypcap = False
diff --git a/src/python/oftest/oft_assert.py b/src/python/oftest/oft_assert.py
deleted file mode 100644
index d773c84..0000000
--- a/src/python/oftest/oft_assert.py
+++ /dev/null
@@ -1,28 +0,0 @@
-"""
-OpenFlow Test Framework
-
-Framework assert definition
-"""
-
-import sys
-import logging
-
-def oft_assert(condition, string):
- """
- Test framework assertion check
-
- @param condition The boolean condition to check
- @param string String to print if error
-
- If condition is not true, it is considered a test framework
- failure and exit is called.
-
- This assert is meant to represent a violation in the
- assumptions of how the test framework is supposed to work
- (for example, an inconsistent packet queue state) rather than
- a test failure.
- """
- if not condition:
- logging.critical("Internal error: " + string)
- sys.exit(1)
-
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index fe53ecc..e8dec6e 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 # for backwards compatibility
def required_wildcards(parent):
w = test_param_get('required_wildcards', default='default')
@@ -296,10 +297,10 @@
"""
b = message.barrier_request()
(resp, pkt) = ctrl.transact(b, timeout=timeout)
+ if resp is None:
+ raise AssertionError("barrier failed")
# We'll trust the transaction processing in the controller that xid matched
- if not resp:
- return -1
- return 0
+ return 0 # for backwards compatibility
def port_config_get(controller, port_no):
"""
@@ -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):
"""
@@ -535,8 +536,7 @@
if action_list is not None:
for act in action_list:
logging.debug("Adding action " + act.show())
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add action" + act.show())
+ request.actions.add(act)
# Set up output/enqueue action if directed
if egr_queue is not None:
@@ -545,16 +545,12 @@
for egr_port in egr_port_list:
act.port = egr_port
act.queue_id = egr_queue
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add enqueue action " +
- str(egr_port) + " Q: " + str(egr_queue))
+ request.actions.add(act)
elif egr_ports is not None:
for egr_port in egr_port_list:
act = action.action_output()
act.port = egr_port
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add output action " +
- str(egr_port))
+ request.actions.add(act)
logging.debug(request.show())
@@ -575,14 +571,12 @@
if clear_table:
logging.debug("Clear flow table")
- rc = delete_all_flows(parent.controller)
- parent.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(parent.controller)
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")
+ do_barrier(parent.controller)
def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None,
dl_vlan=-1, pkt=None, exp_pkt=None,
@@ -637,18 +631,17 @@
msg.data = str(pkt)
if action_list is not None:
for act in action_list:
- assert(msg.actions.add(act))
+ msg.actions.add(act)
# Set up output action
if egr_ports is not None:
for egr_port in egr_ports:
act = action.action_output()
act.port = egr_port
- assert(msg.actions.add(act))
+ 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 82f1a4f..6c55425 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -39,11 +39,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_exactflow,match)
@@ -67,11 +66,10 @@
act = action.action_output()
act.port = of_ports[2]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_exactflow,match)
@@ -96,11 +94,10 @@
act1 = action.action_output()
act1.port = of_ports[1]
- self.assertTrue(msg1.actions.add(act1), "could not add action")
+ msg1.actions.add(act1)
- rv = self.controller.message_send(msg1)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg1)
+ do_barrier(self.controller)
return (pkt_wildcardsrc,match1)
@@ -124,11 +121,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_MatchSrc,match)
@@ -151,11 +147,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchdst,match)
@@ -176,13 +171,12 @@
msg2.match = match2
act2 = action.action_output()
act2.port = of_ports[1]
- self.assertTrue(msg2.actions.add(act2), "could not add action")
+ msg2.actions.add(act2)
if priority != None :
msg2.priority = priority
- rv = self.controller.message_send(msg2)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg2)
+ do_barrier(self.controller)
return (pkt_wildcard,match2)
@@ -209,14 +203,13 @@
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
if priority != None :
msg3.priority = priority
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg3)
+ do_barrier(self.controller)
return (pkt_matchingress,match3)
@@ -243,13 +236,12 @@
act3 = action.action_output()
act3.port = of_ports[2]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
if priority != None :
msg3.priority = priority
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg3)
+ do_barrier(self.controller)
return (pkt_matchingress,match3)
@@ -273,11 +265,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchvlanid,match)
@@ -300,11 +291,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchvlanpcp,match)
@@ -328,11 +318,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_mulL2,match)
@@ -355,11 +344,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_mulL4,match)
@@ -381,11 +369,10 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_iptos,match)
@@ -407,11 +394,10 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_iptos,match)
@@ -435,11 +421,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchtSrc,match)
@@ -461,11 +446,10 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchdst,match)
@@ -489,11 +473,10 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
- rv = self.controller.message_send(msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
return (pkt_matchtype,match)
@@ -510,15 +493,14 @@
msg5.buffer_id = 0xffffffff
act5 = action.action_output()
act5.port = egress_port
- self.assertTrue(msg5.actions.add(act5), "could not add action")
+ msg5.actions.add(act5)
if priority != None :
msg5.priority = priority
# Send the flow with action A'
- rv = self.controller.message_send (msg5)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send (msg5)
+ do_barrier(self.controller)
def modify_flow_action(self,of_ports,match,priority=None):
# Modify the flow action
@@ -533,15 +515,14 @@
msg8.buffer_id = 0xffffffff
act8 = action.action_output()
act8.port = of_ports[2]
- self.assertTrue(msg8.actions.add(act8), "could not add action")
+ msg8.actions.add(act8)
if priority != None :
msg8.priority = priority
# Send the flow with action A'
- rv = self.controller.message_send (msg8)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send (msg8)
+ do_barrier(self.controller)
def enqueue(self,ingress_port,egress_port,egress_queue_id):
#Generate a flow with enqueue action i.e output to a queue configured on a egress_port
@@ -559,12 +540,11 @@
act = action.action_enqueue()
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
return (pkt,match)
@@ -670,28 +650,27 @@
active = 0
for item in response.stats:
-
lookedup += item.lookup_count
matched += item.matched_count
active += item.active_count
- logging.info("Packets Looked up " + str(lookedup) + " packets")
- logging.info("Packets matched " + str(matched) + "packets")
- logging.info("Active flow entries" + str(active) + "flows")
+ logging.info("Packets Looked up: %d", lookedup)
+ logging.info("Packets matched: %d", matched)
+ logging.info("Active flow entries: %d", active)
- if (expect_lookup == None or expect_lookup == lookedup) and \
- (expect_match == None or expect_match == matched) and \
- (expect_active == None or expect_active == active):
+ if (expect_lookup == None or lookedup >= expect_lookup) and \
+ (expect_match == None or matched >= expect_match) and \
+ (expect_active == None or active >= expect_active):
break
sleep(0.1)
if expect_lookup != None :
- self.assertEqual(expect_lookup,item.lookup_count,"lookup counter is not incremented properly")
+ self.assertEqual(expect_lookup, lookedup, "lookup counter is not incremented properly")
if expect_match != None :
- self.assertEqual(expect_match,item.matched_count, "matched counter is not incremented properly")
+ self.assertEqual(expect_match, matched, "matched counter is not incremented properly")
if expect_active != None :
- self.assertEqual(expect_active,item.active_count,"active counter is not incremented properly")
+ self.assertEqual(expect_active, active ,"active counter is not incremented properly")
def verify_flowstats(self,match,byte_count=None,packet_count=None):
@@ -716,21 +695,20 @@
packet_counter += item.packet_count
byte_counter += item.byte_count
- logging.info("Recieved" + str(item.packet_count) + " packets")
-
- logging.info("Received " + str(item.byte_count) + "bytes")
+ logging.info("Received %d packets", packet_counter)
+ logging.info("Received %d bytes", byte_counter)
- if (packet_count == None or packet_count == packet_counter) and \
- (byte_count == None or byte_count == byte_counter):
+ if (packet_count == None or packet_counter >= packet_count) and \
+ (byte_count == None or byte_counter >= byte_count):
break
sleep(0.1)
if packet_count != None :
- self.assertEqual(packet_count,item.packet_count,"packet_count counter is not incremented correctly")
+ self.assertEqual(packet_count, packet_counter, "packet_count counter is not incremented correctly")
if byte_count != None :
- self.assertEqual(byte_count,item.byte_count,"byte_count counter is not incremented correctly")
+ self.assertEqual(byte_count, byte_counter, "byte_count counter is not incremented correctly")
def verify_portstats(self, port,tx_packets=None,rx_packets=None,rx_byte=None,tx_byte=None):
@@ -834,9 +812,8 @@
if priority != None :
msg4.priority = priority
- rv = self.controller.message_send(msg4)
- self.assertTrue(rv!= -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg4)
+ do_barrier(self.controller)
@@ -853,9 +830,8 @@
if priority != None :
msg6.priority = priority
- rv = self.controller.message_send(msg6)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller),0, "Barrier failed")
+ self.controller.message_send(msg6)
+ do_barrier(self.controller)
###########################################################################################################################################################
diff --git a/tests/actions.py b/tests/actions.py
index 330068c..8be69dc 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -38,8 +38,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Install a flow without action")
logging.info("Send packets matching that flow")
@@ -57,9 +56,8 @@
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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg)
+ do_barrier(self.controller)
#Sending N packets matching the flow inserted
for pkt_cnt in range(5):
@@ -137,8 +135,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with output action port OFPP_ALL")
logging.info("Send packet matching the flow")
@@ -150,8 +147,7 @@
act = action.action_output()
#Delete all flows
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -163,9 +159,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send Packet matching the flow
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -191,8 +186,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with output action port OFPP_CONTROLLER")
logging.info("Send packet matching the flow")
@@ -205,8 +199,7 @@
for ingress_port in of_ports:
#Delete all flows
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match.in_port = ingress_port
@@ -217,9 +210,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send packet matching the flow
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -246,8 +238,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with output action port OFPP_LOCAL")
logging.info("Send packet matching the flow")
@@ -260,8 +251,7 @@
for ingress_port in of_ports:
#Delete the flows
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match.in_port = ingress_port
#Create flow mod message
@@ -271,9 +261,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send packet matching the flow
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -297,8 +286,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with output action port OFPP_FORWARD")
logging.info("Send packet matching the flow")
@@ -310,8 +298,7 @@
act = action.action_output()
#Delete all flows
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -323,9 +310,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send Packet matching the flow
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -350,8 +336,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with output action port OFPP_INPORT")
logging.info("Send packet matching the flow")
@@ -363,8 +348,7 @@
act = action.action_output()
#Delete the flows
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -375,9 +359,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send packet matching the flow
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -403,8 +386,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow F with output action port set to some egress_port")
logging.info("Send packet out message (matching flow F) with action.port = OFP.TABLE")
@@ -420,8 +402,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],
@@ -442,8 +423,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- set vlan id, if not skip the test")
logging.info("Insert a flow with set vid action")
@@ -482,8 +462,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify vlan id, if not skip the test")
logging.info("Insert a flow with action --set vid ")
@@ -520,8 +499,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
logging.info("Insert a flow with action -- set vlan priority ")
@@ -559,8 +537,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
logging.info("Insert a flow with action -- set vlan priority ")
@@ -599,8 +576,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l2_src, if not skip the test")
logging.info("Insert a flow with action -- set etherent src address")
@@ -634,8 +610,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test")
logging.info("Insert a flow with action -- set etherent dst address ")
@@ -668,8 +643,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l3_src, if not skip the test")
logging.info("Insert a flow with action -- set network src address ")
@@ -702,8 +676,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test")
logging.info("Insert a flow with action -- set network dst address ")
@@ -737,8 +710,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l4_src, if not skip the test")
logging.info("Insert a flow with action -- set src tcp port")
@@ -771,8 +743,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test")
logging.info("Insert a flow with action -- set dst tcp port")
@@ -805,8 +776,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Verify if switch supports the action -- modify_tos, if not skip the test")
logging.info("Insert a flow with action -- set type of service ")
diff --git a/tests/basic.py b/tests/basic.py
index d78f2ff..16f3b31 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -54,8 +54,7 @@
Test echo response with short string data
"""
def runTest(self):
- request = message.echo_request()
- request.data = 'OpenFlow Will Rule The World'
+ request = message.echo_request(data='OpenFlow Will Rule The World')
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get echo reply (with data)")
@@ -79,9 +78,8 @@
# Send packet to dataplane, once to each port
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
vid = test_param_get('vid', default=TEST_VID_DEFAULT)
@@ -129,9 +127,8 @@
"""
def runTest(self):
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
for of_port in config["port_map"].keys():
pkt = simple_tcp_packet()
@@ -167,9 +164,8 @@
# Need at least two ports
self.assertTrue(len(config["port_map"]) > 1, "Too few ports for test")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
of_ports = config["port_map"].keys()
d_port = of_ports[0]
@@ -195,8 +191,7 @@
# Send packet to dataplane
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# These will get put into function
of_ports = config["port_map"].keys()
@@ -208,16 +203,12 @@
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
logging.info("PKT OUT test with %s, port %s" % (opt, dp_port))
- msg = message.packet_out()
- msg.in_port = ofp.OFPP_NONE
- msg.data = str(outpkt)
- act = action.action_output()
- act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg = message.packet_out(in_port=ofp.OFPP_NONE,
+ data=str(outpkt),
+ actions=[action.output(port=dp_port)])
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
@@ -250,8 +241,7 @@
# Send packet to dataplane
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# These will get put into function
of_ports = config["port_map"].keys()
@@ -265,18 +255,13 @@
dp_ports = of_ports[0:num_ports]
logging.info("PKT OUT test with " + opt +
", ports " + str(dp_ports))
- msg = message.packet_out()
- msg.in_port = ofp.OFPP_NONE
- msg.data = str(outpkt)
- act = action.action_output()
- for i in range(0,num_ports):
- act.port = dp_ports[i]
- self.assertTrue(msg.actions.add(act),
- 'Could not add action to msg')
+ actions = [action.output(port=port) for port in dp_ports]
+ msg = message.packet_out(in_port=ofp.OFPP_NONE,
+ data=str(outpkt),
+ actions=actions)
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),
@@ -294,13 +279,11 @@
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()
- request.out_port = ofp.OFPP_NONE
- request.table_id = 0xff
+ request = message.flow_stats_request(out_port=ofp.OFPP_NONE,
+ table_id=0xff)
request.match.wildcards = 0 # ofp.OFPFW_ALL
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
@@ -317,8 +300,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()
@@ -353,8 +335,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)
@group('smoke')
class PortConfigMod(base_tests.SimpleProtocol):
@@ -381,7 +362,7 @@
rv = port_config_set(self.controller, of_port,
port_config ^ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Verify change took place with same feature request
(hw_addr, port_config2, advert) = \
@@ -396,7 +377,7 @@
rv = port_config_set(self.controller, of_port, port_config,
ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
class PortConfigModErr(base_tests.SimpleProtocol):
"""
diff --git a/tests/bsn_ipmask.py b/tests/bsn_ipmask.py
index ccd97fb..fea7caa 100644
--- a/tests/bsn_ipmask.py
+++ b/tests/bsn_ipmask.py
@@ -51,8 +51,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):
"""
@@ -62,8 +61,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)
@@ -145,19 +143,16 @@
pkt3 = simple_tcp_packet(ip_dst=ip3)
msg = lambda ip: logging.info("Testing dest IP %s" % ip)
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
- 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")
+ do_barrier(self.controller)
msg(ip0)
self.dataplane.send(ports[0], str(pkt0))
diff --git a/tests/bsn_mirror.py b/tests/bsn_mirror.py
index c916382..10c3f93 100644
--- a/tests/bsn_mirror.py
+++ b/tests/bsn_mirror.py
@@ -90,8 +90,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):
"""
@@ -101,8 +100,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)
@@ -148,14 +146,12 @@
act3.port = ports[1]
flow_mod = message.flow_mod()
flow_mod.match = match
- self.assertTrue(flow_mod.actions.add(act1), "Could not add mirror action")
- self.assertTrue(flow_mod.actions.add(act2), "Could not add mirror action")
- self.assertTrue(flow_mod.actions.add(act3), "Could not add output action")
- 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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ flow_mod.actions.add(act1)
+ flow_mod.actions.add(act2)
+ flow_mod.actions.add(act3)
+ delete_all_flows(self.controller)
+ self.controller.message_send(flow_mod)
+ do_barrier(self.controller)
logging.info("Sending packet to port %s" % ports[0])
self.dataplane.send(ports[0], str(pkt))
diff --git a/tests/caps.py b/tests/caps.py
index b01fd48..c75bd56 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -29,8 +29,7 @@
of_ports = config["port_map"].keys()
of_ports.sort()
- rv = delete_all_flows(obj.controller)
- obj.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(obj.controller)
pkt = simple_tcp_packet()
match = packet_to_flow_match(obj, pkt)
@@ -58,9 +57,8 @@
# 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.assertEqual(do_barrier(obj.controller, timeout=10), 0, "Barrier failed")
+ obj.controller.message_send(request)
+ do_barrier(obj.controller, timeout=10)
flow_count = 1
logging.info("Table idx: " + str(table_idx))
@@ -68,10 +66,10 @@
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")
+ do_barrier(obj.controller, timeout=10)
response, pkt = obj.controller.transact(tstats)
obj.assertTrue(response is not None, "Get tab stats failed")
logging.info(response.show())
@@ -88,7 +86,7 @@
logging.error("RESULT: " + str(active_flows) + " flows reported")
# clean up and wait a bit in case the table is really big
- rv = delete_all_flows(obj.controller)
+ delete_all_flows(obj.controller)
time.sleep(flow_count / 100)
diff --git a/tests/counters.py b/tests/counters.py
index 46566cc..4caae4f 100644
--- a/tests/counters.py
+++ b/tests/counters.py
@@ -47,8 +47,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow")
logging.info("Sending N Packets matching the flow")
@@ -80,8 +79,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow")
logging.info("Sending N Packets matching the flow")
@@ -114,8 +112,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow")
logging.info("Send Flow_stats request after n sec intervals")
@@ -157,8 +154,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
# Clear Switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert a flow with match on ingress_port")
logging.info("Send N Packets on an ingress_port P ")
@@ -193,8 +189,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow matching on in_port=ingress_port, action output to egress_port T ")
logging.info("Send N Packets matching the flow on ingress_port P ")
@@ -231,8 +226,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow matching on in_port=ingress_port")
logging.info("Send N Packets matching the flow on ingress_port P ")
@@ -269,8 +263,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T")
logging.info("Send N Packets matching the flow on ingress_port P ")
@@ -306,8 +299,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port T ")
logging.info("Send Table_Stats, verify active_count counter is incremented in accordance")
@@ -333,8 +325,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Insert any flow matching on in_port=ingress_port,action = output to egress_port")
logging.info("Send N packets matching the flow, N' packets not matching the flow")
@@ -385,8 +376,7 @@
for egress_queue_id in queue_id:
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get Queue stats for selected egress queue only
(qs_before,p) = get_queuestats(self,egress_port,egress_queue_id)
@@ -425,8 +415,7 @@
for egress_queue_id in queue_id:
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get Queue stats for selected egress queue only
(qs_before,p) = get_queuestats(self,egress_port,egress_queue_id)
@@ -455,8 +444,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has rx_dropped count ")
@@ -482,8 +470,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has tx_dropped count ")
@@ -510,8 +497,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has rx_errors count ")
@@ -536,8 +522,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has Tx_errors count ")
@@ -562,8 +547,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has rx_frame_err count ")
@@ -589,8 +573,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has rx_over_err count ")
@@ -617,8 +600,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has rx_crc_err count ")
@@ -644,8 +626,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Port_Stats Request")
logging.info("Verify reply has Collisions count ")
@@ -672,8 +653,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Send Queue_Stats Request")
logging.info("Verify reply has Tramitted Overrun errors count ")
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index da1b046..601cc72 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -36,8 +36,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting two overlapping flows")
logging.info("Expecting switch to return an error")
@@ -64,10 +63,9 @@
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ msg3.actions.add(act3)
+ self.controller.message_send(msg3)
+ do_barrier(self.controller)
# Verify Flow does not get inserted
verify_tablestats(self,expect_active=1)
@@ -96,8 +94,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting two overlapping flows")
logging.info("Expecting switch to insert the flows without generating errors")
@@ -128,8 +125,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting two identical flows one by one")
logging.info("Expecting switch to overwrite the first flow and clear the counters associated with it ")
@@ -169,8 +165,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting an emergency flow with timeout values")
logging.info("Expecting switch to generate error ")
@@ -192,10 +187,9 @@
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")
+ do_barrier(self.controller)
#Verify OFPET_FLOW_MOD_FAILED/OFPFMFC_OVERLAP error is recieved on the control plane
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_ERROR,
@@ -224,8 +218,7 @@
logging.info("Expecting flow to get added i.e OFPFC_MODIFY command should be taken as OFPFC_ADD ")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
#Generate a flow-mod,command OFPC_MODIFY
@@ -237,12 +230,11 @@
request.buffer_id = 0xffffffff
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(request.actions.add(act3), "could not add action")
+ request.actions.add(act3)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Verify the flow gets added i.e. active_count= 1
verify_tablestats(self,expect_active=1)
@@ -261,8 +253,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a Flow and incrementing flow counters. Modifying the flow action")
logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
@@ -299,8 +290,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting Flows and incrementing flow counters. Strict Modify the flow action ")
logging.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
@@ -343,8 +333,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Deleting a non-existing flow")
logging.info("Expecting switch to ignore the command , without generating errors")
@@ -379,8 +368,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear swicth state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting flows F1 and F2 without and with send_flow_removed_message flag set ")
logging.info("Deleting the flows")
@@ -411,11 +399,10 @@
msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
rv1 = self.controller.message_send(msg9)
self.assertTrue(rv1 != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Delete the flow-2
- rc2 = delete_all_flows(self.controller)
- self.assertEqual(rc2, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Verify flow removed message is generated for the FLOW-2
@@ -438,8 +425,7 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a emergency flow with send_flow_removed flag set")
logging.info("Expecting no flow_removed_message on the deletion of the emergency flow")
@@ -456,8 +442,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
@@ -482,8 +467,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow with exact match")
logging.info("Issue Strict Delete command , verify it gets deleted")
@@ -569,8 +553,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow with output action --> of_port[1]")
logging.info("Deleting the flow but with out_port set to of_port[2]")
@@ -589,9 +572,8 @@
msg7.buffer_id = 0xffffffff
msg7.match = match
- rv = self.controller.message_send(msg7)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg7)
+ do_barrier(self.controller)
# Verify flow will not get deleted, active_entries in table_stats_request = 1
verify_tablestats(self,expect_active=1)
@@ -606,9 +588,8 @@
msg7.buffer_id = 0xffffffff
msg7.match = match
- rv = self.controller.message_send(msg7)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg7)
+ do_barrier(self.controller)
#Verify flow gets deleted.
verify_tablestats(self,expect_active=0)
@@ -627,8 +608,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting flow entry with idle_timeout set. Also send_flow_removed_message flag set")
logging.info("Expecting the flow entry to delete with given idle_timeout")
@@ -642,7 +622,7 @@
msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
rv1 = self.controller.message_send(msg9)
self.assertTrue(rv1 != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
#Verify flow gets inserted
verify_tablestats(self,expect_active=1)
@@ -671,8 +651,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Adding and modifying flow with out_port fields set")
logging.info("Expecting switch to ignore out_port")
@@ -711,8 +690,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting flow entry with hard_timeout set. Also send_flow_removed_message flag set")
logging.info("Expecting the flow entry to delete with given hard_timeout")
@@ -726,7 +704,7 @@
msg9.flags |= ofp.OFPFF_SEND_FLOW_REM
rv1 = self.controller.message_send(msg9)
self.assertTrue(rv1 != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
#Verify flow gets inserted
verify_tablestats(self,expect_active=1)
@@ -758,8 +736,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting flow entry with hard_timeout set and send_flow_removed_message flag not set")
logging.info("Expecting the flow entry to delete, but no flow removed message")
@@ -780,11 +757,10 @@
msg3.match = match3
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
- rv = self.controller.message_send(msg3)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(msg3)
+ do_barrier(self.controller)
#Verify no flow removed message is generated
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index ad35f23..484f22f 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -37,8 +37,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
pkt = simple_tcp_packet()
match = packet_to_flow_match(self, pkt)
@@ -65,12 +64,11 @@
request.idle_timeout = 1
request.flags |= ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_FLOW_REMOVED,
timeout=test_timeout)
diff --git a/tests/flow_matches.py b/tests/flow_matches.py
index e90ddd0..862633d 100644
--- a/tests/flow_matches.py
+++ b/tests/flow_matches.py
@@ -38,8 +38,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting an all wildcarded flow and sending packets with various match fields")
logging.info("Expecting all sent packets to match")
@@ -95,8 +94,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -135,8 +133,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -177,8 +174,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -219,8 +215,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -257,8 +252,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -298,8 +292,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -339,8 +332,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -393,8 +385,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -432,8 +423,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -472,8 +462,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -511,8 +500,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -551,8 +539,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -591,8 +578,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
@@ -638,8 +624,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[2]
no_ports=set(of_ports).difference([egress_port])
@@ -674,8 +659,7 @@
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
egress_port=of_ports[1]
no_ports=set(of_ports).difference([egress_port])
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 2ff8083..476cd75 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()
@@ -1580,8 +1582,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -1682,8 +1683,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -1797,8 +1797,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -1929,8 +1928,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2051,8 +2049,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2178,8 +2175,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2305,8 +2301,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2456,8 +2451,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2549,8 +2543,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2665,8 +2658,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2789,8 +2781,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
@@ -2946,8 +2937,7 @@
# Clear all flows from switch
logging.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Get switch capabilites
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index 040fec8..8f59ccc 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -119,8 +119,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# build packet
pkt = simple_tcp_packet()
@@ -144,13 +143,12 @@
flow_mod_msg.hard_timeout = 65000
flow_mod_msg.priority = 100
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
- rv = self.controller.message_send(flow_mod_msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg)
+ do_barrier(self.controller)
# no packets sent, so zero packet count
self.verifyStats(flow_mod_msg, match, ofp.OFPP_NONE, test_timeout, 0)
@@ -197,7 +195,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -260,8 +258,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
@@ -270,12 +267,10 @@
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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg2)
+ do_barrier(self.controller)
num_pkt1s = random.randint(10,30)
logging.info("Sending " + str(num_pkt1s) + " pkt1s")
@@ -325,7 +320,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -374,8 +369,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
@@ -384,12 +378,10 @@
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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg2)
+ do_barrier(self.controller)
num_pkt1s = random.randint(10,30)
logging.info("Sending " + str(num_pkt1s) + " pkt1s")
@@ -420,8 +412,7 @@
the query doesn't match any flows.
"""
def runTest(self):
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match = ofp.ofp_match()
match.wildcards = 0
stat_req = message.flow_stats_request()
@@ -441,8 +432,7 @@
the query doesn't match any flows.
"""
def runTest(self):
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match = ofp.ofp_match()
match.wildcards = 0
stat_req = message.aggregate_stats_request()
@@ -478,8 +468,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# build packet
pkt = simple_tcp_packet()
@@ -504,13 +493,12 @@
flow_mod_msg.priority = 100
flow_mod_msg.flags = ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
- rv = self.controller.message_send(flow_mod_msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg)
+ do_barrier(self.controller)
# send packet N times
num_sends = random.randint(10,20)
@@ -521,8 +509,7 @@
# delete flow
logging.info("Deleting flow")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# wait for flow_removed message
flow_removed, _ = self.controller.poll(
diff --git a/tests/load.py b/tests/load.py
index ecd565b..0ad14e9 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -68,15 +68,14 @@
request.hard_timeout = 2 * barrier_count
request.buffer_id = 0xffffffff
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
act = action.action_output()
act.port = ofp.OFPP_CONTROLLER
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
- rv = self.controller.message_send(request)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
# Create packet out and send to port lb_port + 1
msg = message.packet_out()
@@ -84,22 +83,20 @@
msg.data = str(pkt)
act = action.action_output()
act.port = lb_port + 1
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
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")
+ do_barrier(self.controller)
# To do: Add some interesting functionality here
logging.info("Barrier %d completed" % idx)
# Clear the flow table when done
logging.debug("Deleting all flows from switch")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
class PacketInLoad(base_tests.SimpleDataPlane):
"""
@@ -114,9 +111,8 @@
# Send packet to dataplane, once to each port
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
out_count = 0
in_count = 0
@@ -158,8 +154,7 @@
# Send packet to dataplane
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# These will get put into function
of_ports = config["port_map"].keys()
@@ -179,14 +174,13 @@
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("PacketOutLoad to: " + str(dp_port))
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
@@ -237,8 +231,7 @@
for i in range(3):
logging.info("Iteration %d: delete all flows" % i)
- self.assertEqual(delete_all_flows(self.controller), 0,
- "Failed to delete all flows")
+ delete_all_flows(self.controller)
self.checkBarrier()
logging.info("Iteration %d: add %s flows" % (i, num_flows))
diff --git a/tests/message_types.py b/tests/message_types.py
index d0e6822..7785f36 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,
@@ -274,8 +271,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...")
@@ -302,8 +298,7 @@
of_ports.sort()
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
#Send a set_config_request message
miss_send_len = [0 ,32 ,64,100]
@@ -311,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
@@ -351,8 +345,7 @@
of_ports.sort()
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
#Create a simple tcp packet
pkt = simple_tcp_packet()
@@ -376,9 +369,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send packet matching the flow
logging.debug("Sending packet to dp port " + str(of_ports[0]))
@@ -411,15 +403,13 @@
of_ports.sort()
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
#Set miss_send_len field
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
@@ -459,8 +449,7 @@
of_ports.sort()
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# Create a simple tcp packet
pkt = simple_tcp_packet()
@@ -478,9 +467,8 @@
request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
#Send packet matching the flow
logging.debug("Sending packet to dp port " + str(of_ports[0]))
@@ -516,8 +504,7 @@
of_ports = config["port_map"].keys()
#Clear switch state
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
#Bring down the port by shutting the interface connected
try:
@@ -572,7 +559,7 @@
rv = port_config_set(self.controller, of_ports[0],
port_config ^ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Verify change took place with features request
logging.info("Verify the change and then set it back")
@@ -588,7 +575,7 @@
rv = port_config_set(self.controller, of_ports[0],port_config,
ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
class PortModFwd(base_tests.SimpleDataPlane):
@@ -615,7 +602,7 @@
rv = port_config_set(self.controller, of_ports[0],
port_config ^ ofp.OFPPC_NO_FWD, ofp.OFPPC_NO_FWD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Verify change took place with features request
logging.info("Verify the change and then set it back")
@@ -632,7 +619,7 @@
rv = port_config_set(self.controller, of_ports[0],port_config,
ofp.OFPPC_NO_FWD)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
class PortModPacketIn(base_tests.SimpleDataPlane):
@@ -659,7 +646,7 @@
rv = port_config_set(self.controller, of_ports[0],
port_config ^ ofp.OFPPC_NO_PACKET_IN, ofp.OFPPC_NO_PACKET_IN)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Verify change took place with features request
logging.info("Verify the change and then set it back")
@@ -676,7 +663,7 @@
rv = port_config_set(self.controller, of_ports[0],port_config,
ofp.OFPPC_NO_PACKET_IN)
self.assertTrue(rv != -1, "Error sending port mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
class DescStatsReplyBody(base_tests.SimpleDataPlane):
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index 80828c1..b182015 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -36,15 +36,13 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Sending Features_Request")
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)
@@ -66,15 +64,13 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Sending OFPT_GET_CONFIG_REQUEST ")
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)
@@ -95,8 +91,7 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow entry")
logging.info("Expecting active_count=1 in table_stats_reply")
@@ -124,8 +119,7 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow entry and then deleting it")
logging.info("Expecting the active_count=0 in table_stats_reply")
@@ -159,8 +153,7 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow entry and then modifying it")
logging.info("Expecting the Test Packet to implement the modified action")
@@ -190,8 +183,7 @@
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Inserting a flow entry and then sending flow_stats request")
logging.info("Expecting the a flow_stats_reply without errors")
@@ -216,8 +208,7 @@
of_ports.sort()
#Clear Switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Sending a packet-out for each dataplane port")
logging.info("Expecting the packet on appropriate dataplane port")
@@ -232,11 +223,10 @@
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ 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
@@ -274,9 +264,8 @@
ingress_port = of_ports[0]
#Clear Switch state
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
logging.info("Sending a Simple tcp packet a dataplane port")
logging.info("Expecting a packet_in event on the control plane")
diff --git a/tests/pktact.py b/tests/pktact.py
index 0165597..7d30698 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -108,8 +108,7 @@
act = action.action_output()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port = of_ports[idx]
egress_port = of_ports[(idx + 1) % len(of_ports)]
@@ -123,12 +122,11 @@
request.buffer_id = 0xffffffff
act.port = egress_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " +
str(ingress_port))
@@ -178,8 +176,7 @@
"Could not generate flow match from pkt")
act = action.action_output()
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port = of_ports[0]
match.in_port = ingress_port
@@ -190,12 +187,11 @@
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_CONTROLLER
act.max_len = 65535
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " +
str(ingress_port))
@@ -268,8 +264,7 @@
+ " queue " + str(egress_queue_id)
)
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match.in_port = ingress_port
@@ -279,12 +274,11 @@
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
# Get current stats for selected egress queue
@@ -399,8 +393,7 @@
+ " queue " + str(egress_queue_id)
)
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
match.in_port = ingress_port
@@ -410,12 +403,11 @@
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
# Get current stats for selected egress queue
@@ -513,8 +505,7 @@
act = action.action_output()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port = of_ports[idx]
egress_port1 = of_ports[(idx + 1) % len(of_ports)]
@@ -529,15 +520,14 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = egress_port1
- self.assertTrue(request.actions.add(act), "Could not add action1")
+ request.actions.add(act)
act.port = egress_port2
- self.assertTrue(request.actions.add(act), "Could not add action2")
+ request.actions.add(act)
# logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " +
str(ingress_port))
@@ -573,8 +563,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) +
" all non-ingress ports")
@@ -587,14 +576,12 @@
if egress_port == ingress_port:
continue
act.port = egress_port
- self.assertTrue(request.actions.add(act),
- "Could not add output to " + str(egress_port))
+ request.actions.add(act)
logging.debug(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -628,8 +615,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
@@ -642,14 +628,12 @@
act.port = ofp.OFPP_IN_PORT
else:
act.port = egress_port
- self.assertTrue(request.actions.add(act),
- "Could not add output to " + str(egress_port))
+ request.actions.add(act)
# logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -678,8 +662,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
@@ -688,14 +671,12 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -727,8 +708,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
@@ -737,17 +717,14 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
act.port = ofp.OFPP_IN_PORT
- self.assertTrue(request.actions.add(act),
- "Could not add ingress port for output")
+ request.actions.add(act)
logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -776,8 +753,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
@@ -786,14 +762,12 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_ALL
- self.assertTrue(request.actions.add(act),
- "Could not add ALL port action")
+ request.actions.add(act)
logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -825,8 +799,7 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
@@ -835,17 +808,14 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_ALL
- self.assertTrue(request.actions.add(act),
- "Could not add ALL port action")
+ request.actions.add(act)
act.port = ofp.OFPP_IN_PORT
- self.assertTrue(request.actions.add(act),
- "Could not add ingress port for output")
+ request.actions.add(act)
logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -882,8 +852,7 @@
self.assertEqual(rv, 0, "Failed to set port config")
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port = of_ports[idx]
no_flood_idx = (idx + 1) % len(of_ports)
@@ -898,14 +867,12 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
logging.info(request.show())
logging.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")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
logging.info("No flood port is " + str(no_flood_port))
@@ -918,7 +885,7 @@
rv = port_config_set(self.controller, no_flood_port,
0, ofp.OFPPC_NO_FLOOD)
self.assertEqual(rv, 0, "Failed to reset port config")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
# Check that packets are now flooded to no_flood_port
logging.info("Sending packet to dp port " + str(ingress_port))
@@ -985,9 +952,8 @@
self.flowMsgs = {}
def _ClearTable(self):
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ delete_all_flows(self.controller)
+ do_barrier(self.controller)
def runTest(self):
@@ -1065,7 +1031,7 @@
msg.out_port = ofp.OFPP_NONE
logging.debug("Remove flow with priority " + str(prio))
self.controller.message_send(msg)
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
else:
raise Exception("Not initialized")
@@ -1377,8 +1343,7 @@
ing_port = of_ports[0]
egr_ports = of_ports[1]
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
len_untagged = 100
len_w_vid = 104
@@ -1812,9 +1777,8 @@
# 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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flows[0][f_idx])
+ do_barrier(self.controller)
logging.info("Installed %d flows" % flow_count)
@@ -1832,12 +1796,9 @@
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")
+ do_barrier(self.controller)
end = time.time()
divisor = end - start or (end - start + 1)
@@ -1978,7 +1939,7 @@
request.priority = priority
act = action.action_output()
act.port = output_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -1987,7 +1948,7 @@
# This flow should not match, but it has a higher priority.
addFlow(matching=False, priority=1, output_port=ofp.OFPP_IN_PORT)
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -2088,8 +2049,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rv = delete_all_flows(self.controller)
- self.assertEqual(rv, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
ingress_port = of_ports[0]
egress_port = of_ports[1]
@@ -2110,12 +2070,10 @@
request.buffer_id = 0xffffffff
for act in acts:
act.port = egress_port
- rv = request.actions.add(act)
- self.assertTrue(rv, "Could not add action")
+ 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")
@@ -2125,10 +2083,9 @@
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")
+ do_barrier(self.controller)
logging.info("Sending packet to dp port " +
str(ingress_port))
diff --git a/tests/port_stats.py b/tests/port_stats.py
index 8d39d6f..5e0648f 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -149,8 +149,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
# build packet
pkt = simple_tcp_packet()
@@ -173,13 +172,12 @@
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
- rv = self.controller.message_send(flow_mod_msg)
- self.assertTrue(rv != -1, "Error installing flow mod")
- self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg)
+ do_barrier(self.controller)
# get initial port stats count
initTxInPort, initRxInPort = getStats(self, ingress_port)
@@ -220,7 +218,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -238,8 +236,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller)
- self.assertEqual(rc, 0, "Failed to delete all flows")
+ delete_all_flows(self.controller)
pkt1 = simple_tcp_packet()
flow_mod_msg1 = self.buildFlowModMsg(pkt1, ingress_port, egress_port1)
@@ -248,12 +245,10 @@
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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg2)
+ do_barrier(self.controller)
# get initial port stats count
initTxInPort, initRxInPort = getStats(self, ingress_port)
@@ -300,7 +295,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -326,12 +321,10 @@
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.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
+ self.controller.message_send(flow_mod_msg2)
+ do_barrier(self.controller)
num_pkt1s = random.randint(5,10)
logging.info("Sending " + str(num_pkt1s) + " pkt1s")
diff --git a/tools/munger/scripts/action_gen.py b/tools/munger/scripts/action_gen.py
index 116cd7b..bde0291 100644
--- a/tools/munger/scripts/action_gen.py
+++ b/tools/munger/scripts/action_gen.py
@@ -66,20 +66,27 @@
}
template = """
-class action_--TYPE--(--PARENT_TYPE--):
+class --TYPE--(--PARENT_TYPE--):
\"""
Wrapper class for --TYPE-- action object
--DOC_INFO--
\"""
- def __init__(self):
+ def __init__(self, **kwargs):
--PARENT_TYPE--.__init__(self)
self.type = --ACTION_NAME--
self.len = self.__len__()
+ for (k, v) in kwargs.items():
+ if hasattr(self, k):
+ setattr(self, k, v)
+ else:
+ raise NameError("field %s does not exist in %s" % (k, self.__class__))
def show(self, prefix=''):
outstr = prefix + "action_--TYPE--\\n"
outstr += --PARENT_TYPE--.show(self, prefix)
return outstr
+
+action_--TYPE-- = --TYPE-- # for backwards compatibility
"""
if __name__ == '__main__':
diff --git a/tools/munger/scripts/message_gen.py b/tools/munger/scripts/message_gen.py
index 1c627c1..053170a 100644
--- a/tools/munger/scripts/message_gen.py
+++ b/tools/munger/scripts/message_gen.py
@@ -296,18 +296,23 @@
_p1('"""')
print
- _p1("def __init__(self):")
+ _p1("def __init__(self, **kwargs):")
if has_core_members:
_p2(parent + ".__init__(self)")
_p2("self.header = ofp_header()")
_p2("self.header.type = " + msg_name)
if has_list:
- if list_type == None:
- _p2('self.' + list_var + ' = []')
- else:
- _p2('self.' + list_var + ' = ' + list_type + '()')
+ _p2('self.' + list_var + ' = []')
if has_string:
_p2('self.data = ""')
+ _p2('for (k, v) in kwargs.items():')
+ _p3('if hasattr(self, k):')
+ _p4('setattr(self, k, v)')
+ _p3('else:')
+ _p4('raise NameError("field %s does not exist in %s" % (k, self.__class__))')
+ if has_list and list_type != None:
+ _p2('# Coerce keyword arg into list type')
+ _p2('self.%(list_var)s = %(list_type)s(self.%(list_var)s)' % dict(list_type=list_type, list_var=list_var))
print """
@@ -528,12 +533,17 @@
\"""
Wrapper class for --TYPE-- stats request message
\"""
- def __init__(self):
+ def __init__(self, **kwargs):
self.header = ofp_header()
ofp_stats_request.__init__(self)
ofp_--TYPE--_stats_request.__init__(self)
self.header.type = OFPT_STATS_REQUEST
self.type = --STATS_NAME--
+ for (k, v) in kwargs.items():
+ if hasattr(self, k):
+ setattr(self, k, v)
+ else:
+ raise NameError("field %s does not exist in %s" % (k, self.__class__))
def pack(self, assertstruct=True):
self.header.length = len(self)