diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd457908..b186fdd6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -94,8 +94,10 @@
* Set dir /www-data with www-data as owner, see https://github.com/clicon/clixon/issues/37
### Known issues
-* Netconf RPC input is not sanity checked for wrong symbols (just ignored).
-* Yang sub-command order and cardinality not checked.
+* Netconf/Restconf RPC extra input arguments are ignored
+ * https://github.com/clicon/clixon/issues/47
+* Yang sub-command cardinality not checked.
+ * https://github.com/clicon/clixon/issues/48
* Top-level Yang symbol cannot be called "config" in any imported yang file.
* datastore uses "config" as reserved keyword for storing any XML whoich collides with code for detecting Yang sanity.
* Namespace name relabeling is not supported.
diff --git a/README.md b/README.md
index 4feae79d..9c52da1b 100644
--- a/README.md
+++ b/README.md
@@ -114,7 +114,11 @@ Clixon follows:
- [RFC 7895: YANG module library](http://www.rfc-base.org/txt/rfc-7895.txt)
However, the following YANG syntax modules are not implemented:
-`deviation`, `min/max-elements`, `unique`, and `action`.
+- deviation
+- min/max-elements
+- unique
+- action
+- belongs-to
Netconf
=======
@@ -131,6 +135,7 @@ Clixon does not yet support the following netconf features:
- edit-config testopts
- edit-config erropts
- edit-config config-text
+- edit-config operation
Restconf
========
diff --git a/datastore/text/clixon_xmldb_text.c b/datastore/text/clixon_xmldb_text.c
index a7059514..bee21bd0 100644
--- a/datastore/text/clixon_xmldb_text.c
+++ b/datastore/text/clixon_xmldb_text.c
@@ -196,8 +196,7 @@ text_disconnect(xmldb_handle xh)
free(th->th_dbdir);
if (th->th_dbs){
if (th->th_cache){
- if ((keys = hash_keys(th->th_dbs, &klen)) == NULL)
- return 0;
+ keys = hash_keys(th->th_dbs, &klen);
for(i = 0; i < klen; i++)
if ((de = hash_value(th->th_dbs, keys[i], NULL)) != NULL){
if (de->de_xml)
diff --git a/lib/clixon/clixon_stream.h b/lib/clixon/clixon_stream.h
index a3a1457f..a1870395 100644
--- a/lib/clixon/clixon_stream.h
+++ b/lib/clixon/clixon_stream.h
@@ -84,14 +84,14 @@ typedef struct event_stream event_stream_t;
*/
event_stream_t *stream_find(clicon_handle h, const char *name);
int stream_add(clicon_handle h, const char *name, const char *description, int replay_enabled, struct timeval *retention);
-int stream_delete_all(clicon_handle h);
+int stream_delete_all(clicon_handle h, int force);
int stream_get_xml(clicon_handle h, int access, cbuf *cb);
int stream_timer_setup(int fd, void *arg);
/* Subscriptions */
struct stream_subscription *stream_ss_add(clicon_handle h, char *stream,
char *xpath, struct timeval *start, struct timeval *stop,
stream_fn_t fn, void *arg);
-int stream_ss_rm(clicon_handle h, event_stream_t *es, struct stream_subscription *ss);
+int stream_ss_rm(clicon_handle h, event_stream_t *es, struct stream_subscription *ss, int force);
struct stream_subscription *stream_ss_find(event_stream_t *es,
stream_fn_t fn, void *arg);
int stream_ss_delete_all(clicon_handle h, stream_fn_t fn, void *arg);
diff --git a/lib/src/clixon_handle.c b/lib/src/clixon_handle.c
index fd30f0b7..dcb6da5c 100644
--- a/lib/src/clixon_handle.c
+++ b/lib/src/clixon_handle.c
@@ -135,7 +135,7 @@ clicon_handle_exit(clicon_handle h)
hash_free(ha);
if ((ha = clicon_data(h)) != NULL)
hash_free(ha);
- stream_delete_all(h);
+ stream_delete_all(h, 1);
free(ch);
return 0;
}
diff --git a/lib/src/clixon_stream.c b/lib/src/clixon_stream.c
index 0b516fc4..ae454256 100644
--- a/lib/src/clixon_stream.c
+++ b/lib/src/clixon_stream.c
@@ -151,10 +151,12 @@ stream_add(clicon_handle h,
}
/*! Delete complete notification event stream list (not just single stream)
- * @param[in] es
+ * @param[in] h Clicon handle
+ * @param[in] force Force deletion of
*/
int
-stream_delete_all(clicon_handle h)
+stream_delete_all(clicon_handle h,
+ int force)
{
struct stream_replay *r;
struct stream_subscription *ss;
@@ -169,7 +171,7 @@ stream_delete_all(clicon_handle h)
if (es->es_description)
free(es->es_description);
while ((ss = es->es_subscription) != NULL)
- stream_ss_rm(h, es, ss); /* XXX in some cases leaks memory due to DONT clause in stream_ss_rm() */
+ stream_ss_rm(h, es, ss, force); /* XXX in some cases leaks memory due to DONT clause in stream_ss_rm() */
while ((r = es->es_replay) != NULL){
DELQ(r, es->es_replay, struct stream_replay *);
if (r->r_xml)
@@ -262,7 +264,7 @@ stream_timer_setup(int fd,
if (timerisset(&ss->ss_stoptime) && timercmp(&ss->ss_stoptime, &now, <)){
ss1 = NEXTQ(struct stream_subscription *, ss);
/* Signal to remove stream for upper levels */
- if (stream_ss_rm(h, es, ss) < 0)
+ if (stream_ss_rm(h, es, ss, 0) < 0)
goto done;
ss = ss1;
}
@@ -378,19 +380,20 @@ stream_ss_add(clicon_handle h,
int
stream_ss_rm(clicon_handle h,
event_stream_t *es,
- struct stream_subscription *ss)
+ struct stream_subscription *ss,
+ int force)
{
clicon_debug(1, "%s", __FUNCTION__);
DELQ(ss, es->es_subscription, struct stream_subscription *);
/* Remove from upper layers - close socket etc. */
(*ss->ss_fn)(h, 1, NULL, ss->ss_arg);
-#ifdef DONT /* upcall may have deleted it */
- if (ss->ss_stream)
- free(ss->ss_stream);
- if (ss->ss_xpath)
- free(ss->ss_xpath);
- free(ss);
-#endif
+ if (force){
+ if (ss->ss_stream)
+ free(ss->ss_stream);
+ if (ss->ss_xpath)
+ free(ss->ss_xpath);
+ free(ss);
+ }
clicon_debug(1, "%s retval: 0", __FUNCTION__);
return 0;
}
@@ -436,7 +439,7 @@ stream_ss_delete_all(clicon_handle h,
if ((es = clicon_stream(h)) != NULL){
do {
if ((ss = stream_ss_find(es, fn, arg)) != NULL){
- if (stream_ss_rm(h, es, ss) < 0)
+ if (stream_ss_rm(h, es, ss, 1) < 0)
goto done;
}
es = NEXTQ(struct event_stream *, es);
@@ -464,7 +467,7 @@ stream_ss_delete(clicon_handle h,
do {
if (strcmp(name, es->es_name)==0)
if ((ss = stream_ss_find(es, fn, arg)) != NULL){
- if (stream_ss_rm(h, es, ss) < 0)
+ if (stream_ss_rm(h, es, ss, 0) < 0)
goto done;
}
es = NEXTQ(struct event_stream *, es);
@@ -503,7 +506,7 @@ stream_notify1(clicon_handle h,
struct stream_subscription *ss1;
ss1 = NEXTQ(struct stream_subscription *, ss);
/* Signal to remove stream for upper levels */
- if (stream_ss_rm(h, es, ss) < 0)
+ if (stream_ss_rm(h, es, ss, 1) < 0)
goto done;
ss = ss1;
}
diff --git a/test/lib.sh b/test/lib.sh
index a518baf3..6a5138ac 100755
--- a/test/lib.sh
+++ b/test/lib.sh
@@ -12,14 +12,16 @@ testname=
clixon_cli=clixon_cli
# For memcheck / performance
-#clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
#clixon_netconf="valgrind --tool=callgrind clixon_netconf"
+#clixon_netconf="valgrind --leak-check=full --show-leak-kinds=all clixon_netconf"
clixon_netconf=clixon_netconf
# How to run restconf stand-alone and using valgrind
-#sudo su -c "/www-data/clixon_restconf -f $cfg -D 1" -s /bin/sh www-data
-#sudo su -c "valgrind --trace-children=no --child-silent-after-fork=yes --leak-check=full --show-leak-kinds=all /www-data/clixon_restconf -f $cfg -D 1" -s /bin/sh www-data
+#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
+RCWAIT=1 # Wait after restconf start. Set to 10 if valgrind
+# 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
diff --git a/test/test_cli.sh b/test/test_cli.sh
index 5b2574bf..1304bf81 100755
--- a/test/test_cli.sh
+++ b/test/test_cli.sh
@@ -114,8 +114,8 @@ new "cli rpc"
expectfn "$clixon_cli -1 -f $cfg -l o rpc ipv4" 0 "ipv4" "2.3.4.5"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
diff --git a/test/test_feature.sh b/test/test_feature.sh
index 6d444629..a4a8a532 100755
--- a/test/test_feature.sh
+++ b/test/test_feature.sh
@@ -157,16 +157,15 @@ if [ -z "$match" ]; then
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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
-# Check if still alive
-pid=`pgrep clixon_backend`
-if [ -n "$pid" ]; then
- sudo kill $pid
-fi
-
rm -rf $dir
diff --git a/test/test_identity.sh b/test/test_identity.sh
index 8d7bea7f..e006ca34 100755
--- a/test/test_identity.sh
+++ b/test/test_identity.sh
@@ -180,8 +180,8 @@ new "cli validate"
expectfn "$clixon_cli -1 -f $cfg -y $fyang -l o validate" 0 "^$"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
diff --git a/test/test_leafref.sh b/test/test_leafref.sh
index 0e93e704..58aa8e85 100755
--- a/test/test_leafref.sh
+++ b/test/test_leafref.sh
@@ -76,9 +76,9 @@ if [ $? -ne 0 ]; then
err
fi
-new "start backend -s init -f $cfg -y $fyang"
# start new backend
-sudo $clixon_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
if [ $? -ne 0 ]; then
err
fi
@@ -140,13 +140,13 @@ new "cli sender template"
expectfn "$clixon_cli -1f $cfg -y $fyang -l o set sender b template a" 0 "^$"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_list.sh b/test/test_list.sh
index 048a18f3..69b0f7b0 100755
--- a/test/test_list.sh
+++ b/test/test_list.sh
@@ -69,7 +69,7 @@ fi
new "start backend -s init -f $cfg -y $fyang"
# start new backend
-sudo $clixon_backend -s init -f $cfg -y $fyang
+sudo $clixon_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
@@ -119,9 +119,14 @@ new "minmax: validate should fail"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
fi # NYI
-
+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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_nacm.sh b/test/test_nacm.sh
index 764b92c9..7f98fe4a 100755
--- a/test/test_nacm.sh
+++ b/test/test_nacm.sh
@@ -136,12 +136,13 @@ if [ $? -ne 0 ]; then
fi
new "kill old restconf daemon"
-sudo pkill -u www-data clixon_restconf
-sleep 1
-new "start restconf daemon (-a is enable basic authentication)"
-sudo su -c "/www-data/clixon_restconf -f $cfg -y $fyang -- -a" -s /bin/sh www-data &
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
sleep 1
+new "start restconf daemon (-a is enable basic authentication)"
+sudo su -c "$clixon_restconf -f $cfg -y $fyang -- -a" -s /bin/sh www-data &
+
+sleep $RCWAIT
new "restconf DELETE whole datastore"
expecteq "$(curl -u adm1:bar -sS -X DELETE http://localhost/restconf/data)" ""
@@ -192,15 +193,16 @@ new2 "guest edit nacm"
expecteq "$(curl -u guest:bar -sS -X PUT -d '{"x": 3}' http://localhost/restconf/data/x)" '{"ietf-restconf:errors" : {"error": {"error-tag": "access-denied","error-type": "protocol","error-severity": "error","error-message": "The requested URL was unauthorized"}}}
'
new "Kill restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "Kill backend"
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh
index 3d164dff..10b01170 100755
--- a/test/test_nacm_ext.sh
+++ b/test/test_nacm_ext.sh
@@ -158,19 +158,18 @@ fi
sleep 1
new "start backend -s init -f $cfg -y $fyang"
# start new backend
-sudo $clixon_backend -s init -f $cfg -y $fyang
+sudo $clixon_backend -s init -f $cfg -y $fyang
if [ $? -ne 0 ]; then
err
fi
-sleep 1
new "kill old restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon (-a is enable http basic auth)"
-sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang -- -a
+sudo su -c "$clixon_restconf -f $cfg -y $fyang -- -a" -s /bin/sh www-data &
-sleep 1
+sleep $RCWAIT
new "restconf DELETE whole datastore"
expecteq "$(curl -u adm1:bar -sS -X DELETE http://localhost/restconf/data)" ""
@@ -231,15 +230,16 @@ new "cli rpc as guest"
expectfn "$clixon_cli -1 -U guest -l o -f $cfg -y $fyang rpc ipv4" 255 "protocol access-denied access denied"
new "Kill restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "Kill backend"
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_netconf.sh b/test/test_netconf.sh
index ddb8cd3b..b0265345 100755
--- a/test/test_netconf.sh
+++ b/test/test_netconf.sh
@@ -248,16 +248,15 @@ new "netconf client-side rpc"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "example]]>]]>" "^ok]]>]]>$"
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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
-# Check if still alive
-pid=`pgrep clixon_backend`
-if [ -n "$pid" ]; then
- sudo kill $pid
-fi
-
rm -rf $dir
diff --git a/test/test_order.sh b/test/test_order.sh
index 5d292c1f..53e91b44 100755
--- a/test/test_order.sh
+++ b/test/test_order.sh
@@ -167,12 +167,14 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^cbarbfooafie]]>]]>$"
-pid=`pgrep clixon_backend`
+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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_perf.sh b/test/test_perf.sh
index b5703683..2e7147fa 100755
--- a/test/test_perf.sh
+++ b/test/test_perf.sh
@@ -48,7 +48,7 @@ cat < $cfg
ietf-ip
/usr/local/var/$APPNAME/$APPNAME.sock
/usr/local/var/$APPNAME/$APPNAME.pidfile
-false
+ false
/usr/local/var/$APPNAME
/usr/local/lib/xmldb/text.so
@@ -69,12 +69,12 @@ if [ $? -ne 0 ]; then
fi
new "kill old restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon"
-sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D 1
+sudo su -c "$clixon_restconf -f $cfg -y $fyang" -s /bin/sh www-data &
-sleep 1
+sleep $RCWAIT
new "generate 'large' config with $number list entries"
echo -n "" > $fconfig
@@ -164,14 +164,17 @@ expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^01"
+new "Kill restconf daemon"
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
+
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_restconf.sh b/test/test_restconf.sh
index 55718814..107e7f57 100755
--- a/test/test_restconf.sh
+++ b/test/test_restconf.sh
@@ -90,7 +90,7 @@ if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg -y $fyang"
-sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1
+sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1
if [ $? -ne 0 ]; then
err
fi
@@ -99,9 +99,9 @@ new "kill old restconf daemon"
sudo pkill -u www-data clixon_restconf
new "start restconf daemon"
-sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D 1
+sudo su -c "$clixon_restconf -f $cfg -y $fyang" -s /bin/sh www-data &
-sleep 1
+sleep $RCWAIT
new "restconf tests"
@@ -314,16 +314,16 @@ fi
# Cant get shell macros to work, inline matching from lib.sh
new "Kill restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh
index 5f796d35..663a7c3d 100755
--- a/test/test_restconf2.sh
+++ b/test/test_restconf2.sh
@@ -50,18 +50,17 @@ if [ $? -ne 0 ]; then
fi
new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang
-
if [ $? -ne 0 ]; then
err
fi
new "kill old restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon"
-sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang # -D 1
+sudo su -c "$clixon_restconf -f $cfg -y $fyang" -s /bin/sh www-data &
-sleep 1
+sleep $RCWAIT
new "restconf tests"
@@ -135,16 +134,16 @@ new "restconf PUT change key error"
expectfn 'curl -is -X PUT -d {"interface":{"name":"ALPHA","type":"eth0"}} http://localhost/restconf/data/cont1/interface=TEST' 0 '{"ietf-restconf:errors" : {"error": {"rpc-error": {"error-tag": "operation-failed","error-type": "protocol","error-severity": "error","error-message": "api-path keys do not match data keys"}}}}'
new "Kill restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_startup.sh b/test/test_startup.sh
index d3cdcd54..ba4960f7 100755
--- a/test/test_startup.sh
+++ b/test/test_startup.sh
@@ -81,7 +81,7 @@ EOF
fi
new "start backend -f $cfg -s $mode -c $dir/config"
- sudo clixon_backend -f $cfg -s $mode -c $dir/config
+ sudo $clixon_backend -f $cfg -s $mode -c $dir/config
if [ $? -ne 0 ]; then
err
fi
@@ -90,13 +90,13 @@ EOF
expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$expect]]>]]>$"
new "Kill backend"
- # Check if still alive
- pid=`pgrep clixon_backend`
+ # Check if premature kill
+ pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
- sudo clixon_backend -zf $cfg
+ sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_stream.sh b/test/test_stream.sh
index 66f5414d..7e5d0e48 100755
--- a/test/test_stream.sh
+++ b/test/test_stream.sh
@@ -22,6 +22,8 @@
APPNAME=example
UTIL=../util/clixon_util_stream
+NCWAIT=5 # Wait (netconf valgrind may need more time)
+
if [ ! -x $UTIL ]; then
echo "$UTIL not found. To build: (cd ../util; make clixon_util_stream)"
exit 1
@@ -109,19 +111,17 @@ if [ $? -ne 0 ]; then
fi
new "start backend -s init -f $cfg -y $fyang"
sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1
-
if [ $? -ne 0 ]; then
err
fi
new "kill old restconf daemon"
-sudo pkill -u www-data clixon_restconf
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
new "start restconf daemon"
+sudo su -c "$clixon_restconf -f $cfg -y $fyang" -s /bin/sh www-data &
-sudo su -c "/www-data/clixon_restconf -f $cfg -y $fyang" -s /bin/sh www-data &
-
-sleep 2
+sleep $RCWAIT
#
# 1. Netconf RFC5277 stream testing
@@ -136,19 +136,19 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 'EXAMPLE]]>]]>' '^]]>]]>20' 10
+expectwait "$clixon_netconf -qf $cfg -y $fyang" 'EXAMPLE]]>]]>' '^]]>]]>20' $NCWAIT
new "netconf subscription with empty startTime"
-expectwait "$clixon_netconf -qf $cfg -y $fyang" 'EXAMPLE]]>]]>' '^]]>]]>20' 5
+expectwait "$clixon_netconf -qf $cfg -y $fyang" 'EXAMPLE]]>]]>' '^]]>]]>20' $NCWAIT
new "netconf EXAMPLE subscription with simple filter"
-expectwait "$clixon_netconf -qf $cfg -y $fyang" "EXAMPLE]]>]]>" '^]]>]]>20' 5
+expectwait "$clixon_netconf -qf $cfg -y $fyang" "EXAMPLE]]>]]>" '^]]>]]>20' $NCWAIT
new "netconf EXAMPLE subscription with filter classifier"
-expectwait "$clixon_netconf -qf $cfg -y $fyang" "EXAMPLE]]>]]>" '^]]>]]>20' 5
+expectwait "$clixon_netconf -qf $cfg -y $fyang" "EXAMPLE]]>]]>" '^]]>]]>20' $NCWAIT
new "netconf NONEXIST subscription"
-expectwait "$clixon_netconf -qf $cfg -y $fyang" 'NONEXIST]]>]]>' '^invalid-valueapplicationerrorNo such stream]]>]]>$' 5
+expectwait "$clixon_netconf -qf $cfg -y $fyang" 'NONEXIST]]>]]>' '^invalid-valueapplicationerrorNo such stream]]>]]>$' $NCWAIT
new "netconf EXAMPLE subscription with wrong date"
expectwait "$clixon_netconf -qf $cfg -y $fyang" 'EXAMPLEkallekaka]]>]]>' '^bad-elementapplicationstartTimeerrorExpected timestamp]]>]]>$' 0
@@ -158,6 +158,7 @@ expectwait "$clixon_netconf -qf $cfg -y $fyang" 'EXAMPLE$NOW]]>]]>" '^]]>]]>20' 10
sleep 2
+
#
# 2. Restconf RFC8040 stream testing
new "2. Restconf RFC8040 stream testing"
@@ -239,13 +240,15 @@ if [ -z "$match" ]; then
fi
nr=$(echo "$ret" | grep -c "data:")
-if [ $nr -lt 10 -o $nr -gt 14 ]; then
+if [ $nr -lt 9 -o $nr -gt 14 ]; then
err 10 "$nr"
fi
+
# Try parallell
# start background job
curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" "http://localhost/streams/EXAMPLE" > /dev/null &
+PID=$!
new "Start subscription in parallell"
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8)
@@ -260,6 +263,8 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then
err 2 "$nr"
fi
+kill $PID
+
#--------------------------------------------------------------------
# NCHAN Need manual testing
echo "Nchan streams requires manual testing"
@@ -267,27 +272,20 @@ echo "Add http://localhost/pub to config"
echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/EXAMPLE"
#-----------------
-
-sudo pkill -u www-data clixon_restconf
+sleep 5
+new "Kill restconf daemon"
+sudo pkill -u www-data -f "/www-data/clixon_restconf"
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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
-# Check if still alive
-pid=`pgrep clixon_backend`
-if [ -n "$pid" ]; then
- sudo kill $pid
-fi
-
-rm -rf $dir
-
-
-
-
-
-
-
+#rm -rf $dir
diff --git a/test/test_type.sh b/test/test_type.sh
index 0c1f11ef..e8254d0f 100755
--- a/test/test_type.sh
+++ b/test/test_type.sh
@@ -136,7 +136,6 @@ module example{
}
EOF
-
# kill old backend (if any)
new "kill old backend"
sudo clixon_backend -zf $cfg
@@ -202,13 +201,13 @@ new "cli bits validate"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 "^$"
new "Kill backend"
-# Check if still alive
-pid=`pgrep clixon_backend`
+# Check if premature kill
+pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_when_must.sh b/test/test_when_must.sh
index ab4126e1..9f4974e9 100755
--- a/test/test_when_must.sh
+++ b/test/test_when_must.sh
@@ -137,13 +137,14 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^operation-failedapplicationerrorAn Ethernet MTU must be 1500]]>]]>"
-# Check if still alive
-pid=`pgrep clixon_backend`
+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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
diff --git a/test/test_yang.sh b/test/test_yang.sh
index f54e03bc..5176490d 100755
--- a/test/test_yang.sh
+++ b/test/test_yang.sh
@@ -212,15 +212,17 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 ']]>]]>' '121two]]>]]>'
-# Check if still alive
-pid=`pgrep clixon_backend`
+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
-sudo clixon_backend -zf $cfg
+sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err "kill backend"
fi
+sudo pkill -u root -f clixon_backend
rm -rf $dir