* Clixon configuration file top-level symbols has changed to clixon-configand namespace check is enforced.
* clixon-config YAML file has new revision: 2019-03-05. * New URN and changed top-level symbol to `clixon-config` * Removed obsolete `_CLICON_XML_NS_STRICT` variable and `CLICON_XML_NS_STRICT` config option.
This commit is contained in:
parent
4b17af0278
commit
98fb6eceef
50 changed files with 167 additions and 211 deletions
140
test/test_augment.sh
Executable file
140
test/test_augment.sh
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
#!/bin/bash
|
||||
# yang augment and identityref tests in different modules
|
||||
# See RFC7950 Sec 7.17
|
||||
# This test defines an example-augment module which augments an interface
|
||||
# defined in ietf-interface module. The interface then consists of identities
|
||||
# both defined in the basic ietf-interfaces module (type) as well as the main
|
||||
# module through the augmented module ()
|
||||
# The ietf-interfaces is very restricted (not original).
|
||||
# Work-in-progress
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/main.yang
|
||||
fyang2=$dir/ietf-interfaces@2019-03-04.yang
|
||||
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_FEATURE>a:test</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</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_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
# Stub ietf-interfaces for test
|
||||
cat <<EOF > $fyang2
|
||||
module ietf-interfaces {
|
||||
yang-version 1.1;
|
||||
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
|
||||
revision "2019-03-04";
|
||||
prefix if;
|
||||
identity interface-type {
|
||||
description
|
||||
"Base identity from which specific interface types are
|
||||
derived.";
|
||||
}
|
||||
identity eth {
|
||||
base interface-type;
|
||||
}
|
||||
identity fddi {
|
||||
base interface-type;
|
||||
}
|
||||
container interfaces {
|
||||
description "Interface parameters.";
|
||||
list interface {
|
||||
key "name";
|
||||
leaf name {
|
||||
type string;
|
||||
}
|
||||
leaf type {
|
||||
type identityref {
|
||||
base interface-type;
|
||||
}
|
||||
mandatory true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# From rfc7950 sec 7.17
|
||||
# Note "when" is not present
|
||||
cat <<EOF > $fyang
|
||||
module example-augment {
|
||||
yang-version 1.1;
|
||||
namespace "urn:example:augment";
|
||||
prefix mymod;
|
||||
revision "2019-03-04";
|
||||
import ietf-interfaces {
|
||||
prefix if;
|
||||
}
|
||||
identity some-new-iftype {
|
||||
base if:interface-type;
|
||||
}
|
||||
augment "/if:interfaces/if:interface" {
|
||||
/* when 'derived-from-or-self(if:type, "mymod:some-new-iftype")'; */
|
||||
leaf mandatory-leaf {
|
||||
mandatory true;
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
new "test params: -f $cfg -y $fyang"
|
||||
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg -y $fyang
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s init -f $cfg -y $fyang"
|
||||
start_backend -s init -f $cfg -y $fyang
|
||||
|
||||
new "waiting"
|
||||
sleep $RCWAIT
|
||||
fi
|
||||
|
||||
# mandatory-leaf See RFC7950 Sec 7.17
|
||||
# Error1: the xml should have xmlns for "mymod"
|
||||
# XMLNS_YANG_ONLY must be undeffed
|
||||
new "netconf set new if my w augmented type"
|
||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface xmlns:mymod="urn:example:augment"><name>my</name><type>mymod:some-new-iftype</type><mymod:mandatory-leaf>true</mymod:mandatory-leaf></interface></interfaces></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "netconf validate ok"
|
||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||
|
||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
|
||||
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
|
||||
sudo pkill -u root -f clixon_backend
|
||||
|
||||
|
||||
|
||||
rm -rf $dir
|
||||
Loading…
Add table
Add a link
Reference in a new issue