Skip to content

Commit

Permalink
Add unit test for vlan interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ganglyu committed Jun 21, 2024
1 parent fbf0234 commit 08f5381
Showing 1 changed file with 153 additions and 0 deletions.
153 changes: 153 additions & 0 deletions test/test_gnmi_configdb_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2931,6 +2931,152 @@ def create_checkpoint(file_name, text):
}
]

test_data_vlan_interface_patch = [
{
"test_name": "vlan_interface_tc1_add_new",
"operations": [
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001",
"value": {}
},
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|192.168.8.1~121",
"value": {}
},
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|fc02:2000::1~164",
"value": {}
},
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN/Vlan1001",
"value": {
"vlanid": "1001"
}
}
],
"origin_json": {
"VLAN_INTERFACE": {},
"VLAN": {}
},
"target_json": {
"VLAN_INTERFACE": {
"Vlan1001": {},
"Vlan1001|192.168.8.1/21": {},
"Vlan1001|fc02:2000::1/64": {}
},
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
}
},
{
"test_name": "vlan_interface_tc1_add_replace",
"operations": [
{
"op": "del",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|192.168.8.1~121"
},
{
"op": "del",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|fc02:2000::1~164"
},
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|192.168.8.2~121",
"value": {}
},
{
"op": "update",
"path": r"/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE/Vlan1001\|fc02:2000::2~164",
"value": {}
}
],
"origin_json": {
"VLAN_INTERFACE": {
"Vlan1001": {},
"Vlan1001|192.168.8.1/21": {},
"Vlan1001|fc02:2000::1/64": {}
},
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
},
"target_json": {
"VLAN_INTERFACE": {
"Vlan1001": {},
"Vlan1001|192.168.8.2/21": {},
"Vlan1001|fc02:2000::2/64": {}
},
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
}
},
{
"test_name": "vlan_interface_tc1_remove",
"operations": [
{
"op": "del",
"path": "/sonic-db:CONFIG_DB/localhost/VLAN_INTERFACE"
}
],
"origin_json": {
"VLAN_INTERFACE": {
"Vlan1001": {},
"Vlan1001|192.168.8.1/21": {},
"Vlan1001|fc02:2000::1/64": {}
},
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
},
"target_json": {
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
}
},
{
"test_name": "test_vlan_interface_tc2_incremental_change",
"operations": [
{
"op": "update",
"path": "/sonic-db:CONFIG_DB/localhost/VLAN/Vlan1001/description",
"value": "incremental test for Vlan1001"
}
],
"origin_json": {
"VLAN": {
"Vlan1001": {
"vlanid": "1001"
}
}
},
"target_json": {
"VLAN": {
"Vlan1001": {
"vlanid": "1001",
"description": "incremental test for Vlan1001"
}
}
}
}
]

class TestGNMIConfigDbPatch:

def common_test_handler(self, test_data):
Expand Down Expand Up @@ -3122,3 +3268,10 @@ def test_gnmi_syslog_patch(self, test_data):
Generate GNMI request for syslog and verify jsonpatch
'''
self.common_test_handler(test_data)

@pytest.mark.parametrize("test_data", test_data_vlan_interface_patch)
def test_gnmi_vlan_interface_patch(self, test_data):
'''
Generate GNMI request for vlan interface and verify jsonpatch
'''
self.common_test_handler(test_data)

0 comments on commit 08f5381

Please sign in to comment.