#!/usr/bin/env bash # A very simple case - Error in this detected by mgsmith@netgate # Enable modstate and save running on a simple system without upgrade callback # Upgrade yang revision, but no other (upgrade) changes # Then start from running with modstate enabled and the new revision # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=simple cfg=$dir/conf_yang.xml # Create configuration cat < $cfg /usr/local/etc/clixon.xml *:* ${YANG_INSTALLDIR} $dir $APPNAME hello /usr/local/lib/hello/clispec /usr/local/var/hello.sock /usr/local/var/hello.pidfile $dir true false init false EOF cat < $dir/$APPNAME.yang module $APPNAME { yang-version 1.1; namespace "urn:example:simple"; prefix he; revision 2019-04-17 { description "Clixon hello world example"; } container hello{ container world{ presence true; } } } EOF new "test params: -f $cfg" # Bring your own backend if [ $BE -ne 0 ]; then # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg" start_backend -s init -f $cfg fi new "wait backend" wait_backend new "add hello world (with modstate)" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # race condition where backend is killed before flushed to disk sleep $DEMSLEEP 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 # Now add a new yang for hello cat < $dir/$APPNAME.yang module $APPNAME { yang-version 1.1; namespace "urn:example:simple"; prefix he; revision 2020-01-01 { description "Test new revision"; } revision 2019-04-17 { description "Clixon hello world example"; } container hello{ container world{ presence true; } } } EOF # Now start again from running with modstate enabled and new revision if [ $BE -ne 0 ]; then new "start backend -s running -f $cfg" start_backend -s running -f $cfg fi new "wait backend" wait_backend new "netconf get config" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" 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 rm -rf $dir new "endtest" endtest