#!/bin/bash
# Test2: backend and netconf basic functionality
# include err() and new() functions
. ./lib.sh
# For memcheck
# clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
clixon_netconf=clixon_netconf
# kill old backend (if any)
new "kill old backend"
sudo clixon_backend -zf $clixon_cf
if [ $? -ne 0 ]; then
err
fi
new "start backend"
# start new backend
sudo clixon_backend -If $clixon_cf
if [ $? -ne 0 ]; then
err
fi
new "netconf get empty config"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf edit config"
expecteof "$clixon_netconf -qf $clixon_cf" "eth0eth1true9.2.3.424]]>]]>" "^]]>]]>$"
new "netconf get config xpath"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^true]]>]]>$"
new "netconf validate missing type"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf get empty config2"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf edit config eth1"
expecteof "$clixon_netconf -qf $clixon_cf" "eth1eth]]>]]>" "^]]>]]>$"
new "netconf validate"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf commit"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf edit config replace"
expecteof "$clixon_netconf -qf $clixon_cf" "eth2ethmerge ]]>]]>" "^]]>]]>$"
new "netconf get replaced config"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^eth1ethtrueeth2ethtrue]]>]]>$"
new "netconf edit config create"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth3ethnone ]]>]]>' "^]]>]]>$"
new "netconf edit config create 2nd"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth3ethmerge ]]>]]>' "^"
new "netconf edit config delete"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth3ethnone ]]>]]>' "^]]>]]>$"
new "netconf get delete config"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^eth1ethtrueeth2ethtrue]]>]]>$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf lock/unlock"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>]]>]]>" "^]]>]]>]]>]]>$"
new "netconf lock/lock"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf lock"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "close-session"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "kill-session"
expecteof "$clixon_netconf -qf $clixon_cf" "44]]>]]>" "^]]>]]>$"
new "copy startup"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf get startup"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^eth1ethtrue]]>]]>$"
new "netconf delete startup"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf check empty startup"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf subscription"
expectwait "$clixon_netconf -qf $clixon_cf" "ROUTING]]>]]>" "^]]>]]>Routing notification]]>]]>$" 30
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 $clixon_cf
if [ $? -ne 0 ]; then
err "kill backend"
fi