stronger defaults test
This commit is contained in:
parent
acc9c083a4
commit
cfe1f2936e
2 changed files with 77 additions and 57 deletions
|
|
@ -908,7 +908,6 @@ save_config_file(clicon_handle h,
|
||||||
char *dbstr;
|
char *dbstr;
|
||||||
char *varstr;
|
char *varstr;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
cxobj *xc;
|
|
||||||
cxobj *xerr;
|
cxobj *xerr;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
enum genmodel_type gt;
|
enum genmodel_type gt;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Default handling and datastores.
|
# Default handling and datastores.
|
||||||
# There was a bug with loading startup and writing it back to candidate/running
|
# There was a bug with loading startup and writing it back to candidate/running
|
||||||
# where default mode in startup being "explicit" was transformed to "report-all"
|
# where default mode in startup being "explicit" was transformed to "report-all"
|
||||||
# according to RFC 6243.
|
# according to RFC 6243.
|
||||||
# Ie, all default values were populated.
|
# Ie, all default values were populated.
|
||||||
# This test goes through (all) testcases where clixon writes data back to a datastore, and
|
# Also: Check default values and xpaths
|
||||||
# ensures default values are not present in the datastore.
|
|
||||||
# XXX two errors:
|
|
||||||
# 1. Running is changed
|
|
||||||
# XXX 2. type default not set
|
|
||||||
|
|
||||||
# Magic line must be first in script (see README.md)
|
# Magic line must be first in script (see README.md)
|
||||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
|
@ -41,7 +38,7 @@ cat <<EOF > $cfg
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF > $fyang
|
cat <<EOF > $fyang
|
||||||
module example-default {
|
module example-default {
|
||||||
namespace "urn:example:default";
|
namespace "urn:example:default";
|
||||||
prefix "ex";
|
prefix "ex";
|
||||||
typedef def {
|
typedef def {
|
||||||
|
|
@ -50,6 +47,11 @@ cat <<EOF > $fyang
|
||||||
default 42;
|
default 42;
|
||||||
}
|
}
|
||||||
container a{
|
container a{
|
||||||
|
leaf d0 {
|
||||||
|
description "container default";
|
||||||
|
type int32;
|
||||||
|
default 88;
|
||||||
|
}
|
||||||
list b {
|
list b {
|
||||||
key c;
|
key c;
|
||||||
leaf c{
|
leaf c{
|
||||||
|
|
@ -66,19 +68,17 @@ cat <<EOF > $fyang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# No args
|
# Initial data (default y not given)
|
||||||
function testrun(){
|
XML='<a xmlns="urn:example:default"><b><c>0</c></b></a>'
|
||||||
# Initial data (default y not given)
|
|
||||||
XML='<a xmlns="urn:example:default"><b><c>0</c></b></a>'
|
|
||||||
|
|
||||||
db=startup
|
db=startup
|
||||||
if [ $db = startup ]; then
|
if [ $db = startup ]; then
|
||||||
sudo echo "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" > $dir/startup_db
|
sudo echo "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" > $dir/startup_db
|
||||||
fi
|
fi
|
||||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
sudo clixon_backend -zf $cfg
|
sudo clixon_backend -zf $cfg
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
@ -86,31 +86,55 @@ function testrun(){
|
||||||
fi
|
fi
|
||||||
new "start backend -s $db -f $cfg"
|
new "start backend -s $db -f $cfg"
|
||||||
start_backend -s $db -f $cfg
|
start_backend -s $db -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "waiting"
|
# permission kludges
|
||||||
wait_backend
|
sudo chmod 666 $dir/running_db
|
||||||
|
sudo chmod 666 $dir/startup_db
|
||||||
|
|
||||||
# permission kludges
|
new "Checking startup unchanged"
|
||||||
sudo chmod 666 $dir/running_db
|
ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>"))
|
||||||
sudo chmod 666 $dir/startup_db
|
if [ $? -ne 0 ]; then
|
||||||
|
|
||||||
new "Checking startup unchanged"
|
|
||||||
ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>"))
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
err "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" "$ret"
|
err "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" "$ret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Checking running unchanged"
|
new "Checking running unchanged"
|
||||||
ret=$(diff $dir/running_db <(echo -n "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>"))
|
ret=$(diff $dir/running_db <(echo -n "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" "$ret"
|
err "<${DATASTORE_TOP}>$XML</${DATASTORE_TOP}>" "$ret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "check running defaults"
|
new "check running defaults"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><b><c>0</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><d0>88</d0><b><c>0</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
new "delete existing list element"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><edit-config><target><candidate/></target><config><a xmlns=\"urn:example:default\"><b nc:operation=\"delete\"><c>0</c></b></a></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "netconf commit"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS ><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "set new list element"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><a xmlns=\"urn:example:default\"><b><c>17</c></b></a></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list top"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><d0>88</d0><b><c>17</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list xpath /a"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type='subtree'><a xmlns='urn:example:default'/></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><d0>88</d0><b><c>17</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list xpath /a/b"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type='subtree'><a xmlns='urn:example:default'><b/></a></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><b><c>17</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list xpath /a/b/c"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type='subtree'><a xmlns='urn:example:default'><b><c/></b></a></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><b><c>17</c></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list xpath /a/b/c=17"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type='subtree'><a xmlns='urn:example:default'><b><c>17</c></b></a></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><b><c>17</c><d1>foo</d1><d2>42</d2></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get the list xpath /a/b/c=17/d1"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source><filter type='subtree'><a xmlns='urn:example:default'><b><c>17</c><d1/></b></a></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><a xmlns=\"urn:example:default\"><b><c>17</c><d1>foo</d1></b></a></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
# Check if premature kill
|
# Check if premature kill
|
||||||
pid=$(pgrep -u root -f clixon_backend)
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
|
@ -119,10 +143,7 @@ function testrun(){
|
||||||
fi
|
fi
|
||||||
# kill backend
|
# kill backend
|
||||||
stop_backend -f $cfg
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
} # testrun
|
|
||||||
|
|
||||||
testrun
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue