From 45cfb2495f2fade4ab903b240bafb0b853549069 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 15 Oct 2021 11:42:06 -0400 Subject: [PATCH 1/2] lib: Add `metric-type` to possible set operations Several tests used the route_map_create functionality with `metric-type` but never bothered to add the backend code to ensure it works correctly. Add it in so it can be used. Signed-off-by: Donald Sharp --- tests/topotests/lib/common_config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index 1bce3c6bb2..cf8efdea16 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -2552,6 +2552,7 @@ def create_route_maps(tgen, input_dict, build=False): nexthop = set_data.setdefault("nexthop", None) origin = set_data.setdefault("origin", None) ext_comm_list = set_data.setdefault("extcommunity", {}) + metrictype = set_data.setdefault("metric-type", {}) # Local Preference if local_preference: @@ -2559,6 +2560,10 @@ def create_route_maps(tgen, input_dict, build=False): "set local-preference {}".format(local_preference) ) + # Metric-Type + if metrictype: + rmap_data.append("set metric-type {}\n".format(metrictype)) + # Metric if metric: rmap_data.append("set metric {} \n".format(metric)) From 6862166ed513f16e1f6cb59d604a08b03d7a87f5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 15 Oct 2021 11:43:44 -0400 Subject: [PATCH 2/2] tests: Fix ospf_asbr_summary_topo1.py This script is failing occassionally in our upstream topotests. Where it was changing route-maps and attempting to see if summarization was working correctly. The problem was that the code appeared to be attempting to add route-maps to redistribution in ospf then modifying the route-maps behavior to affect summarization as well as the metric type of that summarization. The problem is of course that ospf does not appear to modify the summary routes metric-type when the components of that summary change it's metric-type. So the test is testing nothing. In addition the test had messed up the usage of the route-map generation code and all the generated config was in different sequence numbers but route-map processing would never get to those new sequence numbers because of how route-maps are processed. Let's just remove this part of the test instead of trying to unwind it into anything meaningfull Signed-off-by: Donald Sharp --- .../test_ospf_asbr_summary_topo1.py | 83 ------------------- 1 file changed, 83 deletions(-) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py index 64dfa0c69d..f9fa55e275 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_asbr_summary_topo1.py @@ -669,89 +669,6 @@ def test_ospf_type5_summary_tc48_p0(request): result is True ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) - step("Configure metric type as 1 in route map.") - - routemaps = { - "r0": { - "route_maps": { - "rmap_ipv4": [{"action": "permit", "set": {"metric-type": "type-1"}}] - } - } - } - result = create_route_maps(tgen, routemaps) - assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - - step( - "Verify that external routes(static / connected) are summarised" - " to configured summary address with metric type 2." - ) - input_dict = { - SUMMARY["ipv4"][0]: { - "Summary address": SUMMARY["ipv4"][0], - "Metric-type": "E2", - "Metric": 20, - "Tag": 0, - "External route count": 5, - } - } - dut = "r0" - result = verify_ospf_summary(tgen, topo, dut, input_dict) - assert ( - result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) - - step("Un configure metric type from route map.") - - routemaps = { - "r0": { - "route_maps": { - "rmap_ipv4": [ - { - "action": "permit", - "set": {"metric-type": "type-1"}, - "delete": True, - } - ] - } - } - } - result = create_route_maps(tgen, routemaps) - assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - - step( - "Verify that external routes(static / connected) are summarised" - " to configured summary address with metric type 2." - ) - input_dict = { - SUMMARY["ipv4"][0]: { - "Summary address": SUMMARY["ipv4"][0], - "Metric-type": "E2", - "Metric": 20, - "Tag": 0, - "External route count": 5, - } - } - dut = "r0" - result = verify_ospf_summary(tgen, topo, dut, input_dict) - assert ( - result is True - ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name) - - step("Change rule from permit to deny in prefix list.") - pfx_list = { - "r0": { - "prefix_lists": { - "ipv4": { - "pf_list_1_ipv4": [ - {"seqid": 10, "network": "any", "action": "deny"} - ] - } - } - } - } - result = create_prefix_lists(tgen, pfx_list) - assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - write_test_footer(tc_name)