Added PortConfigMod
Test gets the switch config (via features request), then changes
a bit in a port config and does a port_mod. Then reads the config
back to verify changed.
diff --git a/tests/basic.py b/tests/basic.py
index 2f21f5a..b464b5e 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -243,7 +243,7 @@
request.match.wildcards = 0 # ofp.OFPFW_ALL
response, pkt = self.controller.transact(request, timeout=2)
self.assertTrue(response is not None, "Did not get response")
- basic_logger.info(response.show())
+ basic_logger.debug(response.show())
class FlowMod(SimpleProtocol):
"""
@@ -260,5 +260,50 @@
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Error installing flow mod")
+class PortConfigMod(SimpleProtocol):
+ """
+ Modify a bit in port config and verify changed
+
+ Get the switch configuration, modify the port configuration
+ and write it back; get the config again and verify changed.
+ Then set it back to the way it was.
+ """
+
+ def runTest(self):
+ basic_logger.info("Running " + str(self))
+ request = message.features_request()
+ reply, pkt = self.controller.transact(request, timeout=2)
+ self.assertTrue(reply is not None, "Did not get response to ftr req")
+ basic_logger.info("Reply has " + str(len(reply.ports)) + " ports")
+ #basic_logger.debug(reply.show())
+ tport = reply.ports[0]
+ basic_logger.info("No flood bit port 0 is now " +
+ str(reply.ports[0].config ^ ofp.OFPPC_NO_FLOOD))
+
+ mod = message.port_mod()
+ mod.port_no = tport.port_no
+ mod.hw_addr = tport.hw_addr
+ mod.config = tport.config ^ ofp.OFPPC_NO_FLOOD
+ mod.mask = ofp.OFPPC_NO_FLOOD
+ mod.advertise = tport.advertised
+ #basic_logger.debug(mod.show())
+ rv = self.controller.message_send(mod)
+ self.assertTrue(rv != -1, "Error sending port mod")
+
+ # Verify change took place with same feature request
+ request.header.xid = 0 # Force new XID
+ reply2, pkt = self.controller.transact(request, timeout=2)
+ self.assertTrue(reply2 is not None, "Did not get response ftr req2")
+ #basic_logger.debug(reply2.show())
+ self.assertTrue(reply2.ports[0].port_no == tport.port_no,
+ "Feature reply port order changed; unhandled")
+ self.assertTrue(reply2.ports[0].config & ofp.OFPPC_NO_FLOOD !=
+ tport.config & ofp.OFPPC_NO_FLOOD,
+ "Bit change did not take")
+ # Set it back
+ mod.config ^= ofp.OFPPC_NO_FLOOD
+ rv = self.controller.message_send(mod)
+ self.assertTrue(rv != -1, "Error sending port mod2")
+
if __name__ == "__main__":
print "Please run through oft script: ./oft --test_spec=basic"