Skip to content

Commit

Permalink
added 2 tests and fixed a bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahzad Iqbal (SHAHZADIQBAL) authored and Shahzad Iqbal (SHAHZADIQBAL) committed Aug 9, 2022
1 parent fb4d138 commit 757a6b0
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scripts/vnet_route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ def main():
return rc
asic_db = swsscommon.DBConnector('ASIC_DB', 0)
virtual_router = swsscommon.Table(asic_db, 'ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER')
default_vrf_oid = virtual_router.getKeys()[0]
default_vrf_oid = ""
if virtual_router.getKeys() != []:
default_vrf_oid = virtual_router.getKeys()[0]

app_db_vnet_routes = get_vnet_routes_from_app_db(default_vrf_oid)
asic_db_vnet_routes = get_vnet_routes_from_asic_db(default_vrf_oid)
Expand Down
66 changes: 65 additions & 1 deletion tests/vnet_route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
VNET_ROUTE_TABLE = "VNET_ROUTE_TABLE"
INTF_TABLE = "INTF_TABLE"
ASIC_STATE = "ASIC_STATE"

VNET_ROUTE_TUNNEL_TABLE = "VNET_ROUTE_TUNNEL_TABLE"
RT_ENTRY_KEY_PREFIX = 'SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest":\"'
RT_ENTRY_KEY_SUFFIX = '\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x3000000000d4b\"}'

Expand Down Expand Up @@ -223,6 +223,70 @@
}
}
}
},
"4": {
DESCR: "All tunnel routes are configured in both APP and ASIC DB",
ARGS: "vnet_route_check",
PRE: {
APPL_DB: {
VXLAN_TUNNEL_TABLE: {
"tunnel_v4": { "src_ip": "10.1.0.32" }
},
VNET_TABLE: {
"Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10000"), ("peer_list", "")]
},
VNET_ROUTE_TUNNEL_TABLE: {
"Vnet_v4_in_v4-0:150.62.191.1/32" : { "endpoint" : "100.251.7.1,100.251.7.2" }
}
},
ASIC_DB: {
"ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER": {
"oid:0x3000000000d4b" : { "":"" }
},
ASIC_STATE: {
RT_ENTRY_KEY_PREFIX + "150.62.191.1/32" + RT_ENTRY_KEY_SUFFIX: {}
}
}
},
RESULT: {
"results": {}
}
},
"5": {
DESCR: "Tunnel route present in APP DB but mssing in ASIC DB",
ARGS: "vnet_route_check",
RET: -1,
PRE: {
APPL_DB: {
VXLAN_TUNNEL_TABLE: {
"tunnel_v4": { "src_ip": "10.1.0.32" }
},
VNET_TABLE: {
"Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10000"), ("peer_list", "")]
},
VNET_ROUTE_TUNNEL_TABLE: {
"Vnet_v4_in_v4-0:150.62.191.1/32" : { "endpoint" : "100.251.7.1,100.251.7.2" }
}
},
ASIC_DB: {
"ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER": {
"oid:0x3000000000d4b" : { "":"" }
},
ASIC_STATE: {
}
}
},
RESULT: {
"results": {
"missed_in_asic_db_routes": {
"Vnet_v4_in_v4-0": {
"routes": [
"150.62.191.1/32"
]
}
}
}
}
}
}

Expand Down

0 comments on commit 757a6b0

Please sign in to comment.