Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,8 @@
"Ethernet9": {
"action": "drop",
"detection_time": "100",
"restoration_time": "400"
"restoration_time": "400",
"pfc_stat_history": "enable"
}
},
"PFC_WD": {
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@
"PFC_WDOG_WITH_INVALID_RESTORATION_TIME": {
"desc": "PFC_WDOG_WITH_INVALID_RESTORATION_TIME",
"eStr": ["restoration_time must be greater than or equal to POLL_INTERVAL"]
},
"PFC_WDOG_WITH_VALID_PFC_STAT_HISTORY": {
"desc": "PFC_WDOG_WITH_VALID_PFC_STAT_HISTORY"
},
"PFC_WDOG_WITH_INVALID_PFC_STAT_HISTORY": {
"desc": "PFC_WDOG_WITH_INVALID_PFC_STAT_HISTORY",
"eStr": ["pfc_stat_history must be either enable or disable"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,51 @@
]
}
}
},
"PFC_WDOG_WITH_VALID_PFC_STAT_HISTORY": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet4",
"lanes": "65",
"mtu": "9000",
"name": "Ethernet4",
"tpid": "0x8100",
"speed": "25000"
}
]
}
},
"sonic-pfcwd:sonic-pfcwd": {
"sonic-pfcwd:PFC_WD": {
"PFC_WD_LIST": [
{
"ifname": "Ethernet4",
"action": "drop",
"detection_time": 400,
"restoration_time": 800,
"pfc_stat_history": "enable"
}
]
}
}
},
"PFC_WDOG_WITH_INVALID_PFC_STAT_HISTORY": {
"sonic-pfcwd:sonic-pfcwd": {
"sonic-pfcwd:PFC_WD": {
"PFC_WD_LIST": [
{
"ifname": "Ethernet4",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it catch error for missing leafref in ifname: Ethernet4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I was simply following the example of the other tests, I believe it is because Test_yang_models::runExceptionTest only verifies that each eStr defined in the test case is found in the exceptions from parsing the input.
So from my understanding of the code, it's likely that there would be a missing leafref and possibly any number of other exceptions but the test case passes so long as all exceptions defined in eStr were found at least once.

In my case I am only verifying that "pfc_stat_history must be either enable or disable" is shown and not any other exceptions.

"action": "drop",
"detection_time": 400,
"restoration_time": 800,
"pfc_stat_history": "down"
}
]
}
}
}
}
11 changes: 11 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-pfcwd.yang
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ module sonic-pfcwd {
description
"Time delay before resuming normal PFC operation in msec.";
}
leaf pfc_stat_history {
must "../ifname != 'GLOBAL'";
type string {
pattern "enable|disable" {
error-message "pfc_stat_history must be either enable or disable";
error-app-tag pfc-stat-history-invalid-status;
}
}
description
"Toggle for PFC Historical Statistics estimation.";
}
leaf POLL_INTERVAL {
must "../ifname = 'GLOBAL'";
type uint32 {
Expand Down
Loading