Added tests for OpenConfig compress.
This commit is contained in:
parent
e0ea85d6d5
commit
aeff754110
1 changed files with 56 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#!/usr/bin/env bash
|
||||
# Tests for using the auto cli.
|
||||
# In particular setting a config, displaying as cli commands and reconfigure it
|
||||
# In particular setting a config, displaying as cli commands and reconfigure it
|
||||
# Tests:
|
||||
# Make a config in CLI. Show output as CLI, save it and ensure it is the same
|
||||
# Try the different GENMODEL settings
|
||||
|
|
@ -25,11 +26,20 @@ fi
|
|||
|
||||
# Use yang in example
|
||||
|
||||
if [ ! -d "$OPENCONFIG" ]; then
|
||||
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
|
||||
echo "...skipped: OPENCONFIG not set"
|
||||
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
fi
|
||||
|
||||
OCDIR=$OPENCONFIG/release/models
|
||||
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$OCDIR/</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
|
||||
<CLICON_CLISPEC_DIR>$clidir</CLICON_CLISPEC_DIR>
|
||||
|
|
@ -49,6 +59,7 @@ cat <<EOF > $fyang
|
|||
module $APPNAME {
|
||||
namespace "urn:example:clixon";
|
||||
prefix ex;
|
||||
import openconfig-extensions { prefix oc-ext; }
|
||||
container table{
|
||||
list parameter{
|
||||
key name;
|
||||
|
|
@ -69,6 +80,42 @@ module $APPNAME {
|
|||
}
|
||||
}
|
||||
}
|
||||
container interfaces {
|
||||
oc-ext:operational;
|
||||
list interface {
|
||||
key name;
|
||||
leaf name {
|
||||
type string;
|
||||
}
|
||||
container config {
|
||||
leaf enabled {
|
||||
type boolean;
|
||||
default false;
|
||||
description "Whether the interface is enabled or not.";
|
||||
}
|
||||
}
|
||||
container state {
|
||||
config false;
|
||||
leaf oper-status {
|
||||
type enumeration {
|
||||
enum UP {
|
||||
value 1;
|
||||
description "Ready to pass packets.";
|
||||
}
|
||||
enum DOWN {
|
||||
value 2;
|
||||
description "The interface does not pass any packets.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
leaf enabled {
|
||||
type boolean;
|
||||
default false;
|
||||
description "Whether the interface is enabled or not.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
@ -127,6 +174,9 @@ function testrun()
|
|||
elif [ $mode = HIDE ]; then
|
||||
table=
|
||||
name=
|
||||
elif [ $mode = OC_COMPRESS ]; then
|
||||
table=
|
||||
name=
|
||||
else
|
||||
table=" table"
|
||||
name=
|
||||
|
|
@ -159,7 +209,7 @@ SAVED=$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg show config)
|
|||
new "delete a x"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg delete$table parameter$name a value x)" 0 ""
|
||||
|
||||
new "show match a & b xml"
|
||||
new "show match a & b xml"
|
||||
expectpart "$($clixon_cli -1 -o CLICON_CLI_GENMODEL_TYPE=$mode -f $cfg show xml)" 0 "<table xmlns=\"urn:example:clixon\">" "<parameter>" "<name>a</name>" "</parameter>" "<parameter>" "<name>b</name>" "<value>z</value>" "</parameter>" "</table>" --not-- "<value>x</value>"
|
||||
|
||||
new "delete a"
|
||||
|
|
@ -190,6 +240,9 @@ testrun HIDE
|
|||
new "keywords=ALL"
|
||||
testrun ALL
|
||||
|
||||
new "keywords=OC_COMPRESS"
|
||||
testrun OC_COMPRESS
|
||||
|
||||
new "keywords=VARS"
|
||||
testrun VARS
|
||||
|
||||
|
|
@ -201,7 +254,7 @@ new "commit"
|
|||
expectpart "$($clixon_cli -1 -f $cfg commit)" 0 ""
|
||||
|
||||
new "show state"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show state)" 0 "exstate sender x" "table parameter a" "table parameter a value x"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show state)" 0 "exstate sender x" "table parameter a" "table parameter a value x"
|
||||
|
||||
new "show state exstate"
|
||||
expectpart "$($clixon_cli -1 -f $cfg show state exstate)" 0 "state sender x" --not-- "table parameter a" "table parameter a value x"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue