* Fixed: [Non-obvious behavior of clixon_snmp after snmpset command when transaction validation returns an error](https://github.com/clicon/clixon/issues/375)

* Changed `clicon_rpc_commit()` and `clicon_rpc_validate`: Added three-value return.
This commit is contained in:
Olof hagsand 2022-10-08 17:04:02 +02:00
parent d29c81fce0
commit 575429caa1
5 changed files with 70 additions and 20 deletions

View file

@ -2,6 +2,7 @@
# snmpset. This requires deviation of MIB-YANG to make write operations
# Get default value, set new value via SNMP and check it, set new value via NETCONF and check
# Selected types from CLIXON/IF-MIB/ENTITY mib
# Also an incomplete commit failed test
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -33,6 +34,7 @@ cat <<EOF > $cfg
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_SNMP_AGENT_SOCK>unix:$SOCK</CLICON_SNMP_AGENT_SOCK>
<CLICON_SNMP_MIB>CLIXON-TYPES-MIB</CLICON_SNMP_MIB>
@ -195,9 +197,10 @@ function testrun()
echo "$snmpset $oid $set_type $value"
expectpart "$($snmpset $oid $set_type $value)" 0 "$type:" "$value"
else
echo "$snmpset $oid $set_type $value"
echo "$snmpset $oid $set_type $value2"
expectpart "$($snmpset $oid $set_type $value)" 0 "$type: $value2"
fi
new "Check $name via SNMP"
if [ "$type" == "STRING" ]; then
expectpart "$($snmpget $oid)" 0 "$type:" "$value"
@ -211,6 +214,17 @@ function testrun()
function testexit(){
stop_snmp
if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
fi
}
new "SNMP tests"
@ -241,6 +255,28 @@ expectpart "$($snmpget $oid)" 0 "$type: active(1)"
new "Check $name via CLI"
expectpart "$($clixon_cli -1 -f $cfg show config xml)" 0 "<$name>active</$name>"
# restart backend with synthetic validation failure
# Incomplete commit failed test: the commit fails by logging but this is not actually checked
if [ $BE -ne 0 ]; then
# Kill old backend and start a new one
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err "Failed to start backend"
fi
sudo pkill -f clixon_backend
new "Starting backend"
start_backend -s startup -f $cfg -- -V CLIXON-TYPES-MIB/clixonExampleScalars/clixonExampleInteger
fi
new "wait backend"
wait_backend
new "set value with error"
expectpart "$($snmpset ${MIB}.1.1 i 4321)" 0 "INTEGER: 4321"
new "Cleaning up"
testexit