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

Add unit test for vlan interface #264

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all 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
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)
Loading