blob: 1fe05ee47da1a11b6f083db935982a2e2871fcc5 [file] [log] [blame]
Rich Laneea873262013-01-11 08:15:55 -08001'''
2Created on Jan 27, 2011
3
4@author: capveg
5'''
6
7import logging
8
9import ofp
10from oftest import config
11import oftest.oft12.testutils as testutils
12import oftest.base_tests as base_tests
13
14class FlowMod_ModifyStrict(base_tests.SimpleProtocol):
15 """ Simple FlowMod Modify test
16 delete all flows in the table
17 insert an exact match flow_mod sending to port[1]
18 then swap the output action from port[1] to port[2]
19 then get flow_stats
20 assert that the new actions are in place
21 """
22 def runTest(self):
23 ing_port = config["port_map"].keys()[0]
24 out_port1 = config["port_map"].keys()[1]
25 out_port2 = config["port_map"].keys()[2]
26 pkt = testutils.simple_tcp_packet()
27 testutils.delete_all_flows(self.controller, logging)
28 fm_orig = testutils.flow_msg_create(self, pkt,
29 ing_port=ing_port,
30 egr_port=out_port1)
31 fm_new = testutils.flow_msg_create(self, pkt,
32 ing_port=ing_port,
33 egr_port=out_port2)
34 fm_new.command = ofp.OFPFC_MODIFY_STRICT
35 rv = self.controller.message_send(fm_orig)
36 self.assertEqual(rv, 0, "Failed to insert 1st flow_mod")
37 testutils.do_barrier(self.controller)
38 rv = self.controller.message_send(fm_new)
39 testutils.do_barrier(self.controller)
40 self.assertEqual(rv, 0, "Failed to insert 2nd flow_mod")
41 flow_stats = testutils.flow_stats_get(self)
42 self.assertEqual(len(flow_stats.stats),1,
43 "Expected only one flow_mod")
44 stat = flow_stats.stats[0]
45 self.assertEqual(stat.match, fm_new.match)
ederlffdedc072013-01-18 09:32:00 -020046 self.assertEqual(stat.match_fields, fm_new.match_fields)
Rich Laneea873262013-01-11 08:15:55 -080047 self.assertEqual(stat.instructions, fm_new.instructions)
48 # @todo consider adding more tests here
49
50
51if __name__ == "__main__":
52 print "Please run through oft script: ./oft --test_spec=flow_mods"