Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable BFD for Static Route for chassis-packet. #15383

Merged
merged 13 commits into from
Jul 7, 2023
3 changes: 3 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,9 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
port['mux_cable'] = "true"

if static_routes:
# Enable static Route BFD by default for static route in chassis-packet
if switch_type == "chassis-packet":
static_routes['bfd'] = "true"
Copy link
Contributor

@baorliu baorliu Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UT failed.
It can pass UT test_minigraph_bgp_packet_chassis_static_route output comparison if changed to the following code

        # Enable static Route BFD by default for static route in chassis-packet
        if switch_type == "chassis-packet":
            for static_route in static_routes:
                static_route['bfd'] = "true"

but see the following errors with the above fix:

======================================================================
ERROR: test_minigraph_bgp_packet_chassis_peer (tests.test_cfggen.TestCfgGen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 990, in test_minigraph_bgp_packet_chassis_peer
    output = self.run_script(argument)
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 66, in run_script
    output = subprocess.check_output(self.script_file + ' ' + argument, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command 'python2 /sonic/src/sonic-config-engine/tests/../sonic-cfggen -m "/sonic/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml" -p "/sonic/src/sonic-config-engine/tests/sample-chassis-packet-lc-port-config.ini" -n "asic1" -v "BGP_INTERNAL_NEIGHBOR['8.0.0.1']"' returned non-zero exit status 1

======================================================================
ERROR: test_minigraph_bgp_packet_chassis_static_route (tests.test_cfggen.TestCfgGen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 998, in test_minigraph_bgp_packet_chassis_static_route
    output = self.run_script(argument)
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 66, in run_script
    output = subprocess.check_output(self.script_file + ' ' + argument, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command 'python2 /sonic/src/sonic-config-engine/tests/../sonic-cfggen -m "/sonic/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml" -p "/sonic/src/sonic-config-engine/tests/sample-chassis-packet-lc-port-config.ini" -v "STATIC_ROUTE"' returned non-zero exit status 1

results['STATIC_ROUTE'] = static_routes

for nghbr in list(neighbors.keys()):
Expand Down
4 changes: 2 additions & 2 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,14 +1011,14 @@ def test_minigraph_bgp_packet_chassis_static_route(self):
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}")
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false', 'bfd':'true'}}")
)

argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-n', "asic1", '-v', "STATIC_ROUTE"]
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}")
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false', 'bfd':'true'}}")
)

def test_minigraph_bgp_packet_chassis_vlan_subintf(self):
Expand Down