Skip to content

Commit

Permalink
[test_yang_model.py]: One more extra test for must condition in sonic…
Browse files Browse the repository at this point in the history
…-crm.yang

Signed-off-by: Praveen Chaudhary<[email protected]>
  • Loading branch information
Praveen Chaudhary committed Nov 12, 2020
1 parent a4a62f5 commit 9281269
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def initTest(self):
'desc': 'CRM_WITH_WRONG_PERCENTAGE must condition failure.',
'eStr': self.defaultYANGFailure['Must']
},
'CRM_WITH_HIGH_THRESHOLD_ERR': {
'desc': 'CRM_WITH_HIGH_THRESHOLD_ERR must condition failure \
about high threshold being lower than low threshold.',
'eStr': self.defaultYANGFailure['high_threshold should be more \
than low_threshold']
},
'CRM_WITH_CORRECT_USED_VALUE': {
'desc': 'CRM_WITH_CORRECT_USED_VALUE no failure.',
'eStr': self.defaultYANGFailure['None']
Expand Down Expand Up @@ -317,7 +323,7 @@ def loadConfigData(self, jInput, verify=None):
s = 'verified'
except Exception as e:
s = str(e)
log.debug(s)
log.info(s)
return s

"""
Expand All @@ -338,7 +344,7 @@ def runExceptionTest(self, test):
log.info(desc + " Passed\n")
return PASS
else:
raise Exception("Unknown Error")
raise Exception("Mismatch {} and {}".format(eStr, s))
except Exception as e:
printExceptionDetails()
log.info(desc + " Failed\n")
Expand Down Expand Up @@ -380,10 +386,10 @@ def runVlanSpecialTest(self, test):
Run all tests from list self.tests
"""
def test_run_tests(self):
ret = 0
try:
self.initTest()
self.loadYangModel(self.yangDir)
ret = 0
for test in self.tests:
test = test.strip()
if test in self.ExceptionTests:
Expand All @@ -394,6 +400,7 @@ def test_run_tests(self):
raise Exception("Unexpected Test")
except Exception as e:
printExceptionDetails()

assert ret == 0
return
# End of Class
Expand Down
16 changes: 14 additions & 2 deletions src/sonic-yang-models/tests/yang_model_tests/yangTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,20 @@
"sonic-crm:sonic-crm": {
"sonic-crm:CRM": {
"Config": {
"acl_counter_high_threshold": 85,
"acl_counter_low_threshold": 110,
"acl_counter_high_threshold": 110,
"acl_counter_low_threshold": 85,
"acl_counter_threshold_type": "PERCENTAGE"
}
}
}
},

"CRM_WITH_HIGH_THRESHOLD_ERR": {
"sonic-crm:sonic-crm": {
"sonic-crm:CRM": {
"Config": {
"acl_counter_high_threshold": 80,
"acl_counter_low_threshold": 81,
"acl_counter_threshold_type": "PERCENTAGE"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-yang-models/yang-models/sonic-crm.yang
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module sonic-crm {
leaf acl_counter_high_threshold {
must "(current() > ../acl_counter_low_threshold)"
{
error-message "high_threshold should be more that low_threshold";
error-message "high_threshold should be more than low_threshold";
}
type threshold;
}
Expand Down

0 comments on commit 9281269

Please sign in to comment.