#!/bin/bash # Startup test: Start clicon daemon in the (four) different startup modes # and 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 APPNAME=example # include err() and new() functions and creates $dir . ./lib.sh cfg=$dir/conf_startup.xml cat < $cfg $cfg /usr/local/share/$APPNAME/yang 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 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so 0 init true EOF run(){ mode=$1 expect=$2 dbdir=$dir/db cat < $dbdir run eth EOF sudo mv $dbdir /usr/local/var/$APPNAME/running_db cat < $dbdir startup eth EOF sudo mv $dbdir /usr/local/var/$APPNAME/startup_db cat < $dir/config extra eth EOF # 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" sudo clixon_backend -f $cfg -s $mode -c $dir/config if [ $? -ne 0 ]; then err fi new "Check $mode" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' "^$expect]]>]]>$" new "Kill backend" # Check if still alive pid=`pgrep clixon_backend` if [ -z "$pid" ]; then err "backend already dead" fi # kill backend sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err "kill backend" fi } run init '' run none 'runethtrue' run running 'extraethtruelolocaltruerunethtrue' run startup 'extraethtruelolocaltruestartupethtrue' rm -rf $dir