From d9cf43bd466a364c01569acde96a0bc3047028f4 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 17 Aug 2019 17:25:20 +0200 Subject: [PATCH] Preparing for 4.1.0 --- CHANGELOG.md | 8 +- configure | 2 +- configure.ac | 2 +- doc/ROADMAP.md | 1 - docker/base/README.md | 2 +- test/test_perf_api.sh | 242 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 252 insertions(+), 5 deletions(-) create mode 100755 test/test_perf_api.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 8622973c..054f6f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Clixon Changelog -## 4.1.0 (Expected: August 2019) +## 4.1.0 (18 August 2019) + +### Summary + +The 4.1.0 release is a RESTCONF feature upgrade release. Highlights are +RFC8040 plan PATCH, many query parameters, compliant return codes, and +more. ### Major New features * Restconf RFC 8040 increased feature compliance diff --git a/configure b/configure index e0a21472..7b577b86 100755 --- a/configure +++ b/configure @@ -2174,7 +2174,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MINOR="1" CLIXON_VERSION_PATCH="0" -CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" +CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" # Check CLIgen if test "$prefix" = "NONE"; then diff --git a/configure.ac b/configure.ac index bdebd977..d03a9361 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_INIT(lib/clixon/clixon.h.in) CLIXON_VERSION_MAJOR="4" CLIXON_VERSION_MINOR="1" CLIXON_VERSION_PATCH="0" -CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\"" +CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}\"" # Check CLIgen if test "$prefix" = "NONE"; then diff --git a/doc/ROADMAP.md b/doc/ROADMAP.md index d7f2527e..fb830b64 100644 --- a/doc/ROADMAP.md +++ b/doc/ROADMAP.md @@ -1,7 +1,6 @@ # Clixon roadmap - Support for restconf call-home (RFC 8071) -- Support for restconf PATCH method - NETCONF - Support for additional Netconf [edit-config modes](https://github.com/clicon/clixon/issues/53) - Netconf [framing](https://github.com/clicon/clixon/issues/50) diff --git a/docker/base/README.md b/docker/base/README.md index 0acdca79..2782b8b0 100644 --- a/docker/base/README.md +++ b/docker/base/README.md @@ -5,7 +5,7 @@ container. By default it is pushed to docker hub clixon/clixon, but you can chan the IMAGE in Makefile.in and push it to another name. The clixon docker base image can be used to build clixon -applications. It has all the whole code for a clixon release which it +applications. It has the whole code for a clixon release which it downloads from git. See [clixon-system](../main/README.md) for a more complete clixon image. diff --git a/test/test_perf_api.sh b/test/test_perf_api.sh new file mode 100755 index 00000000..34a274ae --- /dev/null +++ b/test/test_perf_api.sh @@ -0,0 +1,242 @@ +#!/bin/bash +# Order test. test ordered-by user and ordered-by system. +# For each leaf and leaf-lists, there are two lists, +# one ordered-by user and one ordered by system. +# The ordered-by user MUST be the order it is entered. +# No test of ordered-by system is done yet +# (we may want to sort them alphabetically for better performance). +# Also: ordered-by-user and "insert" and "key"/"value" attributes + +# Magic line must be first in script (see README.md) +s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi + +# Which format to use as datastore format internally +: ${format:=xml} + +APPNAME=example + + +cfg=$dir/conf_yang.xml +fyang=$dir/example-order.yang +cfile=$dir/example-order.c +pdir=$dir/plugin +sofile=$pdir/example-order.so + +if [ ! -d $pdir ]; then + mkdir $pdir +fi + +cat < $cfg + + /tmp/conf_yang.xml + /usr/local/share/clixon + $IETFRFC + $fyang + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + /usr/local/var/$APPNAME/$APPNAME.sock + false + $pdir + /usr/local/var/$APPNAME/$APPNAME.pidfile + $dir + $format + +EOF + +cat < $fyang +module example-order{ + yang-version 1.1; + namespace "urn:example:order"; + prefix ex; + container c { + leaf-list y0 { + ordered-by user; + type string; + } + leaf-list y1 { + ordered-by system; + type string; + } + list y2 { + ordered-by user; + key "k"; + leaf k { + type int32; + } + leaf val { + type string; + } + } + list y3 { + ordered-by system; + key "k"; + leaf k { + type int32; + } + leaf val { + type string; + } + } + } + rpc trigger { + description "trigger an action in the backend"; + } +} +EOF + +cat< $cfile +#include +#include +#include +#include +#include +#include +#include +#include + +/* clicon */ +#include + +/* Clicon library functions. */ +#include + +/* These include signatures for plugin and transaction callbacks. */ +#include + +static int +trigger_rpc(clicon_handle h, /* Clicon handle */ + cxobj *xe, /* Request: */ + cbuf *cbret, /* Reply eg ... */ + void *arg, /* client_entry */ + void *regarg) /* Argument given at register */ +{ + int retval = -1; + cxobj *xret = NULL; + cxobj *xc = NULL; + cxobj *x = NULL; + char *k; + char *val; + + if (xmldb_get(h, "running", "/c", &xret) < 0) + goto done; + clicon_debug(1, "%s xret:%s", __FUNCTION__, xml_name(xret)); + xc = xpath_first(xret, "/c"); + clicon_debug(1, "%s xc:%s", __FUNCTION__, xml_name(xc)); + + /* Method 1 loop */ + x = NULL; + val = NULL; + while ((x = xml_child_each(xc, x, -1)) != NULL) { + if (strcmp(xml_name(x), "y3") != 0) + continue; + if ((k = xml_find_body(x, "k")) != NULL && + strcmp(k, "5") == 0){ + val = xml_find_body(x, "val"); + break; + } + } + clicon_debug(1, "%s Method 1: val:%s", __FUNCTION__, val?val:"null"); + + /* Method 2 xpath */ + val = NULL; + if ((x = xpath_first(xc, "y3[k=5]")) != NULL) + val = xml_find_body(x, "val"); + clicon_debug(1, "%s Method 2: val:%s", __FUNCTION__, val?val:"null"); + + /* Method 3 binsearch */ + val = NULL; + if ((x = xml_binsearch(xc, "y3", "k", "5")) != NULL) + val = xml_find_body(x, "val"); + clicon_debug(1, "%s Method 3: val:%s", __FUNCTION__, val?val:"null"); + + cprintf(cbret, ""); + retval = 0; + done: + clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); +// if (xret) + // xml_free(xret); + return retval; +} + +clixon_plugin_api *clixon_plugin_init(clicon_handle h); + +static clixon_plugin_api api = { + "order", /* name */ /*--- Common fields. ---*/ + clixon_plugin_init, /* init */ +}; + +/*! Backend plugin initialization + * @param[in] h Clixon handle + * @retval NULL Error with clicon_err set + * @retval api Pointer to API struct + */ +clixon_plugin_api * +clixon_plugin_init(clicon_handle h) +{ + clicon_debug(1, "%s test-order", __FUNCTION__); + + /* From example.yang (clicon) */ + if (rpc_callback_register(h, trigger_rpc, + NULL, + "urn:example:order", + "trigger"/* Xml tag when callback is made */ + ) < 0) + return NULL; + return &api; +} + +EOF + +new "compile $cfile" +gcc -Wall -rdynamic -fPIC -shared $cfile -o $sofile + +new "test params: -s running -f $cfg" + +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend" + start_backend -s running -f $cfg + +fi + +new "kill old restconf daemon" +sudo pkill -u www-data -f "/www-data/clixon_restconf" + +new "start restconf daemon" +start_restconf -f $cfg + +new "waiting" +wait_backend +wait_restconf + +XML='235zorro7' + +# Add a set of entries using restconf +new "PUT a set of entries" +expectpart "$(curl -si -X PUT -H 'Content-Type: application/yang-data+xml' http://localhost/restconf/data/example-order:c -d "$XML")" 0 "HTTP/1.1 201 Created" + +new "Check entries" +expectpart "$(curl -si -X GET http://localhost/restconf/data/example-order:c -H 'Accept: application/yang-data+xml')" 0 'HTTP/1.1 200 OK' "$XML" + +new "Send a trigger" +expectpart "$(curl -si -X POST http://localhost/restconf/operations/example-order:trigger -H 'Accept: application/yang-data+json')" 0 'HTTP/1.1 204 No Content' + +if [ $BE -eq 0 ]; then + exit # BE +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 +stop_backend -f $cfg + +rm -rf $dir