Skip to content

Commit 97a340b

Browse files
authored
bugfix[2024] vnet route check exit code fix. (#2480)
* Fix for the incorrect return value and added a test.
1 parent d1ca2cd commit 97a340b

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

scripts/vnet_route_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ def main():
393393
rc = RC_ERR
394394
print_message(syslog.LOG_ERR, json.dumps(res, indent=4))
395395
print_message(syslog.LOG_ERR, 'Vnet Route Mismatch reported')
396-
397-
return rc, res
396+
return rc, res
397+
return rc
398398

399399

400400
if __name__ == "__main__":

tests/vnet_route_check_test.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
CNTR_DB: {
7373
"COUNTERS_RIF_NAME_MAP": { "Vlan3001": "oid:0x6000000000d76" }
7474
}
75-
},
76-
RESULT: {
77-
"results": {}
7875
}
7976
},
8077
"1": {
@@ -253,9 +250,6 @@
253250
RT_ENTRY_KEY_PREFIX + "fd01:fc00::1/128" + RT_ENTRY_KEY_SUFFIX: {}
254251
}
255252
}
256-
},
257-
RESULT: {
258-
"results": {}
259253
}
260254
},
261255
"5": {
@@ -293,6 +287,24 @@
293287
}
294288
}
295289
}
290+
},
291+
"6": {
292+
DESCR: "Only Vxlan tunnel configured, No routes.",
293+
ARGS: "vnet_route_check",
294+
PRE: {
295+
APPL_DB: {
296+
VXLAN_TUNNEL_TABLE: {
297+
"tunnel_v4": { "src_ip": "10.1.0.32" }
298+
},
299+
VNET_TABLE: {
300+
"Vnet1": { "vxlan_tunnel": "tunnel_v4", "vni": "10001" }
301+
},
302+
INTF_TABLE: {
303+
"Vlan3001": { "vnet_name": "Vnet1" },
304+
"Vlan3001:30.1.10.1/24": {}
305+
},
306+
},
307+
}
296308
}
297309
}
298310

@@ -384,9 +396,15 @@ def test_vnet_route_check(self, mock_table, mock_conn):
384396
do_start_test("route_test", i, ct_data)
385397

386398
with patch('sys.argv', ct_data[ARGS].split()):
387-
ret, res = vnet_route_check.main()
388399
expect_ret = ct_data[RET] if RET in ct_data else 0
389400
expect_res = ct_data[RESULT] if RESULT in ct_data else None
401+
res = None
402+
if expect_ret == 0:
403+
ret = vnet_route_check.main()
404+
if ret != 0:
405+
ret, res = vnet_route_check.main()
406+
else:
407+
ret, res = vnet_route_check.main()
390408
if res:
391409
print("res={}".format(json.dumps(res, indent=4)))
392410
if expect_res:

0 commit comments

Comments
 (0)