#!/bin/bash # Startup test: Start clicon daemon in the (four) different startup modes # (init, none, running, or startup) # The dbs and files are setup as follows: # - The example reset_state callback adds "lo" interface # - An extra xml configuration file starts with an "extra" interface # - running db starts with a "run" interface # - startup db starts with a "start" interface # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example cfg=$dir/conf_startup.xml cat < $cfg $cfg /usr/local/share/clixon $IETFRFC clixon-example $APPNAME /usr/local/lib/$APPNAME/backend /usr/local/lib/$APPNAME/netconf /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli /usr/local/lib/$APPNAME/clispec /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir /usr/local/lib/xmldb/text.so 0 init EOF # Create a pre-set running, startup and (extra) config. # The configs are identified by an interface called run, startup, extra. # Depending on startup mode (init, none, running, or startup) # expect different output of an initial get-config testrun(){ mode=$1 expect=$2 # Create running-db containin the interface "run" sudo rm -f $dir/running_db cat < $dir/running_db run ex:eth EOF # Create startup-db containin the interface "startup" sudo rm -f $dir/startup_db cat < $dir/startup_db startup ex:eth EOF # Create extra xml containin the interface "extra" sudo rm -f $dir/config cat < $dir/config extra ex:eth EOF if [ $BE -ne 0 ]; then # Bring your own backend # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -f $cfg -s $mode -c $dir/config" start_backend -s $mode -f $cfg -c $dir/config new "waiting" sleep $RCWAIT else new "Restart backend as eg follows: -Ff $cfg -s $mode -c $dir/config # $BETIMEOUT s" sleep $BETIMEOUT fi new "Startup test for init mode: $mode" expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$expect]]>]]>$" 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 } # testrun testrun init 'extraex:ethtrue' testrun none 'runex:ethtrue' testrun running 'extraex:ethtruerunex:ethtrue' testrun startup 'extraex:ethtruestartupex:ethtrue' rm -rf $dir