#!/bin/bash # Test2: backend and netconf basic functionality APPNAME=example # include err() and new() functions and creates $dir . ./lib.sh cfg=$dir/conf_yang.xml cat < $cfg $cfg /usr/local/share/$APPNAME/yang example /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/backend /usr/local/lib/$APPNAME/netconf /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so EOF # kill old backend (if any) new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg" # start new backend sudo clixon_backend -s init -f $cfg # -D 1 if [ $? -ne 0 ]; then err fi new "netconf get-config" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' '^]]>]]>$' new "Add subtree eth/0/0 using none which should not change anything" expecteof "$clixon_netconf -qf $cfg" "noneeth/0/0]]>]]>" "^]]>]]>$" new "Check nothing added" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' '^]]>]]>$' new "Add subtree eth/0/0 using none and create which should add eth/0/0" expecteof "$clixon_netconf -qf $cfg" 'eth/0/0ethnone ]]>]]>' "^]]>]]>$" new "Check eth/0/0 added using xpath" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' "^eth/0/0ethtrue]]>]]>$" new "Re-create same eth/0/0 which should generate error" expecteof "$clixon_netconf -qf $cfg" 'eth/0/0ethnone ]]>]]>' "^" new "Delete eth/0/0 using none config" expecteof "$clixon_netconf -qf $cfg" 'eth/0/0ethnone ]]>]]>' "^]]>]]>$" new "Check deleted eth/0/0 (non-presence container)" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' '^]]>]]>$' new "Re-Delete eth/0/0 using none should generate error" expecteof "$clixon_netconf -qf $cfg" 'eth/0/0ethnone ]]>]]>' "^" new "netconf edit config" expecteof "$clixon_netconf -qf $cfg" "eth/0/0eth1true
9.2.3.424
]]>]]>" "^]]>]]>$" new "netconf get config xpath" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' "^eth1true]]>]]>$" new "netconf get config xpath parent" expecteof "$clixon_netconf -qf $cfg" ']]>]]>' "^eth/0/0trueeth1truetruefalse
9.2.3.424
]]>]]>$" new "netconf validate missing type" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf get empty config2" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf edit extra xml" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf edit config eth1" expecteof "$clixon_netconf -qf $cfg" "eth1eth]]>]]>" "^]]>]]>$" new "netconf validate" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf commit" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf edit config replace XXX is merge?" expecteof "$clixon_netconf -qf $cfg" "eth2ethmerge]]>]]>" "^]]>]]>$" new "netconf get replaced config" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^eth1ethtrueeth2ethtrue]]>]]>$" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf edit state operation should fail" expecteof "$clixon_netconf -qf $cfg" "eth1eth]]>]]>" "^invalid-value" new "netconf get state operation" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^eth0eth42]]>]]>$" new "netconf lock/unlock" expecteof "$clixon_netconf -qf $cfg" "]]>]]>]]>]]>" "^]]>]]>]]>]]>$" new "netconf lock/lock" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf lock" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "close-session" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "kill-session" expecteof "$clixon_netconf -qf $cfg" "44]]>]]>" "^]]>]]>$" new "copy startup" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf get startup" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^eth1ethtrue]]>]]>$" new "netconf delete startup" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf check empty startup" expecteof "$clixon_netconf -qf $cfg" "]]>]]>" "^]]>]]>$" new "netconf rpc" expecteof "$clixon_netconf -qf $cfg" "ipv4ipv4]]>]]>" "^ipv4" new "netconf rpc w/o namespace" expecteof "$clixon_netconf -qf $cfg" "ipv4ipv4]]>]]>" "^ipv4" new "netconf client-side rpc" expecteof "$clixon_netconf -qf $cfg" "example]]>]]>" "^ok]]>]]>$" new "netconf subscription" expectwait "$clixon_netconf -qf $cfg" "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 $cfg if [ $? -ne 0 ]; then err "kill backend" fi rm -rf $dir