[YANG error when poking on EOS configuration](https://github.com/clicon/clixon-controller/issues/26)
This commit is contained in:
parent
d1b8dcdf1f
commit
0e81e8137b
6 changed files with 151 additions and 319 deletions
|
|
@ -7,16 +7,19 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
|||
APPNAME=example
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
cfd=$dir/conf_yang.d
|
||||
if [ ! -d $cfd ]; then
|
||||
mkdir $cfd
|
||||
fi
|
||||
fyang=$dir/example.yang
|
||||
fyang2=$dir/example-external.yang
|
||||
fyang3=$dir/example-external3.yang
|
||||
|
||||
# Whether grouping treeref is enabled
|
||||
grouping_treeref=true
|
||||
|
||||
# XXX try -E?
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_CONFIGDIR>$cfd</CLICON_CONFIGDIR>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
|
|
@ -29,16 +32,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY>
|
||||
<autocli>
|
||||
<module-default>false</module-default>
|
||||
<list-keyword-default>kw-nokey</list-keyword-default>
|
||||
<grouping-treeref>${grouping_treeref}</grouping-treeref>
|
||||
<rule>
|
||||
<name>include ${APPNAME}</name>
|
||||
<operation>enable</operation>
|
||||
<module-name>${APPNAME}*</module-name>
|
||||
</rule>
|
||||
</autocli>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -54,6 +47,7 @@ set @datamodel, cli_auto_set();
|
|||
merge @datamodel, cli_auto_merge();
|
||||
create @datamodel, cli_auto_create();
|
||||
commit("Commit the changes"), cli_commit();
|
||||
validate("Validate changes"), cli_validate();
|
||||
delete("Delete a configuration item") {
|
||||
@datamodel, cli_auto_del();
|
||||
all("Delete whole candidate configuration"), delete_all("candidate");
|
||||
|
|
@ -83,14 +77,28 @@ module example {
|
|||
type string;
|
||||
}
|
||||
list index1{
|
||||
key i;
|
||||
leaf i{
|
||||
type string;
|
||||
}
|
||||
leaf iv{
|
||||
description "a value";
|
||||
type string;
|
||||
}
|
||||
key i;
|
||||
leaf i{
|
||||
type string;
|
||||
}
|
||||
leaf iv{
|
||||
description "a value";
|
||||
type string;
|
||||
}
|
||||
/* See https://github.com/clicon/clixon-controller/issues/26
|
||||
* reference that goes beyond the scope of this grouping
|
||||
*/
|
||||
leaf-list scope {
|
||||
type leafref {
|
||||
path "../../value0";
|
||||
}
|
||||
}
|
||||
/* leaf-list inscope {
|
||||
type leafref {
|
||||
path "../iv";
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
container table{
|
||||
|
|
@ -145,65 +153,121 @@ module example-external3 {
|
|||
}
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -z -f $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
# Args:
|
||||
# 1: grouping_treeref
|
||||
function testrun()
|
||||
{
|
||||
# Whether grouping treeref is enabled
|
||||
grouping_treeref=$1
|
||||
echo "grouping_treeref=$1"
|
||||
# cat <<EOF > $cfd/autocli.xml # XXX
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_CONFIGDIR>$cfd</CLICON_CONFIGDIR>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
|
||||
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
|
||||
<CLICON_CLISPEC_DIR>$dir</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY>
|
||||
<autocli>
|
||||
<module-default>false</module-default>
|
||||
<list-keyword-default>kw-nokey</list-keyword-default>
|
||||
<grouping-treeref>${grouping_treeref}</grouping-treeref>
|
||||
<rule>
|
||||
<name>include ${APPNAME}</name>
|
||||
<operation>enable</operation>
|
||||
<module-name>${APPNAME}*</module-name>
|
||||
</rule>
|
||||
</autocli>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg"
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -z -f $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s init -f $cfg"
|
||||
start_backend -s init -f $cfg
|
||||
fi
|
||||
new "start backend -s init -f $cfg"
|
||||
start_backend -s init -f $cfg
|
||||
fi
|
||||
|
||||
new "wait backend"
|
||||
wait_backend
|
||||
new "wait backend"
|
||||
wait_backend
|
||||
|
||||
# Test of generated clispecs. With autocli grouping_treeref, there should be treerefs for
|
||||
# groupings. Without they should not be present
|
||||
# The testcase assumes enabled
|
||||
if ${grouping_treeref}; then
|
||||
new "verify grouping is enabled"
|
||||
expectpart "$($clixon_cli -f $cfg -G -1 2>&1)" 0 "@grouping-urn:example:clixon-pg1" "@grouping-urn:example:external-pg2" "@grouping-urn:example:external-pg3"
|
||||
else
|
||||
new "verify grouping is disabled"
|
||||
expectpart "$($clixon_cli -f $cfg -G -1 2>&1)" 0 --not-- "@grouping-urn:example:clixon-pg1" "@grouping-urn:example:external-pg2" "@grouping-urn:example:external-pg3"
|
||||
fi
|
||||
|
||||
new "set top-level grouping"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set value1 39)" 0 ""
|
||||
|
||||
new "set inline grouping value"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value0 40)" 0 ""
|
||||
|
||||
new "set grouping in same module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value1 41)" 0 ""
|
||||
|
||||
new "set list grouping in same module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x index1 a iv foo)" 0 ""
|
||||
|
||||
new "set grouping in other module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value2 42)" 0 ""
|
||||
|
||||
new "set grouping in other+other module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x c2 value3 43)" 0 ""
|
||||
|
||||
new "commit"
|
||||
expectpart "$($clixon_cli -f $cfg -1 commit)" 0 ""
|
||||
|
||||
new "show config"
|
||||
expectpart "$($clixon_cli -f $cfg -1 show config)" 0 "<table xmlns=\"urn:example:clixon\"><parameter><name>x</name><value0>40</value0><value1>41</value1><index1><i>a</i><iv>foo</iv></index1><value2>42</value2><c2><value3>43</value3></c2></parameter></table>" "<value1 xmlns=\"urn:example:clixon\">39</value1>"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
# Test of generated clispecs. With autocli grouping_treeref, there should be treerefs for
|
||||
# groupings. Without they should not be present
|
||||
# The testcase assumes enabled
|
||||
if ${grouping_treeref}; then
|
||||
new "verify grouping is enabled"
|
||||
expectpart "$($clixon_cli -f $cfg -G -1 2>&1)" 0 "@grouping-urn:example:clixon-pg1" "@grouping-urn:example:external-pg2" "@grouping-urn:example:external-pg3"
|
||||
else
|
||||
new "verify grouping is disabled"
|
||||
expectpart "$($clixon_cli -f $cfg -G -1 2>&1)" 0 --not-- "@grouping-urn:example:clixon-pg1" "@grouping-urn:example:external-pg2" "@grouping-urn:example:external-pg3"
|
||||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
|
||||
new "set top-level grouping"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set value1 39)" 0 ""
|
||||
|
||||
new "set inline grouping value"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value0 40)" 0 ""
|
||||
|
||||
new "set grouping in same module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value1 41)" 0 ""
|
||||
|
||||
new "set list grouping in same module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x index1 a iv foo)" 0 ""
|
||||
|
||||
new "set grouping in other module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value2 42)" 0 ""
|
||||
|
||||
new "set grouping in other+other module"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x c2 value3 43)" 0 ""
|
||||
|
||||
new "commit"
|
||||
expectpart "$($clixon_cli -f $cfg -1 commit)" 0 ""
|
||||
|
||||
new "show config"
|
||||
expectpart "$($clixon_cli -f $cfg -1 show config)" 0 "<table xmlns=\"urn:example:clixon\"><parameter><name>x</name><value0>40</value0><value1>41</value1><index1><i>a</i><iv>foo</iv></index1><value2>42</value2><c2><value3>43</value3></c2></parameter></table>" "<value1 xmlns=\"urn:example:clixon\">39</value1>"
|
||||
|
||||
new "set leafref lack origin"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x index1 a scope 43)" 0 ""
|
||||
|
||||
new "validate expect fail"
|
||||
expectpart "$($clixon_cli -f $cfg -1 validate 2>&1)" 255 "bad-element Leafref validation failed: No leaf 43 matching path"
|
||||
|
||||
new "set leafref expect fail"
|
||||
expectpart "$($clixon_cli -f $cfg -1 set table parameter x value0 43)" 0 ""
|
||||
|
||||
new "validate ok"
|
||||
expectpart "$($clixon_cli -f $cfg -1 validate)" 0 "^$" --not-- "bad-element Leafref validation failed: No leaf 43 matching path"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
fi
|
||||
# kill backend
|
||||
stop_backend -f $cfg
|
||||
fi
|
||||
}
|
||||
|
||||
new "autocli grouping=true"
|
||||
testrun true
|
||||
|
||||
new "autocli grouping=false"
|
||||
testrun false
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue