Skip to content

Commit

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

How I did it
This unit test uses ntp config from GCU test.
This unit test generates GNMI request for ntp 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 20, 2024
1 parent e5c43a4 commit 0bbb9ef
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions test/test_gnmi_configdb_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,90 @@ def create_checkpoint(file_name, text):
}
]

test_data_ntp_patch = [
{
"test_name": "ntp_server_tc1_add_config",
"operations": [
{
"op": "update",
"path": "/sonic-db:CONFIG_DB/localhost/NTP_SERVER",
"value": {
"10.0.0.1": {
"resolve_as": "10.0.0.1",
"association_type": "server",
"iburst": "on"
}
}
}
],
"origin_json": {},
"target_json": {
"NTP_SERVER": {
"10.0.0.1": {
"resolve_as": "10.0.0.1",
"association_type": "server",
"iburst": "on"
}
}
}
},
{
"test_name": "ntp_server_tc1_replace",
"operations": [
{
"op": "del",
"path": "/sonic-db:CONFIG_DB/localhost/NTP_SERVER/10.0.0.1"
},
{
"op": "update",
"path": "/sonic-db:CONFIG_DB/localhost/NTP_SERVER/10.0.0.2",
"value": {
"resolve_as": "10.0.0.2",
"association_type": "server",
"iburst": "on"
}
}
],
"origin_json": {
"NTP_SERVER": {
"10.0.0.1": {
"resolve_as": "10.0.0.1",
"association_type": "server",
"iburst": "on"
}
}
},
"target_json": {
"NTP_SERVER": {
"10.0.0.1": {
"resolve_as": "10.0.0.2",
"association_type": "server",
"iburst": "on"
}
}
}
},
{
"test_name": "ntp_server_tc1_remove",
"operations": [
{
"op": "del",
"path": "/sonic-db:CONFIG_DB/localhost/NTP_SERVER"
}
],
"origin_json": {
"NTP_SERVER": {
"10.0.0.1": {
"resolve_as": "10.0.0.1",
"association_type": "server",
"iburst": "on"
}
}
},
"target_json": {}
}
]

class TestGNMIConfigDbPatch:

def common_test_handler(self, test_data):
Expand Down

0 comments on commit 0bbb9ef

Please sign in to comment.