-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed: [connection open does local commit on services](#119) Fixed problem with optimization of moving per-dev commits to single per-transition
- Loading branch information
1 parent
b0dbb1c
commit 971e2e9
Showing
10 changed files
with
660 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Simple C / non-python service checking shared object create and delete | ||
# Uses util/controller_service.c as C-based server | ||
# Keep non-device config after pull, see https://github.com/clicon/clixon-controller/issues/119 | ||
# | ||
|
||
# Magic line must be first in script (see README.md) | ||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi | ||
|
||
if [ $nr -lt 2 ]; then | ||
echo "Test requires nr=$nr to be greater than 1" | ||
if [ "$s" = $0 ]; then exit 0; else return 0; fi | ||
fi | ||
|
||
dir=/var/tmp/$0 | ||
CFG=$dir/controller.xml | ||
CFD=$dir/confdir | ||
test -d $dir || mkdir -p $dir | ||
test -d $CFD || mkdir -p $CFD | ||
|
||
fyang=$dir/myyang.yang | ||
|
||
: ${clixon_controller_xpath:=clixon_controller_xpath} | ||
|
||
# source IMG/USER etc | ||
. ./site.sh | ||
|
||
# Common NACM scripts | ||
. ./nacm.sh | ||
|
||
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_FEATURE>clixon-restconf:allow-auth-none</CLICON_FEATURE> | ||
<CLICON_CONFIG_EXTEND>clixon-controller-config</CLICON_CONFIG_EXTEND> | ||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR> | ||
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR> | ||
<CLICON_CLI_MODE>operation</CLICON_CLI_MODE> | ||
<CLICON_CLI_DIR>${LIBDIR}/controller/cli</CLICON_CLI_DIR> | ||
<CLICON_CLISPEC_DIR>${LIBDIR}/controller/clispec</CLICON_CLISPEC_DIR> | ||
<CLICON_BACKEND_DIR>${LIBDIR}/controller/backend</CLICON_BACKEND_DIR> | ||
<CLICON_SOCK>${LOCALSTATEDIR}/run/controller.sock</CLICON_SOCK> | ||
<CLICON_SOCK_GROUP>${CLICON_GROUP}</CLICON_SOCK_GROUP> | ||
<CLICON_SOCK_PRIO>true</CLICON_SOCK_PRIO> | ||
<CLICON_BACKEND_PIDFILE>${LOCALSTATEDIR}/run/controller.pid</CLICON_BACKEND_PIDFILE> | ||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR> | ||
<CLICON_XMLDB_MULTI>true</CLICON_XMLDB_MULTI> | ||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE> | ||
<CLICON_STREAM_DISCOVERY_RFC5277>true</CLICON_STREAM_DISCOVERY_RFC5277> | ||
<CLICON_RESTCONF_USER>${CLICON_USER}</CLICON_RESTCONF_USER> | ||
<CLICON_RESTCONF_PRIVILEGES>drop_perm</CLICON_RESTCONF_PRIVILEGES> | ||
<CLICON_RESTCONF_INSTALLDIR>${SBINDIR}</CLICON_RESTCONF_INSTALLDIR> | ||
<CLICON_BACKEND_USER>${CLICON_USER}</CLICON_BACKEND_USER> | ||
<CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML> | ||
<CLICON_CLI_HELPSTRING_TRUNCATE>true</CLICON_CLI_HELPSTRING_TRUNCATE> | ||
<CLICON_CLI_HELPSTRING_LINES>1</CLICON_CLI_HELPSTRING_LINES> | ||
<CLICON_CLI_OUTPUT_FORMAT>text</CLICON_CLI_OUTPUT_FORMAT> | ||
<CLICON_YANG_SCHEMA_MOUNT>true</CLICON_YANG_SCHEMA_MOUNT> | ||
<CLICON_NACM_CREDENTIALS>exact</CLICON_NACM_CREDENTIALS> | ||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE> | ||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY> | ||
</clixon-config> | ||
EOF | ||
|
||
cat<<EOF > $CFD/autocli.xml | ||
<clixon-config xmlns="http://clicon.org/config"> | ||
<autocli> | ||
<module-default>false</module-default> | ||
<list-keyword-default>kw-nokey</list-keyword-default> | ||
<treeref-state-default>true</treeref-state-default> | ||
<grouping-treeref>true</grouping-treeref> | ||
<rule> | ||
<name>include controller</name> | ||
<module-name>clixon-controller</module-name> | ||
<operation>enable</operation> | ||
</rule> | ||
<rule> | ||
<name>include openconfig</name> | ||
<module-name>openconfig*</module-name> | ||
<operation>enable</operation> | ||
</rule> | ||
<!-- there are many more arista/openconfig top-level modules --> | ||
</autocli> | ||
</clixon-config> | ||
EOF | ||
|
||
cat <<EOF > $fyang | ||
module myyang { | ||
yang-version 1.1; | ||
namespace "urn:example:test"; | ||
prefix test; | ||
import clixon-controller { | ||
prefix ctrl; | ||
} | ||
revision 2023-03-22{ | ||
description "Initial prototype"; | ||
} | ||
augment "/ctrl:services" { | ||
list testA { | ||
description "Test A service"; | ||
key a_name; | ||
leaf a_name { | ||
description "Test A instance"; | ||
type string; | ||
} | ||
leaf-list params{ | ||
type string; | ||
min-elements 1; /* For validate fail*/ | ||
} | ||
uses ctrl:created-by-service; | ||
} | ||
} | ||
augment "/ctrl:services" { | ||
list testB { | ||
description "Test B service"; | ||
key b_name; | ||
leaf b_name { | ||
description "Test B instance"; | ||
type string; | ||
} | ||
leaf-list params{ | ||
type string; | ||
} | ||
uses ctrl:created-by-service; | ||
} | ||
} | ||
} | ||
EOF | ||
|
||
RULES=$(cat <<EOF | ||
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm"> | ||
<enable-nacm>true</enable-nacm> | ||
<read-default>permit</read-default> | ||
<write-default>permit</write-default> | ||
<exec-default>permit</exec-default> | ||
$NGROUPS | ||
$NADMIN | ||
</nacm> | ||
EOF | ||
) | ||
|
||
# Start from startup which by default should start it | ||
# First disable services process | ||
cat <<EOF > $dir/startup_db | ||
<config> | ||
<processes xmlns="http://clicon.org/controller"> | ||
<services> | ||
<enabled>true</enabled> | ||
</services> | ||
</processes> | ||
$RULES | ||
</config> | ||
EOF | ||
|
||
cat<<EOF > $CFD/action-command.xml | ||
<clixon-config xmlns="http://clicon.org/config"> | ||
<CONTROLLER_ACTION_COMMAND xmlns="http://clicon.org/controller-config">${BINDIR}/clixon_controller_service -f $CFG</CONTROLLER_ACTION_COMMAND> | ||
</clixon-config> | ||
EOF | ||
|
||
# Reset devices with initial config | ||
. ./reset-devices.sh | ||
|
||
if $BE; then | ||
new "Kill old backend" | ||
stop_backend -f $CFG | ||
fi | ||
if $BE; then | ||
new "Start new backend -s startup -f $CFG -D $DBG" | ||
sudo clixon_backend -s startup -f $CFG -D $DBG | ||
fi | ||
|
||
new "Wait backend 1" | ||
wait_backend | ||
|
||
# Reset controller by initiating with clixon/openconfig devices and a pull | ||
. ./reset-controller.sh | ||
|
||
new "close connections" | ||
expectpart "$(${clixon_cli} -1f $CFG connect close)" 0 "" | ||
|
||
new "Set service" | ||
expectpart "$(${clixon_cli} -1f $CFG -m configure set services testA bar params AA)" 0 "" | ||
|
||
new "Compare service" | ||
expectpart "$($clixon_cli -1 -f $CFG -m configure show compare xml)" 0 "^+\ *<testA xmlns=\"urn:example:test\">" "^+\ *<a_name>bar</a_name>" "^+\ *<params>AA</params>" | ||
|
||
new "open connections" | ||
expectpart "$(${clixon_cli} -1f $CFG connect open wait)" 0 "" | ||
|
||
new "Compare service again" | ||
expectpart "$($clixon_cli -1 -f $CFG -m configure show compare xml)" 0 "^+\ *<testA xmlns=\"urn:example:test\">" "^+\ *<a_name>bar</a_name>" "^+\ *<params>AA</params>" | ||
|
||
if $BE; then | ||
new "Kill old backend" | ||
stop_backend -f $CFG | ||
fi | ||
|
||
endtest |
Oops, something went wrong.