-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chassis] Modify the show ip route to hide the Ethernet-IB port in th…
…e output (#3537) * update show ip route for voq chassis Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com> * add UT * add more UT * Fix linter errors * fix UT * make linter happy --------- Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
- Loading branch information
Showing
11 changed files
with
698 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import os | ||
from importlib import reload | ||
import pytest | ||
from unittest import mock | ||
|
||
import show.main as show | ||
from . import show_ip_route_common | ||
import utilities_common.multi_asic as multi_asic_util | ||
from click.testing import CliRunner | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
scripts_path = os.path.join(modules_path, "scripts") | ||
|
||
|
||
class TestMultiAsicVoqLcShowIpRouteDisplayAllCommands(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "2" | ||
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" | ||
from .mock_tables import mock_multi_asic | ||
reload(mock_multi_asic) | ||
from .mock_tables import dbconnector | ||
dbconnector.load_namespace_config() | ||
|
||
@pytest.mark.parametrize('setup_multi_asic_bgp_instance', | ||
['ip_route_lc'], indirect=['setup_multi_asic_bgp_instance']) | ||
@mock.patch("sonic_py_common.device_info.is_voq_chassis", mock.MagicMock(return_value=True)) | ||
def test_voq_chassis_lc( | ||
self, | ||
setup_ip_route_commands, | ||
setup_multi_asic_bgp_instance): | ||
|
||
runner = CliRunner() | ||
result = runner.invoke( | ||
show.cli.commands["ip"].commands["route"], ["-dfrontend"]) | ||
print("{}".format(result.output)) | ||
assert result.exit_code == 0 | ||
assert result.output == show_ip_route_common.SHOW_IP_ROUTE_LC | ||
|
||
@pytest.mark.parametrize('setup_multi_asic_bgp_instance', | ||
['ip_route_remote_lc'], indirect=['setup_multi_asic_bgp_instance']) | ||
@mock.patch("sonic_py_common.device_info.is_voq_chassis", mock.MagicMock(return_value=True)) | ||
def test_voq_chassis_remote_lc( | ||
self, | ||
setup_ip_route_commands, | ||
setup_multi_asic_bgp_instance): | ||
|
||
runner = CliRunner() | ||
result = runner.invoke( | ||
show.cli.commands["ip"].commands["route"], ["-dfrontend"]) | ||
print("{}".format(result.output)) | ||
assert result.exit_code == 0 | ||
assert result.output == show_ip_route_common.SHOW_IP_ROUTE_REMOTE_LC | ||
|
||
@pytest.mark.parametrize('setup_multi_asic_bgp_instance', | ||
['ip_route_lc'], indirect=['setup_multi_asic_bgp_instance']) | ||
@mock.patch("sonic_py_common.device_info.is_voq_chassis", mock.MagicMock(return_value=True)) | ||
def test_voq_chassis_lc_def_route( | ||
self, | ||
setup_ip_route_commands, | ||
setup_multi_asic_bgp_instance): | ||
|
||
runner = CliRunner() | ||
result = runner.invoke( | ||
show.cli.commands["ip"].commands["route"], ["0.0.0.0/0"]) | ||
print("{}".format(result.output)) | ||
assert result.exit_code == 0 | ||
assert result.output == show_ip_route_common.SHOW_IP_ROUTE_LC_DEFAULT_ROUTE | ||
|
||
@pytest.mark.parametrize('setup_multi_asic_bgp_instance', | ||
['ip_route_remote_lc'], indirect=['setup_multi_asic_bgp_instance']) | ||
@mock.patch("sonic_py_common.device_info.is_voq_chassis", mock.MagicMock(return_value=True)) | ||
def test_voq_chassis_remote_lc_default_route( | ||
self, | ||
setup_ip_route_commands, | ||
setup_multi_asic_bgp_instance): | ||
|
||
runner = CliRunner() | ||
result = runner.invoke( | ||
show.cli.commands["ip"].commands["route"], ["0.0.0.0/0"]) | ||
print("{}".format(result.output)) | ||
assert result.exit_code == 0 | ||
assert result.output == show_ip_route_common.SHOW_IP_ROUTE_REMOTE_LC_DEFAULT_ROUTE | ||
|
||
@pytest.mark.parametrize('setup_multi_asic_bgp_instance', | ||
['ip_route_lc_2'], indirect=['setup_multi_asic_bgp_instance']) | ||
@mock.patch("sonic_py_common.device_info.is_voq_chassis", mock.MagicMock(return_value=True)) | ||
@mock.patch.object(multi_asic_util.MultiAsic, "get_ns_list_based_on_options", | ||
mock.MagicMock(return_value=["asic0", "asic1"])) | ||
def test_voq_chassis_lc_def_route_2( | ||
self, | ||
setup_ip_route_commands, | ||
setup_multi_asic_bgp_instance): | ||
|
||
runner = CliRunner() | ||
result = runner.invoke( | ||
show.cli.commands["ip"].commands["route"], ["0.0.0.0/0"]) | ||
print("{}".format(result.output)) | ||
assert result.exit_code == 0 | ||
assert result.output == show_ip_route_common.SHOW_IP_ROUTE_LC_DEFAULT_ROUTE_2 | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") | ||
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) | ||
os.environ["UTILITIES_UNIT_TESTING"] = "0" | ||
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "" | ||
from .mock_tables import mock_single_asic | ||
reload(mock_single_asic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"0.0.0.0/0": [ | ||
{ | ||
"prefix": "0.0.0.0/0", | ||
"prefixLen": 0, | ||
"protocol": "bgp", | ||
"vrfId": 0, | ||
"vrfName": "default", | ||
"selected": true, | ||
"destSelected": true, | ||
"distance": 20, | ||
"metric": 0, | ||
"installed": true, | ||
"table": 254, | ||
"internalStatus": 16, | ||
"internalFlags": 8, | ||
"internalNextHopNum": 4, | ||
"internalNextHopActiveNum": 4, | ||
"nexthopGroupId": 566, | ||
"installedNexthopGroupId": 566, | ||
"uptime": "04w0d11h", | ||
"nexthops": [ | ||
{ | ||
"flags": 3, | ||
"fib": true, | ||
"ip": "20.1.0.128", | ||
"afi": "ipv4", | ||
"interfaceIndex": 2, | ||
"interfaceName": "PortChannel1", | ||
"active": true, | ||
"weight": 1 | ||
}, | ||
{ | ||
"flags": 3, | ||
"fib": true, | ||
"ip": "20.1.8.128", | ||
"afi": "ipv4", | ||
"interfaceIndex": 4, | ||
"interfaceName": "PortChannel5", | ||
"active": true, | ||
"weight": 1 | ||
}, | ||
{ | ||
"flags": 3, | ||
"fib": true, | ||
"ip": "20.1.16.128", | ||
"afi": "ipv4", | ||
"interfaceIndex": 5, | ||
"interfaceName": "PortChannel9", | ||
"active": true, | ||
"weight": 1 | ||
}, | ||
{ | ||
"flags": 3, | ||
"fib": true, | ||
"ip": "20.1.24.128", | ||
"afi": "ipv4", | ||
"interfaceIndex": 3, | ||
"interfaceName": "PortChannel13", | ||
"active": true, | ||
"weight": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"0.0.0.0/0": [ | ||
{ | ||
"prefix": "0.0.0.0/0", | ||
"prefixLen": 0, | ||
"protocol": "bgp", | ||
"vrfId": 0, | ||
"vrfName": "default", | ||
"selected": true, | ||
"destSelected": true, | ||
"distance": 20, | ||
"metric": 0, | ||
"installed": true, | ||
"table": 254, | ||
"internalStatus": 16, | ||
"internalFlags": 9, | ||
"internalNextHopNum": 3, | ||
"internalNextHopActiveNum": 3, | ||
"nexthopGroupId": 2122, | ||
"installedNexthopGroupId": 2122, | ||
"uptime": "01:01:51", | ||
"nexthops": [ | ||
{ | ||
"flags": 3, | ||
"fib": true, | ||
"ip": "10.0.0.1", | ||
"afi": "ipv4", | ||
"interfaceIndex": 29, | ||
"interfaceName": "PortChannel102", | ||
"active": true, | ||
"weight": 1 | ||
}, | ||
{ | ||
"flags": 5, | ||
"ip": "10.0.0.7", | ||
"afi": "ipv4", | ||
"active": true, | ||
"recursive": true, | ||
"weight": 1 | ||
}, | ||
{ | ||
"flags": 11, | ||
"fib": true, | ||
"ip": "10.0.0.7", | ||
"afi": "ipv4", | ||
"interfaceIndex": 52, | ||
"interfaceName": "Ethernet-IB0", | ||
"resolver": true, | ||
"active": true, | ||
"onLink": true, | ||
"weight": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.