#!/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 tests"
new "netconf get empty config"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' '^]]>]]>$'
new "Add subtree eth/0/0 using none which should not change anything"
expecteof "$clixon_netconf -qf $clixon_cf" "noneeth/0/0]]>]]>" "^]]>]]>$"
new "Check nothing added"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' '^]]>]]>$'
new "Add subtree eth/0/0 using none and create which should add eth/0/0"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth/0/0ethnone ]]>]]>' "^]]>]]>$"
new "Check eth/0/0 added using xpath"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' "^eth/0/0ethtrue]]>]]>$"
new "Re-create same eth/0/0 which should generate error"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth/0/0ethnone ]]>]]>' "^"
new "Delete eth/0/0 using none config"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth/0/0ethnone ]]>]]>' "^]]>]]>$"
new "Check deleted eth/0/0 (non-presence container)"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' '^]]>]]>$'
new "Re-Delete eth/0/0 using none should generate error"
expecteof "$clixon_netconf -qf $clixon_cf" 'eth/0/0ethnone ]]>]]>' "^"
new "netconf edit config"
expecteof "$clixon_netconf -qf $clixon_cf" "eth/0/0eth1true9.2.3.424]]>]]>" "^]]>]]>$"
new "netconf get config xpath"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' "^eth1true]]>]]>$"
new "netconf get config xpath parent"
expecteof "$clixon_netconf -qf $clixon_cf" ']]>]]>' "^eth/0/0trueeth1truetruefalse9.2.3.424]]>]]>$"
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 discard-changes"
expecteof "$clixon_netconf -qf $clixon_cf" "]]>]]>" "^]]>]]>$"
new "netconf edit state operation should fail"
expecteof "$clixon_netconf -qf $clixon_cf" "eth1eth]]>]]>" "^invalid-value"
new "netconf get state operation"
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 rpc"
expecteof "$clixon_netconf -qf $clixon_cf" "ipv4ipv4]]>]]>" "^ipv4"
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