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

route_check: Skip route checks if bgp feature is not enabled #3075

Merged
merged 6 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions scripts/route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ def filter_out_standalone_tunnel_routes(namespace, routes):

return updated_routes

def is_feature_bgp_enabled(namespace):
"""
Check if bgp feature is enabled or disabled.
Return True if enabled else False.
"""
cfg_db = multi_asic.connect_config_db_for_ns(namespace)
feature_table = cfg_db.get_table("FEATURE")
bgp_enabled = False
if 'bgp' in feature_table:
if feature_table['bgp']["state"] == "enabled":
bgp_enabled = True
return bgp_enabled

def check_frr_pending_routes(namespace):
"""
Expand Down Expand Up @@ -765,12 +777,13 @@ def check_routes(namespace):
results[namespace] = {}
results[namespace]["Unaccounted_ROUTE_ENTRY_TABLE_entries"] = rt_asic_miss

rt_frr_miss = check_frr_pending_routes(namespace)
if is_feature_bgp_enabled(namespace):
rt_frr_miss = check_frr_pending_routes(namespace)

if rt_frr_miss:
if namespace not in results:
results[namespace] = {}
results[namespace]["missed_FRR_routes"] = rt_frr_miss
if rt_frr_miss:
if namespace not in results:
results[namespace] = {}
results[namespace]["missed_FRR_routes"] = rt_frr_miss

if results:
if rt_frr_miss and not rt_appl_miss and not rt_asic_miss:
Expand Down
9 changes: 6 additions & 3 deletions tests/route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ def test_timeout(self, mock_dbs, force_hang):
# Test timeout
ex_raised = False
# Use an expected failing test case to trigger the select
set_test_case_data(TEST_DATA['2'])

ct_data = TEST_DATA['2']
set_test_case_data(ct_data)
try:
with patch('sys.argv', [route_check.__file__.split('/')[-1]]):
with patch('sys.argv', [route_check.__file__.split('/')[-1]]), \
patch('route_check.load_db_config', side_effect=lambda: init_db_conns(ct_data[NAMESPACE])):

ret, res = route_check.main()

except Exception as err:
ex_raised = True
expect = "timeout occurred"
Expand Down
142 changes: 140 additions & 2 deletions tests/route_check_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
VNET_ROUTE_TABLE = 'VNET_ROUTE_TABLE'
INTF_TABLE = 'INTF_TABLE'
RT_ENTRY_TABLE = 'ASIC_STATE'
FEATURE_TABLE = 'FEATURE'
SEPARATOR = ":"
DEVICE_METADATA = "DEVICE_METADATA"
MUX_CABLE = "MUX_CABLE"
Expand All @@ -32,7 +33,17 @@
RT_ENTRY_KEY_PREFIX = 'SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest":\"'
RT_ENTRY_KEY_SUFFIX = '\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000023\"}'

DEFAULT_CONFIG_DB = {DEVICE_METADATA: {LOCALHOST: {}}}
DEFAULT_CONFIG_DB = {
DEVICE_METADATA: {
LOCALHOST: {
}
},
FEATURE_TABLE: {
"bgp": {
"state": "enabled"
}
}
}

TEST_DATA = {
"0": {
Expand Down Expand Up @@ -881,5 +892,132 @@
},
RET: -1,
},

"21": {
DESCR: "basic good one on single asic, bgp disabled",
MULTI_ASIC: False,
NAMESPACE: [''],
ARGS: "route_check -m INFO -i 1000",
PRE: {
DEFAULTNS: {
CONFIG_DB: {
DEVICE_METADATA: {
LOCALHOST: {
}
},
FEATURE_TABLE: {
"bgp": {
"state": "disabled"
}
}
},
APPL_DB: {
ROUTE_TABLE: {
"0.0.0.0/0" : { "ifname": "portchannel0" },
"10.10.196.12/31" : { "ifname": "portchannel0" },
},
INTF_TABLE: {
"PortChannel1013:10.10.196.24/31": {},
"PortChannel1023:2603:10b0:503:df4::5d/126": {},
"PortChannel1024": {}
}
},
ASIC_DB: {
RT_ENTRY_TABLE: {
RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}
}
},
},
},
FRR_ROUTES: {
DEFAULTNS: {
"0.0.0.0/0": [
{
"prefix": "0.0.0.0/0",
"vrfName": "default",
"protocol": "bgp",
"offloaded": "true",
},
],
"10.10.196.12/31": [
{
"prefix": "10.10.196.12/31",
"vrfName": "default",
"protocol": "bgp",
},
],
"10.10.196.24/31": [
{
"protocol": "connected",
},
],
},
},
},
"22": {
DESCR: "basic good one on multi-asic, bgp disabled",
MULTI_ASIC: True,
NAMESPACE: ['asic0'],
ARGS: "route_check -m INFO -i 1000",
PRE: {
ASIC0: {
CONFIG_DB: {
DEVICE_METADATA: {
LOCALHOST: {
}
},
FEATURE_TABLE: {
"bgp": {
"state": "disabled"
}
}
},
APPL_DB: {
ROUTE_TABLE: {
"0.0.0.0/0" : { "ifname": "portchannel0" },
"10.10.196.12/31" : { "ifname": "portchannel0" },
},
INTF_TABLE: {
"PortChannel1013:10.10.196.24/31": {},
"PortChannel1023:2603:10b0:503:df4::5d/126": {},
"PortChannel1024": {}
}
},
ASIC_DB: {
RT_ENTRY_TABLE: {
RT_ENTRY_KEY_PREFIX + "10.10.196.12/31" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "10.10.196.24/32" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "2603:10b0:503:df4::5d/128" + RT_ENTRY_KEY_SUFFIX: {},
RT_ENTRY_KEY_PREFIX + "0.0.0.0/0" + RT_ENTRY_KEY_SUFFIX: {}
}
},
},
},
FRR_ROUTES: {
ASIC0: {
"0.0.0.0/0": [
{
"prefix": "0.0.0.0/0",
"vrfName": "default",
"protocol": "bgp",
"offloaded": "true",
},
],
"10.10.196.12/31": [
{
"prefix": "10.10.196.12/31",
"vrfName": "default",
"protocol": "bgp",
},
],
"10.10.196.24/31": [
{
"protocol": "connected",
},
],
},
},
},
}
Loading