#!/usr/bin/env bash # test for data creator attribute: add same object from sessions s1 and s2 # Restart and ensure attributes remain # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi cfg=$dir/conf.xml fyang=$dir/clixon-example.yang : ${clixon_util_xpath:=clixon_util_xpath} cat < $cfg $cfg ${YANG_INSTALLDIR} $dir $fyang $clispec /usr/local/lib/$APPNAME/cli example /usr/local/var/run/$APPNAME.sock /usr/local/var/run/$APPNAME.pidfile $dir true EOF cat < $fyang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; container table { list parameter{ key name; leaf name{ type string; } leaf value{ type string; } } } } EOF new "test params: -f $cfg" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg" start_backend -s init -f $cfg fi new "wait backend 1" wait_backend conf="-d candidate -b $dir -y $fyang" new "s1 add x" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "nonexfoo
" "" "" new "datastore get" expectpart "$(sudo $clixon_util_xpath -f $dir/candidate_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]" new "rpc get-config" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "xfoo
" "" # duplicate new "s1 merge x" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "nonexfoo
" "" "" new "datastore get" expectpart "$(sudo $clixon_util_xpath -f $dir/candidate_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]" # New service new "s2 merge x" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "nonexfoo
" "" "" new "datastore get" expectpart "$(sudo $clixon_util_xpath -f $dir/candidate_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]s2/table/parameter\[name=\"x\"\]" # New entry new "s1 create y=bar" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "noneybar
" "" "" new "datastore get" expectpart "$(sudo $clixon_util_xpath -f $dir/candidate_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]/table/parameter\[name=\"y\"\]s2/table/parameter\[name=\"x\"\]" # To running new "commit to running" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "datastore get running" expectpart "$(sudo $clixon_util_xpath -f $dir/running_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]/table/parameter\[name=\"y\"\]s2/table/parameter\[name=\"x\"\]" new "rpc get-config" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "xfooybar
" "" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi fi if [ $BE -ne 0 ]; then new "start backend -s running -f $cfg" start_backend -s running -f $cfg fi new "wait backend 2" wait_backend new "datastore get running" expectpart "$(sudo $clixon_util_xpath -f $dir/running_db -p /config/creators)" 0 "s1/table/parameter\[name=\"x\"\]/table/parameter\[name=\"y\"\]s2/table/parameter\[name=\"x\"\]" new "rpc get-config" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "xfooybar
" "" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi fi rm -rf $dir new "endtest" endtest