Added valgrind memory leak tests for backend. Fixed some minor leaks and file descriptor closes.

This commit is contained in:
Olof hagsand 2019-02-19 13:16:59 +01:00
parent add43d250d
commit 4c0b412e9f
34 changed files with 318 additions and 382 deletions

View file

@ -135,7 +135,8 @@
* Replaced all calls to (obsolete) `cli_output` with `fprintf` * Replaced all calls to (obsolete) `cli_output` with `fprintf`
* Added _experimental_ config option `CLICON_CLI_UTF8` default set to 0. * Added _experimental_ config option `CLICON_CLI_UTF8` default set to 0.
* CLIgen UTF8 does not work with scrolling and control editing * CLIgen UTF8 does not work with scrolling and control editing
* Added valgrind memory leak tests in testmem.sh for cli and netconf * Added valgrind memory leak tests in testmem.sh for cli, netconf and backend
* remains: restconf
* Added `make test` from top-level Makefile * Added `make test` from top-level Makefile
* Added `xml_rootchild_node()` lib function as variant of `xml_rootchild()` * Added `xml_rootchild_node()` lib function as variant of `xml_rootchild()`
* Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf. * Added -o "<option>=<value>" command-line option to all programs: backend, cli, netconf, restconf.

View file

@ -83,8 +83,10 @@ backend_terminate(clicon_handle h)
{ {
yang_spec *yspec; yang_spec *yspec;
char *pidfile = clicon_backend_pidfile(h); char *pidfile = clicon_backend_pidfile(h);
int sockfamily = clicon_sock_family(h);
char *sockpath = clicon_sock(h); char *sockpath = clicon_sock(h);
cxobj *x; cxobj *x;
struct stat st;
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
if ((yspec = clicon_dbspec_yang(h)) != NULL) if ((yspec = clicon_dbspec_yang(h)) != NULL)
@ -99,10 +101,12 @@ backend_terminate(clicon_handle h)
clixon_plugin_exit(h); clixon_plugin_exit(h);
/* Delete all backend plugin RPC callbacks */ /* Delete all backend plugin RPC callbacks */
rpc_callback_delete_all(); rpc_callback_delete_all();
if (pidfile) if (pidfile)
unlink(pidfile); unlink(pidfile);
if (sockpath) if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0)
unlink(sockpath); unlink(sockpath);
xmldb_plugin_unload(h); /* unload storage plugin */ xmldb_plugin_unload(h); /* unload storage plugin */
backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */ backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */
event_exit(); event_exit();
@ -203,9 +207,12 @@ db_merge(clicon_handle h,
} }
/*! Create backend server socket and register callback /*! Create backend server socket and register callback
* @param[in] h Clicon handle
* @retval s Server socket file descriptor (see socket(2))
* @retval -1 Error
*/ */
static int static int
server_socket(clicon_handle h) backend_server_socket(clicon_handle h)
{ {
int ss; int ss;
@ -571,6 +578,7 @@ main(int argc,
yang_spec *yspec = NULL; yang_spec *yspec = NULL;
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */ yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
char *str; char *str;
int ss = -1; /* server socket */
/* In the startup, logs to stderr & syslog and debug flag set later */ /* In the startup, logs to stderr & syslog and debug flag set later */
clicon_log_init(__PROGRAM__, LOG_INFO, logdst); clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
@ -924,7 +932,7 @@ main(int argc,
} }
/* Initialize server socket */ /* Initialize server socket */
if (server_socket(h) < 0) if ((ss = backend_server_socket(h)) < 0)
goto done; goto done;
if (debug) if (debug)
@ -937,6 +945,8 @@ main(int argc,
retval = 0; retval = 0;
done: done:
clicon_log(LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval); clicon_log(LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval);
if (ss != -1)
close(ss);
backend_terminate(h); /* Cannot use h after this */ backend_terminate(h); /* Cannot use h after this */
return retval; return retval;

View file

@ -74,6 +74,13 @@
#include "backend_client.h" #include "backend_client.h"
#include "backend_handle.h" #include "backend_handle.h"
/*! Open an INET stream socket and bind it to a file descriptor
*
o * @param[in] h Clicon handle
* @param[in] dst IPv4 address (see inet_pton(3))
* @retval s Socket file descriptor (see socket(2))
* @retval -1 Error
*/
static int static int
config_socket_init_ipv4(clicon_handle h, config_socket_init_ipv4(clicon_handle h,
char *dst) char *dst)
@ -112,10 +119,14 @@ config_socket_init_ipv4(clicon_handle h,
return -1; return -1;
} }
/*! Open a socket and bind it to a file descriptor /*! Open a UNIX domain socket and bind it to a file descriptor
* *
* The socket is accessed via CLICON_SOCK option, has 770 permissions * The socket is accessed via CLICON_SOCK option, has 770 permissions
* and group according to CLICON_SOCK_GROUP option. * and group according to CLICON_SOCK_GROUP option.
* @param[in] h Clicon handle
* @param[in] sock Unix file-system path
* @retval s Socket file descriptor (see socket(2))
* @retval -1 Error
*/ */
static int static int
config_socket_init_unix(clicon_handle h, config_socket_init_unix(clicon_handle h,
@ -175,10 +186,16 @@ config_socket_init_unix(clicon_handle h,
return -1; return -1;
} }
/*! Open backend socket, the one clients send requests to, either ip or unix
*
* @param[in] h Clicon handle
* @retval s Socket file descriptor (see socket(2))
* @retval -1 Error
*/
int int
backend_socket_init(clicon_handle h) backend_socket_init(clicon_handle h)
{ {
char *sock; char *sock; /* unix path or ip address string */
if ((sock = clicon_sock(h)) == NULL){ if ((sock = clicon_sock(h)) == NULL){
clicon_err(OE_FATAL, 0, "CLICON_SOCK option not set"); clicon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
@ -191,8 +208,12 @@ backend_socket_init(clicon_handle h)
case AF_INET: case AF_INET:
return config_socket_init_ipv4(h, sock); return config_socket_init_ipv4(h, sock);
break; break;
default:
clicon_err(OE_UNIX, EINVAL, "No such address family: %d",
clicon_sock_family(h));
break;
} }
return 0; return -1;
} }
/*! Accept new socket client /*! Accept new socket client

View file

@ -160,9 +160,11 @@ clicon_file_dirent(const char *dir,
qsort((void *)new, nent, sizeof(*new), clicon_file_dirent_sort); qsort((void *)new, nent, sizeof(*new), clicon_file_dirent_sort);
*ent = new; *ent = new;
new = NULL;
retval = nent; retval = nent;
quit: quit:
if (new)
free(new);
if (dirp) if (dirp)
closedir(dirp); closedir(dirp);
if (regexp) if (regexp)

View file

@ -103,6 +103,7 @@ clicon_log_exit(void)
{ {
if (_logfile) if (_logfile)
fclose(_logfile); fclose(_logfile);
closelog(); /* optional */
return 0; return 0;
} }

View file

@ -2556,6 +2556,8 @@ yang_spec_load_dir(clicon_handle h,
goto done; goto done;
retval = 0; retval = 0;
done: done:
if (dp)
free(dp);
if (base) if (base)
free(base); free(base);
return retval; return retval;

View file

@ -3,12 +3,13 @@
## Overview ## Overview
Tests called 'test_*.sh' and placed in this directory will be Tests called 'test_*.sh' and placed in this directory will be
automatically run as part of the all.sh, sum.sh tests etc. The scripts need to follow some rules to work properly, such as add this magic line as the first command line in the script, which ensures it works well when started from `all.sh`: automatically run as part of the all.sh, sum.sh tests etc. The scripts
``` need to follow some rules to work properly, please look at one or two
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi to get the idea.
```
## Prerequisites See also the [site.sh](#site.sh) for example for skipping tests or setting some site-specific variables.
## Getting started
You need to build and install the clixon utility programs before running the tests as some of the tests rely on them: You need to build and install the clixon utility programs before running the tests as some of the tests rely on them:
``` ```
@ -20,6 +21,7 @@ You need to build and install the clixon utility programs before running the tes
You need to start nginx for some of the text. There are instructions in You need to start nginx for some of the text. There are instructions in
* If you run systemd: `sudo systemctl start nginx.service` * If you run systemd: `sudo systemctl start nginx.service`
* The [example](../example/README.md) has instructions * The [example](../example/README.md) has instructions
* See also the [clixon test container](../docker/system) where all test are encapsulated.
## Prefix variable ## Prefix variable
@ -28,7 +30,7 @@ You can prefix a test with `BE=0` if you want to run your own backend.
To run with debug flags, use the `DBG=<number>` environment variable. To run with debug flags, use the `DBG=<number>` environment variable.
Other variables include: Other variables include:
* DEMSLEEP Number of seconds to sleep after daemons have started * RCWAIT Number of seconds to sleep after daemons have started
## Run all tests ## Run all tests
@ -47,6 +49,8 @@ These tests use valgrind to check for memory leaks:
``` ```
mem.sh cli mem.sh cli
mem.sh netconf mem.sh netconf
mem.sh backend
# mem.sh restconf # NYI
``` ```
## Site.sh ## Site.sh
@ -63,7 +67,3 @@ You may add your site-specific modifications in a `site.sh` file. Example:
IETFRFC=$YANGMODELS/standard/ietf/RFC IETFRFC=$YANGMODELS/standard/ietf/RFC
``` ```
## See also
The [clixon test container](../docker/system) encapsulates the `all.sh` test in a test container.

View file

@ -43,8 +43,16 @@ fi
# Single test. Set by "new" # Single test. Set by "new"
testname= testname=
# If valgrindtest use a file to log valgrind output on (checked by new) # Valgind memory leak check.
# The values are:
# 0: No valgrind check
# 1: Start valgrind at every new testcase. Check result every next new
# 2: Start valgrind every new backend start. Check when backend stops
# 3: Start valgrind every new restconf start. Check when restconf stops
#
: ${valgrindtest=0} : ${valgrindtest=0}
# Valgrind log file. This is usually removed automatically
: ${valgrindfile=$(mktemp)} : ${valgrindfile=$(mktemp)}
# If set to 0, override starting of clixon_backend in test (you bring your own) # If set to 0, override starting of clixon_backend in test (you bring your own)
@ -72,22 +80,14 @@ testname=
: ${IETFRFC=../yang/standard} : ${IETFRFC=../yang/standard}
#: ${IETFRFC=$YANGMODELS/standard/ietf/RFC} #: ${IETFRFC=$YANGMODELS/standard/ietf/RFC}
# For memcheck # Follow the binary programs that can be parametrized (eg with valgrind)
#clixon_cli="valgrind --leak-check=full --show-leak-kinds=all clixon_cli"
: ${clixon_cli:=clixon_cli} : ${clixon_cli:=clixon_cli}
# For memcheck / performance
#clixon_netconf="valgrind --tool=callgrind clixon_netconf"
# use kcachegrind to view
#clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
: ${clixon_netconf:=clixon_netconf} : ${clixon_netconf:=clixon_netconf}
# How to run restconf stand-alone and using valgrind
#clixon_restconf="valgrind --trace-children=no --child-silent-after-fork=yes --leak-check=full --show-leak-kinds=all /www-data/clixon_restconf"
: ${clixon_restconf:=/www-data/clixon_restconf} : ${clixon_restconf:=/www-data/clixon_restconf}
# If you test w valgrind, you need to set -F & and sleep 10 when starting
#clixon_backend="valgrind --leak-check=full --show-leak-kinds=all clixon_backend"
: ${clixon_backend:=clixon_backend} : ${clixon_backend:=clixon_backend}
dir=/var/tmp/$0 dir=/var/tmp/$0
@ -122,10 +122,36 @@ checkvalgrind(){
res=$(cat $valgrindfile | grep -e "reachable" -e "lost:"|awk '{print $4}' | grep -v '^0$') res=$(cat $valgrindfile | grep -e "reachable" -e "lost:"|awk '{print $4}' | grep -v '^0$')
if [ -n "$res" ]; then if [ -n "$res" ]; then
>&2 cat $valgrindfile >&2 cat $valgrindfile
rm -f $valgrindfile sudo rm -f $valgrindfile
exit -1 exit -1
fi fi
rm -f $valgrindfile sudo rm -f $valgrindfile
fi
}
# Start backend with all varargs.
# If valgrindtest == 2, start valgrind
start_backend(){
if [ $valgrindtest -eq 2 ]; then
# Start in background since daemon version creates two traces: parent,
# child. If background then only the single relevant.
sudo $clixon_backend -F $* -D $DBG &
else
sudo $clixon_backend $* -D $DBG
fi
if [ $? -ne 0 ]; then
err
fi
}
stop_backend(){
sudo clixon_backend -z $*
if [ $? -ne 0 ]; then
err "kill backend"
fi
if [ $valgrindtest -eq 2 ]; then
sleep 1
checkvalgrind
fi fi
} }

View file

@ -14,32 +14,33 @@ echo "valgrindfile:$valgrindfile"
case "$PROGRAM" in case "$PROGRAM" in
'cli') 'cli')
valgrindtest=1 valgrindtest=1
DEMSLEEP=1 RCWAIT=1
clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli"
;; ;;
'netconf') 'netconf')
valgrindtest=1 valgrindtest=1
DEMSLEEP=1 RCWAIT=1
clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf"
;; ;;
# 'backend') 'backend')
# valgrindtest=2 valgrindtest=2 # This means backend valgrind test
# DEMSLEEP=20 RCWAIT=10 # valgrind backend needs some time to get up
# clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=yes --log-file=$valgrindfile clixon_backend" perfnr=100 # test_perf.sh restconf put more or less stops
#;; perfreq=10
clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend"
;;
*) *)
echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks
exit -1 exit -1
;; ;;
esac esac
rm -f
err=0 err=0
testnr=0 testnr=0
for test in test*.sh; do for test in test_*.sh; do
testfile=$test testfile=$test
DEMSLEEP=$DEMSLEEP . ./$test . ./$test
errcode=$? errcode=$?
if [ $errcode -ne 0 ]; then if [ $errcode -ne 0 ]; then
err=1 err=1
@ -47,12 +48,9 @@ for test in test*.sh; do
echo -ne "\e[0m" echo -ne "\e[0m"
exit $errcode exit $errcode
fi fi
if [ $valgrindtest -eq 2 ]; then
# sudo cat $valgrindfile
sudo checkvalgrind
# sudo rm -f $valgrindfile
fi
done done
checkvalgrind if [ $valgrindtest -eq 1 ]; then
rm -f $valgrindfile checkvalgrind
sudo rm -f $valgrindfile
fi

View file

@ -99,10 +99,7 @@ if [ $BE -ne 0 ]; then
sudo pkill clixon_backend # to be sure sudo pkill clixon_backend # to be sure
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -111,6 +108,9 @@ sudo pkill -u www-data clixon_restconf
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $RCLOG $cfg -y $fyang -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $RCLOG $cfg -y $fyang -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT
# First vanilla (protocol) case # First vanilla (protocol) case
new "netconf validate empty" new "netconf validate empty"
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><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
@ -207,9 +207,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -44,10 +44,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "cli configure top" new "cli configure top"
@ -131,9 +131,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -35,8 +35,7 @@ cat <<EOF > $cfg
EOF EOF
testrun(){
run(){
mode=$1 mode=$1
expect=$2 expect=$2
@ -86,17 +85,18 @@ EOF
fi fi
new "start backend -f $cfg -s $mode -c $dir/config" new "start backend -f $cfg -s $mode -c $dir/config"
sudo $clixon_backend -f $cfg -s $mode -c $dir/config start_backend -f $cfg -s $mode -c $dir/config
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "Check $mode" new "Check $mode"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' "^<rpc-reply>$expect</rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' "^<rpc-reply>$expect</rpc-reply>]]>]]>$"
if [ $BE -eq 0 ]; then if [ $BE -eq 0 ]; then
exit # BE return # BE
fi fi
new "Kill backend" new "Kill backend"
@ -106,14 +106,11 @@ EOF
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then } # testrun
err "kill backend"
fi
} # run testrun running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
run running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>' testrun startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
run startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
rm -rf $dir rm -rf $dir

View file

@ -70,11 +70,10 @@ if [ $BE -ne 0 ]; then
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
# start new backend start_backend -s init -f $cfg -y $fyang
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
fi fi
new "cli enabled feature" new "cli enabled feature"
@ -183,9 +182,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -117,11 +117,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
# start new backend start_backend -s init -f $cfg -y $fyang
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
fi fi
new "Set crypto to aes" new "Set crypto to aes"
@ -196,9 +195,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -zf $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -85,10 +85,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "leafref base config" new "leafref base config"
@ -155,9 +155,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -75,10 +75,10 @@ if [ $BE -ne 0 ]; then
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend # start new backend
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "minmax: minimal" new "minmax: minimal"
@ -137,9 +137,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -119,10 +119,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -132,6 +129,7 @@ sleep 1
new "start restconf daemon (-a is enable basic authentication)" new "start restconf daemon (-a is enable basic authentication)"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "auth get" new "auth get"
@ -193,9 +191,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -139,10 +139,7 @@ if [ $BE -ne 0 ]; then
sleep 1 sleep 1
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend # start new backend
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -151,6 +148,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon (-a is enable http basic auth)" new "start restconf daemon (-a is enable http basic auth)"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "auth get" new "auth get"
@ -222,9 +220,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -134,10 +134,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -147,6 +144,7 @@ sleep 1
new "start restconf daemon (-a is enable basic authentication)" new "start restconf daemon (-a is enable basic authentication)"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "auth set authentication config" new "auth set authentication config"
@ -287,9 +285,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -142,10 +142,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -155,6 +152,7 @@ sleep 1
new "start restconf daemon (-a is enable basic authentication)" new "start restconf daemon (-a is enable basic authentication)"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
# Set nacm from scratch # Set nacm from scratch
@ -269,9 +267,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -142,10 +142,7 @@ if [ $BE -ne 0 ]; then
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -155,6 +152,7 @@ sleep 1
new "start restconf daemon (-a is enable basic authentication)" new "start restconf daemon (-a is enable basic authentication)"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "auth set authentication config" new "auth set authentication config"
@ -231,9 +229,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -43,11 +43,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg -D $DBG
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
fi fi
new "netconf hello" new "netconf hello"
@ -216,9 +215,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -140,10 +140,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend" new "start backend"
sudo $clixon_backend -s running -f $cfg -y $fyang -D $DBG start_backend -s running -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
# STATE (should not be ordered) # STATE (should not be ordered)
@ -227,9 +227,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -4,24 +4,17 @@
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
number=5000 # Number of list/leaf-list entries in file
req=100 : ${perfnr:=1000}
if [ $# = 0 ]; then
number=1000 # Number of requests made get/put
elif [ $# = 1 ]; then : ${perfreq:=100}
number=$1
elif [ $# = 2 ]; then
number=$1
req=$2
else
echo "Usage: $0 [<number> [<requests>]]"
exit 1 # Scaling
fi
APPNAME=example APPNAME=example
cfg=$dir/scaling-conf.xml cfg=$dir/scaling-conf.xml
fyang=$dir/scaling.yang fyang=$dir/scaling.yang
fconfig=$dir/config fconfig=$dir/large.xml
cat <<EOF > $fyang cat <<EOF > $fyang
module scaling{ module scaling{
@ -57,10 +50,11 @@ cat <<EOF > $cfg
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY> <CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN> <CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_XMLDB_PRETTY>false</CLICON_XMLDB_PRETTY>
</config> </config>
EOF EOF
new "test params: -f $cfg" -y $fyang new "test params: -f $cfg -y $fyang"
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
new "kill old backend" new "kill old backend"
sudo clixon_backend -zf $cfg -y $fyang sudo clixon_backend -zf $cfg -y $fyang
@ -68,12 +62,8 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
# start new backend start_backend -s init -f $cfg -y $fyang
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -82,69 +72,75 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "generate 'large' config with $number list entries" new "generate 'large' config with $perfnr list entries"
echo -n "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\">" > $fconfig echo -n "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\">" > $fconfig
for (( i=0; i<$number; i++ )); do for (( i=0; i<$perfnr; i++ )); do
echo -n "<y><a>$i</a><b>$i</b></y>" >> $fconfig echo -n "<y><a>$i</a><b>$i</b></y>" >> $fconfig
done done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig
# Just for manual dbg # Now take large config file and write it via netconf to candidate
echo "$clixon_netconf -qf $cfg -y $fyang"
new "netconf write large config" new "netconf write large config"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
#echo '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' | $clixon_netconf -qf $cfg -y $fyang # Here, there are $perfnr entries in candidate
new "netconf write large config again" new "netconf write large config again"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
#echo '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' | $clixon_netconf -qf $cfg -y $fyang # Remove the file, its used for different purposes further down
rm $fconfig rm $fconfig
# Now commit it from candidate to running
new "netconf commit large config" new "netconf commit large config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Now commit it again from candidate (validation takes time when
# comparing to existing)
new "netconf commit large config again" new "netconf commit large config again"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf add small (1 entry) config" # Having a large db, get and put single entries many times
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><y><a>x</a><b>y</b></y></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$" # Note same entries in the range alreayd there, db has same size
new "netconf add $perfreq small config"
new "netconf get $req small config" time -p for (( i=0; i<$perfreq; i++ )); do
time -p for (( i=0; i<$req; i++ )); do rnd=$(( ( RANDOM % $perfnr ) ))
rnd=$(( ( RANDOM % $number ) ))
echo "<rpc><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/x/y[a=$rnd][b=$rnd]\" /></get-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf get $req restconf small config"
time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
#XXX curl -sX PUT -d {"y":{"a":"$rnd","b":"$rnd"}} http://localhost/restconf/data/x/y=$rnd,$rnd
done
new "netconf add $req small config"
time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>" echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf add $req restconf small config" new "netconf get $perfreq small config"
time -p for (( i=0; i<$req; i++ )); do time -p for (( i=0; i<$perfreq; i++ )); do
rnd=$(( ( RANDOM % $number ) )) rnd=$(( ( RANDOM % $perfnr ) ))
curl -sG http://localhost/restconf/data/x/y=$rnd,$rnd > /dev/null echo "<rpc><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/x/y[a=$rnd][b=$rnd]\" /></get-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "restconf get $perfreq small config"
time -p for (( i=0; i<$perfreq; i++ )); do
rnd=$(( ( RANDOM % $perfnr ) ))
curl -sG http://localhost/restconf/data/scaling:x/y=$rnd,$rnd > /dev/null
done done
new "restconf add $perfreq small config"
time -p for (( i=0; i<$perfreq; i++ )); do
rnd=$(( ( RANDOM % $perfnr ) ))
curl -s -X PUT http://localhost/restconf/data/scaling:x/y=$rnd -d '{"scaling:y":{"a":"'$rnd'","b":"'$rnd'"}}'
done
# Instead of many small entries, get one large in netconf and restconf
new "netconf get large config" new "netconf get large config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b>' expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b>'
new "restconf get large config"
expecteof "/usr/bin/time -f %e curl -sG http://localhost/restconf/data" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^{"data": {"scaling:x": {"y": \[{"a": "0","b": "0"},{ "a": "1","b": "1"},'
# Now do leaf-lists istead of leafs
new "generate large leaf-list config" new "generate large leaf-list config"
echo -n "<rpc><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><x xmlns=\"urn:example:clixon\">" > $fconfig echo -n "<rpc><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><x xmlns=\"urn:example:clixon\">" > $fconfig
for (( i=0; i<$number; i++ )); do for (( i=0; i<$perfnr; i++ )); do
echo -n "<c>$i</c>" >> $fconfig echo -n "<c>$i</c>" >> $fconfig
done done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig
@ -157,9 +153,9 @@ rm $fconfig
new "netconf commit large leaf-list config" new "netconf commit large leaf-list config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf add $req small leaf-list config" new "netconf add $perfreq small leaf-list config"
time -p for (( i=0; i<$req; i++ )); do time -p for (( i=0; i<$perfreq; i++ )); do
rnd=$(( ( RANDOM % $number ) )) rnd=$(( ( RANDOM % $perfnr ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><c>$rnd</c></x></config></edit-config></rpc>]]>]]>" echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><c>$rnd</c></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
@ -186,9 +182,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -44,10 +44,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -56,6 +53,7 @@ sudo pkill -u www-data clixon_restconf
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "restconf tests" new "restconf tests"
@ -280,9 +278,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -76,10 +76,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -88,6 +85,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "restconf tests" new "restconf tests"
@ -197,9 +195,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -41,10 +41,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -53,6 +50,7 @@ sudo pkill -u www-data clixon_restconf
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
new "rpc tests" new "rpc tests"
@ -164,9 +162,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -36,7 +36,7 @@ cat <<EOF > $cfg
EOF EOF
run(){ testrun(){
mode=$1 mode=$1
expect=$2 expect=$2
@ -83,11 +83,11 @@ EOF
err err
fi fi
new "start backend -f $cfg -s $mode -c $dir/config" new "start backend -f $cfg -s $mode -c $dir/config"
sudo $clixon_backend -f $cfg -s $mode -c $dir/config start_backend -s $mode -f $cfg -c $dir/config
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
new "Check $mode" new "Check $mode"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' "^<rpc-reply>$expect</rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' "^<rpc-reply>$expect</rpc-reply>]]>]]>$"
@ -99,15 +99,15 @@ EOF
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then } # testrun
err "kill backend"
fi
}
run init '<data/>' testrun init '<data/>'
run none '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
run running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>' testrun none '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
run startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun running '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>run</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
testrun startup '<data><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>extra</name><type>ex:eth</type><enabled>true</enabled></interface><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface><interface><name>startup</name><type>ex:eth</type><enabled>true</enabled></interface></interfaces></data>'
rm -rf $dir rm -rf $dir

View file

@ -111,10 +111,7 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
fi fi
new "kill old restconf daemon" new "kill old restconf daemon"
@ -123,6 +120,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon" new "start restconf daemon"
sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data &
new "waiting"
sleep $RCWAIT sleep $RCWAIT
# #
@ -289,9 +287,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
#rm -rf $dir rm -rf $dir

View file

@ -203,10 +203,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "cli set transitive string" new "cli set transitive string"
@ -493,9 +493,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -86,10 +86,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "cli set transitive string" new "cli set transitive string"
@ -112,9 +112,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -99,10 +99,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "when: add static route" new "when: add static route"
@ -152,9 +152,6 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
rm -rf $dir rm -rf $dir

View file

@ -151,10 +151,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg -y $fyang" new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang -D $DBG start_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "cli defined extension" new "cli defined extension"
@ -292,10 +292,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
rm -rf $dir rm -rf $dir

View file

@ -79,10 +79,10 @@ if [ $BE -ne 0 ]; then
err err
fi fi
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
sudo $clixon_backend -s init -f $cfg -D $DBG start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
fi fi
new "1. Set newex" new "1. Set newex"
@ -105,10 +105,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -133,10 +130,10 @@ EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend # start new backend
sudo $clixon_backend -s init -f $cfg start_backend -s init -f $cfg
if [ $? -ne 0 ]; then
err new "waiting"
fi sleep $RCWAIT
new "Set oldex" new "Set oldex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -154,10 +151,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -177,11 +171,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set newex" new "Set newex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -198,11 +191,7 @@ pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend stop_backend -f $cfg
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -223,11 +212,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set oldex" new "Set oldex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -245,10 +233,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -268,11 +253,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set newex" new "Set newex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -290,10 +274,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -314,11 +295,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set oldex" new "Set oldex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -336,10 +316,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
@ -362,11 +339,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set oldex" new "Set oldex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -384,10 +360,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
#-------------------------------------- #--------------------------------------
@ -409,11 +382,10 @@ cat <<EOF > $cfg
EOF EOF
new "start backend -s init -f $cfg" new "start backend -s init -f $cfg"
# start new backend start_backend -s init -f $cfg
sudo $clixon_backend -s init -f $cfg
if [ $? -ne 0 ]; then new "waiting"
err sleep $RCWAIT
fi
new "Set oldex" new "Set oldex"
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$' expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
@ -431,10 +403,7 @@ if [ -z "$pid" ]; then
err "backend already dead" err "backend already dead"
fi fi
# kill backend # kill backend
sudo clixon_backend -z -f $cfg stop_backend -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
sudo pkill -u root -f clixon_backend sudo pkill -u root -f clixon_backend
rm -rf $dir rm -rf $dir