Skip to content

Commit

Permalink
Add unit test for pfcwd status (#260)
Browse files Browse the repository at this point in the history
Why I did it
GCU has verified pfcwd status config, we need to verify that GNMI can support the same pfcwd status config.
Microsoft ADO: 27231866

How I did it
This unit test uses pfcwd status config from GCU test.
This unit test generates GNMI request for pfcwd status config and use jsonpatch to verify patch file generated by GNMI server.

How to verify it
Run GNMI unit test.
  • Loading branch information
ganglyu authored Jun 21, 2024
1 parent 65a43bc commit 8a10d9f
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions test/test_gnmi_configdb_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,79 @@ def create_checkpoint(file_name, text):
}
]

test_data_pfcwd_status_patch = [
{
"test_name": "test_start_pfcwd",
"operations": [
{
"op": "update",
"path": "/sonic-db:CONFIG_DB/localhost/PFC_WD/Ethernet0",
"value": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
}
},
{
"op": "update",
"path": "/sonic-db:CONFIG_DB/localhost/PFC_WD/Ethernet4",
"value": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
}
}
],
"origin_json": {
"PFC_WD": {}
},
"target_json": {
"PFC_WD": {
"Ethernet0": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
},
"Ethernet4": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
}
}
}
},
{
"test_name": "test_stop_pfcwd",
"operations": [
{
"op": "del",
"path": "/sonic-db:CONFIG_DB/localhost/PFC_WD/Ethernet0"
},
{
"op": "del",
"path": "/sonic-db:CONFIG_DB/localhost/PFC_WD/Ethernet4"
}
],
"origin_json": {
"PFC_WD": {
"Ethernet0": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
},
"Ethernet4": {
"action": "drop",
"detection_time": "400",
"restoration_time": "400"
}
}
},
"target_json": {
"PFC_WD": {}
}
}
]

class TestGNMIConfigDbPatch:

def common_test_handler(self, test_data):
Expand Down Expand Up @@ -2807,3 +2880,10 @@ def test_gnmi_pfcwd_interval_patch(self, test_data):
Generate GNMI request for pfcwd interval and verify jsonpatch
'''
self.common_test_handler(test_data)

@pytest.mark.parametrize("test_data", test_data_pfcwd_status_patch)
def test_gnmi_pfcwd_status_patch(self, test_data):
'''
Generate GNMI request for pfcwd status and verify jsonpatch
'''
self.common_test_handler(test_data)

0 comments on commit 8a10d9f

Please sign in to comment.