Merge branch 'modules-state'

This commit is contained in:
Olof hagsand 2019-02-26 16:53:59 +01:00
commit 2394c6f46e
43 changed files with 1755 additions and 587 deletions

View file

@ -1,6 +1,7 @@
#!/bin/bash
# Startup test: Start clicon daemon in the (four) different startup modes
# and the dbs and files are setup as follows:
# (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
@ -27,8 +28,7 @@ cat <<EOF > $cfg
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
@ -36,12 +36,17 @@ cat <<EOF > $cfg
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
dbdir=$dir/db
cat <<EOF > $dbdir
# Create running-db containin the interface "run"
sudo rm -f $dir/running_db
cat <<EOF > $dir/running_db
<config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
@ -51,9 +56,10 @@ testrun(){
</interfaces>
</config>
EOF
sudo mv $dbdir /usr/local/var/$APPNAME/running_db
cat <<EOF > $dbdir
# Create startup-db containin the interface "startup"
sudo rm -f $dir/startup_db
cat <<EOF > $dir/startup_db
<config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
@ -63,8 +69,9 @@ EOF
</interfaces>
</config>
EOF
sudo mv $dbdir /usr/local/var/$APPNAME/startup_db
# Create extra xml containin the interface "extra"
sudo rm -f $dir/config
cat <<EOF > $dir/config
<config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
@ -76,20 +83,23 @@ EOF
</config>
EOF
# kill old backend (if any)
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
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 "start backend -f $cfg -s $mode -c $dir/config"
start_backend -s $mode -f $cfg -c $dir/config
new "waiting"
sleep $RCWAIT
new "Check $mode"
new "Startup test for init mode: $mode"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' "^<rpc-reply>$expect</rpc-reply>]]>]]>$"
new "Kill backend"
@ -102,12 +112,12 @@ EOF
stop_backend -f $cfg
} # testrun
testrun init '<data/>'
testrun init '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun none '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
rm -rf $dir