From bca657ed42ecd4ce6c32cdadce18627fc1dababa Mon Sep 17 00:00:00 2001 From: Tony van der Peet Date: Thu, 21 Nov 2013 13:31:35 +1300 Subject: [PATCH 1/3] Change packet tests to send 10 packets instead of 1. This will test that flows in the datapath will correctly forward packets. --- src/python/oftest/testutils.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py index 743e4e703..be0eb6635 100644 --- a/src/python/oftest/testutils.py +++ b/src/python/oftest/testutils.py @@ -797,7 +797,7 @@ def flow_msg_install(parent, request, clear_table_override=None): def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None, vlan_vid=-1, pkt=None, exp_pkt=None, - action_list=None): + action_list=None, send_reps=10): """ Flow match test on single TCP packet @param egr_ports A single port or list of ports @@ -822,16 +822,17 @@ def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None, flow_msg_install(parent, request) - logging.debug("Send packet: " + str(ing_port) + " to " + + logging.debug("Send " + str(send_reps) + " packet: " + str(ing_port) + " to " + str(egr_ports)) - parent.dataplane.send(ing_port, str(pkt)) + for i in range(send_reps): + parent.dataplane.send(ing_port, str(pkt)) - exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] - verify_packets(parent, exp_pkt, exp_ports) + exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] + verify_packets(parent, exp_pkt, exp_ports) def flow_match_test_pktout(parent, ing_port, egr_ports, vlan_vid=-1, pkt=None, exp_pkt=None, - action_list=None): + action_list=None, send_reps=10): """ Packet-out test on single TCP packet @param egr_ports A single port or list of ports @@ -862,10 +863,11 @@ def flow_match_test_pktout(parent, ing_port, egr_ports, msg.actions.append(act) logging.debug(msg.show()) - parent.controller.message_send(msg) + for i in range(send_reps): + parent.controller.message_send(msg) - exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] - verify_packets(parent, exp_pkt, exp_ports) + exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] + verify_packets(parent, exp_pkt, exp_ports) def get_egr_list(parent, of_ports, how_many, exclude_list=[]): """ @@ -893,7 +895,7 @@ def get_egr_list(parent, of_ports, how_many, exclude_list=[]): def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, exp_pkt=None, action_list=None, - max_test=0, egr_count=1, ing_port=False): + max_test=0, egr_count=1, ing_port=False, send_reps=10): """ Run flow_match_test_port_pair on all port pairs and packet-out @@ -929,7 +931,7 @@ def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, flow_match_test_port_pair(parent, ingress_port, egr_ports, wildcards=wildcards, vlan_vid=vlan_vid, pkt=pkt, exp_pkt=exp_pkt, - action_list=action_list) + action_list=action_list, send_reps=send_reps) test_count += 1 if (max_test > 0) and (test_count > max_test): logging.info("Ran " + str(test_count) + " tests; exiting") @@ -946,7 +948,7 @@ def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, flow_match_test_pktout(parent, ingress_port, egr_ports, vlan_vid=vlan_vid, pkt=pkt, exp_pkt=exp_pkt, - action_list=action_list) + action_list=action_list, send_reps=send_reps) def test_param_get(key, default=None): """ From 52c5406cd9c9630c15037a9abbbdd4fc40afc317 Mon Sep 17 00:00:00 2001 From: Tony van der Peet Date: Thu, 28 Apr 2016 13:19:01 +1200 Subject: [PATCH 2/3] Fix flow_expire.FlowExpire and flow_stats.SingleFlowStats Both tests have the same fix, which is to to wildcard the match against PCP which is required because there's no VLAN tag in the packet. --- tests/flow_expire.py | 1 + tests/flow_stats.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/flow_expire.py b/tests/flow_expire.py index ccbad2068..409f1b422 100644 --- a/tests/flow_expire.py +++ b/tests/flow_expire.py @@ -40,6 +40,7 @@ def runTest(self): pkt = simple_tcp_packet() match = packet_to_flow_match(self, pkt) match.wildcards &= ~ofp.OFPFW_IN_PORT + match.wildcards |= ofp.OFPFW_DL_VLAN_PCP self.assertTrue(match is not None, "Could not generate flow match from pkt") act = ofp.action.output() diff --git a/tests/flow_stats.py b/tests/flow_stats.py index 772be6854..06cd0bd2c 100644 --- a/tests/flow_stats.py +++ b/tests/flow_stats.py @@ -119,6 +119,7 @@ def runTest(self): pkt = simple_tcp_packet() match = packet_to_flow_match(self, pkt) match.wildcards &= ~ofp.OFPFW_IN_PORT + match.wildcards |= ofp.OFPFW_DL_VLAN_PCP self.assertTrue(match is not None, "Could not generate flow match from pkt") act = ofp.action.output() From 5d87519e9adc664184ec27ccce205950b13801f6 Mon Sep 17 00:00:00 2001 From: Tony van der Peet Date: Thu, 28 Apr 2016 13:36:23 +1200 Subject: [PATCH 3/3] Revert "Change packet tests to send 10 packets instead of 1. This will test that" This reverts commit bca657ed42ecd4ce6c32cdadce18627fc1dababa. --- src/python/oftest/testutils.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py index 893141fdd..f9601a9d7 100644 --- a/src/python/oftest/testutils.py +++ b/src/python/oftest/testutils.py @@ -802,7 +802,7 @@ def flow_msg_install(parent, request, clear_table_override=None): def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None, vlan_vid=-1, pkt=None, exp_pkt=None, - action_list=None, send_reps=10): + action_list=None): """ Flow match test on single TCP packet @param egr_ports A single port or list of ports @@ -827,17 +827,16 @@ def flow_match_test_port_pair(parent, ing_port, egr_ports, wildcards=None, flow_msg_install(parent, request) - logging.debug("Send " + str(send_reps) + " packet: " + str(ing_port) + " to " + + logging.debug("Send packet: " + str(ing_port) + " to " + str(egr_ports)) - for i in range(send_reps): - parent.dataplane.send(ing_port, str(pkt)) + parent.dataplane.send(ing_port, str(pkt)) - exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] - verify_packets(parent, exp_pkt, exp_ports) + exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] + verify_packets(parent, exp_pkt, exp_ports) def flow_match_test_pktout(parent, ing_port, egr_ports, vlan_vid=-1, pkt=None, exp_pkt=None, - action_list=None, send_reps=10): + action_list=None): """ Packet-out test on single TCP packet @param egr_ports A single port or list of ports @@ -868,11 +867,10 @@ def flow_match_test_pktout(parent, ing_port, egr_ports, msg.actions.append(act) logging.debug(msg.show()) - for i in range(send_reps): - parent.controller.message_send(msg) + parent.controller.message_send(msg) - exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] - verify_packets(parent, exp_pkt, exp_ports) + exp_ports = [ing_port if port == ofp.OFPP_IN_PORT else port for port in egr_ports] + verify_packets(parent, exp_pkt, exp_ports) def get_egr_list(parent, of_ports, how_many, exclude_list=[]): """ @@ -900,7 +898,7 @@ def get_egr_list(parent, of_ports, how_many, exclude_list=[]): def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, exp_pkt=None, action_list=None, - max_test=0, egr_count=1, ing_port=False, send_reps=10): + max_test=0, egr_count=1, ing_port=False): """ Run flow_match_test_port_pair on all port pairs and packet-out @@ -936,7 +934,7 @@ def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, flow_match_test_port_pair(parent, ingress_port, egr_ports, wildcards=wildcards, vlan_vid=vlan_vid, pkt=pkt, exp_pkt=exp_pkt, - action_list=action_list, send_reps=send_reps) + action_list=action_list) test_count += 1 if (max_test > 0) and (test_count > max_test): logging.info("Ran " + str(test_count) + " tests; exiting") @@ -953,7 +951,7 @@ def flow_match_test(parent, port_map, wildcards=None, vlan_vid=-1, pkt=None, flow_match_test_pktout(parent, ingress_port, egr_ports, vlan_vid=vlan_vid, pkt=pkt, exp_pkt=exp_pkt, - action_list=action_list, send_reps=send_reps) + action_list=action_list) def test_param_get(key, default=None): """