Skip to content

Commit

Permalink
Added qos maps yang test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
AshokDaparthi committed Oct 18, 2021
1 parent 98db480 commit c132df1
Show file tree
Hide file tree
Showing 3 changed files with 881 additions and 9 deletions.
62 changes: 53 additions & 9 deletions src/sonic-yang-mgmt/sonic_yang_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,17 @@ def _yangConvert(val):
QOS MAPS Yang has inner list, which is diffrent from config DB.
Each field value in config db should be converted to inner list with
key and value.
Example:
Example:
Config DB:
Config DB:
"DSCP_TO_TC_MAP": {
"Dscp_to_tc_map1": {
"Dscp_to_tc_map1": {
"1": "1",
"2": "2"
}
}
Yang:
YANG Model:
module: sonic-dscp-tc-map
+--rw sonic-dscp-tc-map
+--rw DSCP_TO_TC_MAP
Expand All @@ -443,6 +443,27 @@ def _yangConvert(val):
+--rw DSCP_TO_TC_MAP* [dscp]
+--rw dscp string
+--rw tc? string
YANG JSON:
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "64",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
"""
def _xlateQosMapList(self, model, yang, config, table, exceptionList):

Expand Down Expand Up @@ -724,10 +745,11 @@ def _revYangConvert(val):

"""
Rev xlate from <TABLE>_LIST to table in config DB
QOS MAP Yang has inner list, each inner list key:val should
QOS MAP Yang has inner list, each inner list key:val should
be mapped to field:value in Config DB.
Example:
Yang:
Example:
YANG:
module: sonic-dscp-tc-map
+--rw sonic-dscp-tc-map
+--rw DSCP_TO_TC_MAP
Expand All @@ -736,9 +758,31 @@ def _revYangConvert(val):
+--rw DSCP_TO_TC_MAP* [dscp]
+--rw dscp string
+--rw tc? string
Config DB:
YANG JSON:
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "64",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
Config DB:
"DSCP_TO_TC_MAP": {
"Dscp_to_tc_map1": {
"Dscp_to_tc_map1": {
"1": "1",
"2": "2"
}
Expand Down
104 changes: 104 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"DSCP_TO_TC_MAP_CRETAE": {
"desc": "Configure a DSCP to Traffic class map."
},

"DSCP_TO_TC_MAP_CREATE_INVALID_DSCP": {
"desc": "Configure a DSCP to Traffic class map with invalid key.",
"eStr": "Invalid DSCP"
},

"DSCP_TO_TC_MAP_CREATE_INVALID_TC": {
"desc": "Configure a DSCP to Traffic class map with invalid value.",
"eStr": "Invalid Traffic Class"
},

"DOT1P_TO_TC_MAP_CRETAE": {
"desc": "Configure a DOT1P to Traffic class map."
},

"DOT1P_TO_TC_MAP_CREATE_INVALID_DOT1P": {
"desc": "Configure a DOT1P to Traffic class map with invalid key.",
"eStr": "Invalid DOT1P"
},

"DOT1P_TO_TC_MAP_CREATE_INVALID_TC": {
"desc": "Configure a DOT1P to Traffic class map with invalid value.",
"eStr": "Invalid Traffic Class"
},

"TC_TO_QUEUE_MAP_CRETAE": {
"desc": "Configure a Traffic Class to Queue map."
},

"TC_TO_QUEUE_MAP_CREATE_INVALID_TC": {
"desc": "Configure a Traffic class to Queue map with invalid key.",
"eStr": "Invalid Traffic Class"
},

"TC_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"desc": "Configure a Traffic class to Queue map with invalid value.",
"eStr": "Invalid queue index"
},

"TC_TO_PRIORITY_GROUP_MAP_CRETAE": {
"desc": "Configure a Traffic Class to Priority Group map."
},

"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_TC": {
"desc": "Configure a Traffic class to Priority Group map with invalid key.",
"eStr": "Invalid Traffic Class"
},

"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"desc": "Configure a Traffic class to Priority Group map with invalid value.",
"eStr": "Invalid Priority Group"
},

"PFC_PRIORITY_TO_QUEUE_MAP_CRETAE": {
"desc": "Configure a PFC priority to Queue map."
},

"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_PFC_PRIORITY": {
"desc": "Configure a PFC priority to Queue map with invalid key.",
"eStr": "Invalid pfc priority"
},

"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"desc": "Configure a PFC priority to Queue map with invalid value.",
"eStr": "Invalid queue index"
},

"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CRETAE": {
"desc": "Configure a PFC priority to Priority Group map."
},

"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PFC_PRIORITY": {
"desc": "Configure a PFC priority to Priority Group map with invalid key.",
"eStr": "Invalid pfc priority"
},

"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"desc": "Configure a PFC priority to Priority Group map with invalid value.",
"eStr": "Invalid Priority Group"
},

"PORT_QOS_MAP_APPLY_MAPS": {
"desc": "Configure qos maps on port."
},

"PORT_QOS_MAP_APPLY_NON_EXISTS_MAPS": {
"desc": "Configure non exists qos maps on port.",
"eStrKey": "LeafRef"
},

"PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": {
"desc": "Configure port qos map entry on non exists port.",
"eStrKey": "LeafRef"
},

"PORT_QOS_MAP_APPLY_INVALID_PFC": {
"desc": "Configure port pfc enable with invalid pfc priority.",
"eStrKey": "Pattern"
}
}
Loading

0 comments on commit c132df1

Please sign in to comment.