Test: added BE conditional for exiting backend (run your own backend)

in multiple places where it was not in place.
This commit is contained in:
Olof hagsand 2022-01-25 15:56:57 +01:00
parent 504967864d
commit e116e51791
9 changed files with 102 additions and 83 deletions

View file

@ -125,6 +125,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><commit/></
fi fi
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -133,6 +134,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -328,6 +328,7 @@ EOF
new "Test hidden parameter in imported module" new "Test hidden parameter in imported module"
testparam testparam
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -336,6 +337,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -385,6 +385,7 @@ expectpart "$($clixon_cli -1 -f $cfg set interfaces interface e config enabled t
new "Openconfig: OC_VARS+extension: no compresssion (negative)" new "Openconfig: OC_VARS+extension: no compresssion (negative)"
expectpart "$($clixon_cli -1 -f $cfg set interfaces interface e enabled true 2>&1)" 255 "Unknown command" expectpart "$($clixon_cli -1 -f $cfg set interfaces interface e enabled true 2>&1)" 255 "Unknown command"
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -393,6 +394,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -152,6 +152,7 @@ EOF
new "set p1 i2" new "set p1 i2"
expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>p1</name><value>42</value><index><i>i1</i><iv>abc</iv></index></parameter></table>' expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 '<table xmlns="urn:example:clixon"><parameter><name>p1</name><value>42</value><index><i>i1</i><iv>abc</iv></index></parameter></table>'
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -160,6 +161,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -199,6 +199,7 @@ expectpart "$(echo "show $top config parameter a value ?" | $clixon_cli -f $cfg
#--------- @add:show+@add:nonconfig #--------- @add:show+@add:nonconfig
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -207,6 +208,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -112,6 +112,7 @@ expectpart "$($clixon_cli -1 -f $cfg err x)" 255 "Config error: api-path syntax
new "err x a" new "err x a"
expectpart "$($clixon_cli -1 -f $cfg err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument" expectpart "$($clixon_cli -1 -f $cfg err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument"
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -120,6 +121,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
endtest endtest

View file

@ -228,12 +228,14 @@ if [ $? -ne 0 ]; then
err "<${DATASTORE_TOP}>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></${DATASTORE_TOP}>" "$moreret" err "<${DATASTORE_TOP}>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></${DATASTORE_TOP}>" "$moreret"
fi fi
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
fi
# From startup 2, only presence p4, s4/np5 should be filled in # From startup 2, only presence p4, s4/np5 should be filled in
cat <<EOF > $dir/startup_db cat <<EOF > $dir/startup_db
@ -258,12 +260,14 @@ wait_backend
new "get startup config with presence" new "get startup config with presence"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML</data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML</data></rpc-reply>]]>]]>$"
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
fi
# Only single x list element # Only single x list element
cat <<EOF > $dir/startup_db cat <<EOF > $dir/startup_db
@ -288,12 +292,14 @@ wait_backend
new "get startup config with list default" new "get startup config with list default"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML<xs-config xmlns=\"urn:example:clixon\"><x><name>a</name><y><inside>false</inside></y><outside>false</outside></x></xs-config></data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML<xs-config xmlns=\"urn:example:clixon\"><x><name>a</name><y><inside>false</inside></y><outside>false</outside></x></xs-config></data></rpc-reply>]]>]]>$"
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
fi
rm -rf $dir rm -rf $dir

View file

@ -73,6 +73,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><commit/></
# race condition where backend is killed before flushed to disk # race condition where backend is killed before flushed to disk
sleep $DEMSLEEP sleep $DEMSLEEP
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -81,6 +82,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
# Now add a new yang for hello # Now add a new yang for hello
cat <<EOF > $dir/$APPNAME.yang cat <<EOF > $dir/$APPNAME.yang
@ -107,7 +109,6 @@ EOF
# Now start again from running with modstate enabled and new revision # Now start again from running with modstate enabled and new revision
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
new "start backend -s running -f $cfg" new "start backend -s running -f $cfg"
start_backend -s running -f $cfg start_backend -s running -f $cfg
@ -118,6 +119,7 @@ fi
new "netconf get config" new "netconf get config"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><hello xmlns=\"urn:example:simple\"><world/></hello></data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><hello xmlns=\"urn:example:simple\"><world/></hello></data></rpc-reply>]]>]]>$"
if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -126,6 +128,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
rm -rf $dir rm -rf $dir

View file

@ -278,10 +278,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><validate><
new "netconf submodule discard-changes" new "netconf submodule discard-changes"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
if [ "$BE" -eq 0 ]; then if [ $BE -ne 0 ]; then
exit # BE
fi
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -290,6 +287,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f "$cfg" stop_backend -f "$cfg"
fi
rm -rf "$dir" rm -rf "$dir"