With-default cli test, use xpath to only show config tree

Make all tests independent of CLICON_STREAM_DISCOVERY_RFC8040 setting
This commit is contained in:
Olof hagsand 2022-09-19 10:57:15 +02:00
parent 3bf8a7dca3
commit 07536fc8d2
5 changed files with 36 additions and 28 deletions

View file

@ -27,6 +27,7 @@ cat <<EOF > $cfg
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR> <CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY> <CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY>
<CLICON_STREAM_DISCOVERY_RFC8040>false</CLICON_STREAM_DISCOVERY_RFC8040>
</clixon-config> </clixon-config>
EOF EOF

View file

@ -40,6 +40,7 @@ cat <<EOF > $cfg
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML> <CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML>
<CLICON_STREAM_DISCOVERY_RFC8040>false</CLICON_STREAM_DISCOVERY_RFC8040>
</clixon-config> </clixon-config>
EOF EOF

View file

@ -145,6 +145,7 @@ function testrun()
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY> <CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY>
<CLICON_YANG_UNKNOWN_ANYDATA>$unknown</CLICON_YANG_UNKNOWN_ANYDATA> <CLICON_YANG_UNKNOWN_ANYDATA>$unknown</CLICON_YANG_UNKNOWN_ANYDATA>
<CLICON_STREAM_DISCOVERY_RFC8040>false</CLICON_STREAM_DISCOVERY_RFC8040>
$F $F
$RESTCONFIG $RESTCONFIG
</clixon-config> </clixon-config>

View file

@ -131,22 +131,22 @@ show("Show a particular state of the system"){
configuration("Show configuration") configuration("Show configuration")
xml("Show configuration and state as XML") xml("Show configuration and state as XML")
default("With-default mode"){ default("With-default mode"){
report-all, cli_show_auto_mode("candidate", "xml", false, false, "report-all"); report-all @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all");
trim, cli_show_auto_mode("candidate", "xml", false, false, "trim"); trim @datamodelshow, cli_show_auto("candidate", "xml", false, false, "trim");
explicit, cli_show_auto_mode("candidate", "xml", false, false, "explicit"); explicit @datamodelshow, cli_show_auto("candidate", "xml", false, false, "explicit");
report-all-tagged, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged"); report-all-tagged @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-default"); report-all-tagged-default @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("candidate", "xml", false, false, "report-all-tagged-strip"); report-all-tagged-strip @datamodelshow, cli_show_auto("candidate", "xml", false, false, "report-all-tagged-strip");
} }
state("Show configuration and state") state("Show configuration and state")
xml("Show configuration and state as XML") xml("Show configuration and state as XML")
default("With-default mode"){ default("With-default mode"){
report-all, cli_show_auto_mode("running", "xml", false, true, "report-all"); report-all @datamodelshow, cli_show_auto("running", "xml", false, true, "report-all");
trim, cli_show_auto_mode("running", "xml", false, true, "trim"); trim @datamodelshow, cli_show_auto("running", "xml", false, true, "trim");
explicit, cli_show_auto_mode("running", "xml", false, true, "explicit"); explicit @datamodelshow, cli_show_auto("running", "xml", false, true, "explicit");
report-all-tagged, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged"); report-all-tagged @datamodelshow, cli_show_auto("running", "xml", false, true, "report-all-tagged");
report-all-tagged-default, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-default"); report-all-tagged-default @datamodelshow, cli_show_auto("running", "xml", false, true, "report-all-tagged-default");
report-all-tagged-strip, cli_show_auto_mode("running", "xml", false, true, "report-all-tagged-strip"); report-all-tagged-strip @datamodelshow, cli_show_auto("running", "xml", false, true, "report-all-tagged-strip");
} }
} }
EOF EOF
@ -570,45 +570,45 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR
# CLI tests # CLI tests
mode=explicit mode=explicit
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv></interfaces>$"
mode=report-all mode=report-all
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu>1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu>1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$"
mode=report-all-tagged mode=report-all-tagged
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu></interface><cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu></interface><cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu><status wd:default=\"true\">ok</status></interface><interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu><status wd:default=\"true\">ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu><status>waking up</status></interface><cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu><status wd:default=\"true\">ok</status></interface><interface><name>eth1</name><mtu wd:default=\"true\">1500</mtu><status wd:default=\"true\">ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu wd:default=\"true\">1500</mtu><status>waking up</status></interface><cedv><edv wd:default=\"true\">edv</edv></cedv><cdv><dv wd:default=\"true\">dv</dv></cdv></interfaces>$"
mode=trim mode=trim
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name></interface></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name></interface></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><status>waking up</status></interface></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><status>waking up</status></interface></interfaces>$"
mode=report-all-tagged-default mode=report-all-tagged-default
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu>1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name><mtu>1500</mtu></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name><mtu>1500</mtu></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu><status>ok</status></interface><interface><name>eth1</name><mtu>1500</mtu><status>ok</status></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><mtu>1500</mtu><status>waking up</status></interface><cedv><edv>edv</edv></cedv><cdv><dv>dv</dv></cdv></interfaces>$"
mode=report-all-tagged-strip mode=report-all-tagged-strip
new "cli with-default config $mode" new "cli with-default config $mode"
expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name></interface></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show config xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu></interface><interface><name>eth3</name></interface></interfaces>$"
new "cli with-default state $mode" new "cli with-default state $mode"
expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><status>waking up</status></interface></interfaces>$" expectpart "$($clixon_cli -1 -f $cfg show state xml default $mode interfaces)" 0 "^<interfaces xmlns=\"http://example.com/ns/interfaces\" xmlns:wd=\"urn:ietf:params:xml:ns:netconf:default:1.0\"><interface><name>eth0</name><mtu>8192</mtu></interface><interface><name>eth1</name></interface><interface><name>eth2</name><mtu>9000</mtu><status>not feeling so good</status></interface><interface><name>eth3</name><status>waking up</status></interface></interfaces>$"
mode=negative-test mode=negative-test
new "cli with-default config $mode" new "cli with-default config $mode"

View file

@ -1074,7 +1074,8 @@ module clixon-config {
leaf CLICON_STREAM_DISCOVERY_RFC5277 { leaf CLICON_STREAM_DISCOVERY_RFC5277 {
type boolean; type boolean;
default false; default false;
description "Enable event stream discovery as described in RFC 5277 description
"Enable event stream discovery as described in RFC 5277
sections 3.2. If enabled, available streams will appear sections 3.2. If enabled, available streams will appear
when doing netconf get or restconf GET"; when doing netconf get or restconf GET";
} }
@ -1082,7 +1083,11 @@ module clixon-config {
type boolean; type boolean;
default false; default false;
description description
"Enable monitoring information for the RESTCONF protocol from RFC 8040"; "Enable monitoring information for the RESTCONF protocol from RFC 8040 as specified
in module ietf-restconf-monitoring.yang
Note that the name of this option is misleading, the monitoring module defines state
for both capabilities and streams, not only streams which the name indicates.
Also, consider changinf default to true.";
} }
leaf CLICON_STREAM_PATH { leaf CLICON_STREAM_PATH {
type string; type string;