summaryrefslogtreecommitdiff
path: root/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2021-05-12 18:54:11 +0200
committerLouis Scalbert <louis.scalbert@6wind.com>2021-06-08 10:47:35 +0200
commit96c81f66717110e0bf77f5dfa043d9862896d495 (patch)
treeeec49df4b47854241d5401ddcb18a3fd403cb9b5 /tests/topotests/all_protocol_startup/test_all_protocol_startup.py
parentce1944f06a4bd09458f496bf4fc9528b61115e92 (diff)
bgpd: add terse display option on show bgp summary
Add a terse option to show bgp summary to shorten output. Do not show the following information about the BGP instances: the number of RIB entries, the table version and the used memory. The "terse" option can be used in combination with the "remote-as", "neighbor", "failed" and "established" filters, and with the "wide" option as well. Before patch: ubuntu# show bgp summary remote-as 123456 IPv4 Unicast Summary (VRF default): BGP router identifier X.X.X.X, local AS number XXX vrf-id 0 BGP table version 0 RIB entries 3, using 552 bytes of memory Peers 5, using 3635 KiB of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 10.200.200.2 4 123456 81432 4 0 56092 0 00:00:13 572106 0 N/A Displayed neighbors 1 Total number of neighbors 4 IPv6 Unicast Summary (VRF default): BGP router identifier X.X.X.X, local AS number XXX vrf-id 0 BGP table version 0 RIB entries 3, using 552 bytes of memory Peers 5, using 3635 KiB of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc % No matching neighbor Total number of neighbors 5 After patch: ubuntu# show bgp summary remote-as 123456 terse IPv4 Unicast Summary (VRF default): BGP router identifier X.X.X.X, local AS number XXX vrf-id 0 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 10.200.200.2 4 123456 81432 4 0 56092 0 00:00:13 572106 0 N/A Displayed neighbors 1 Total number of neighbors 4 IPv6 Unicast Summary (VRF default): BGP router identifier X.X.X.X, local AS number XXX vrf-id 1 % No matching neighbor Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'tests/topotests/all_protocol_startup/test_all_protocol_startup.py')
-rw-r--r--tests/topotests/all_protocol_startup/test_all_protocol_startup.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
index dea054b8bc..2d75428f1a 100644
--- a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
+++ b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
@@ -906,17 +906,25 @@ def test_bgp_summary():
# Read expected result from file
expected_original = open(refTableFile).read().rstrip()
- for filter in ["", "remote-as internal", "remote-as external",
+ for arguments in ["", "remote-as internal", "remote-as external",
"remote-as 100", "remote-as 123",
"neighbor 192.168.7.10", "neighbor 192.168.7.10",
"neighbor fc00:0:0:8::1000",
- "neighbor 10.0.0.1"]:
+ "neighbor 10.0.0.1",
+ "terse",
+ "remote-as internal terse",
+ "remote-as external terse",
+ "remote-as 100 terse", "remote-as 123 terse",
+ "neighbor 192.168.7.10 terse", "neighbor 192.168.7.10 terse",
+ "neighbor fc00:0:0:8::1000 terse",
+ "neighbor 10.0.0.1 terse"]:
# Actual output from router
actual = (
net["r%s" % i]
- .cmd('vtysh -c "show ip bgp summary ' + filter + '" 2> /dev/null')
+ .cmd('vtysh -c "show ip bgp summary ' + arguments + '" 2> /dev/null')
.rstrip()
)
+
# Mask out "using XXiXX bytes" portion. They are random...
actual = re.sub(r"using [0-9]+ bytes", "using XXXX bytes", actual)
# Mask out "using XiXXX KiB" portion. They are random...
@@ -948,30 +956,36 @@ def test_bgp_summary():
)
expected = expected_original
- # apply filters on expected output
- if "internal" in filter or "remote-as 100" in filter:
+ # apply argumentss on expected output
+ if "internal" in arguments or "remote-as 100" in arguments:
expected = re.sub(r".+\s+200\s+.+", "", expected)
- elif "external" in filter:
+ elif "external" in arguments:
expected = re.sub(r".+\s+100\s+.+Active.+", "", expected)
- elif "remote-as 123" in filter:
+ elif "remote-as 123" in arguments:
expected = re.sub(
r"(192.168.7.(1|2)0|fc00:0:0:8::(1|2)000).+Active.+",
"", expected
)
+ expected = re.sub(r"\nNeighbor.+Desc", "", expected)
expected = expected + "% No matching neighbor\n"
- elif "192.168.7.10" in filter:
+ elif "192.168.7.10" in arguments:
expected = re.sub(
r"(192.168.7.20|fc00:0:0:8::(1|2)000).+Active.+",
"", expected
)
- elif "fc00:0:0:8::1000" in filter:
+ elif "fc00:0:0:8::1000" in arguments:
expected = re.sub(
r"(192.168.7.(1|2)0|fc00:0:0:8::2000).+Active.+",
"", expected
)
- elif "10.0.0.1" in filter:
+ elif "10.0.0.1" in arguments:
expected = "No such neighbor in VRF default"
+ if "terse" in arguments:
+ expected = re.sub(r"BGP table version .+", "", expected)
+ expected = re.sub(r"RIB entries .+", "", expected)
+ expected = re.sub(r"Peers [0-9]+, using .+", "", expected)
+
# Strip empty lines
actual = actual.lstrip().rstrip()
expected = expected.lstrip().rstrip()
@@ -979,13 +993,17 @@ def test_bgp_summary():
expected = re.sub(r"\n+", "\n", expected)
# reapply initial formatting
- actual = re.sub(r"KiB of memory\n", "KiB of memory\n\n", actual)
- expected = re.sub(r"KiB of memory\n", "KiB of memory\n\n", expected)
+ if "terse" in arguments:
+ actual = re.sub(r" vrf-id 0\n", " vrf-id 0\n\n", actual)
+ expected = re.sub(r" vrf-id 0\n", " vrf-id 0\n\n", expected)
+ else:
+ actual = re.sub(r"KiB of memory\n", "KiB of memory\n\n", actual)
+ expected = re.sub(r"KiB of memory\n", "KiB of memory\n\n", expected)
# realign expected neighbor columns if needed
try:
- idx_actual = re.search(r"\n(Neighbor\s+V\s+)", actual).group(1).find("V")
- idx_expected = re.search(r"\n(Neighbor\s+V\s+)", expected).group(1).find("V")
+ idx_actual = re.search(r"(Neighbor\s+V\s+)", actual).group(1).find("V")
+ idx_expected = re.search(r"(Neighbor\s+V\s+)", expected).group(1).find("V")
idx_diff = idx_expected - idx_actual
if idx_diff > 0:
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
@@ -1003,8 +1021,8 @@ def test_bgp_summary():
diff = topotest.get_textdiff(
actual,
expected,
- title1="actual SHOW IP BGP SUMMARY " + filter.upper() ,
- title2="expected SHOW IP BGP SUMMARY " + filter.upper(),
+ title1="actual SHOW IP BGP SUMMARY " + arguments.upper() ,
+ title2="expected SHOW IP BGP SUMMARY " + arguments.upper(),
)
# Empty string if it matches, otherwise diff contains unified diff