Skip to content

Commit

Permalink
bugfix[2024] vnet route check exit code fix. (#2480)
Browse files Browse the repository at this point in the history
* Fix for the incorrect return value and added a test.
  • Loading branch information
siqbal1986 authored and yxieca committed Nov 29, 2022
1 parent d8c49dc commit 6ed2afb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions scripts/vnet_route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def main():
rc = RC_ERR
print_message(syslog.LOG_ERR, json.dumps(res, indent=4))
print_message(syslog.LOG_ERR, 'Vnet Route Mismatch reported')

return rc, res
return rc, res
return rc


if __name__ == "__main__":
Expand Down
32 changes: 25 additions & 7 deletions tests/vnet_route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
CNTR_DB: {
"COUNTERS_RIF_NAME_MAP": { "Vlan3001": "oid:0x6000000000d76" }
}
},
RESULT: {
"results": {}
}
},
"1": {
Expand Down Expand Up @@ -253,9 +250,6 @@
RT_ENTRY_KEY_PREFIX + "fd01:fc00::1/128" + RT_ENTRY_KEY_SUFFIX: {}
}
}
},
RESULT: {
"results": {}
}
},
"5": {
Expand Down Expand Up @@ -293,6 +287,24 @@
}
}
}
},
"6": {
DESCR: "Only Vxlan tunnel configured, No routes.",
ARGS: "vnet_route_check",
PRE: {
APPL_DB: {
VXLAN_TUNNEL_TABLE: {
"tunnel_v4": { "src_ip": "10.1.0.32" }
},
VNET_TABLE: {
"Vnet1": { "vxlan_tunnel": "tunnel_v4", "vni": "10001" }
},
INTF_TABLE: {
"Vlan3001": { "vnet_name": "Vnet1" },
"Vlan3001:30.1.10.1/24": {}
},
},
}
}
}

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

with patch('sys.argv', ct_data[ARGS].split()):
ret, res = vnet_route_check.main()
expect_ret = ct_data[RET] if RET in ct_data else 0
expect_res = ct_data[RESULT] if RESULT in ct_data else None
res = None
if expect_ret == 0:
ret = vnet_route_check.main()
if ret != 0:
ret, res = vnet_route_check.main()
else:
ret, res = vnet_route_check.main()
if res:
print("res={}".format(json.dumps(res, indent=4)))
if expect_res:
Expand Down

0 comments on commit 6ed2afb

Please sign in to comment.