use the singleton logger object
There was no need for each test file to have its own logger.
diff --git a/tests/actions.py b/tests/actions.py
index cd54093..d0dab71 100644
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -25,7 +25,6 @@
from FuncUtils import *
ac_port_map = None
-ac_logger = None
ac_config = None
of_ports = None
@@ -33,12 +32,9 @@
basic.test_set_init(config)
global ac_port_map
- global ac_logger
global ac_config
global of_ports
- ac_logger = logging.getLogger("Running Actions test-suite")
- ac_logger.info("Initializing test set")
ac_port_map = config["port_map"]
ac_config = config
@@ -53,19 +49,19 @@
def runTest(self):
- ac_logger.info("Running No_Action test")
+ logging.info("Running No_Action test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Install a flow without action")
- ac_logger.info("Send packets matching that flow")
- ac_logger.info("Expecting switch to drop all packets")
+ logging.info("Install a flow without action")
+ logging.info("Send packets matching that flow")
+ logging.info("Expecting switch to drop all packets")
# Insert a flow wildcard all without any action
pkt = simple_tcp_packet()
@@ -105,10 +101,10 @@
def runTest(self):
- ac_logger.info("Running Announcement test")
+ logging.info("Running Announcement test")
- ac_logger.info("Sending Features_Request")
- ac_logger.info("Expecting Features Reply with supported actions")
+ logging.info("Sending Features_Request")
+ logging.info("Expecting Features Reply with supported actions")
# Sending Features_Request
request = message.features_request()
@@ -142,7 +138,7 @@
if(reply.actions &1<<ofp.OFPAT_ENQUEUE):
supported_actions.append('OFPAT_ENQUEUE')
- ac_logger.info(supported_actions)
+ logging.info(supported_actions)
class ForwardAll(basic.SimpleDataPlane):
@@ -152,19 +148,19 @@
def runTest(self):
- ac_logger.info("Running Forward_All test")
+ logging.info("Running Forward_All test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow with output action port OFPP_ALL")
- ac_logger.info("Send packet matching the flow")
- ac_logger.info("Expecting packet on all dataplane ports except ingress_port")
+ logging.info("Insert a flow with output action port OFPP_ALL")
+ logging.info("Send packet matching the flow")
+ logging.info("Expecting packet on all dataplane ports except ingress_port")
#Create a packet
pkt = simple_tcp_packet()
@@ -172,7 +168,7 @@
act = action.action_output()
#Delete all flows
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -184,19 +180,19 @@
act.port = ofp.OFPP_ALL
request.actions.add(act)
- ac_logger.info("Inserting flow")
+ 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")
#Send Packet matching the flow
- ac_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
#Verifying packets recieved on expected dataplane ports
yes_ports = set(of_ports).difference([ingress_port])
receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
- self, ac_logger, ac_config)
+ self, ac_config)
class ForwardController(basic.SimpleDataPlane):
@@ -206,19 +202,19 @@
def runTest(self):
- ac_logger.info("Running Forward_Controller test")
+ logging.info("Running Forward_Controller test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow with output action port OFPP_CONTROLLER")
- ac_logger.info("Send packet matching the flow")
- ac_logger.info("Expecting packet on the control plane")
+ logging.info("Insert a flow with output action port OFPP_CONTROLLER")
+ logging.info("Send packet matching the flow")
+ logging.info("Expecting packet on the control plane")
#Create packet
pkt = simple_tcp_packet()
@@ -227,7 +223,7 @@
for ingress_port in of_ports:
#Delete all flows
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
match.in_port = ingress_port
@@ -238,13 +234,13 @@
act.port = ofp.OFPP_CONTROLLER
request.actions.add(act)
- ac_logger.info("Inserting flow")
+ 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")
#Send packet matching the flow
- ac_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
#Verifying packet recieved on the control plane port
@@ -261,19 +257,19 @@
def runTest(self):
- ac_logger.info("Running Forward_Local test")
+ logging.info("Running Forward_Local test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow with output action port OFPP_LOCAL")
- ac_logger.info("Send packet matching the flow")
- ac_logger.info("Expecting packet in the local networking stack of switch")
+ logging.info("Insert a flow with output action port OFPP_LOCAL")
+ logging.info("Send packet matching the flow")
+ logging.info("Expecting packet in the local networking stack of switch")
#Clear switch state
pkt = simple_tcp_packet()
@@ -282,7 +278,7 @@
for ingress_port in of_ports:
#Delete the flows
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
match.in_port = ingress_port
@@ -292,13 +288,13 @@
act.port = ofp.OFPP_LOCAL
request.actions.add(act)
- ac_logger.info("Inserting flow")
+ 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")
#Send packet matching the flow
- ac_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
#TBD: Verification of packets being recieved.
@@ -313,18 +309,18 @@
def runTest(self):
- ac_logger.info("Running Forward_Flood test")
+ logging.info("Running Forward_Flood test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow with output action port OFPP_FORWARD")
- ac_logger.info("Send packet matching the flow")
- ac_logger.info("Expecting packet on all the ports except the input port")
+ logging.info("Insert a flow with output action port OFPP_FORWARD")
+ logging.info("Send packet matching the flow")
+ logging.info("Expecting packet on all the ports except the input port")
#Create a packet
pkt = simple_tcp_packet()
@@ -332,7 +328,7 @@
act = action.action_output()
#Delete all flows
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -344,19 +340,19 @@
act.port = ofp.OFPP_FLOOD
request.actions.add(act)
- ac_logger.info("Inserting flow")
+ 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")
#Send Packet matching the flow
- ac_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
#Verifying packets recieved on expected dataplane ports
yes_ports = set(of_ports).difference([ingress_port])
receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
- self, ac_logger, ac_config)
+ self, ac_config)
class ForwardInport(basic.SimpleDataPlane):
@@ -365,19 +361,19 @@
def runTest(self):
- ac_logger.info("Running Forward_Inport test")
+ logging.info("Running Forward_Inport test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow with output action port OFPP_INPORT")
- ac_logger.info("Send packet matching the flow")
- ac_logger.info("Expecting packet on the input port")
+ logging.info("Insert a flow with output action port OFPP_INPORT")
+ logging.info("Send packet matching the flow")
+ logging.info("Expecting packet on the input port")
#Create a packet
pkt = simple_tcp_packet()
@@ -385,7 +381,7 @@
act = action.action_output()
#Delete the flows
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port=of_ports[0]
match.in_port = ingress_port
@@ -396,19 +392,19 @@
act.port = ofp.OFPP_IN_PORT
request.actions.add(act)
- ac_logger.info("Inserting flow")
+ 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")
#Send packet matching the flow
- ac_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
yes_ports = [ingress_port]
#Verfying packet recieved on expected dataplane ports
receive_pkt_check(self.dataplane, pkt, yes_ports,set(of_ports).difference([ingress_port]),
- self, ac_logger, ac_config)
+ self, ac_config)
class ForwardTable(basic.SimpleDataPlane):
@@ -418,19 +414,19 @@
def runTest(self):
- ac_logger.info("Running Forward_Table test")
+ logging.info("Running Forward_Table test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Insert a flow F with output action port set to some egress_port")
- ac_logger.info("Send packet out message (matching flow F) with action.port = OFP.TABLE")
- ac_logger.info("Expecting packet on the egress_port")
+ 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")
+ logging.info("Expecting packet on the egress_port")
#Insert a all wildcarded flow
(pkt,match) = Wildcard_All(self,of_ports)
@@ -457,19 +453,19 @@
def runTest(self):
- ac_logger.info("Running Add_vlan_tag test")
+ logging.info("Running Add_vlan_tag test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- set vlan id, if not skip the test")
- ac_logger.info("Insert a flow with set vid action")
- ac_logger.info("Send packet matching the flow , verify recieved packet has vid set")
+ 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")
+ logging.info("Send packet matching the flow , verify recieved packet has vid set")
#Verify set_vlan_id is a supported action
sup_acts = sw_supported_actions(self)
@@ -497,19 +493,19 @@
def runTest(self):
- ac_logger.info("Running Modify_Vlan_Tag test")
+ logging.info("Running Modify_Vlan_Tag test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify vlan id, if not skip the test")
- ac_logger.info("Insert a flow with action --set vid ")
- ac_logger.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten")
+ 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 ")
+ logging.info("Send tagged packet matching the flow , verify recieved packet has vid rewritten")
#Verify set_vlan_id is a supported action
sup_acts = sw_supported_actions(self)
@@ -535,19 +531,19 @@
def runTest(self):
- ac_logger.info("Running vlan_Prio_1 test")
+ logging.info("Running vlan_Prio_1 test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
- ac_logger.info("Insert a flow with action -- set vlan priority ")
- ac_logger.info("Send untagged packet matching the flow , verify recieved packet has specified VLAN priority and has vid set tO 0 ")
+ 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 ")
+ logging.info("Send untagged packet matching the flow , verify recieved packet has specified VLAN priority and has vid set tO 0 ")
#Verify set_vlan_priority is a supported action
sup_acts = sw_supported_actions(self)
@@ -574,19 +570,19 @@
def runTest(self):
- ac_logger.info("Running Vlan_Prio_2 test")
+ logging.info("Running Vlan_Prio_2 test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- set vlan priority, if not skip the test")
- ac_logger.info("Insert a flow with action -- set vlan priority ")
- ac_logger.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten")
+ 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 ")
+ logging.info("Send tagged packet matching the flow, verify recieved packet has vlan priority rewritten")
#Verify set_vlan_priority is a supported action
sup_acts = sw_supported_actions(self,"true")
@@ -614,19 +610,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L2_Src test")
+ logging.info("Running Modify_L2_Src test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l2_src, if not skip the test")
- ac_logger.info("Insert a flow with action -- set etherent src address")
- ac_logger.info("Send packet matching the flow, verify recieved packet src address rewritten ")
+ 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")
+ logging.info("Send packet matching the flow, verify recieved packet src address rewritten ")
#Verify set_dl_src is a supported action
sup_acts = sw_supported_actions(self,use_cache="true")
@@ -649,19 +645,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L2_Dst test")
+ logging.info("Running Modify_L2_Dst test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l2_dst, if not skip the test")
- ac_logger.info("Insert a flow with action -- set etherent dst address ")
- ac_logger.info("Send packet matching the flow, verify recieved packet dst address rewritten ")
+ 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 ")
+ logging.info("Send packet matching the flow, verify recieved packet dst address rewritten ")
#Verify set_dl_dst is a supported action
sup_acts = sw_supported_actions(self)
@@ -683,19 +679,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L3_Src test")
+ logging.info("Running Modify_L3_Src test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l3_src, if not skip the test")
- ac_logger.info("Insert a flow with action -- set network src address ")
- ac_logger.info("Send packet matching the flow, verify recieved packet network src address rewritten ")
+ 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 ")
+ logging.info("Send packet matching the flow, verify recieved packet network src address rewritten ")
#Verify set_nw_src is a supported action
sup_acts = sw_supported_actions(self)
@@ -717,19 +713,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L3_Dst test")
+ logging.info("Running Modify_L3_Dst test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l3_dst, if not skip the test")
- ac_logger.info("Insert a flow with action -- set network dst address ")
- ac_logger.info("Send packet matching the flow, verify recieved packet network dst address rewritten ")
+ 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 ")
+ logging.info("Send packet matching the flow, verify recieved packet network dst address rewritten ")
#Verify set_nw_dst is a supported action
sup_acts = sw_supported_actions(self,use_cache="true")
@@ -752,19 +748,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L4_Src test")
+ logging.info("Running Modify_L4_Src test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l4_src, if not skip the test")
- ac_logger.info("Insert a flow with action -- set src tcp port")
- ac_logger.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ")
+ 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")
+ logging.info("Send packet matching the flow, verify recieved packet src tcp port is rewritten ")
#Verify set_tp_src is a supported action
sup_acts = sw_supported_actions(self,use_cache="true")
@@ -786,19 +782,19 @@
def runTest(self):
- ac_logger.info("Running Modify_L4_Dst test")
+ logging.info("Running Modify_L4_Dst test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_l4_dst, if not skip the test")
- ac_logger.info("Insert a flow with action -- set dst tcp port")
- ac_logger.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ")
+ 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")
+ logging.info("Send packet matching the flow, verify recieved packet dst tcp port is rewritten ")
#Verify set_tp_dst is a supported action
sup_acts = sw_supported_actions(self,use_cache="true")
@@ -820,19 +816,19 @@
def runTest(self):
- ac_logger.info("Running Modify_Tos test")
+ logging.info("Running Modify_Tos test")
of_ports = ac_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rv = delete_all_flows(self.controller, ac_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- ac_logger.info("Verify if switch supports the action -- modify_tos, if not skip the test")
- ac_logger.info("Insert a flow with action -- set type of service ")
- ac_logger.info("Send packet matching the flow, verify recieved packet has TOS rewritten ")
+ 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 ")
+ logging.info("Send packet matching the flow, verify recieved packet has TOS rewritten ")
#Verify set_tos is a supported action
sup_acts = sw_supported_actions(self,use_cache="true")
diff --git a/tests/basic.py b/tests/basic.py
index 53947b4..0112734 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -36,8 +36,6 @@
#@var basic_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
basic_port_map = None
-#@var basic_logger Local logger object
-basic_logger = None
#@var basic_config Local copy of global configuration data
basic_config = None
@@ -53,11 +51,8 @@
"""
global basic_port_map
- global basic_logger
global basic_config
- basic_logger = logging.getLogger("basic")
- basic_logger.info("Initializing test set")
basic_port_map = config["port_map"]
basic_config = config
@@ -67,22 +62,21 @@
"""
def sig_handler(self, v1, v2):
- basic_logger.critical("Received interrupt signal; exiting")
+ logging.critical("Received interrupt signal; exiting")
print "Received interrupt signal; exiting"
self.clean_shutdown = False
self.tearDown()
raise KeyboardInterrupt
def setUp(self):
- self.logger = basic_logger
self.config = basic_config
#@todo Test cases shouldn't monkey with signals; move SIGINT handler
# to top-level oft
try:
signal.signal(signal.SIGINT, self.sig_handler)
except ValueError, e:
- basic_logger.info("Could not set SIGINT handler: %s" % e)
- basic_logger.info("** START TEST CASE " + str(self))
+ logging.info("Could not set SIGINT handler: %s" % e)
+ logging.info("** START TEST CASE " + str(self))
self.controller = controller.Controller(
host=basic_config["controller_host"],
port=basic_config["controller_port"])
@@ -100,13 +94,13 @@
raise Exception("Controller startup failed")
if self.controller.switch_addr is None:
raise Exception("Controller startup failed (no switch addr)")
- basic_logger.info("Connected " + str(self.controller.switch_addr))
+ logging.info("Connected " + str(self.controller.switch_addr))
request = message.features_request()
reply, pkt = self.controller.transact(request)
self.assertTrue(reply is not None,
"Did not complete features_request for handshake")
self.supported_actions = reply.actions
- basic_logger.info("Supported actions: " + hex(self.supported_actions))
+ logging.info("Supported actions: " + hex(self.supported_actions))
def inheritSetup(self, parent):
"""
@@ -123,15 +117,14 @@
the state after the sub_test is run must be taken into account
by subsequent operations.
"""
- self.logger = parent.logger
self.config = parent.config
- basic_logger.info("** Setup " + str(self) + " inheriting from "
+ logging.info("** Setup " + str(self) + " inheriting from "
+ str(parent))
self.controller = parent.controller
self.supported_actions = parent.supported_actions
def tearDown(self):
- basic_logger.info("** END TEST CASE " + str(self))
+ logging.info("** END TEST CASE " + str(self))
self.controller.shutdown()
#@todo Review if join should be done on clean_shutdown
if self.clean_shutdown:
@@ -139,13 +132,13 @@
def runTest(self):
# Just a simple sanity check as illustration
- basic_logger.info("Running simple proto test")
+ logging.info("Running simple proto test")
self.assertTrue(self.controller.switch_socket is not None,
str(self) + 'No connection to switch')
def assertTrue(self, cond, msg):
if not cond:
- basic_logger.error("** FAILED ASSERTION: " + msg)
+ logging.error("** FAILED ASSERTION: " + msg)
unittest.TestCase.assertTrue(self, cond, msg)
test_prio["SimpleProtocol"] = 1
@@ -170,11 +163,11 @@
self.dataplane = parent.dataplane
def tearDown(self):
- basic_logger.info("Teardown for simple dataplane test")
+ logging.info("Teardown for simple dataplane test")
SimpleProtocol.tearDown(self)
if hasattr(self, 'dataplane'):
self.dataplane.kill(join_threads=self.clean_shutdown)
- basic_logger.info("Teardown done")
+ logging.info("Teardown done")
def runTest(self):
self.assertTrue(self.controller.switch_socket is not None,
@@ -188,7 +181,7 @@
"""
def sig_handler(self, v1, v2):
- basic_logger.critical("Received interrupt signal; exiting")
+ logging.critical("Received interrupt signal; exiting")
print "Received interrupt signal; exiting"
self.clean_shutdown = False
self.tearDown()
@@ -196,26 +189,25 @@
def setUp(self):
self.clean_shutdown = True
- self.logger = basic_logger
self.config = basic_config
#@todo Test cases shouldn't monkey with signals; move SIGINT handler
# to top-level oft
try:
signal.signal(signal.SIGINT, self.sig_handler)
except ValueError, e:
- basic_logger.info("Could not set SIGINT handler: %s" % e)
- basic_logger.info("** START DataPlaneOnly CASE " + str(self))
+ logging.info("Could not set SIGINT handler: %s" % e)
+ logging.info("** START DataPlaneOnly CASE " + str(self))
self.dataplane = dataplane.DataPlane(self.config)
for of_port, ifname in basic_port_map.items():
self.dataplane.port_add(ifname, of_port)
def tearDown(self):
- basic_logger.info("Teardown for simple dataplane test")
+ logging.info("Teardown for simple dataplane test")
self.dataplane.kill(join_threads=self.clean_shutdown)
- basic_logger.info("Teardown done")
+ logging.info("Teardown done")
def runTest(self):
- basic_logger.info("DataPlaneOnly")
+ logging.info("DataPlaneOnly")
# self.dataplane.show()
# Would like an assert that checks the data plane
@@ -265,7 +257,7 @@
# Send packet to dataplane, once to each port
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller, basic_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -279,7 +271,7 @@
(simple_eth_packet(), "simple Ethernet packet"),
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
- basic_logger.info("PKT IN test with %s, port %s" % (pt, of_port))
+ logging.info("PKT IN test with %s, port %s" % (pt, of_port))
self.dataplane.send(of_port, str(pkt))
#@todo Check for unexpected messages?
count = 0
@@ -299,8 +291,8 @@
'Packet in message not received on port ' +
str(of_port))
if not dataplane.match_exp_pkt(pkt, response.data):
- basic_logger.debug("Sent %s" % format_packet(pkt))
- basic_logger.debug("Resp %s" % format_packet(response.data))
+ logging.debug("Sent %s" % format_packet(pkt))
+ logging.debug("Resp %s" % format_packet(response.data))
self.assertTrue(False,
'Response packet does not match send packet' +
' for port ' + str(of_port))
@@ -313,7 +305,7 @@
in message is received from the controller for each
"""
def runTest(self):
- rc = delete_all_flows(self.controller, basic_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -352,7 +344,7 @@
# Need at least two ports
self.assertTrue(len(basic_port_map) > 1, "Too few ports for test")
- rc = delete_all_flows(self.controller, basic_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -360,7 +352,7 @@
d_port = of_ports[0]
pkt = simple_eth_packet(dl_dst='ff:ff:ff:ff:ff:ff')
- basic_logger.info("BCast Leak Test, send to port %s" % d_port)
+ logging.info("BCast Leak Test, send to port %s" % d_port)
self.dataplane.send(d_port, str(pkt))
(of_port, pkt_in, pkt_time) = self.dataplane.poll(exp_pkt=pkt)
@@ -381,7 +373,7 @@
# Send packet to dataplane
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller, basic_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# These will get put into function
@@ -393,14 +385,14 @@
(simple_eth_packet(), "simple Ethernet packet"),
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
- basic_logger.info("PKT OUT test with %s, port %s" % (opt, dp_port))
+ logging.info("PKT OUT test with %s, port %s" % (opt, dp_port))
msg = message.packet_out()
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
- basic_logger.info("PacketOut to: " + str(dp_port))
+ logging.info("PacketOut to: " + str(dp_port))
rv = self.controller.message_send(msg)
self.assertTrue(rv == 0, "Error sending out message")
@@ -413,12 +405,12 @@
exp_pkt=exp_pkt_arg)
self.assertTrue(pkt is not None, 'Packet not received')
- basic_logger.info("PacketOut: got pkt from " + str(of_port))
+ logging.info("PacketOut: got pkt from " + str(of_port))
if of_port is not None:
self.assertEqual(of_port, dp_port, "Unexpected receive port")
if not dataplane.match_exp_pkt(outpkt, pkt):
- basic_logger.debug("Sent %s" % format_packet(outpkt))
- basic_logger.debug("Resp %s" % format_packet(
+ logging.debug("Sent %s" % format_packet(outpkt))
+ logging.debug("Resp %s" % format_packet(
str(pkt)[:len(str(outpkt))]))
self.assertEqual(str(outpkt), str(pkt)[:len(str(outpkt))],
'Response packet does not match send packet')
@@ -435,7 +427,7 @@
# Send packet to dataplane
# Poll controller with expect message type packet in
- rc = delete_all_flows(self.controller, basic_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# These will get put into function
@@ -448,7 +440,7 @@
(simple_eth_packet(pktlen=40), "tiny Ethernet packet")]:
dp_ports = of_ports[0:num_ports]
- basic_logger.info("PKT OUT test with " + opt +
+ logging.info("PKT OUT test with " + opt +
", ports " + str(dp_ports))
msg = message.packet_out()
msg.data = str(outpkt)
@@ -458,13 +450,13 @@
self.assertTrue(msg.actions.add(act),
'Could not add action to msg')
- basic_logger.info("PacketOut to: " + str(dp_ports))
+ logging.info("PacketOut to: " + str(dp_ports))
rv = self.controller.message_send(msg)
self.assertTrue(rv == 0, "Error sending out message")
receive_pkt_check(self.dataplane, outpkt, dp_ports,
set(of_ports).difference(dp_ports),
- self, basic_logger, basic_config)
+ self, basic_config)
class FlowStatsGet(SimpleProtocol):
"""
@@ -473,13 +465,13 @@
Simply verify stats get transaction
"""
def runTest(self):
- basic_logger.info("Running StatsGet")
- basic_logger.info("Inserting trial flow")
+ logging.info("Running StatsGet")
+ logging.info("Inserting trial flow")
request = flow_mod_gen(basic_port_map, True)
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Failed to insert test flow")
- basic_logger.info("Sending flow request")
+ logging.info("Sending flow request")
request = message.flow_stats_request()
request.out_port = ofp.OFPP_NONE
request.table_id = 0xff
@@ -487,7 +479,7 @@
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get response for flow stats")
- basic_logger.debug(response.show())
+ logging.debug(response.show())
test_prio["FlowStatsGet"] = -1
@@ -498,18 +490,18 @@
Simply verify table stats get transaction
"""
def runTest(self):
- basic_logger.info("Running TableStatsGet")
- basic_logger.info("Inserting trial flow")
+ logging.info("Running TableStatsGet")
+ logging.info("Inserting trial flow")
request = flow_mod_gen(basic_port_map, True)
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Failed to insert test flow")
- basic_logger.info("Sending table stats request")
+ logging.info("Sending table stats request")
request = message.table_stats_request()
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get reply for table stats")
- basic_logger.debug(response.show())
+ logging.debug(response.show())
class DescStatsGet(SimpleProtocol):
"""
@@ -518,14 +510,14 @@
Simply verify stats get transaction
"""
def runTest(self):
- basic_logger.info("Running DescStatsGet")
+ logging.info("Running DescStatsGet")
- basic_logger.info("Sending stats request")
+ logging.info("Sending stats request")
request = message.desc_stats_request()
response, pkt = self.controller.transact(request)
self.assertTrue(response is not None,
"Did not get reply for desc stats")
- basic_logger.debug(response.show())
+ logging.debug(response.show())
class FlowMod(SimpleProtocol):
"""
@@ -535,7 +527,7 @@
"""
def runTest(self):
- basic_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
request = flow_mod_gen(basic_port_map, True)
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -550,26 +542,25 @@
"""
def runTest(self):
- basic_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
for of_port, ifname in basic_port_map.items(): # Grab first port
break
(hw_addr, config, advert) = \
- port_config_get(self.controller, of_port, basic_logger)
+ port_config_get(self.controller, of_port)
self.assertTrue(config is not None, "Did not get port config")
- basic_logger.debug("No flood bit port " + str(of_port) + " is now " +
+ logging.debug("No flood bit port " + str(of_port) + " is now " +
str(config & ofp.OFPPC_NO_FLOOD))
rv = port_config_set(self.controller, of_port,
- config ^ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD,
- basic_logger)
+ config ^ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
# Verify change took place with same feature request
(hw_addr, config2, advert) = \
- port_config_get(self.controller, of_port, basic_logger)
- basic_logger.debug("No flood bit port " + str(of_port) + " is now " +
+ port_config_get(self.controller, of_port)
+ logging.debug("No flood bit port " + str(of_port) + " is now " +
str(config2 & ofp.OFPPC_NO_FLOOD))
self.assertTrue(config2 is not None, "Did not get port config2")
self.assertTrue(config2 & ofp.OFPPC_NO_FLOOD !=
@@ -577,7 +568,7 @@
"Bit change did not take")
# Set it back
rv = port_config_set(self.controller, of_port, config,
- ofp.OFPPC_NO_FLOOD, basic_logger)
+ ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
class PortConfigModErr(SimpleProtocol):
@@ -587,7 +578,7 @@
"""
def runTest(self):
- basic_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
# pick a random bad port number
bad_port = random.randint(1, ofp.OFPP_MAX)
@@ -596,11 +587,10 @@
bad_port = random.randint(1, ofp.OFPP_MAX)
count = count + 1
self.assertTrue(count < 50, "Error selecting bad port")
- basic_logger.info("Select " + str(bad_port) + " as invalid port")
+ logging.info("Select " + str(bad_port) + " as invalid port")
rv = port_config_set(self.controller, bad_port,
- ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD,
- basic_logger)
+ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
self.assertTrue(rv != -1, "Error sending port mod")
# poll for error message
@@ -609,7 +599,7 @@
if not response: # Timeout
break
if response.code == ofp.OFPPMFC_BAD_PORT:
- basic_logger.info("Received error message with OFPPMFC_BAD_PORT code")
+ logging.info("Received error message with OFPPMFC_BAD_PORT code")
break
if not basic_config["relax"]: # Only one attempt to match
break
@@ -625,7 +615,7 @@
"""
def runTest(self):
- basic_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
request = illegal_message.illegal_message_type()
reply, pkt = self.controller.transact(request)
diff --git a/tests/bsn_ipmask.py b/tests/bsn_ipmask.py
index 489b980..6a4d389 100644
--- a/tests/bsn_ipmask.py
+++ b/tests/bsn_ipmask.py
@@ -14,8 +14,6 @@
#@var port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
im_port_map = None
-#@var im_logger Local logger object
-im_logger = None
#@var im_config Local copy of global configuration data
im_config = None
@@ -27,11 +25,8 @@
basic.test_set_init(config)
global im_port_map
- global im_logger
global im_config
- im_logger = logging.getLogger("ipmask")
- im_logger.info("Initializing test set")
im_port_map = config["port_map"]
im_config = config
@@ -68,7 +63,7 @@
Use the BSN_SET_IP_MASK vendor command to change the IP mask for the
given wildcard index
"""
- im_logger.info("Setting index %d to mask is %s" % (index, mask))
+ logging.info("Setting index %d to mask is %s" % (index, mask))
m = message.vendor()
m.vendor = 0x005c16c7
m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask)
@@ -99,34 +94,34 @@
"IP src must be wildcarded")
for index in range(0, 64):
mask = self.bsn_get_ip_mask(index)
- im_logger.info("Index %d mask is %s" %
+ logging.info("Index %d mask is %s" %
(index, scapy.utils.ltoa(mask)))
self.assertEqual(mask, normal_ip_mask(index), "Unexpected IP mask")
for index in range(0, 64):
mask = normal_ip_mask(index)
if mask == 0:
- im_logger.info("Skipping IP wildcard index %d" % index)
+ logging.info("Skipping IP wildcard index %d" % index)
else:
- im_logger.info("Testing IP wildcard index %d" % index)
+ logging.info("Testing IP wildcard index %d" % index)
self.check_ip_mask(True, index, mask)
self.check_ip_mask(False, index, mask)
- im_logger.info("Setting fancy IP masks")
+ logging.info("Setting fancy IP masks")
for index in range(0, 64):
self.bsn_set_ip_mask(index, fancy_ip_mask(index))
for index in range(0, 64):
mask = self.bsn_get_ip_mask(index)
- im_logger.info("Index %d mask is %s" %
+ logging.info("Index %d mask is %s" %
(index, scapy.utils.ltoa(mask)))
self.assertEqual(mask, fancy_ip_mask(index), "Unexpected IP mask")
for index in range(0, 64):
mask = fancy_ip_mask(index)
if mask == 0:
- im_logger.info("Skipping IP wildcard index %d" % index)
+ logging.info("Skipping IP wildcard index %d" % index)
else:
- im_logger.info("Testing IP wildcard index %d" % index)
+ logging.info("Testing IP wildcard index %d" % index)
self.check_ip_mask(True, index, mask)
self.check_ip_mask(False, index, mask)
@@ -156,7 +151,7 @@
pkt1 = simple_tcp_packet(ip_src=ip1)
pkt2 = simple_tcp_packet(ip_src=ip2)
pkt3 = simple_tcp_packet(ip_src=ip3)
- msg = lambda ip: im_logger.info("Testing source IP %s" % ip)
+ msg = lambda ip: logging.info("Testing source IP %s" % ip)
else:
wildcards = ((ofp.OFPFW_ALL ^ ofp.OFPFW_DL_TYPE ^ ofp.OFPFW_NW_DST_MASK)
| (index << ofp.OFPFW_NW_DST_SHIFT))
@@ -164,9 +159,9 @@
pkt1 = simple_tcp_packet(ip_dst=ip1)
pkt2 = simple_tcp_packet(ip_dst=ip2)
pkt3 = simple_tcp_packet(ip_dst=ip3)
- msg = lambda ip: im_logger.info("Testing dest IP %s" % ip)
+ msg = lambda ip: logging.info("Testing dest IP %s" % ip)
- rc = delete_all_flows(self.controller, im_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
rc = self.controller.message_send(flow_msg_create(
diff --git a/tests/caps.py b/tests/caps.py
index 93403ea..823d55c 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -20,8 +20,6 @@
#@var caps_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
caps_port_map = None
-#@var caps_logger Local logger object
-caps_logger = None
#@var caps_config Local copy of global configuration data
caps_config = None
@@ -38,11 +36,8 @@
basic.test_set_init(config)
global caps_port_map
- global caps_logger
global caps_config
- caps_logger = logging.getLogger("caps")
- caps_logger.info("Initializing caps test set")
caps_port_map = config["port_map"]
caps_config = config
@@ -59,7 +54,7 @@
of_ports = caps_port_map.keys()
of_ports.sort()
- rv = delete_all_flows(obj.controller, caps_logger)
+ rv = delete_all_flows(obj.controller)
obj.assertEqual(rv, 0, "Failed to delete all flows")
pkt = simple_tcp_packet()
@@ -78,7 +73,7 @@
request.match = match
request.buffer_id = 0xffffffff # set to NONE
- caps_logger.info(request.show())
+ logging.info(request.show())
tstats = message.table_stats_request()
try: # Determine the table index to check (or "all")
@@ -87,14 +82,14 @@
table_idx = -1 # Accumulate all table counts
# Make sure we can install at least one flow
- caps_logger.info("Inserting initial 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), 0, "Barrier failed")
flow_count = 1
- caps_logger.info("Table idx: " + str(table_idx))
- caps_logger.info("Check every " + str(count_check) + " inserts")
+ logging.info("Table idx: " + str(table_idx))
+ logging.info("Check every " + str(count_check) + " inserts")
while True:
request.match.nw_src += 1
@@ -104,7 +99,7 @@
obj.assertEqual(do_barrier(obj.controller), 0, "Barrier failed")
response, pkt = obj.controller.transact(tstats)
obj.assertTrue(response is not None, "Get tab stats failed")
- caps_logger.info(response.show())
+ logging.info(response.show())
if table_idx == -1: # Accumulate for all tables
active_flows = 0
for stats in response.stats:
@@ -114,8 +109,8 @@
if active_flows != flow_count:
break
- caps_logger.error("RESULT: " + str(flow_count) + " flows inserted")
- caps_logger.error("RESULT: " + str(active_flows) + " flows reported")
+ logging.error("RESULT: " + str(flow_count) + " flows inserted")
+ logging.error("RESULT: " + str(active_flows) + " flows reported")
class FillTableExact(basic.SimpleProtocol):
@@ -136,7 +131,7 @@
you can control which table to check.
"""
def runTest(self):
- caps_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
flow_caps_common(self)
test_prio["FillTableExact"] = -1
@@ -161,7 +156,7 @@
"""
def runTest(self):
- caps_logger.info("Running " + str(self))
+ logging.info("Running " + str(self))
flow_caps_common(self, is_exact=False)
test_prio["FillTableWC"] = -1
diff --git a/tests/cxn.py b/tests/cxn.py
index b658074..2c56692 100644
--- a/tests/cxn.py
+++ b/tests/cxn.py
@@ -22,8 +22,6 @@
#@var cxn_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
cxn_port_map = None
-#@var cxn_logger Local logger object
-cxn_logger = None
#@var cxn_config Local copy of global configuration data
cxn_config = None
@@ -37,11 +35,8 @@
"""
global cxn_port_map
- global cxn_logger
global cxn_config
- cxn_logger = logging.getLogger("cxn")
- cxn_logger.info("Initializing test set")
cxn_port_map = config["port_map"]
cxn_config = config
@@ -51,7 +46,7 @@
"""
def sig_handler(self, v1, v2):
- cxn_logger.critical("Received interrupt signal; exiting")
+ logging.critical("Received interrupt signal; exiting")
print "Received interrupt signal; exiting"
self.clean_shutdown = False
self.tearDown()
@@ -75,15 +70,14 @@
"Controller startup failed, no switch addr")
def setUp(self):
- self.logger = cxn_logger
self.config = cxn_config
#@todo Test cases shouldn't monkey with signals; move SIGINT handler
# to top-level oft
try:
signal.signal(signal.SIGINT, self.sig_handler)
except ValueError, e:
- cxn_logger.info("Could not set SIGINT handler: %s" % e)
- cxn_logger.info("** START TEST CASE " + str(self))
+ logging.info("Could not set SIGINT handler: %s" % e)
+ logging.info("** START TEST CASE " + str(self))
self.test_timeout = test_param_get(cxn_config,
'handshake_timeout') or 60
@@ -103,14 +97,13 @@
the state after the sub_test is run must be taken into account
by subsequent operations.
"""
- self.logger = parent.logger
self.config = parent.config
- cxn_logger.info("** Setup " + str(self) +
+ logging.info("** Setup " + str(self) +
" inheriting from " + str(parent))
self.controller = parent.controller
def tearDown(self):
- cxn_logger.info("** END TEST CASE " + str(self))
+ logging.info("** END TEST CASE " + str(self))
self.controller.shutdown()
if self.clean_shutdown:
self.controller.join()
@@ -121,7 +114,7 @@
def assertTrue(self, cond, msg):
if not cond:
- cxn_logger.error("** FAILED ASSERTION: " + msg)
+ logging.error("** FAILED ASSERTION: " + msg)
unittest.TestCase.assertTrue(self, cond, msg)
test_prio["BaseHandshake"] = -1
@@ -135,9 +128,9 @@
self.controllerSetup(cxn_config["controller_host"],
cxn_config["controller_port"])
- cxn_logger.info("TCP Connected " +
+ logging.info("TCP Connected " +
str(self.controller.switch_addr))
- cxn_logger.info("Hello not sent, waiting for timeout")
+ logging.info("Hello not sent, waiting for timeout")
# wait for controller to die
count = 0
@@ -156,12 +149,12 @@
self.controllerSetup(cxn_config["controller_host"],
cxn_config["controller_port"])
- cxn_logger.info("TCP Connected " +
+ logging.info("TCP Connected " +
str(self.controller.switch_addr))
- cxn_logger.info("Sending hello")
+ logging.info("Sending hello")
self.controller.message_send(message.hello())
- cxn_logger.info("Features request not sent, waiting for timeout")
+ logging.info("Features request not sent, waiting for timeout")
# wait for controller to die
count = 0
@@ -180,16 +173,16 @@
self.controllerSetup(cxn_config["controller_host"],
cxn_config["controller_port"])
- cxn_logger.info("TCP Connected " +
+ logging.info("TCP Connected " +
str(self.controller.switch_addr))
- cxn_logger.info("Sending hello")
+ logging.info("Sending hello")
self.controller.message_send(message.hello())
request = message.features_request()
reply, pkt = self.controller.transact(request, timeout=20)
self.assertTrue(reply is not None,
"Did not complete features_request for handshake")
- cxn_logger.info("Handshake complete with " +
+ logging.info("Handshake complete with " +
str(self.controller.switch_addr))
self.controller.keep_alive = True
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index d45935d..b13659d 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -22,7 +22,6 @@
from FuncUtils import *
cs_port_map = None
-cs_logger = None
cs_config = None
def test_set_init(config):
@@ -31,11 +30,8 @@
basic.test_set_init(config)
global cs_port_map
- global cs_logger
global cs_config
- cs_logger = logging.getLogger("Detailed controller to switch messages")
- cs_logger.info("Initializing test set")
cs_port_map = config["port_map"]
cs_config = config
@@ -47,18 +43,18 @@
def runTest(self):
- cs_logger.info("Running Overlap_Checking test")
+ logging.info("Running Overlap_Checking test")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting two overlapping flows")
- cs_logger.info("Expecting switch to return an error")
+ logging.info("Inserting two overlapping flows")
+ logging.info("Expecting switch to return an error")
#Insert a flow F with wildcarded all fields
(pkt,match) = Wildcard_All(self,of_ports)
@@ -107,18 +103,18 @@
def runTest(self):
- cs_logger.info("Running No_Overlap_Checking test")
+ logging.info("Running No_Overlap_Checking test")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear Switch State
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting two overlapping flows")
- cs_logger.info("Expecting switch to insert the flows without generating errors")
+ logging.info("Inserting two overlapping flows")
+ logging.info("Expecting switch to insert the flows without generating errors")
#Build a flow F with wildcarded all fields.
(pkt,match) = Wildcard_All(self,of_ports)
@@ -139,18 +135,18 @@
def runTest(self):
- cs_logger.info("Running Identical_Flows test ")
+ logging.info("Running Identical_Flows test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting two identical flows one by one")
- cs_logger.info("Expecting switch to overwrite the first flow and clear the counters associated with it ")
+ 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 ")
# Create and add flow-1, check on dataplane it is active.
(pkt,match) = Wildcard_All(self,of_ports)
@@ -180,18 +176,18 @@
def runTest(self):
- cs_logger.info("Running Emergency_Flow_Timeout test")
+ logging.info("Running Emergency_Flow_Timeout test")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting an emergency flow with timeout values")
- cs_logger.info("Expecting switch to generate error ")
+ logging.info("Inserting an emergency flow with timeout values")
+ logging.info("Expecting switch to generate error ")
#Insert an emergency flow
pkt = simple_tcp_packet()
@@ -209,7 +205,7 @@
act.port = of_ports[1]
request.actions.add(act)
- cs_logger.info("Inserting flow")
+ logging.info("Inserting flow")
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Flow addition did not fail.")
@@ -232,17 +228,17 @@
def runTest(self):
- cs_logger.info("Running Missing_Modify_Add test")
+ logging.info("Running Missing_Modify_Add test")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- cs_logger.info("Inserting a flow-modify that does not match an existing flow")
- cs_logger.info("Expecting flow to get added i.e OFPFC_MODIFY command should be taken as OFPFC_ADD ")
+ logging.info("Inserting a flow-modify that does not match an existing flow")
+ 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, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
#Generate a flow-mod,command OFPC_MODIFY
@@ -257,7 +253,7 @@
act3.port = of_ports[1]
self.assertTrue(request.actions.add(act3), "could not add action")
- cs_logger.info("Inserting flow")
+ 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")
@@ -272,18 +268,18 @@
def runTest(self):
- cs_logger.info("Running Modify_Action test ")
+ logging.info("Running Modify_Action test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting a Flow and incrementing flow counters. Modifying the flow action")
- cs_logger.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
+ 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")
#Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A , output to of_port[1]
(pkt,match) = Match_All_Except_Source_Address(self,of_ports)
@@ -310,18 +306,18 @@
def runTest(self):
- cs_logger.info("Running Strict_Modify_Action test")
+ logging.info("Running Strict_Modify_Action test")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting Flows and incrementing flow counters. Strict Modify the flow action ")
- cs_logger.info("Expecting the flow action to be modified , but the flow-counters should be preserved")
+ 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")
#Create and add flow-1 Match on all, except one wildcarded (src adddress).Action A
(pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
@@ -354,18 +350,18 @@
def runTest(self):
- cs_logger.info("Delete_NonExisting_Flow test begins")
+ logging.info("Delete_NonExisting_Flow test begins")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Deleting a non-existing flow")
- cs_logger.info("Expecting switch to ignore the command , without generating errors")
+ logging.info("Deleting a non-existing flow")
+ logging.info("Expecting switch to ignore the command , without generating errors")
# Issue a delete command
msg = message.flow_mod()
@@ -390,19 +386,19 @@
def runTest(self):
- cs_logger.info("Running Send_Flow_Rem test ")
+ logging.info("Running Send_Flow_Rem test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear swicth state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting flows F1 and F2 without and with send_flow_removed_message flag set ")
- cs_logger.info("Deleting the flows")
- cs_logger.info("Expecting flow removed message only for F2")
+ logging.info("Inserting flows F1 and F2 without and with send_flow_removed_message flag set ")
+ logging.info("Deleting the flows")
+ logging.info("Expecting flow removed message only for F2")
# Insert flow-1 with F without OFPFF_SEND_FLOW_REM flag set.
(pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -432,7 +428,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# Delete the flow-2
- rc2 = delete_all_flows(self.controller, cs_logger)
+ rc2 = delete_all_flows(self.controller)
self.assertEqual(rc2, 0, "Failed to delete all flows")
# Verify flow removed message is generated for the FLOW-2
@@ -450,17 +446,17 @@
def runTest(self):
- cs_logger.info("Running Delete_Emer_Flow")
+ logging.info("Running Delete_Emer_Flow")
of_ports = cs_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting a emergency flow with send_flow_removed flag set")
- cs_logger.info("Expecting no flow_removed_message on the deletion of the emergency flow")
+ 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")
# Insert a flow with emergency bit set.
pkt = simple_tcp_packet()
@@ -493,18 +489,18 @@
def runTest(self):
- cs_logger.info("Strict_Vs_Nonstrict test begins")
+ logging.info("Strict_Vs_Nonstrict test begins")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting a flow with exact match")
- cs_logger.info("Issue Strict Delete command , verify it gets deleted")
+ logging.info("Inserting a flow with exact match")
+ logging.info("Issue Strict Delete command , verify it gets deleted")
#Insert F with an exact Match
(pkt,match) = Exact_Match(self,of_ports)
@@ -514,9 +510,9 @@
Strict_Delete(self,match)
Verify_TableStats(self,active_entries=0)
- cs_logger.info("Inserting two overlapping flows")
- cs_logger.info("Issue Strict Delete command ")
- cs_logger.info("Expecting only one flow gets deleted , because Strict Delete matches on wildcards as well")
+ logging.info("Inserting two overlapping flows")
+ logging.info("Issue Strict Delete command ")
+ logging.info("Expecting only one flow gets deleted , because Strict Delete matches on wildcards as well")
#Insert Flow T with match on all , except one wildcarded ( say src adddress ).
(pkt,match) = Match_All_Except_Source_Address(self,of_ports)
@@ -529,9 +525,9 @@
Strict_Delete(self,match1)
Verify_TableStats(self,active_entries=1)
- cs_logger.info("Inserting two overlapping flows")
- cs_logger.info("Issue Non-Strict Delete command ")
- cs_logger.info("Expecting both the flow gets deleted , because wildcards are active")
+ logging.info("Inserting two overlapping flows")
+ logging.info("Issue Non-Strict Delete command ")
+ logging.info("Expecting both the flow gets deleted , because wildcards are active")
#Insert T and T' again .
(pkt,match) = Match_All_Except_Source_Address(self,of_ports)
@@ -542,9 +538,9 @@
NonStrict_Delete(self,match1)
Verify_TableStats(self,active_entries=0)
- cs_logger.info("Inserting three overlapping flows with different priorities")
- cs_logger.info("Issue Non-Strict Delete command ")
- cs_logger.info("Expecting all the flows to get deleted")
+ logging.info("Inserting three overlapping flows with different priorities")
+ logging.info("Issue Non-Strict Delete command ")
+ logging.info("Expecting all the flows to get deleted")
#Insert T , add Priority P (say 100 )
(pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
@@ -560,9 +556,9 @@
NonStrict_Delete(self,match1,priority=200)
Verify_TableStats(self,active_entries=0)
- cs_logger.info("Inserting three overlapping flows with different priorities")
- cs_logger.info("Issue Strict Delete command ")
- cs_logger.info("Expecting only one to get deleted because here priorities & wildcards are being matched")
+ logging.info("Inserting three overlapping flows with different priorities")
+ logging.info("Issue Strict Delete command ")
+ logging.info("Expecting only one to get deleted because here priorities & wildcards are being matched")
#Issue Strict-Delete and verify only T'' gets deleted.
(pkt,match) = Match_All_Except_Source_Address(self,of_ports,priority=100)
@@ -580,19 +576,19 @@
def runTest(self):
- cs_logger.info("Outport1 test begins")
+ logging.info("Outport1 test begins")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting a flow with output action --> of_port[1]")
- cs_logger.info("Deleting the flow but with out_port set to of_port[2]")
- cs_logger.info("Expecting switch to filter the delete command")
+ 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]")
+ logging.info("Expecting switch to filter the delete command")
#Build and send Flow-1 with action output to of_port[1]
(pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -614,8 +610,8 @@
# Verify flow will not get deleted, active_entries in table_stats_request = 1
Verify_TableStats(self,active_entries=1)
- cs_logger.info("Deleting the flow with out_port set to of_port[1]")
- cs_logger.info("Expecting switch to delete the flow")
+ logging.info("Deleting the flow with out_port set to of_port[1]")
+ logging.info("Expecting switch to delete the flow")
#Send Delete command with contraint out_port = of_ports[1]
msg7 = message.flow_mod()
@@ -638,18 +634,18 @@
def runTest(self):
- cs_logger.info("Running Idle_Timeout test ")
+ logging.info("Running Idle_Timeout test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting flow entry with idle_timeout set. Also send_flow_removed_message flag set")
- cs_logger.info("Expecting the flow entry to delete with given idle_timeout")
+ 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")
#Insert a flow entry with idle_timeout=1.Send_Flow_Rem flag set
msg9 = message.flow_mod()
@@ -682,18 +678,18 @@
def runTest(self):
- cs_logger.info("Running Outport2 test ")
+ logging.info("Running Outport2 test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Adding and modifying flow with out_port fields set")
- cs_logger.info("Expecting switch to ignore out_port")
+ logging.info("Adding and modifying flow with out_port fields set")
+ logging.info("Expecting switch to ignore out_port")
# Create and add flow-1,Action A ,output to port of_port[1], out_port set to of_ports[2]
(pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -722,18 +718,18 @@
def runTest(self):
- cs_logger.info("Running Hard_Timeout test ")
+ logging.info("Running Hard_Timeout test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting flow entry with hard_timeout set. Also send_flow_removed_message flag set")
- cs_logger.info("Expecting the flow entry to delete with given hard_timeout")
+ 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")
# Insert a flow entry with hardtimeout=1 and send_flow_removed flag set
msg9 = message.flow_mod()
@@ -769,18 +765,18 @@
def runTest(self):
- cs_logger.info("Running Flow_Timeout test ")
+ logging.info("Running Flow_Timeout test ")
of_ports = cs_port_map.keys()
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
#Clear switch state
- rc = delete_all_flows(self.controller, cs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- cs_logger.info("Inserting flow entry with hard_timeout set and send_flow_removed_message flag not set")
- cs_logger.info("Expecting the flow entry to delete, but no flow removed message")
+ 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")
# Insert a flow with hard_timeout = 1 but no Send_Flow_Rem flag set
pkt = simple_tcp_packet()
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index 9be5fdd..20d8efc 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -23,8 +23,6 @@
#@var port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
fe_port_map = None
-#@var fe_logger Local logger object
-fe_logger = None
#@var fe_config Local copy of global configuration data
fe_config = None
@@ -38,11 +36,8 @@
basic.test_set_init(config)
global fe_port_map
- global fe_logger
global fe_config
- fe_logger = logging.getLogger("flow_expire")
- fe_logger.info("Initializing test set")
fe_port_map = config["port_map"]
fe_config = config
@@ -64,7 +59,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller, fe_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
pkt = simple_tcp_packet()
@@ -80,7 +75,7 @@
ingress_port = of_ports[0]
egress_port = of_ports[1]
- fe_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
@@ -94,7 +89,7 @@
act.port = egress_port
self.assertTrue(request.actions.add(act), "Could not add action")
- fe_logger.info("Inserting flow")
+ 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")
diff --git a/tests/flow_query.py b/tests/flow_query.py
index 3017eed..9931c89 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -80,8 +80,6 @@
#@var port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
fq_port_map = None
-#@var fq_logger Local logger object
-fq_logger = None
#@var fq_config Local copy of global configuration data
fq_config = None
@@ -99,11 +97,8 @@
basic.test_set_init(config)
global fq_port_map
- global fq_logger
global fq_config
- fq_logger = logging.getLogger("flowq")
- fq_logger.info("Initializing test set")
fq_port_map = config["port_map"]
fq_config = config
@@ -179,8 +174,8 @@
if test_param_get(fq_config, "vlans", []) != []:
self.vlans = test_param_get(fq_config, "vlans", [])
- fq_logger.info("Overriding VLAN ids to:")
- fq_logger.info(self.vlans)
+ logging.info("Overriding VLAN ids to:")
+ logging.info(self.vlans)
else:
self.vlans = []
i = 0
@@ -529,8 +524,8 @@
actions_force = test_param_get(fq_config, "actions_force", 0)
if actions_force != 0:
- fq_logger.info("Forced actions:")
- fq_logger.info(actions_bmap_to_str(actions_force))
+ logging.info("Forced actions:")
+ logging.info(actions_bmap_to_str(actions_force))
ACTION_MAX_LEN = 65535 # @fixme Should be test param?
supported_actions = []
@@ -642,8 +637,8 @@
actions_force = test_param_get(fq_config, "actions_force", 0)
if actions_force != 0:
- fq_logger.info("Forced actions:")
- fq_logger.info(actions_bmap_to_str(actions_force))
+ logging.info("Forced actions:")
+ logging.info(actions_bmap_to_str(actions_force))
ACTION_MAX_LEN = 65535 # @fixme Should be test param?
supported_actions = []
@@ -727,8 +722,8 @@
def rand(self, fi, wildcards_force, valid_wildcards, valid_actions, valid_ports,
valid_queues):
if wildcards_force != 0:
- fq_logger.info("Wildcards forced:")
- fq_logger.info(wildcards_to_str(wildcards_force))
+ logging.info("Wildcards forced:")
+ logging.info(wildcards_to_str(wildcards_force))
# Start with no wildcards, i.e. everything specified
self.match.wildcards = 0
@@ -1236,17 +1231,17 @@
self.removed_msgs = []
def error_handler(self, controller, msg, rawmsg):
- fq_logger.info("Got an ERROR message, type=%d, code=%d" \
+ logging.info("Got an ERROR message, type=%d, code=%d" \
% (msg.type, msg.code) \
)
- fq_logger.info("Message header:")
- fq_logger.info(msg.header.show())
+ logging.info("Message header:")
+ logging.info(msg.header.show())
self.error_msgs.append(msg)
def removed_handler(self, controller, msg, rawmsg):
- fq_logger.info("Got a REMOVED message")
- fq_logger.info("Message header:")
- fq_logger.info(msg.header.show())
+ logging.info("Got a REMOVED message")
+ logging.info("Message header:")
+ logging.info(msg.header.show())
self.removed_msgs.append(msg)
def controller_set(self, controller):
@@ -1262,15 +1257,15 @@
request = message.features_request()
(self.sw_features, pkt) = self.controller.transact(request)
if self.sw_features is None:
- fq_logger.error("Get switch features failed")
+ logging.error("Get switch features failed")
return False
self.valid_ports = map(lambda x: x.port_no, self.sw_features.ports)
- fq_logger.info("Ports reported by switch:")
- fq_logger.info(self.valid_ports)
+ logging.info("Ports reported by switch:")
+ logging.info(self.valid_ports)
ports_override = test_param_get(fq_config, "ports", [])
if ports_override != []:
- fq_logger.info("Overriding ports to:")
- fq_logger.info(ports_override)
+ logging.info("Overriding ports to:")
+ logging.info(ports_override)
self.valid_ports = ports_override
# TBD - OFPP_LOCAL is returned by OVS is switch features --
@@ -1286,16 +1281,16 @@
# ofp.OFPP_CONTROLLER \
# ] \
# )
- fq_logger.info("Supported actions reported by switch:")
- fq_logger.info("0x%x=%s" \
+ logging.info("Supported actions reported by switch:")
+ logging.info("0x%x=%s" \
% (self.sw_features.actions, \
actions_bmap_to_str(self.sw_features.actions) \
) \
)
actions_override = test_param_get(fq_config, "actions", -1)
if actions_override != -1:
- fq_logger.info("Overriding supported actions to:")
- fq_logger.info(actions_bmap_to_str(actions_override))
+ logging.info("Overriding supported actions to:")
+ logging.info(actions_bmap_to_str(actions_override))
self.sw_features.actions = actions_override
return True
@@ -1304,24 +1299,24 @@
request = message.table_stats_request()
(self.tbl_stats, pkt) = self.controller.transact(request)
if self.tbl_stats is None:
- fq_logger.error("Get table stats failed")
+ logging.error("Get table stats failed")
return False
i = 0
for ts in self.tbl_stats.stats:
- fq_logger.info("Supported wildcards for table %d reported by switch:"
+ logging.info("Supported wildcards for table %d reported by switch:"
% (i)
)
- fq_logger.info("0x%x=%s" \
+ logging.info("0x%x=%s" \
% (ts.wildcards, \
wildcards_to_str(ts.wildcards) \
) \
)
wildcards_override = test_param_get(fq_config, "wildcards", -1)
if wildcards_override != -1:
- fq_logger.info("Overriding supported wildcards for table %d to:"
+ logging.info("Overriding supported wildcards for table %d to:"
% (i)
)
- fq_logger.info(wildcards_to_str(wildcards_override))
+ logging.info(wildcards_to_str(wildcards_override))
ts.wildcards = wildcards_override
i = i + 1
return True
@@ -1333,17 +1328,17 @@
request.queue_id = ofp.OFPQ_ALL
(self.queue_stats, pkt) = self.controller.transact(request)
if self.queue_stats is None:
- fq_logger.error("Get queue stats failed")
+ logging.error("Get queue stats failed")
return False
self.valid_queues = map(lambda x: (x.port_no, x.queue_id), \
self.queue_stats.stats \
)
- fq_logger.info("(Port, queue) pairs reported by switch:")
- fq_logger.info(self.valid_queues)
+ logging.info("(Port, queue) pairs reported by switch:")
+ logging.info(self.valid_queues)
queues_override = test_param_get(fq_config, "queues", [])
if queues_override != []:
- fq_logger.info("Overriding (port, queue) pairs to:")
- fq_logger.info(queues_override)
+ logging.info("Overriding (port, queue) pairs to:")
+ logging.info(queues_override)
self.valid_queues = queues_override
return True
@@ -1380,7 +1375,7 @@
self.flow_stats.stats.extend(resp.stats)
n = n + 1
if len(self.flow_stats.stats) > limit:
- fq_logger.error("Too many flows returned")
+ logging.error("Too many flows returned")
return False
if (resp.flags & 1) == 0:
break # No more responses expected
@@ -1396,7 +1391,7 @@
if flow_cfg.send_rem:
flow_mod_msg.flags = flow_mod_msg.flags | ofp.OFPFF_SEND_FLOW_REM
flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
- fq_logger.info("Sending flow_mod(add), xid=%d"
+ logging.info("Sending flow_mod(add), xid=%d"
% (flow_mod_msg.header.xid)
)
return (self.controller.message_send(flow_mod_msg) != -1)
@@ -1408,7 +1403,7 @@
flow_mod_msg.buffer_id = 0xffffffff
flow_cfg.to_flow_mod_msg(flow_mod_msg)
flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
- fq_logger.info("Sending flow_mod(mod), xid=%d"
+ logging.info("Sending flow_mod(mod), xid=%d"
% (flow_mod_msg.header.xid)
)
return (self.controller.message_send(flow_mod_msg) != -1)
@@ -1422,7 +1417,7 @@
flow_mod_msg.out_port = ofp.OFPP_NONE
flow_cfg.to_flow_mod_msg(flow_mod_msg)
flow_mod_msg.header.xid = random.randrange(1,0xffffffff)
- fq_logger.info("Sending flow_mod(del), xid=%d"
+ logging.info("Sending flow_mod(del), xid=%d"
% (flow_mod_msg.header.xid)
)
return (self.controller.message_send(flow_mod_msg) != -1)
@@ -1434,42 +1429,42 @@
def errors_verify(self, num_exp, type = 0, code = 0):
result = True
- fq_logger.info("Expecting %d error messages" % (num_exp))
+ logging.info("Expecting %d error messages" % (num_exp))
num_got = len(self.error_msgs)
- fq_logger.info("Got %d error messages" % (num_got))
+ logging.info("Got %d error messages" % (num_got))
if num_got != num_exp:
- fq_logger.error("Incorrect number of error messages received")
+ logging.error("Incorrect number of error messages received")
result = False
if num_exp == 0:
return result
elif num_exp == 1:
- fq_logger.info("Expecting error message, type=%d, code=%d" \
+ logging.info("Expecting error message, type=%d, code=%d" \
% (type, code) \
)
f = False
for e in self.error_msgs:
if e.type == type and e.code == code:
- fq_logger.info("Got it")
+ logging.info("Got it")
f = True
if not f:
- fq_logger.error("Did not get it")
+ logging.error("Did not get it")
result = False
else:
- fq_logger.error("Can't expect more than 1 error message type")
+ logging.error("Can't expect more than 1 error message type")
result = False
return result
def removed_verify(self, num_exp):
result = True
- fq_logger.info("Expecting %d removed messages" % (num_exp))
+ logging.info("Expecting %d removed messages" % (num_exp))
num_got = len(self.removed_msgs)
- fq_logger.info("Got %d removed messages" % (num_got))
+ logging.info("Got %d removed messages" % (num_got))
if num_got != num_exp:
- fq_logger.error("Incorrect number of removed messages received")
+ logging.error("Incorrect number of removed messages received")
result = False
if num_exp < 2:
return result
- fq_logger.error("Can't expect more than 1 error message type")
+ logging.error("Can't expect more than 1 error message type")
return False
# modf == True <=> Verify for flow modify, else for add/delete
@@ -1477,88 +1472,88 @@
result = True
# Verify flow count in switch
- fq_logger.info("Reading table stats")
- fq_logger.info("Expecting %d flows" % (self.flow_tbl.count()))
+ logging.info("Reading table stats")
+ logging.info("Expecting %d flows" % (self.flow_tbl.count()))
if not self.tbl_stats_get():
- fq_logger.error("Get table stats failed")
+ logging.error("Get table stats failed")
return False
n = 0
for ts in self.tbl_stats.stats:
n = n + ts.active_count
- fq_logger.info("Table stats reported %d active flows" \
+ logging.info("Table stats reported %d active flows" \
% (n) \
)
if n != self.flow_tbl.count():
- fq_logger.error("Incorrect number of active flows reported")
+ logging.error("Incorrect number of active flows reported")
result = False
# Read flows from switch
- fq_logger.info("Retrieving flows from switch")
- fq_logger.info("Expecting %d flows" % (self.flow_tbl.count()))
+ logging.info("Retrieving flows from switch")
+ logging.info("Expecting %d flows" % (self.flow_tbl.count()))
if not self.flow_stats_get():
- fq_logger.error("Get flow stats failed")
+ logging.error("Get flow stats failed")
return False
- fq_logger.info("Retrieved %d flows" % (len(self.flow_stats.stats)))
+ logging.info("Retrieved %d flows" % (len(self.flow_stats.stats)))
# Verify flows returned by switch
if len(self.flow_stats.stats) != self.flow_tbl.count():
- fq_logger.error("Switch reported incorrect number of flows")
+ logging.error("Switch reported incorrect number of flows")
result = False
- fq_logger.info("Verifying received flows")
+ logging.info("Verifying received flows")
for fc in self.flow_tbl.values():
fc.matched = False
for fs in self.flow_stats.stats:
flow_in = Flow_Cfg()
flow_in.from_flow_stat(fs)
- fq_logger.info("Received flow:")
- fq_logger.info(str(flow_in))
+ logging.info("Received flow:")
+ logging.info(str(flow_in))
fc = self.flow_tbl.find(flow_in)
if fc is None:
- fq_logger.error("Received flow:")
- fq_logger.error(str(flow_in))
- fq_logger.error("does not match any defined flow")
+ logging.error("Received flow:")
+ logging.error(str(flow_in))
+ logging.error("does not match any defined flow")
result = False
elif fc.matched:
- fq_logger.error("Received flow:")
- fq_logger.error(str(flow_in))
- fq_logger.error("re-matches defined flow:")
- fq_logger.info(str(fc))
+ logging.error("Received flow:")
+ logging.error(str(flow_in))
+ logging.error("re-matches defined flow:")
+ logging.info(str(fc))
result = False
else:
- fq_logger.info("matched")
+ logging.info("matched")
if modf:
# Check for modify
if flow_in.cookie != fc.cookie:
- fq_logger.warning("Defined flow:")
- fq_logger.warning(str(fc))
- fq_logger.warning("Received flow:")
- fq_logger.warning(str(flow_in))
- fq_logger.warning("cookies do not match")
+ logging.warning("Defined flow:")
+ logging.warning(str(fc))
+ logging.warning("Received flow:")
+ logging.warning(str(flow_in))
+ logging.warning("cookies do not match")
if not flow_in.actions_equal(fc):
- fq_logger.error("Defined flow:")
- fq_logger.error(str(fc))
- fq_logger.error("Received flow:")
- fq_logger.error(str(flow_in))
- fq_logger.error("actions do not match")
+ logging.error("Defined flow:")
+ logging.error(str(fc))
+ logging.error("Received flow:")
+ logging.error(str(flow_in))
+ logging.error("actions do not match")
else:
# Check for add/delete
if not flow_in == fc:
- fq_logger.error("Defined flow:")
- fq_logger.error(str(fc))
- fq_logger.error("Received flow:")
- fq_logger.error(str(flow_in))
- fq_logger.error("non-key portions of flow do not match")
+ logging.error("Defined flow:")
+ logging.error(str(fc))
+ logging.error("Received flow:")
+ logging.error(str(flow_in))
+ logging.error("non-key portions of flow do not match")
result = False
fc.matched = True
for fc in self.flow_tbl.values():
if not fc.matched:
- fq_logger.error("Defined flow:")
- fq_logger.error(str(fc))
- fq_logger.error("was not returned by switch")
+ logging.error("Defined flow:")
+ logging.error(str(fc))
+ logging.error("was not returned by switch")
result = False
return result
@@ -1605,14 +1600,14 @@
"""
def runTest(self):
- fq_logger.info("Flow_Add_5 TEST BEGIN")
+ logging.info("Flow_Add_5 TEST BEGIN")
num_flows = test_param_get(fq_config, "num_flows", 100)
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -1629,7 +1624,7 @@
for ts in sw.tbl_stats.stats:
num_flows = num_flows + ts.max_entries
- fq_logger.info("Generating %d flows" % (num_flows))
+ logging.info("Generating %d flows" % (num_flows))
# Dream up some flow information, i.e. space to chose from for
# random flow parameter generation
@@ -1644,10 +1639,10 @@
# Send flow table to switch
- fq_logger.info("Sending flow adds to switch")
+ logging.info("Sending flow adds to switch")
for fc in ft.values(): # Randomizes order of sending
- fq_logger.info("Adding flow:")
- fq_logger.info(str(fc));
+ logging.info("Adding flow:")
+ logging.info(str(fc));
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
# Do barrier, to make sure all flows are in
@@ -1670,7 +1665,7 @@
result = False
self.assertTrue(result, "Flow_Add_5 TEST FAILED")
- fq_logger.info("Flow_Add_5 TEST PASSED")
+ logging.info("Flow_Add_5 TEST PASSED")
# FLOW ADD 5_1
@@ -1707,14 +1702,14 @@
"""
def runTest(self):
- fq_logger.info("Flow_Add_5_1 TEST BEGIN")
+ logging.info("Flow_Add_5_1 TEST BEGIN")
num_flows = test_param_get(fq_config, "num_flows", 100)
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -1750,10 +1745,10 @@
# Send it to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
- fq_logger.info("should be canonicalized as:")
- fq_logger.info(str(fcc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
+ logging.info("should be canonicalized as:")
+ logging.info(str(fcc))
fc.send_rem = False
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -1777,7 +1772,7 @@
result = False
self.assertTrue(result, "Flow_Add_5_1 TEST FAILED")
- fq_logger.info("Flow_Add_5_1 TEST PASSED")
+ logging.info("Flow_Add_5_1 TEST PASSED")
# FLOW ADD 6
@@ -1824,12 +1819,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Add_6 TEST BEGIN")
+ logging.info("Flow_Add_6 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -1843,8 +1838,8 @@
for ts in sw.tbl_stats.stats:
num_flows = num_flows + ts.max_entries
- fq_logger.info("Switch capacity is %d flows" % (num_flows))
- fq_logger.info("Generating %d flows" % (num_flows))
+ logging.info("Switch capacity is %d flows" % (num_flows))
+ logging.info("Generating %d flows" % (num_flows))
# Dream up some flow information, i.e. space to chose from for
# random flow parameter generation
@@ -1859,10 +1854,10 @@
# Send flow table to switch
- fq_logger.info("Sending flow adds to switch")
+ logging.info("Sending flow adds to switch")
for fc in ft.values(): # Randomizes order of sending
- fq_logger.info("Adding flow:")
- fq_logger.info(str(fc));
+ logging.info("Adding flow:")
+ logging.info(str(fc));
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
# Do barrier, to make sure all flows are in
@@ -1880,7 +1875,7 @@
# Dream up one more flow
- fq_logger.info("Creating one more flow")
+ logging.info("Creating one more flow")
while True:
fc = Flow_Cfg()
fc.rand(fi, \
@@ -1897,8 +1892,8 @@
# Send one-more flow
fc.send_rem = False
- fq_logger.info("Sending flow add switch")
- fq_logger.info(str(fc));
+ logging.info("Sending flow add switch")
+ logging.info(str(fc));
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
# Do barrier, to make sure all flows are in
@@ -1922,7 +1917,7 @@
result = False
self.assertTrue(result, "Flow_add_6 TEST FAILED")
- fq_logger.info("Flow_add_6 TEST PASSED")
+ logging.info("Flow_add_6 TEST PASSED")
# FLOW ADD 7
@@ -1956,12 +1951,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Add_7 TEST BEGIN")
+ logging.info("Flow_Add_7 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -1991,8 +1986,8 @@
# Send it to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -2012,8 +2007,8 @@
# Send that to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc2))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc2))
fc2.send_rem = False
self.assertTrue(sw.flow_add(fc2), "Failed to add flow")
ft.insert(fc2)
@@ -2038,7 +2033,7 @@
result = False
self.assertTrue(result, "Flow_Add_7 TEST FAILED")
- fq_logger.info("Flow_Add_7 TEST PASSED")
+ logging.info("Flow_Add_7 TEST PASSED")
# FLOW ADD 8
@@ -2078,12 +2073,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Add_8 TEST BEGIN")
+ logging.info("Flow_Add_8 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2116,8 +2111,8 @@
# Send it to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -2139,14 +2134,14 @@
wn = "OFPFW_NW_DST"
else:
wn = all_wildcard_names[w]
- fq_logger.info("Wildcarding out %s" % (wn))
+ logging.info("Wildcarding out %s" % (wn))
fc2.match.wildcards = fc2.match.wildcards | w
fc2 = fc2.canonical()
# Send that to the switch, with overlap checking
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc2))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc2))
fc2.send_rem = False
self.assertTrue(sw.flow_add(fc2, True), "Failed to add flow")
@@ -2172,7 +2167,7 @@
result = False
self.assertTrue(result, "Flow_Add_8 TEST FAILED")
- fq_logger.info("Flow_Add_8 TEST PASSED")
+ logging.info("Flow_Add_8 TEST PASSED")
# FLOW MODIFY 1
@@ -2205,12 +2200,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Mod_1 TEST BEGIN")
+ logging.info("Flow_Mod_1 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2240,8 +2235,8 @@
# Send it to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -2261,8 +2256,8 @@
# Send that to the switch
- fq_logger.info("Sending strict flow mod to switch:")
- fq_logger.info(str(fc2))
+ logging.info("Sending strict flow mod to switch:")
+ logging.info(str(fc2))
fc2.send_rem = False
self.assertTrue(sw.flow_mod(fc2, True), "Failed to modify flow")
ft.insert(fc2)
@@ -2287,7 +2282,7 @@
result = False
self.assertTrue(result, "Flow_Mod_1 TEST FAILED")
- fq_logger.info("Flow_Mod_1 TEST PASSED")
+ logging.info("Flow_Mod_1 TEST PASSED")
# FLOW MODIFY 2
@@ -2330,14 +2325,14 @@
"""
def runTest(self):
- fq_logger.info("Flow_Mod_2 TEST BEGIN")
+ logging.info("Flow_Mod_2 TEST BEGIN")
num_flows = test_param_get(fq_config, "num_flows", 100)
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2361,10 +2356,10 @@
# Send flow table to switch
- fq_logger.info("Sending flow adds to switch")
+ logging.info("Sending flow adds to switch")
for fc in ft.values(): # Randomizes order of sending
- fq_logger.info("Adding flow:")
- fq_logger.info(str(fc));
+ logging.info("Adding flow:")
+ logging.info(str(fc));
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
# Do barrier, to make sure all flows are in
@@ -2426,9 +2421,9 @@
if n > 1:
break
- fq_logger.info("Modifying %d flows" % (n))
- fq_logger.info("Sending flow mod to switch:")
- fq_logger.info(str(mfc))
+ logging.info("Modifying %d flows" % (n))
+ logging.info("Sending flow mod to switch:")
+ logging.info(str(mfc))
self.assertTrue(sw.flow_mod(mfc, False), "Failed to modify flow")
# Do barrier, to make sure all flows are in
@@ -2454,7 +2449,7 @@
result = False
self.assertTrue(result, "Flow_Mod_2 TEST FAILED")
- fq_logger.info("Flow_Mod_2 TEST PASSED")
+ logging.info("Flow_Mod_2 TEST PASSED")
# FLOW MODIFY 3
@@ -2483,12 +2478,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Mod_3 TEST BEGIN")
+ logging.info("Flow_Mod_3 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2518,8 +2513,8 @@
# Send it to the switch
- fq_logger.info("Sending flow mod to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow mod to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_mod(fc, True), "Failed to modify flows")
@@ -2545,7 +2540,7 @@
result = False
self.assertTrue(result, "Flow_Mod_3 TEST FAILED")
- fq_logger.info("Flow_Mod_3 TEST PASSED")
+ logging.info("Flow_Mod_3 TEST PASSED")
# FLOW MODIFY 3_1
@@ -2576,12 +2571,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Mod_3_1 TEST BEGIN")
+ logging.info("Flow_Mod_3_1 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2611,8 +2606,8 @@
# Send it to the switch
- fq_logger.info("Sending flow mod to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow mod to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_mod(fc, True), "Failed to modify flows")
@@ -2639,8 +2634,8 @@
# Send same flow to the switch again
- fq_logger.info("Sending flow mod to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow mod to switch:")
+ logging.info(str(fc))
self.assertTrue(sw.flow_mod(fc, True), "Failed to modify flows")
# Do barrier, to make sure all flows are in
@@ -2660,7 +2655,7 @@
result = False
self.assertTrue(result, "Flow_Mod_3_1 TEST FAILED")
- fq_logger.info("Flow_Mod_3_1 TEST PASSED")
+ logging.info("Flow_Mod_3_1 TEST PASSED")
# FLOW DELETE 1
@@ -2692,12 +2687,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Del_1 TEST BEGIN")
+ logging.info("Flow_Del_1 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2727,8 +2722,8 @@
# Send it to the switch
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = False
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -2748,8 +2743,8 @@
# Delete strictly
- fq_logger.info("Sending strict flow del to switch:")
- fq_logger.info(str(fc2))
+ logging.info("Sending strict flow del to switch:")
+ logging.info(str(fc2))
self.assertTrue(sw.flow_del(fc2, True), "Failed to delete flow")
ft.delete(fc)
@@ -2773,7 +2768,7 @@
result = False
self.assertTrue(result, "Flow_Del_1 TEST FAILED")
- fq_logger.info("Flow_Del_1 TEST PASSED")
+ logging.info("Flow_Del_1 TEST PASSED")
# FLOW DELETE 2
@@ -2814,14 +2809,14 @@
"""
def runTest(self):
- fq_logger.info("Flow_Del_2 TEST BEGIN")
+ logging.info("Flow_Del_2 TEST BEGIN")
num_flows = test_param_get(fq_config, "num_flows", 100)
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -2845,10 +2840,10 @@
# Send flow table to switch
- fq_logger.info("Sending flow adds to switch")
+ logging.info("Sending flow adds to switch")
for fc in ft.values(): # Randomizes order of sending
- fq_logger.info("Adding flow:")
- fq_logger.info(str(fc));
+ logging.info("Adding flow:")
+ logging.info(str(fc));
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
# Do barrier, to make sure all flows are in
@@ -2910,9 +2905,9 @@
if n > 1:
break
- fq_logger.info("Deleting %d flows" % (n))
- fq_logger.info("Sending flow del to switch:")
- fq_logger.info(str(dfc))
+ logging.info("Deleting %d flows" % (n))
+ logging.info("Sending flow del to switch:")
+ logging.info(str(dfc))
self.assertTrue(sw.flow_del(dfc, False), "Failed to delete flows")
# Do barrier, to make sure all flows are in
@@ -2938,7 +2933,7 @@
result = False
self.assertTrue(result, "Flow_Del_2 TEST FAILED")
- fq_logger.info("Flow_Del_2 TEST PASSED")
+ logging.info("Flow_Del_2 TEST PASSED")
# FLOW DELETE 4
@@ -2973,12 +2968,12 @@
"""
def runTest(self):
- fq_logger.info("Flow_Del_4 TEST BEGIN")
+ logging.info("Flow_Del_4 TEST BEGIN")
# Clear all flows from switch
- fq_logger.info("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, fq_logger)
+ logging.info("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Get switch capabilites
@@ -3008,8 +3003,8 @@
# Send it to the switch. with "notify on removed"
- fq_logger.info("Sending flow add to switch:")
- fq_logger.info(str(fc))
+ logging.info("Sending flow add to switch:")
+ logging.info(str(fc))
ft = Flow_Tbl()
fc.send_rem = True
self.assertTrue(sw.flow_add(fc), "Failed to add flow")
@@ -3029,8 +3024,8 @@
# Delete strictly
- fq_logger.info("Sending strict flow del to switch:")
- fq_logger.info(str(fc2))
+ logging.info("Sending strict flow del to switch:")
+ logging.info(str(fc2))
self.assertTrue(sw.flow_del(fc2, True), "Failed to delete flow")
ft.delete(fc)
@@ -3057,5 +3052,5 @@
result = False
self.assertTrue(result, "Flow_Del_4 TEST FAILED")
- fq_logger.info("Flow_Del_4 TEST PASSED")
+ logging.info("Flow_Del_4 TEST PASSED")
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index 8ff8b69..ecc8157 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -23,8 +23,6 @@
#@var fs_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
fs_port_map = None
-#@var fs_logger Local logger object
-fs_logger = None
#@var fs_config Local copy of global configuration data
fs_config = None
@@ -54,17 +52,14 @@
basic.test_set_init(config)
global fs_port_map
- global fs_logger
global fs_config
- fs_logger = logging.getLogger("flow_stats")
- fs_logger.info("Initializing test set")
fs_port_map = config["port_map"]
fs_config = config
def sendPacket(obj, pkt, ingress_port, egress_port, test_timeout):
- fs_logger.info("Sending packet to dp port " + str(ingress_port) +
+ logging.info("Sending packet to dp port " + str(ingress_port) +
", expecting output on " + str(egress_port))
obj.dataplane.send(ingress_port, str(pkt))
@@ -78,7 +73,7 @@
exp_pkt=exp_pkt_arg)
obj.assertTrue(rcv_pkt is not None,
"Packet not received on port " + str(egress_port))
- fs_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
+ logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
str(rcv_port))
obj.assertEqual(rcv_port, egress_port,
"Packet received on port " + str(rcv_port) +
@@ -105,7 +100,7 @@
all_packets_received = 0
for i in range(0,test_timeout):
- fs_logger.info("Sending stats request")
+ logging.info("Sending stats request")
response, pkt = self.controller.transact(stat_req,
timeout=test_timeout)
self.assertTrue(response is not None,
@@ -119,7 +114,7 @@
#obj.match.pad2 = [0, 0]
#self.assertEqual(match, obj.match,
# "Matches do not match")
- fs_logger.info("Received " + str(obj.packet_count) + " packets")
+ logging.info("Received " + str(obj.packet_count) + " packets")
if obj.packet_count == packet_count:
all_packets_received = 1
@@ -140,7 +135,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller, fs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# build packet
@@ -154,7 +149,7 @@
# build flow
ingress_port = of_ports[0];
egress_port = of_ports[1];
- fs_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
flow_mod_msg = message.flow_mod()
@@ -167,7 +162,7 @@
self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
# send flow
- fs_logger.info("Inserting 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")
@@ -177,7 +172,7 @@
# send packet N times
num_sends = random.randint(10,20)
- fs_logger.info("Sending " + str(num_sends) + " test packets")
+ logging.info("Sending " + str(num_sends) + " test packets")
for i in range(0,num_sends):
sendPacket(self, pkt, ingress_port, egress_port,
test_timeout)
@@ -219,7 +214,7 @@
act.port = egress_port
self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
- fs_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
return flow_mod_msg
@@ -233,7 +228,7 @@
#obj.match.pad2 = [0, 0]
#self.assertEqual(match, obj.match,
# "Matches do not match")
- fs_logger.info("Received " + str(obj.packet_count)
+ logging.info("Received " + str(obj.packet_count)
+ " packets")
total_packets += obj.packet_count
return total_packets
@@ -246,7 +241,7 @@
all_packets_received = 0
for i in range(0,test_timeout):
- fs_logger.info("Sending stats request")
+ logging.info("Sending stats request")
# TODO: move REPLY_MORE handling to controller.transact?
response, pkt = self.controller.transact(stat_req,
timeout=test_timeout)
@@ -282,7 +277,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller, fs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
pkt1 = simple_tcp_packet()
@@ -291,31 +286,31 @@
pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
- fs_logger.info("Inserting flow1")
+ logging.info("Inserting flow1")
rv = self.controller.message_send(flow_mod_msg1)
self.assertTrue(rv != -1, "Error installing flow mod")
- fs_logger.info("Inserting flow2")
+ 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")
num_pkt1s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
+ logging.info("Sending " + str(num_pkt1s) + " pkt1s")
num_pkt2s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
+ logging.info("Sending " + str(num_pkt2s) + " pkt2s")
for i in range(0,num_pkt1s):
sendPacket(self, pkt1, ingress_port, egress_port1, test_timeout)
for i in range(0,num_pkt2s):
sendPacket(self, pkt2, ingress_port, egress_port2, test_timeout)
match1 = packet_to_flow_match(self, pkt1)
- fs_logger.info("Verifying flow1's " + str(num_pkt1s) + " packets")
+ logging.info("Verifying flow1's " + str(num_pkt1s) + " packets")
self.verifyStats(match1, ofp.OFPP_NONE, test_timeout, num_pkt1s)
match2 = packet_to_flow_match(self, pkt2)
- fs_logger.info("Verifying flow2's " + str(num_pkt2s) + " packets")
+ logging.info("Verifying flow2's " + str(num_pkt2s) + " packets")
self.verifyStats(match2, ofp.OFPP_NONE, test_timeout, num_pkt2s)
match1.wildcards |= ofp.OFPFW_DL_SRC
- fs_logger.info("Verifying combined " + str(num_pkt1s+num_pkt2s) + " packets")
+ logging.info("Verifying combined " + str(num_pkt1s+num_pkt2s) + " packets")
self.verifyStats(match1, ofp.OFPP_NONE, test_timeout,
num_pkt1s+num_pkt2s)
# TODO: sweep through the wildcards to verify matching?
@@ -349,7 +344,7 @@
act.port = egress_port
self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
- fs_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
return flow_mod_msg
@@ -363,7 +358,7 @@
all_packets_received = 0
for i in range(0,test_timeout):
- fs_logger.info("Sending stats request")
+ logging.info("Sending stats request")
response, pkt = self.controller.transact(stat_req,
timeout=test_timeout)
self.assertTrue(response is not None,
@@ -374,7 +369,7 @@
self.assertTrue(obj.flow_count == flow_count,
"Flow count " + str(obj.flow_count) +
" does not match expected " + str(flow_count))
- fs_logger.info("Received " + str(obj.packet_count) + " packets")
+ logging.info("Received " + str(obj.packet_count) + " packets")
if obj.packet_count == packet_count:
all_packets_received = 1
@@ -398,7 +393,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller, fs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
pkt1 = simple_tcp_packet()
@@ -407,18 +402,18 @@
pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
- fs_logger.info("Inserting flow1")
+ logging.info("Inserting flow1")
rv = self.controller.message_send(flow_mod_msg1)
self.assertTrue(rv != -1, "Error installing flow mod")
- fs_logger.info("Inserting flow2")
+ 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")
num_pkt1s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
+ logging.info("Sending " + str(num_pkt1s) + " pkt1s")
num_pkt2s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
+ logging.info("Sending " + str(num_pkt2s) + " pkt2s")
for i in range(0,num_pkt1s):
sendPacket(self, pkt1, ingress_port, egress_port1, test_timeout)
for i in range(0,num_pkt2s):
diff --git a/tests/load.py b/tests/load.py
index d09608e..dadb42f 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -36,8 +36,6 @@
#@var load_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
load_port_map = None
-#@var load_logger Local logger object
-load_logger = None
#@var load_config Local copy of global configuration data
load_config = None
@@ -54,11 +52,8 @@
"""
global load_port_map
- global load_logger
global load_config
- load_logger = logging.getLogger("load")
- load_logger.info("Initializing test set")
load_port_map = config["port_map"]
load_config = config
@@ -114,20 +109,20 @@
act = action.action_output()
act.port = lb_port + 1
self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
- load_logger.info("Sleeping before starting storm")
+ logging.info("Sleeping before starting storm")
time.sleep(1) # Root causing issue with fast disconnects
- load_logger.info("Sending packet out to %d" % (lb_port + 1))
+ logging.info("Sending packet out to %d" % (lb_port + 1))
rv = self.controller.message_send(msg)
self.assertTrue(rv == 0, "Error sending out message")
for idx in range(0, barrier_count):
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
# To do: Add some interesting functionality here
- load_logger.info("Barrier %d completed" % idx)
+ logging.info("Barrier %d completed" % idx)
# Clear the flow table when done
- load_logger.debug("Deleting all flows from switch")
- rc = delete_all_flows(self.controller, load_logger)
+ logging.debug("Deleting all flows from switch")
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# Do not run by default; still mysterious disconnects often
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index c8ad1b8..5f29da5 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -24,7 +24,6 @@
of_port_map = None
-of_logger = None
of_config = None
def test_set_init(config):
@@ -33,11 +32,8 @@
basic.test_set_init(config)
global of_port_map
- global of_logger
global of_config
- of_logger = logging.getLogger("Start Openflow_Protocol_Messages Conformance Test-suite")
- of_logger.info("Initializing test set")
of_port_map = config["port_map"]
of_config = config
@@ -49,17 +45,17 @@
b) Verify OFPT_FEATURES_REPLY is received without errors"""
def runTest(self):
- of_logger.info("Running Features_Request test")
+ logging.info("Running Features_Request test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Sending Features_Request")
- of_logger.info("Expecting Features_Reply")
+ logging.info("Sending Features_Request")
+ logging.info("Expecting Features_Reply")
request = message.features_request()
rv = self.controller.message_send(request)
@@ -79,17 +75,17 @@
def runTest(self):
- of_logger.info("Running Configuration_Request test ")
+ logging.info("Running Configuration_Request test ")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Sending OFPT_GET_CONFIG_REQUEST ")
- of_logger.info("Expecting OFPT_GET_CONFIG_REPLY ")
+ 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)
@@ -108,17 +104,17 @@
def runTest(self):
- of_logger.info("Running Modify_State_Add test")
+ logging.info("Running Modify_State_Add test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller,of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Inserting a flow entry")
- of_logger.info("Expecting active_count=1 in table_stats_reply")
+ logging.info("Inserting a flow entry")
+ logging.info("Expecting active_count=1 in table_stats_reply")
#Insert a flow entry matching on ingress_port
(Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -137,17 +133,17 @@
def runTest(self):
- of_logger.info("Running Modify_State_Delete test")
+ logging.info("Running Modify_State_Delete test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller,of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Inserting a flow entry and then deleting it")
- of_logger.info("Expecting the active_count=0 in table_stats_reply")
+ logging.info("Inserting a flow entry and then deleting it")
+ logging.info("Expecting the active_count=0 in table_stats_reply")
#Insert a flow matching on ingress_port
(Pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -172,17 +168,17 @@
def runTest(self):
- of_logger.info("Running Modify_State_Modify test")
+ logging.info("Running Modify_State_Modify test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Inserting a flow entry and then modifying it")
- of_logger.info("Expecting the Test Packet to implement the modified action")
+ logging.info("Inserting a flow entry and then modifying it")
+ logging.info("Expecting the Test Packet to implement the modified action")
# Insert a flow matching on ingress_port with action A (output to of_port[1])
(pkt,match) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -203,17 +199,17 @@
def runTest(self):
- of_logger.info("Running Read_State test")
+ logging.info("Running Read_State test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Inserting a flow entry and then sending flow_stats request")
- of_logger.info("Expecting the a flow_stats_reply without errors")
+ logging.info("Inserting a flow entry and then sending flow_stats request")
+ logging.info("Expecting the a flow_stats_reply without errors")
# Insert a flow with match on ingress_port
(pkt,match ) = Wildcard_All_Except_Ingress(self,of_ports)
@@ -229,17 +225,17 @@
def runTest(self):
- of_logger.info("Running Packet_Out test")
+ logging.info("Running Packet_Out test")
of_ports = of_port_map.keys()
of_ports.sort()
#Clear Switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
- of_logger.info("Sending a packet-out for each dataplane port")
- of_logger.info("Expecting the packet on appropriate dataplane port")
+ logging.info("Sending a packet-out for each dataplane port")
+ logging.info("Expecting the packet on appropriate dataplane port")
for dp_port in of_ports:
for outpkt, opt in [
@@ -253,7 +249,7 @@
act.port = dp_port
self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
- of_logger.info("PacketOut to: " + str(dp_port))
+ logging.info("PacketOut to: " + str(dp_port))
rv = self.controller.message_send(msg)
self.assertTrue(rv == 0, "Error sending out message")
@@ -267,12 +263,12 @@
exp_pkt=exp_pkt_arg)
self.assertTrue(pkt is not None, 'Packet not received')
- of_logger.info("PacketOut: got pkt from " + str(of_port))
+ logging.info("PacketOut: got pkt from " + str(of_port))
if of_port is not None:
self.assertEqual(of_port, dp_port, "Unexpected receive port")
if not dataplane.match_exp_pkt(outpkt, pkt):
- of_logger.debug("Sent %s" % format_packet(outpkt))
- of_logger.debug("Resp %s" % format_packet(
+ logging.debug("Sent %s" % format_packet(outpkt))
+ logging.debug("Resp %s" % format_packet(
str(pkt)[:len(str(outpkt))]))
self.assertEqual(str(outpkt), str(pkt)[:len(str(outpkt))],
'Response packet does not match send packet')
@@ -286,24 +282,24 @@
def runTest(self):
- of_logger.info("Running Packet_In test")
+ logging.info("Running Packet_In test")
of_ports = of_port_map.keys()
of_ports.sort()
ingress_port = of_ports[0]
#Clear Switch state
- rc = delete_all_flows(self.controller, of_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- of_logger.info("Sending a Simple tcp packet a dataplane port")
- of_logger.info("Expecting a packet_in event on the control plane")
+ logging.info("Sending a Simple tcp packet a dataplane port")
+ logging.info("Expecting a packet_in event on the control plane")
# Send packet on dataplane port and verify packet_in event gets generated.
pkt = simple_tcp_packet()
self.dataplane.send(ingress_port, str(pkt))
- of_logger.info("Sending packet to dp port " + str(ingress_port) +
+ logging.info("Sending packet to dp port " + str(ingress_port) +
", expecting packet_in on control plane" )
(response, pkt) = self.controller.poll(exp_msg=ofp.OFPT_PACKET_IN,
@@ -321,10 +317,10 @@
def runTest(self):
- of_logger.info("Running Hello test")
+ logging.info("Running Hello test")
- of_logger.info("Sending Hello")
- of_logger.info("Expecting a Hello on the control plane with version--1.0.0")
+ logging.info("Sending Hello")
+ logging.info("Expecting a Hello on the control plane with version--1.0.0")
#Send Hello message
request = message.hello()
@@ -344,10 +340,10 @@
def runTest(self):
- of_logger.info("Running Echo_Without_Body test")
+ logging.info("Running Echo_Without_Body test")
- of_logger.info("Sending Echo Request")
- of_logger.info("Expecting a Echo Reply with version--1.0.0 and same xid")
+ logging.info("Sending Echo Request")
+ logging.info("Expecting a Echo Reply with version--1.0.0 and same xid")
# Send echo_request
request = message.echo_request()
@@ -367,10 +363,10 @@
def runTest(self):
- of_logger.info("Running Barrier_Request_Reply test")
+ logging.info("Running Barrier_Request_Reply test")
- of_logger.info("Sending Barrier Request")
- of_logger.info("Expecting a Barrier Reply with same xid")
+ logging.info("Sending Barrier Request")
+ logging.info("Expecting a Barrier Reply with same xid")
#Send Barrier Request
request = message.barrier_request()
diff --git a/tests/pktact.py b/tests/pktact.py
index fd1b014..ef7505e 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -35,8 +35,6 @@
#@var port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
pa_port_map = None
-#@var pa_logger Local logger object
-pa_logger = None
#@var pa_config Local copy of global configuration data
pa_config = None
@@ -100,11 +98,8 @@
basic.test_set_init(config)
global pa_port_map
- global pa_logger
global pa_config
- pa_logger = logging.getLogger("pkt_act")
- pa_logger.info("Initializing test set")
pa_port_map = config["port_map"]
pa_config = config
@@ -137,12 +132,12 @@
act = action.action_output()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port = of_ports[idx]
egress_port = of_ports[(idx + 1) % len(of_ports)]
- pa_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
@@ -154,12 +149,12 @@
act.port = egress_port
self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " +
+ logging.info("Sending packet to dp port " +
str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -172,7 +167,7 @@
(rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
exp_pkt=exp_pkt_arg)
self.assertTrue(rcv_pkt is not None, "Did not receive packet")
- pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
+ logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
str(rcv_port))
self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
self.assertEqual(str(pkt), str(rcv_pkt),
@@ -206,7 +201,7 @@
"Could not generate flow match from pkt")
act = action.action_output()
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port = of_ports[0]
@@ -220,12 +215,12 @@
act.max_len = 65535
self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " +
+ logging.info("Sending packet to dp port " +
str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -234,8 +229,8 @@
self.assertTrue(response is not None,
'Packet in message not received by controller')
if not dataplane.match_exp_pkt(pkt, response.data):
- pa_logger.debug("Sent %s" % format_packet(pkt))
- pa_logger.debug("Resp %s" % format_packet(response.data))
+ logging.debug("Sent %s" % format_packet(pkt))
+ logging.debug("Resp %s" % format_packet(response.data))
self.assertTrue(False,
'Response packet does not match send packet' +
' for controller port')
@@ -291,12 +286,12 @@
egress_port = of_ports[(idx + 1) % len(of_ports)]
for egress_queue_id in self.portQueuesGet(queue_stats, egress_port):
- pa_logger.info("Ingress " + str(ingress_port)
+ logging.info("Ingress " + str(ingress_port)
+ " to egress " + str(egress_port)
+ " queue " + str(egress_queue_id)
)
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
match.in_port = ingress_port
@@ -309,7 +304,7 @@
act.queue_id = egress_queue_id
self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Inserting flow")
+ 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")
@@ -322,7 +317,7 @@
(qs_before, p) = self.controller.transact(request)
self.assertNotEqual(qs_before, None, "Queue stats request failed")
- pa_logger.info("Sending packet to dp port " +
+ logging.info("Sending packet to dp port " +
str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -335,7 +330,7 @@
(rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
exp_pkt=exp_pkt_arg)
self.assertTrue(rcv_pkt is not None, "Did not receive packet")
- pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
+ logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
str(rcv_port))
self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
self.assertEqual(str(pkt), str(rcv_pkt),
@@ -414,17 +409,17 @@
ingress_port = of_ports[idx]
egress_port = ofp.OFPP_CONTROLLER
- pa_logger.info("Ingress port " + str(ingress_port)
+ logging.info("Ingress port " + str(ingress_port)
+ ", controller port queues "
+ str(self.portQueuesGet(queue_stats, egress_port)))
for egress_queue_id in self.portQueuesGet(queue_stats, egress_port):
- pa_logger.info("Ingress " + str(ingress_port)
+ logging.info("Ingress " + str(ingress_port)
+ " to egress " + str(egress_port)
+ " queue " + str(egress_queue_id)
)
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
match.in_port = ingress_port
@@ -437,7 +432,7 @@
act.queue_id = egress_queue_id
self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Inserting flow")
+ 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")
@@ -450,7 +445,7 @@
(qs_before, p) = self.controller.transact(request)
self.assertNotEqual(qs_before, None, "Queue stats request failed")
- pa_logger.info("Sending packet to dp port " +
+ logging.info("Sending packet to dp port " +
str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
@@ -472,8 +467,8 @@
self.assertTrue(response is not None,
'Packet in message not received by controller')
if not dataplane.match_exp_pkt(pkt, response.data):
- basic_logger.debug("Sent %s" % format_packet(pkt))
- basic_logger.debug("Resp %s" % format_packet(response.data))
+ logging.debug("Sent %s" % format_packet(pkt))
+ logging.debug("Resp %s" % format_packet(response.data))
self.assertTrue(False,
'Response packet does not match send packet' +
' for controller port')
@@ -537,13 +532,13 @@
act = action.action_output()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port = of_ports[idx]
egress_port1 = of_ports[(idx + 1) % len(of_ports)]
egress_port2 = of_ports[(idx + 2) % len(of_ports)]
- pa_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port1) + " and " +
str(egress_port2))
@@ -556,21 +551,21 @@
self.assertTrue(request.actions.add(act), "Could not add action1")
act.port = egress_port2
self.assertTrue(request.actions.add(act), "Could not add action2")
- # pa_logger.info(request.show())
+ # logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " +
+ logging.info("Sending packet to dp port " +
str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
yes_ports = set([egress_port1, egress_port2])
no_ports = set(of_ports).difference(yes_ports)
receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports,
- self, pa_logger, pa_config)
+ self, pa_config)
class DirectMCNonIngress(basic.SimpleDataPlane):
"""
@@ -597,10 +592,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" all non-ingress ports")
match.in_port = ingress_port
@@ -613,18 +608,18 @@
act.port = egress_port
self.assertTrue(request.actions.add(act),
"Could not add output to " + str(egress_port))
- pa_logger.debug(request.show())
+ logging.debug(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
yes_ports = set(of_ports).difference([ingress_port])
receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
- self, pa_logger, pa_config)
+ self, pa_config)
class DirectMC(basic.SimpleDataPlane):
@@ -652,10 +647,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+ logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
request = message.flow_mod()
@@ -668,17 +663,16 @@
act.port = egress_port
self.assertTrue(request.actions.add(act),
"Could not add output to " + str(egress_port))
- # pa_logger.info(request.show())
+ # logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
- receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
- pa_logger, pa_config)
+ receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
class Flood(basic.SimpleDataPlane):
"""
@@ -703,10 +697,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+ logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
request = message.flow_mod()
@@ -715,18 +709,18 @@
act.port = ofp.OFPP_FLOOD
self.assertTrue(request.actions.add(act),
"Could not add flood port action")
- pa_logger.info(request.show())
+ logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
yes_ports = set(of_ports).difference([ingress_port])
receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
- self, pa_logger, pa_config)
+ self, pa_config)
class FloodPlusIngress(basic.SimpleDataPlane):
"""
@@ -752,10 +746,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+ logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
request = message.flow_mod()
@@ -767,17 +761,16 @@
act.port = ofp.OFPP_IN_PORT
self.assertTrue(request.actions.add(act),
"Could not add ingress port for output")
- pa_logger.info(request.show())
+ logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
- receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
- pa_logger, pa_config)
+ receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
class All(basic.SimpleDataPlane):
"""
@@ -802,10 +795,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+ logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
request = message.flow_mod()
@@ -814,18 +807,18 @@
act.port = ofp.OFPP_ALL
self.assertTrue(request.actions.add(act),
"Could not add ALL port action")
- pa_logger.info(request.show())
+ logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
yes_ports = set(of_ports).difference([ingress_port])
receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
- self, pa_logger, pa_config)
+ self, pa_config)
class AllPlusIngress(basic.SimpleDataPlane):
"""
@@ -851,10 +844,10 @@
act = action.action_output()
for ingress_port in of_ports:
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
- pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+ logging.info("Ingress " + str(ingress_port) + " to all ports")
match.in_port = ingress_port
request = message.flow_mod()
@@ -866,17 +859,16 @@
act.port = ofp.OFPP_IN_PORT
self.assertTrue(request.actions.add(act),
"Could not add ingress port for output")
- pa_logger.info(request.show())
+ logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
- receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
- pa_logger, pa_config)
+ receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
class FloodMinusPort(basic.SimpleDataPlane):
"""
@@ -903,15 +895,14 @@
act = action.action_output()
for idx in range(len(of_ports)):
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
ingress_port = of_ports[idx]
no_flood_idx = (idx + 1) % len(of_ports)
no_flood_port = of_ports[no_flood_idx]
rv = port_config_set(self.controller, no_flood_port,
- ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD,
- pa_logger)
+ ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
self.assertEqual(rv, 0, "Failed to set port config")
match.in_port = ingress_port
@@ -922,24 +913,23 @@
act.port = ofp.OFPP_FLOOD
self.assertTrue(request.actions.add(act),
"Could not add flood port action")
- pa_logger.info(request.show())
+ logging.info(request.show())
- pa_logger.info("Inserting flow")
+ 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")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
- pa_logger.info("No flood port is " + str(no_flood_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("No flood port is " + str(no_flood_port))
self.dataplane.send(ingress_port, str(pkt))
no_ports = set([ingress_port, no_flood_port])
yes_ports = set(of_ports).difference(no_ports)
- receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports, self,
- pa_logger, pa_config)
+ receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports, self, pa_config)
# Turn no flood off again
rv = port_config_set(self.controller, no_flood_port,
- 0, ofp.OFPPC_NO_FLOOD, pa_logger)
+ 0, ofp.OFPPC_NO_FLOOD)
self.assertEqual(rv, 0, "Failed to reset port config")
#@todo Should check no other packets received
@@ -951,9 +941,8 @@
class BaseMatchCase(basic.SimpleDataPlane):
def setUp(self):
basic.SimpleDataPlane.setUp(self)
- self.logger = pa_logger
def runTest(self):
- self.logger.info("BaseMatchCase")
+ logging.info("BaseMatchCase")
class ExactMatch(BaseMatchCase):
"""
@@ -1004,7 +993,7 @@
self.flowMsgs = {}
def _ClearTable(self):
- rc = delete_all_flows(self.controller, self.logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -1039,7 +1028,7 @@
self._ClearTable()
# Sanity check flow at lower priority from pA to pB
- self.logger.info("runPrioFlows(pA=%d,pB=%d,pC=%d,ph=%d,pl=%d"
+ logging.info("runPrioFlows(pA=%d,pB=%d,pC=%d,ph=%d,pl=%d"
% (portA, portB, portC, prioHigher, prioLower))
# Sanity check flow at lower priority from pA to pC
@@ -1072,7 +1061,7 @@
wildcards=wildcards,
egr_ports=egp)
request.priority = prio
- self.logger.debug("Install flow with priority " + str(prio))
+ logging.debug("Install flow with priority " + str(prio))
flow_msg_install(self, request, clear_table_override=False)
self.flowMsgs[prio] = request
@@ -1082,7 +1071,7 @@
msg.command = ofp.OFPFC_DELETE_STRICT
# This *must* be set for DELETE
msg.out_port = ofp.OFPP_NONE
- self.logger.debug("Remove flow with priority " + str(prio))
+ logging.debug("Remove flow with priority " + str(prio))
self.controller.message_send(msg)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
else:
@@ -1093,10 +1082,8 @@
if pkt == None:
pkt = self.pkt
- self.logger.info("Pkt match test: " + str(inp) +
- " to " + str(egp))
- self.logger.debug("Send packet: " + str(inp) + " to "
- + str(egp))
+ logging.info("Pkt match test: " + str(inp) + " to " + str(egp))
+ logging.debug("Send packet: " + str(inp) + " to " + str(egp))
self.dataplane.send(inp, str(pkt))
receive_pkt_verify(self, egp, pkt, inp)
@@ -1321,8 +1308,8 @@
of_ports = pa_port_map.keys()
of_ports.sort()
ing_port = of_ports[0]
- pa_logger.info("Sending packet to " + str(ing_port))
- pa_logger.debug("Data: " + str(pkt).encode('hex'))
+ logging.info("Sending packet to " + str(ing_port))
+ logging.debug("Data: " + str(pkt).encode('hex'))
self.dataplane.send(ing_port, str(pkt))
class PacketOnlyTagged(basic.DataPlaneOnly):
@@ -1335,8 +1322,8 @@
of_ports = pa_port_map.keys()
of_ports.sort()
ing_port = of_ports[0]
- pa_logger.info("Sending packet to " + str(ing_port))
- pa_logger.debug("Data: " + str(pkt).encode('hex'))
+ logging.info("Sending packet to " + str(ing_port))
+ logging.debug("Data: " + str(pkt).encode('hex'))
self.dataplane.send(ing_port, str(pkt))
test_prio["PacketOnly"] = -1
@@ -1393,7 +1380,7 @@
ing_port = of_ports[0]
egr_ports = of_ports[1]
- rv = delete_all_flows(self.controller, pa_logger)
+ rv = delete_all_flows(self.controller)
self.assertEqual(rv, 0, "Failed to delete all flows")
len_untagged = 100
@@ -1412,12 +1399,12 @@
action_list=[vid_act])
flow_msg_install(self, request)
- pa_logger.debug("Send untagged packet: " + str(ing_port) + " to " +
+ logging.debug("Send untagged packet: " + str(ing_port) + " to " +
str(egr_ports))
self.dataplane.send(ing_port, str(untagged_pkt))
receive_pkt_verify(self, egr_ports, exp_pkt, ing_port)
- pa_logger.debug("Send tagged packet: " + str(ing_port) + " to " +
+ logging.debug("Send tagged packet: " + str(ing_port) + " to " +
str(egr_ports))
self.dataplane.send(ing_port, str(tagged_pkt))
receive_pkt_verify(self, egr_ports, exp_pkt, ing_port)
@@ -1724,7 +1711,7 @@
flow_count = test_param_get(self.config, 'ft_flow_count', default=20)
iter_count = test_param_get(self.config, 'ft_iter_count', default=10)
- pa_logger.info("Running flow toggle with %d flows, %d iterations" %
+ logging.info("Running flow toggle with %d flows, %d iterations" %
(flow_count, iter_count))
acts = []
acts.append(action.action_output())
@@ -1758,8 +1745,8 @@
flows[toggle].append(msg)
# Show two sample flows
- pa_logger.debug(flows[0][0].show())
- pa_logger.debug(flows[1][0].show())
+ logging.debug(flows[0][0].show())
+ logging.debug(flows[1][0].show())
# Install the first set of flows
for f_idx in range(flow_count):
@@ -1767,7 +1754,7 @@
self.assertTrue(rv != -1, "Error installing flow %d" % f_idx)
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- pa_logger.info("Installed %d flows" % flow_count)
+ logging.info("Installed %d flows" % flow_count)
# Repeatedly modify all the flows back and forth
updates = 0
@@ -1776,7 +1763,7 @@
start = time.time()
for iter_idx in range(iter_count):
if not iter_idx % mod_val:
- pa_logger.info("Flow Toggle: iter %d of %d. " %
+ logging.info("Flow Toggle: iter %d of %d. " %
(iter_idx, iter_count) +
"%d updates in %d secs" %
(updates, time.time() - start))
@@ -1792,8 +1779,8 @@
end = time.time()
divisor = end - start or (end - start + 1)
- pa_logger.info("Flow toggle: %d iterations" % iter_count)
- pa_logger.info(" %d flow mods in %d secs, %d mods/sec" %
+ logging.info("Flow toggle: %d iterations" % iter_count)
+ logging.info(" %d flow mods in %d secs, %d mods/sec" %
(updates, end - start, updates/divisor))
@@ -1829,11 +1816,11 @@
def runTest(self):
count = test_param_get(self.config, 'iter_count', default=10)
tests_done = 0
- pa_logger.info("Running iteration test " + str(count) + " times")
+ logging.info("Running iteration test " + str(count) + " times")
start = time.time()
last = start
for idx in range(count):
- pa_logger.info("Iteration " + str(idx + 1))
+ logging.info("Iteration " + str(idx + 1))
for cls in iter_classes:
test = cls()
test.inheritSetup(self)
@@ -1842,17 +1829,17 @@
# Report update about every minute, between tests
if time.time() - last > 60:
last = time.time()
- pa_logger.info(
+ logging.info(
"IterCases: Iter %d of %d; Ran %d tests in %d " %
(idx, count, tests_done, last - start) +
"seconds so far")
stats = all_stats_get(self)
last = time.time()
- pa_logger.info("\nIterCases ran %d tests in %d seconds." %
+ logging.info("\nIterCases ran %d tests in %d seconds." %
(tests_done, last - start))
- pa_logger.info(" flows: %d. packets: %d. bytes: %d" %
+ logging.info(" flows: %d. packets: %d. bytes: %d" %
(stats["flows"], stats["packets"], stats["bytes"]))
- pa_logger.info(" active: %d. lookups: %d. matched %d." %
+ logging.info(" active: %d. lookups: %d. matched %d." %
(stats["active"], stats["lookups"], stats["matched"]))
# Don't run by default
@@ -1903,14 +1890,14 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- delete_all_flows(self.controller, pa_logger)
+ delete_all_flows(self.controller)
pkt = simple_tcp_packet()
ingress_port = of_ports[0]
egress_port = of_ports[1]
def testField(field, mask):
- pa_logger.info("Testing field %s" % field)
+ logging.info("Testing field %s" % field)
def addFlow(matching, priority, output_port):
match = packet_to_flow_match(self, pkt)
@@ -1932,7 +1919,7 @@
act = action.action_output()
act.port = output_port
self.assertTrue(request.actions.add(act), "Could not add action")
- pa_logger.info("Inserting flow")
+ logging.info("Inserting flow")
self.controller.message_send(request)
# This flow should match.
@@ -1942,7 +1929,7 @@
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
- pa_logger.info("Sending packet to dp port " + str(ingress_port))
+ logging.info("Sending packet to dp port " + str(ingress_port))
self.dataplane.send(ingress_port, str(pkt))
exp_pkt_arg = None
@@ -1954,7 +1941,7 @@
(rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
exp_pkt=exp_pkt_arg)
self.assertTrue(rcv_pkt is not None, "Did not receive packet")
- pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " + str(rcv_port))
+ logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " + str(rcv_port))
self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
self.assertEqual(str(pkt), str(rcv_pkt), 'Response packet does not match send packet')
diff --git a/tests/port_stats.py b/tests/port_stats.py
index 96d3cc5..5cfb1bb 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -23,8 +23,6 @@
#@var fs_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
fs_port_map = None
-#@var fs_logger Local logger object
-fs_logger = None
#@var fs_config Local copy of global configuration data
fs_config = None
@@ -54,17 +52,14 @@
basic.test_set_init(config)
global fs_port_map
- global fs_logger
global fs_config
- fs_logger = logging.getLogger("flow_stats")
- fs_logger.info("Initializing test set")
fs_port_map = config["port_map"]
fs_config = config
def sendPacket(obj, pkt, ingress_port, egress_port, test_timeout):
- fs_logger.info("Sending packet to dp port " + str(ingress_port) +
+ logging.info("Sending packet to dp port " + str(ingress_port) +
", expecting output on " + str(egress_port))
obj.dataplane.send(ingress_port, str(pkt))
@@ -78,7 +73,7 @@
exp_pkt=exp_pkt_arg)
obj.assertTrue(rcv_pkt is not None,
"Packet not received on port " + str(egress_port))
- fs_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
+ logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " +
str(rcv_port))
obj.assertEqual(rcv_port, egress_port,
"Packet received on port " + str(rcv_port) +
@@ -90,17 +85,17 @@
stat_req = message.port_stats_request()
stat_req.port_no = port
- fs_logger.info("Sending stats request")
+ logging.info("Sending stats request")
response, pkt = obj.controller.transact(stat_req, timeout=2)
obj.assertTrue(response is not None,
"No response to stats request")
obj.assertTrue(len(response.stats) == 1,
"Did not receive port stats reply")
for item in response.stats:
- fs_logger.info("Sent " + str(item.tx_packets) + " packets")
+ logging.info("Sent " + str(item.tx_packets) + " packets")
packet_sent = item.tx_packets
packet_recv = item.rx_packets
- fs_logger.info("Port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
+ logging.info("Port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
return packet_sent, packet_recv
def verifyStats(obj, port, test_timeout, packet_sent, packet_recv):
@@ -111,7 +106,7 @@
all_packets_sent = 0
sent = recv = 0
for i in range(0,test_timeout):
- fs_logger.info("Sending stats request")
+ logging.info("Sending stats request")
response, pkt = obj.controller.transact(stat_req,
timeout=test_timeout)
obj.assertTrue(response is not None,
@@ -121,10 +116,10 @@
for item in response.stats:
sent = item.tx_packets
recv = item.rx_packets
- fs_logger.info("Sent " + str(item.tx_packets) + " packets")
+ logging.info("Sent " + str(item.tx_packets) + " packets")
if item.tx_packets == packet_sent:
all_packets_sent = 1
- fs_logger.info("Received " + str(item.rx_packets) + " packets")
+ logging.info("Received " + str(item.rx_packets) + " packets")
if item.rx_packets == packet_recv:
all_packets_received = 1
@@ -132,8 +127,8 @@
break
sleep(1)
- fs_logger.info("Expected port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
- fs_logger.info("Actual port %d stats count: tx %d rx %d" % (port, sent, recv))
+ logging.info("Expected port %d stats count: tx %d rx %d" % (port, packet_sent, packet_recv))
+ logging.info("Actual port %d stats count: tx %d rx %d" % (port, sent, recv))
obj.assertTrue(all_packets_sent,
"Packet sent does not match number sent")
obj.assertTrue(all_packets_received,
@@ -160,7 +155,7 @@
of_ports.sort()
self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
- rc = delete_all_flows(self.controller, fs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
# build packet
@@ -174,7 +169,7 @@
# build flow
ingress_port = of_ports[0];
egress_port = of_ports[1];
- fs_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
match.in_port = ingress_port
flow_mod_msg = message.flow_mod()
@@ -187,7 +182,7 @@
self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
# send flow
- fs_logger.info("Inserting 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")
@@ -198,7 +193,7 @@
# send packet N times
num_sends = random.randint(10,20)
- fs_logger.info("Sending " + str(num_sends) + " test packets")
+ logging.info("Sending " + str(num_sends) + " test packets")
for i in range(0,num_sends):
sendPacket(self, pkt, ingress_port, egress_port,
test_timeout)
@@ -234,7 +229,7 @@
act.port = egress_port
self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
- fs_logger.info("Ingress " + str(ingress_port) +
+ logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
return flow_mod_msg
@@ -252,7 +247,7 @@
egress_port1 = of_ports[1];
egress_port2 = of_ports[2];
- rc = delete_all_flows(self.controller, fs_logger)
+ rc = delete_all_flows(self.controller)
self.assertEqual(rc, 0, "Failed to delete all flows")
pkt1 = simple_tcp_packet()
@@ -261,10 +256,10 @@
pkt2 = simple_tcp_packet(dl_src='0:7:7:7:7:7')
flow_mod_msg2 = self.buildFlowModMsg(pkt2, ingress_port, egress_port2)
- fs_logger.info("Inserting flow1")
+ logging.info("Inserting flow1")
rv = self.controller.message_send(flow_mod_msg1)
self.assertTrue(rv != -1, "Error installing flow mod")
- fs_logger.info("Inserting flow2")
+ 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")
@@ -275,9 +270,9 @@
initTxOutPort2, initRxOutPort2 = getStats(self, egress_port2)
num_pkt1s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt1s) + " pkt1s")
+ logging.info("Sending " + str(num_pkt1s) + " pkt1s")
num_pkt2s = random.randint(10,30)
- fs_logger.info("Sending " + str(num_pkt2s) + " pkt2s")
+ logging.info("Sending " + str(num_pkt2s) + " pkt2s")
for i in range(0,num_pkt1s):
sendPacket(self, pkt1, ingress_port, egress_port1, test_timeout)
for i in range(0,num_pkt2s):
diff --git a/tests/serial_failover.py b/tests/serial_failover.py
index 311dde1..8ba1766 100644
--- a/tests/serial_failover.py
+++ b/tests/serial_failover.py
@@ -22,8 +22,6 @@
#@var serial_failover_port_map Local copy of the configuration map from OF port
# numbers to OS interfaces
serial_failover_port_map = None
-#@var serial_failover_logger Local logger object
-serial_failover_logger = None
#@var serial_failover_config Local copy of global configuration data
serial_failover_config = None
@@ -37,11 +35,8 @@
"""
global serial_failover_port_map
- global serial_failover_logger
global serial_failover_config
- serial_failover_logger = logging.getLogger("serial_failover")
- serial_failover_logger.info("Initializing test set")
serial_failover_port_map = config["port_map"]
serial_failover_config = config
@@ -65,7 +60,7 @@
test_iterations = 0
def sig_handler(self, v1, v2):
- serial_failover_logger.critical("Received interrupt signal; exiting")
+ logging.critical("Received interrupt signal; exiting")
print "Received interrupt signal; exiting"
self.clean_shutdown = False
self.tearDown()
@@ -89,7 +84,7 @@
reply, pkt = self.controller.transact(request, timeout=20)
self.assertTrue(reply is not None,
"Did not complete features_request for handshake")
- serial_failover_logger.info("Connected " +
+ logging.info("Connected " +
str(self.controller.switch_addr))
# send echo request and wait for reply
@@ -103,10 +98,10 @@
def connectionKill(self, kill_method):
if kill_method == 'controller_shutdown':
- serial_failover_logger.info("Shutting down controller")
+ logging.info("Shutting down controller")
self.controller.shutdown()
elif kill_method == 'no_echo':
- serial_failover_logger.info("Disabling controller keep alive")
+ logging.info("Disabling controller keep alive")
self.controller.keep_alive = False
# wait for controller to die
@@ -121,7 +116,7 @@
# controller_list is list of ip/port tuples
partial_list = test_param_get(serial_failover_config,
'controller_list')
- serial_failover_logger.debug("ctrl list: " + str(partial_list))
+ logging.debug("ctrl list: " + str(partial_list))
self.controller_list = [(serial_failover_config["controller_host"],
serial_failover_config["controller_port"])]
if partial_list is not None:
@@ -143,15 +138,14 @@
return self.controller_list[self.controller_idx]
def setUp(self):
- self.logger = serial_failover_logger
self.config = serial_failover_config
#@todo Test cases shouldn't monkey with signals; move SIGINT handler
# to top-level oft
try:
signal.signal(signal.SIGINT, self.sig_handler)
except ValueError, e:
- serial_failover_logger.info("Could not set SIGINT handler: %s" % e)
- serial_failover_logger.info("** START TEST CASE " + str(self))
+ logging.info("Could not set SIGINT handler: %s" % e)
+ logging.info("** START TEST CASE " + str(self))
self.test_timeout = test_param_get(serial_failover_config,
'failover_timeout') or 60
@@ -178,27 +172,26 @@
the state after the sub_test is run must be taken into account
by subsequent operations.
"""
- self.logger = parent.logger
self.config = parent.config
- serial_failover_logger.info("** Setup " + str(self) +
+ logging.info("** Setup " + str(self) +
" inheriting from " + str(parent))
self.controller = parent.controller
def tearDown(self):
- serial_failover_logger.info("** END TEST CASE " + str(self))
+ logging.info("** END TEST CASE " + str(self))
self.controller.shutdown()
if self.clean_shutdown:
self.controller.join()
def doFailover(self, killmethod):
- serial_failover_logger.info("Starting serial failover test")
+ logging.info("Starting serial failover test")
self.assertTrue(self.controller.switch_socket is not None,
str(self) + 'No connection to switch')
# kill controller connection
self.connectionKill(killmethod)
# establish new controller connection
controller = self.getNextController()
- serial_failover_logger.debug("** Next controller (%u/%u)%s:%u" %
+ logging.debug("** Next controller (%u/%u)%s:%u" %
(self.controller_idx,
len(self.controller_list),
controller[0],
@@ -211,7 +204,7 @@
def assertTrue(self, cond, msg):
if not cond:
- serial_failover_logger.error("** FAILED ASSERTION: " + msg)
+ logging.error("** FAILED ASSERTION: " + msg)
unittest.TestCase.assertTrue(self, cond, msg)
test_prio["SerialFailover"] = -1