* Changed base OS in clixon-system container to Alpine
* Moved datastore/text/ code to datastore/ since there is only one type of datastore. * Added "magic script line" to test script for sourced and scriped exits
This commit is contained in:
parent
9fc8ac2e8e
commit
d64d433468
58 changed files with 579 additions and 538 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -7,9 +7,9 @@ lex.*_parse.c
|
|||
Makefile
|
||||
apps/Makefile
|
||||
apps/*/Makefile
|
||||
datastore/Makefile
|
||||
docker/Makefile
|
||||
docker/base/Makefile
|
||||
docker/system/Makefile
|
||||
docker/*/Makefile
|
||||
etc/Makefile
|
||||
example/Makefile
|
||||
lib/Makefile
|
||||
|
|
@ -34,10 +34,6 @@ apps/netconf/clixon_netconf
|
|||
apps/restconf/clixon_restconf
|
||||
apps/xmldb/clixon_xmldb
|
||||
|
||||
docker/backend/Dockerfile
|
||||
docker/cli/Dockerfile
|
||||
docker/netconf/Dockerfile
|
||||
|
||||
etc/clixonrc
|
||||
|
||||
include/clixon_config.h
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@
|
|||
* XML prolog syntax for 'well-formed' XML
|
||||
* `<!DOCTYPE` (ie DTD) is not supported.
|
||||
* Added Clixon example full system docker container, see [docker/system](docker/system).
|
||||
* Moved datastore/text/ code to datastore/ since there is only one type of datastore.
|
||||
* Changed clixon base system container to use Alpine [docker/base](docker/base).
|
||||
* clixon-config YAML file has new revision: 2019-02-06.
|
||||
* Added new log function: `clicon_log_xml()` for logging XML tree
|
||||
|
|
@ -521,7 +522,6 @@ enables saved files to be used as datastore without any editing. Thanks Matt, Ne
|
|||
|
||||
* New configuration option: CLICON_RESTCONF_PRETTY. Default true. Set to false to get more compact Restconf output.
|
||||
|
||||
|
||||
* Default configure file handling generalized by Renato Botelho/Matt Smith. Config file FILE is selected in the following priority order:
|
||||
* Provide -f FILE option when starting a program (eg clixon_backend -f FILE)
|
||||
* Provide --with-configfile=FILE when configuring
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ INSTALL = @INSTALL@
|
|||
INCLUDES = -I. -I@srcdir@ @INCLUDES@
|
||||
SHELL = /bin/sh
|
||||
|
||||
SUBDIRS = lib apps include etc datastore util yang
|
||||
SUBDIRS = lib apps include etc datastore yang
|
||||
|
||||
.PHONY: doc example all clean depend $(SUBDIRS) install loc TAGS .config.status docker test
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ bindir = @bindir@
|
|||
libdir = @libdir@
|
||||
mandir = @mandir@
|
||||
libexecdir = @libexecdir@
|
||||
wwwdir = /www-data
|
||||
localstatedir = @localstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
includedir = @includedir@
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ sysconfdir = @sysconfdir@
|
|||
includedir = @includedir@
|
||||
HOST_VENDOR = @host_vendor@
|
||||
|
||||
# XXX why is not wwwdir under prefix?
|
||||
wwwdir = @wwwdir@
|
||||
wwwuser = @wwwuser@
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ distclean: clean
|
|||
# Put other executables in libexec/
|
||||
# Also create a libexec/ directory for writeable/temporary files.
|
||||
# Put config file in etc/
|
||||
# Also a rule for letting www-dir be owned by www-data, which only orks for sudo
|
||||
# Also a rule for letting www-dir be owned by www-data, which only works for sudo
|
||||
install: install-lib $(APPL)
|
||||
ifeq ($(shell whoami),root)
|
||||
install -d -m 0755 -o $(wwwuser) -g $(wwwuser) $(DESTDIR)$(wwwdir)
|
||||
|
|
|
|||
|
|
@ -61,11 +61,11 @@
|
|||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/stat.h> /* chmod */
|
||||
|
||||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
|
@ -694,6 +694,11 @@ main(int argc,
|
|||
clicon_err(OE_CFG, errno, "FCGX_OpenSocket");
|
||||
goto done;
|
||||
}
|
||||
/* umask settings may interfer: we want group to write: this is 774 */
|
||||
if (chmod(sockpath, S_IRWXU|S_IRWXG|S_IROTH) < 0){
|
||||
clicon_err(OE_UNIX, errno, "chmod");
|
||||
goto done;
|
||||
}
|
||||
if (FCGX_InitRequest(r, sock, 0) != 0){
|
||||
clicon_err(OE_CFG, errno, "FCGX_InitRequest");
|
||||
goto done;
|
||||
|
|
|
|||
17
configure
vendored
17
configure
vendored
|
|
@ -715,6 +715,7 @@ with_cligen
|
|||
enable_stdyangs
|
||||
enable_publish
|
||||
with_restconf
|
||||
with_wwwuser
|
||||
with_configfile
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
|
|
@ -1362,6 +1363,7 @@ Optional Packages:
|
|||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--with-cligen=dir Use CLIGEN here
|
||||
--without-restconf disable support for restconf
|
||||
--with-wwwuser=<user> Set www user different from www-data
|
||||
--with-configfile=FILE set default path to config file
|
||||
|
||||
Some influential environment variables:
|
||||
|
|
@ -4170,6 +4172,18 @@ fi
|
|||
|
||||
fi
|
||||
|
||||
# This is for changing web user default www-data
|
||||
|
||||
# Check whether --with-wwwuser was given.
|
||||
if test "${with_wwwuser+set}" = set; then :
|
||||
withval=$with_wwwuser;
|
||||
fi
|
||||
|
||||
if test "${with_wwwuser}"; then
|
||||
wwwuser=${with_wwwuser}
|
||||
fi
|
||||
echo "wwwuser:$wwwuser"
|
||||
|
||||
# Set default config file location
|
||||
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
||||
|
||||
|
|
@ -4433,7 +4447,7 @@ _ACEOF
|
|||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile extras/rpm/Makefile docker/Makefile docker/system/Makefile docker/base/Makefile datastore/Makefile datastore/text/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/standard/Makefile doc/Makefile test/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile extras/rpm/Makefile docker/Makefile docker/system/Makefile docker/base/Makefile datastore/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/standard/Makefile doc/Makefile test/Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
|
|
@ -5145,7 +5159,6 @@ do
|
|||
"docker/system/Makefile") CONFIG_FILES="$CONFIG_FILES docker/system/Makefile" ;;
|
||||
"docker/base/Makefile") CONFIG_FILES="$CONFIG_FILES docker/base/Makefile" ;;
|
||||
"datastore/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/Makefile" ;;
|
||||
"datastore/text/Makefile") CONFIG_FILES="$CONFIG_FILES datastore/text/Makefile" ;;
|
||||
"util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;;
|
||||
"yang/Makefile") CONFIG_FILES="$CONFIG_FILES yang/Makefile" ;;
|
||||
"yang/clixon/Makefile") CONFIG_FILES="$CONFIG_FILES yang/clixon/Makefile" ;;
|
||||
|
|
|
|||
|
|
@ -191,6 +191,14 @@ if test "x${with_restconf}" == xyes; then
|
|||
AC_CHECK_LIB(fcgi, FCGX_Init,, AC_MSG_ERROR([libfcgi-dev missing]))
|
||||
fi
|
||||
|
||||
# This is for changing web user default www-data
|
||||
AC_ARG_WITH([wwwuser],
|
||||
[AS_HELP_STRING([--with-wwwuser=<user>],[Set www user different from www-data])])
|
||||
if test "${with_wwwuser}"; then
|
||||
wwwuser=${with_wwwuser}
|
||||
fi
|
||||
echo "wwwuser:$wwwuser"
|
||||
|
||||
# Set default config file location
|
||||
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
||||
AC_ARG_WITH([configfile],
|
||||
|
|
@ -245,7 +253,6 @@ AC_OUTPUT(Makefile
|
|||
docker/system/Makefile
|
||||
docker/base/Makefile
|
||||
datastore/Makefile
|
||||
datastore/text/Makefile
|
||||
util/Makefile
|
||||
yang/Makefile
|
||||
yang/clixon/Makefile
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
#
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
datarootdir = @datarootdir@
|
||||
srcdir = @srcdir@
|
||||
|
|
@ -43,78 +42,60 @@ mandir = @mandir@
|
|||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
HOST_VENDOR = @host_vendor@
|
||||
|
||||
VPATH = @srcdir@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAGS = @CFLAGS@ -rdynamic -fPIC
|
||||
INSTALLFLAGS = @INSTALLFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
with_restconf = @with_restconf@
|
||||
|
||||
SH_SUFFIX = @SH_SUFFIX@
|
||||
CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@
|
||||
CLIXON_MINOR = @CLIXON_VERSION_MINOR@
|
||||
|
||||
# Use this clixon lib for linking
|
||||
CLIXON_LIB = libclixon.so.$(CLIXON_MAJOR).$(CLIXON_MINOR)
|
||||
|
||||
# For dependency
|
||||
LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB)
|
||||
|
||||
LIBS = -L$(top_srcdir)/lib/src @LIBS@ $(top_srcdir)/lib/src/$(CLIXON_LIB)
|
||||
|
||||
DATASTORE = text
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
INCLUDES = -I. -I$(top_srcdir)/lib/src -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir) @INCLUDES@
|
||||
INCLUDES = -I. -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir) @INCLUDES@
|
||||
|
||||
PLUGIN = $(DATASTORE).so
|
||||
|
||||
SUBDIRS = text
|
||||
SRC = clixon_xmldb_text.c
|
||||
|
||||
.PHONY: all clean depend install $(SUBDIRS)
|
||||
OBJS = $(SRC:.c=.o)
|
||||
|
||||
APPSRC = datastore_client.c
|
||||
APPOBJ = $(APPSRC:.c=.o)
|
||||
APPL = datastore_client
|
||||
all: $(PLUGIN)
|
||||
|
||||
all: $(SUBDIRS) $(APPL)
|
||||
$(PLUGIN): $(SRC)
|
||||
ifeq ($(HOST_VENDOR),apple)
|
||||
$(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ -lc $^ $(LIBS)
|
||||
else
|
||||
$(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -shared -o $@ -lc $^ $(LIBS)
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f $(PLUGIN) $(OBJS) *.core
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *~ .depend
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDES) -D__PROGRAM__=\"$(APPL)\" $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
.c.o: $(SRC)
|
||||
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
$(APPL) : $(APPOBJ) $(LIBDEPS)
|
||||
$(CC) $(LDFLAGS) $(APPOBJ) $(LIBS) -o $@
|
||||
|
||||
|
||||
depend:
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i; $(MAKE) $(MFLAGS) $@); done
|
||||
|
||||
$(SUBDIRS):
|
||||
(cd $@; $(MAKE) $(MFLAGS) all)
|
||||
install: $(PLUGIN)
|
||||
install -d -m 0755 $(DESTDIR)$(libdir)/xmldb
|
||||
install -m 0644 $(INSTALLFLAGS) $(PLUGIN) $(DESTDIR)$(libdir)/xmldb
|
||||
|
||||
install-include:
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i ; $(MAKE) $(MFLAGS) $@)||exit 1; done;
|
||||
|
||||
install:
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done
|
||||
|
||||
uninstall:
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done
|
||||
|
||||
clean:
|
||||
rm -f *.core $(APPL) $(APPOBJ)
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i; $(MAKE) $(MFLAGS) $@); done
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *~ .depend
|
||||
for i in $(SUBDIRS); \
|
||||
do (cd $$i; $(MAKE) $(MFLAGS) $@); done
|
||||
rm -rf $(DESTDIR)$(libdir)/xmldb/$(PLUGIN)
|
||||
|
||||
TAGS:
|
||||
find $(srcdir) -name '*.[chyl]' -print | etags -
|
||||
find . -name '*.[chyl]' -print | etags -
|
||||
|
||||
depend:
|
||||
$(CC) $(DEPENDFLAGS) @DEFS@ $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend
|
||||
|
||||
#include .depend
|
||||
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
#
|
||||
# Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren
|
||||
#
|
||||
# This file is part of CLIXON
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# the GNU General Public License Version 3 or later (the "GPL"),
|
||||
# in which case the provisions of the GPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of the GPL, and not to allow others to
|
||||
# use your version of this file under the terms of Apache License version 2,
|
||||
# indicate your decision by deleting the provisions above and replace them with
|
||||
# the notice and other provisions required by the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the Apache License version 2 or the GPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
#
|
||||
prefix = @prefix@
|
||||
datarootdir = @datarootdir@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
dbdir = @prefix@/db
|
||||
mandir = @mandir@
|
||||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
HOST_VENDOR = @host_vendor@
|
||||
|
||||
VPATH = @srcdir@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ -rdynamic -fPIC
|
||||
INSTALLFLAGS = @INSTALLFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
DATASTORE = text
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
INCLUDES = -I. -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir) @INCLUDES@
|
||||
|
||||
PLUGIN = $(DATASTORE).so
|
||||
|
||||
SRC = clixon_xmldb_text.c
|
||||
|
||||
OBJS = $(SRC:.c=.o)
|
||||
|
||||
all: $(PLUGIN)
|
||||
|
||||
$(PLUGIN): $(SRC)
|
||||
ifeq ($(HOST_VENDOR),apple)
|
||||
$(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -shared -undefined dynamic_lookup -o $@ -lc $^ $(LIBS)
|
||||
else
|
||||
$(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -shared -o $@ -lc $^ $(LIBS)
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f $(PLUGIN) $(OBJS) *.core
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *~ .depend
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
.c.o: $(SRC)
|
||||
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
install: $(PLUGIN)
|
||||
install -d -m 0755 $(DESTDIR)$(libdir)/xmldb
|
||||
install -m 0644 $(INSTALLFLAGS) $(PLUGIN) $(DESTDIR)$(libdir)/xmldb
|
||||
|
||||
install-include:
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/xmldb/$(PLUGIN)
|
||||
|
||||
TAGS:
|
||||
find . -name '*.[chyl]' -print | etags -
|
||||
|
||||
depend:
|
||||
$(CC) $(DEPENDFLAGS) @DEFS@ $(INCLUDES) $(CFLAGS) -MM $(SRC) > .depend
|
||||
|
||||
#include .depend
|
||||
|
||||
|
|
@ -37,11 +37,9 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
|
|||
# For clixon and cligen
|
||||
RUN apk add --update git make build-base gcc flex bison fcgi-dev curl-dev
|
||||
|
||||
|
||||
# Create a directory to hold source-code, dependencies etc
|
||||
RUN mkdir /clixon
|
||||
RUN mkdir /clixon/build
|
||||
|
||||
WORKDIR /clixon
|
||||
|
||||
# Clone cligen
|
||||
|
|
@ -58,37 +56,54 @@ RUN mkdir /clixon/clixon
|
|||
WORKDIR /clixon/clixon
|
||||
COPY clixon .
|
||||
|
||||
# Build clixon (without restconf if you dont have nginx)
|
||||
RUN ./configure --without-restconf --prefix=/clixon/build --with-cligen=/clixon/build
|
||||
# Need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Configure, build and install clixon
|
||||
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN make install-include
|
||||
|
||||
# Build and install the clixon example (not really necessary for base)
|
||||
WORKDIR /clixon/clixon/example
|
||||
RUN DESTDIR=/clixon/build make
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN install example.xml /clixon/build/etc/clixon.xml
|
||||
|
||||
#
|
||||
# Stage 2
|
||||
#
|
||||
|
||||
FROM alpine
|
||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||
|
||||
# For clixon and cligen
|
||||
RUN apk add --update flex bison # fcgi-dev curl-dev
|
||||
RUN apk add --update flex bison fcgi-dev
|
||||
|
||||
# Run a clicon group - actually an application may want another
|
||||
# need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
#RUN apk add --update sudo curl bash
|
||||
|
||||
# Expose nginx port for restconf
|
||||
EXPOSE 80
|
||||
|
||||
# Create clicon group
|
||||
RUN addgroup clicon
|
||||
RUN adduser nginx clicon
|
||||
RUN adduser www-data clicon
|
||||
|
||||
COPY --from=0 /clixon/build/ /usr/local/
|
||||
COPY --from=0 /www-data /www-data
|
||||
|
||||
# For debug
|
||||
#RUN apk add --update bash nano
|
||||
|
||||
|
||||
|
||||
|
||||
# Manually created
|
||||
RUN chown www-data /www-data
|
||||
RUN chgrp www-data /www-data
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,23 +12,24 @@ See [clixon-system](../system/README.md) for a more complete clixon image.
|
|||
|
||||
## Build and push
|
||||
|
||||
Perform the build by `make docker`.
|
||||
You may also do `make push` if you want to push the image, but you may then consider changing the image name (in the makefile:s).
|
||||
Perform the build by `make docker`. This copies the latest _committed_ clixon code into the container.
|
||||
|
||||
You may run the container directly by going directly to example and
|
||||
the docker runtime scripts there
|
||||
You may also do `make push` if you want to push the image, but you may then consider changing the image name (in the makefile:s).
|
||||
|
||||
(You may have to login for push with sudo docker login -u <username>)
|
||||
|
||||
## Example run
|
||||
|
||||
The following shows a simple example of how to run the example
|
||||
application. First,the container is started, then the backend is startend in the background inside the container, and finally the CLI is started in the foreground.
|
||||
The base container is a minimal and primitive example. Look at the [clixon-system](../system) for a more stream-lined application.
|
||||
|
||||
The following shows a simple example of how to run the example
|
||||
application. First, the container is started with the backend running:
|
||||
```
|
||||
$ sudo docker run --name clixon --rm -td clixon/clixon
|
||||
$ sudo docker exec -it clixon clixon_backend -s init -f /usr/local/etc/example.xml
|
||||
$ sudo docker exec -it clixon clixon_cli -f /usr/local/etc/example.xml
|
||||
$ sudo docker run --rm --name clixon-base -d clixon/clixon clixon_backend -Fs init
|
||||
```
|
||||
Then a CLI is started, and finally the container is removed:
|
||||
```
|
||||
$ sudo docker exec -it clixon-base clixon_cli
|
||||
> set interfaces interface e
|
||||
> show configuration
|
||||
interfaces {
|
||||
|
|
@ -38,10 +39,10 @@ application. First,the container is started, then the backend is startend in the
|
|||
}
|
||||
}
|
||||
> q
|
||||
$ sudo docker kill clixon
|
||||
$ sudo docker kill clixon-base
|
||||
```
|
||||
|
||||
Note that this is a special case since the example is
|
||||
Note that the clixon example application is a special case since the example is
|
||||
already a part of the installation. If you want to add your own
|
||||
application, such as plugins, cli syntax files, yang models, etc, you
|
||||
need to extend the base container with your own additions.
|
||||
|
|
|
|||
16
docker/base/start.sh
Executable file
16
docker/base/start.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
# Usage: ./startup.sh
|
||||
# Debug: DBG=1 ./startup.sh
|
||||
# See also cleanup.sh
|
||||
|
||||
>&2 echo "Running script: $0"
|
||||
|
||||
|
||||
# Start clixon-example backend
|
||||
sudo docker run --name clixon --rm -td clixon/clixon || err "Error starting clixon"
|
||||
|
||||
>&2 echo "clixon started"
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,34 +31,23 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
#
|
||||
|
||||
# This application could use the base image, but it does not at this point.
|
||||
FROM debian
|
||||
FROM alpine
|
||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||
|
||||
# Clixon dependenies (not needed if build from base)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git make gcc flex bison \
|
||||
libfcgi-dev \
|
||||
libcurl4-openssl-dev
|
||||
|
||||
# Application-specific
|
||||
RUN apt-get update && apt-get install -y nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
RUN apt-get update && apt-get install -y sudo curl procps time
|
||||
|
||||
# The example uses "clicon" group
|
||||
RUN groupadd clicon
|
||||
RUN usermod -a -G clicon www-data
|
||||
# For clixon and cligen
|
||||
RUN apk add --update git make build-base gcc flex bison fcgi-dev curl-dev
|
||||
|
||||
# Create a directory to hold source-code, dependencies etc
|
||||
RUN mkdir /clixon
|
||||
RUN mkdir /clixon/build
|
||||
WORKDIR /clixon
|
||||
|
||||
# Clone and build cligen (not necessary if use base image)
|
||||
# Clone cligen
|
||||
RUN git clone https://github.com/olofhagsand/cligen.git
|
||||
|
||||
# Build cligen
|
||||
WORKDIR /clixon/cligen
|
||||
RUN ./configure
|
||||
RUN ./configure --prefix=/clixon/build
|
||||
RUN make
|
||||
RUN make install
|
||||
|
||||
|
|
@ -67,30 +56,69 @@ RUN mkdir /clixon/clixon
|
|||
WORKDIR /clixon/clixon
|
||||
COPY clixon .
|
||||
|
||||
RUN ./configure
|
||||
# Need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Configure, build and install clixon
|
||||
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-wwwuser=www-data
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN make install-include
|
||||
|
||||
# Install utils
|
||||
WORKDIR /clixon/clixon/util
|
||||
RUN make
|
||||
RUN make install
|
||||
|
||||
# Build and install the clixon example
|
||||
WORKDIR /clixon/clixon/example
|
||||
RUN make
|
||||
RUN make install
|
||||
RUN install example.xml /usr/local/etc/clixon.xml
|
||||
RUN install example.xml /clixon/build/etc/clixon.xml
|
||||
|
||||
RUN ldconfig
|
||||
# Copy tests
|
||||
WORKDIR /clixon/clixon/test
|
||||
RUN install -d /clixon/build/bin/test
|
||||
RUN install *.sh /clixon/build/bin/test
|
||||
|
||||
# Copy startscript
|
||||
WORKDIR /clixon
|
||||
COPY startsystem.sh startsystem.sh
|
||||
RUN install startsystem.sh /usr/local/bin/
|
||||
RUN install startsystem.sh /clixon/build/bin/
|
||||
|
||||
#
|
||||
# Stage 2
|
||||
#
|
||||
FROM alpine
|
||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||
|
||||
# For clixon and cligen
|
||||
RUN apk add --update flex bison fcgi-dev
|
||||
|
||||
# need to add www user manually
|
||||
RUN adduser -D -H www-data
|
||||
# nginx adds group www-data
|
||||
RUN apk add --update nginx
|
||||
|
||||
# Test-specific (for test scripts)
|
||||
RUN apk add --update sudo curl procps grep make bash
|
||||
|
||||
# Expose nginx port for restconf
|
||||
EXPOSE 80
|
||||
|
||||
# Create clicon group
|
||||
RUN addgroup clicon
|
||||
RUN adduser nginx clicon
|
||||
RUN adduser www-data clicon
|
||||
|
||||
COPY --from=0 /clixon/build/ /usr/local/
|
||||
COPY --from=0 /www-data /www-data
|
||||
|
||||
# Manually created
|
||||
RUN chown www-data /www-data
|
||||
RUN chgrp www-data /www-data
|
||||
|
||||
# Log to stderr.
|
||||
CMD /usr/local/bin/startsystem.sh
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ push:
|
|||
# Start the clixon system container and run the test script
|
||||
test: docker
|
||||
./cleanup.sh ; PORT=8080 ./start.sh # kill (ignore error) and the start it
|
||||
sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test && ./all.sh'
|
||||
sudo docker exec -it clixon-system bash -c 'cd /usr/local/bin/test && ./all.sh'
|
||||
|
||||
depend:
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ As restconf using curl on exposed port 80:
|
|||
```
|
||||
Or run tests:
|
||||
```
|
||||
$ sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test&& ./all.sh'
|
||||
$ sudo docker exec -it clixon-system bash -c 'cd /usr/local/bin/test&& ./all.sh'
|
||||
```
|
||||
|
||||
To check status and then kill it:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
DBG=${DBG:-0}
|
||||
|
||||
WWWUSER=${WWWUSER:-www-data}
|
||||
|
||||
# Initiate clixon configuration (env variable)
|
||||
echo "$CONFIG" > /usr/local/etc/clixon.xml
|
||||
|
||||
|
|
@ -19,7 +21,7 @@ echo "$STORE" > /usr/local/var/example/running_db
|
|||
|
||||
>&2 echo "Write nginx config files"
|
||||
# nginx site config file
|
||||
cat <<EOF > /etc/nginx/sites-enabled/default
|
||||
cat <<EOF > /etc/nginx/conf.d/default.conf
|
||||
#
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
|
@ -28,7 +30,6 @@ server {
|
|||
server_name localhost;
|
||||
server_name _;
|
||||
location / {
|
||||
root /usr/share/nginx/html/restconf;
|
||||
fastcgi_pass unix:/www-data/fastcgi_restconf.sock;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
|
@ -46,13 +47,17 @@ server {
|
|||
EOF
|
||||
|
||||
# This is a clixon site test file. Disable all model testing.
|
||||
cat <<EOF > /clixon/clixon/test/site.sh
|
||||
cat <<EOF > /usr/local/bin/test/site.sh
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
MODELS=0 # Dont run yangmodels/openconfig tests
|
||||
IETFRFC=/clixon/clixon/yang/standard
|
||||
SKIPLIST="test_yangmodels.sh test_openconfig.sh test_install.sh test_order.sh"
|
||||
#IETFRFC=
|
||||
EOF
|
||||
|
||||
chmod 775 /usr/local/bin/test/site.sh
|
||||
|
||||
if [ ! -d /run/nginx ]; then
|
||||
mkdir /run/nginx
|
||||
fi
|
||||
|
||||
# Start nginx
|
||||
#/usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
|
||||
|
|
@ -60,9 +65,12 @@ EOF
|
|||
>&2 echo "nginx started"
|
||||
|
||||
# Start clixon_restconf
|
||||
su -c "/www-data/clixon_restconf -l f/www-data/restconf.log -D $DBG" -s /bin/sh www-data &
|
||||
su -c "/www-data/clixon_restconf -l f/www-data/restconf.log -D $DBG" -s /bin/sh $WWWUSER &
|
||||
>&2 echo "clixon_restconf started"
|
||||
|
||||
# Set grp write XXX do this when creating
|
||||
chmod g+w /www-data/fastcgi_restconf.sock
|
||||
|
||||
# Start clixon backend
|
||||
>&2 echo "start clixon_backend:"
|
||||
/usr/local/sbin/clixon_backend -FD $DBG -s running -l e # logs on docker logs
|
||||
|
|
|
|||
|
|
@ -21,7 +21,22 @@ application. Assumes setup of http daemon as describe under apps/restonf
|
|||
- test_datastore.sh Datastore tests
|
||||
- and many more...
|
||||
|
||||
Tests called 'test*.sh' and placed in this directory will be automatically run as part of the all.sh, sum.sh tests etc.
|
||||
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`:
|
||||
```
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
```
|
||||
|
||||
You need to build and install the clixon utility programs before running the tests as some of the tests rely on them:
|
||||
```
|
||||
cd util
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
You need to start nginx for some of the text. There are instructions in
|
||||
* If you run systemd: `sudo systemctl start nginx.service`
|
||||
* The [example](../example/README.md) has instructions
|
||||
|
||||
You can prefix a test with `BE=0` if you want to run your own backend.
|
||||
|
||||
|
|
@ -37,14 +52,16 @@ Run all tests but continue after errors and only print a summary test output ide
|
|||
all.sh summary
|
||||
```
|
||||
|
||||
You need to start nginx. There are instructions in [the example](../example/README.md)
|
||||
|
||||
Example site.sh file:
|
||||
```
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
# Add test to this list that you dont want run
|
||||
SKIPLIST="test_openconfig.sh test_yangmodels.sh"
|
||||
# Parse yang openconfig models from https://github.com/openconfig/public
|
||||
OPENCONFIG=/home/olof/src/clixon/test/public
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
YANGMODELS=/usr/local/share/yangmodels
|
||||
# Standard IETF RFC yang files.
|
||||
IETFRFC=$YANGMODELS/standard/ietf/RFC
|
||||
```
|
||||
|
||||
#!/bin/bash
|
||||
# Add your local site specific env variables (or tests) here.
|
||||
# get from: https://github.com/openconfig/public
|
||||
OPENCONFIG=/home/olof/src/clixon/test/public
|
||||
# get from: https://github.com/YangModels/yang
|
||||
YANGMODELS=/usr/local/share/yangmodels
|
||||
IETFRFC=$YANGMODELS/standard/ietf/RFC
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@ if [ $# -gt 0 ]; then
|
|||
exit -1
|
||||
fi
|
||||
|
||||
# include err() and new() functions
|
||||
. ./lib.sh
|
||||
err=0
|
||||
testnr=0
|
||||
for test in test*.sh; do
|
||||
echo "Running $test"
|
||||
./$test
|
||||
testfile=$test
|
||||
. ./$test
|
||||
errcode=$?
|
||||
if [ $errcode -ne 0 ]; then
|
||||
err=1
|
||||
|
|
|
|||
33
test/lib.sh
33
test/lib.sh
|
|
@ -12,18 +12,34 @@
|
|||
|
||||
#set -e
|
||||
|
||||
# Probe nginx
|
||||
#sudo systemctl status nginx.service > /dev/null
|
||||
#if [ $? -ne 0 ]; then
|
||||
# sudo systemctl start nginx.service
|
||||
#fi
|
||||
# Testfile (not including path)
|
||||
: ${testfile:=$(basename $0)}
|
||||
|
||||
# Add test to this list that you dont want run
|
||||
# Typically add them in your site file
|
||||
: ${SKIPLIST:=""}
|
||||
|
||||
>&2 echo "Running $testfile"
|
||||
|
||||
# Site file, an example of this file in README.md
|
||||
if [ -x ./site.sh ]; then
|
||||
|
||||
. ./site.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
return -1 # skip
|
||||
fi
|
||||
# test skiplist.
|
||||
for f in $SKIPLIST; do
|
||||
if [ "$testfile" = "$f" ]; then
|
||||
return -1 # skip
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
testnr=0
|
||||
# Running test number
|
||||
: ${testnr:=0}
|
||||
|
||||
# Single test. Set by "new"
|
||||
testname=
|
||||
|
||||
# If set to 0, override starting of clixon_backend in test (you bring your own)
|
||||
|
|
@ -36,11 +52,6 @@ testname=
|
|||
# eg logging to a file: RCLOG="-l f/www-data/restconf.log"
|
||||
: ${RCLOG:=}
|
||||
|
||||
# If reset, do NOT run tests with external yang models.
|
||||
# This involves downloading
|
||||
# https://github.com/openconfig/public and https://github.com/YangModels/yang
|
||||
: ${MODELS:=1}
|
||||
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
# Recommended: checkout yangmodels elsewhere in the tree and set the env
|
||||
# to that
|
||||
|
|
|
|||
10
test/sum.sh
10
test/sum.sh
|
|
@ -7,16 +7,14 @@ if [ $# -gt 0 ]; then
|
|||
exit -1
|
||||
fi
|
||||
|
||||
# include err() and new() functions
|
||||
. ./lib.sh
|
||||
err=0
|
||||
for test in test*.sh; do
|
||||
echo "Running $test"
|
||||
./$test > /dev/null 2>&1
|
||||
for testfile in test*.sh; do # For lib.sh the variable must be called testfile
|
||||
echo "Running $testfile"
|
||||
./$testfile > /dev/null 2>&1
|
||||
errcode=$?
|
||||
if [ $errcode -ne 0 ]; then
|
||||
err=1
|
||||
echo -e "\e[31mError in $test errcode=$errcode"
|
||||
echo -e "\e[31mError in $testfile errcode=$errcode"
|
||||
echo -ne "\e[0m"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
# Use-case: The ietf-netconf edit-config has a shorthand version of choice w mandatory:
|
||||
# container { choice target { mandatory; leaf candidate; leaf running; }}
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/choice.xml
|
||||
fyang=$dir/type.yang
|
||||
|
|
@ -95,7 +96,7 @@ if [ $BE -ne 0 ]; then
|
|||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
pkill clixon_backend # to be sure
|
||||
sudo pkill clixon_backend # to be sure
|
||||
|
||||
new "start backend -s init -f $cfg -y $fyang"
|
||||
sudo $clixon_backend -s init -f $cfg -y $fyang
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Test1: backend and cli basic functionality
|
||||
# Start backend server
|
||||
# Add an ethernet interface and an address
|
||||
|
|
@ -8,9 +7,13 @@
|
|||
# Set the mandatory type
|
||||
# Commit
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
# 1) Load <3.9 startup/running/extra files without namespaces - ensure it returns namespaces
|
||||
#
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_startup.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
@ -29,7 +31,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Test5: datastore tests.
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# datastore tests.
|
||||
# Just run a binary direct to datastore. No clixon.
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
fyang=$dir/ietf-ip.yang
|
||||
|
||||
datastore=../datastore/datastore_client
|
||||
# If set, enable debugging (of backend)
|
||||
: ${clixon_util_datastore:=clixon_util_datastore}
|
||||
: ${clixon_datastore_lib:=/usr/local/lib/xmldb/text.so}
|
||||
|
||||
cat <<EOF > $fyang
|
||||
module ietf-ip{
|
||||
|
|
@ -46,126 +49,124 @@ module ietf-ip{
|
|||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
xml='<config><x xmlns="urn:example:clixon"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></config>'
|
||||
|
||||
run(){
|
||||
name=$1
|
||||
mydir=$dir/$name
|
||||
|
||||
if [ ! -d $mydir ]; then
|
||||
mkdir $mydir
|
||||
fi
|
||||
rm -rf $mydir/*
|
||||
name=text
|
||||
|
||||
conf="-d candidate -b $mydir -p ../datastore/$name/$name.so -y $dir/ietf-ip.yang"
|
||||
|
||||
new "datastore $name init"
|
||||
expectfn "$datastore $conf init" 0 ""
|
||||
mydir=$dir/$name
|
||||
|
||||
new "datastore $name put all replace"
|
||||
ret=$($datastore $conf put replace "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
if [ ! -d $mydir ]; then
|
||||
mkdir $mydir
|
||||
fi
|
||||
rm -rf $mydir/*
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
# XXX static link
|
||||
conf="-d candidate -b $mydir -p $clixon_datastore_lib -y $dir/ietf-ip.yang"
|
||||
|
||||
new "datastore $name put all remove"
|
||||
expectfn "$datastore $conf put remove <config/>" 0 ""
|
||||
new "datastore init"
|
||||
expectfn "$clixon_util_datastore $conf init" 0 ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^<config/>$"
|
||||
new "datastore put all replace"
|
||||
ret=$($clixon_util_datastore $conf put replace "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name put all merge"
|
||||
ret=$($datastore $conf put merge "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
# expectfn "$datastore $conf put merge $xml" 0 ""
|
||||
new "datastore put all remove"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config/>" 0 ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^<config/>$"
|
||||
|
||||
new "datastore $name put all delete"
|
||||
expectfn "$datastore $conf put remove <config/>" 0 ""
|
||||
new "datastore put all merge"
|
||||
ret=$($clixon_util_datastore $conf put merge "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^<config/>$"
|
||||
# expectfn "$clixon_util_datastore $conf put merge $xml" 0 ""
|
||||
|
||||
new "datastore $name put all create"
|
||||
ret=$($datastore $conf put create "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
new "datastore $name get"
|
||||
expectfn "$datastore $conf get /" 0 "^$xml$"
|
||||
new "datastore put all delete"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config/>" 0 ""
|
||||
|
||||
new "datastore $name put top create"
|
||||
expectfn "$datastore $conf put create <config><x/></config>" 0 "" # error
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^<config/>$"
|
||||
|
||||
# Single key operations
|
||||
# leaf
|
||||
new "datastore $name put all delete"
|
||||
expectfn "$datastore $conf delete" 0 ""
|
||||
new "datastore put all create"
|
||||
ret=$($clixon_util_datastore $conf put create "$xml")
|
||||
expectmatch "$ret" $? "0" ""
|
||||
|
||||
new "datastore $name init"
|
||||
expectfn "$datastore $conf init" 0 ""
|
||||
new "datastore get"
|
||||
expectfn "$clixon_util_datastore $conf get /" 0 "^$xml$"
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore put top create"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x/></config>" 0 "" # error
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
# Single key operations
|
||||
# leaf
|
||||
new "datastore put all delete"
|
||||
expectfn "$clixon_util_datastore $conf delete" 0 ""
|
||||
|
||||
new "datastore $name delete leaf"
|
||||
expectfn "$datastore $conf put delete <config><x><y><a>1</a><b>3</b></y></x></config>" 0 ""
|
||||
new "datastore init"
|
||||
expectfn "$clixon_util_datastore $conf init" 0 ""
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name remove leaf"
|
||||
expectfn "$datastore $conf put remove <config><x><g/></x></config>" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name remove leaf"
|
||||
expectfn "$datastore $conf put remove <config><x><y><a>1</a><b>3</b><c/></y></x></config>" 0 ""
|
||||
new "datastore delete leaf"
|
||||
expectfn "$clixon_util_datastore $conf put delete <config><x><y><a>1</a><b>3</b></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name delete leaf"
|
||||
expectfn "$datastore $conf put delete <config><x><g/></x></config>" 0 ""
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name merge leaf"
|
||||
expectfn "$datastore $conf put merge <config><x><g>nalle</g></x></config>" 0 ""
|
||||
new "datastore remove leaf"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config><x><g/></x></config>" 0 ""
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put replace <config><x><g>nalle</g></x></config>" 0 ""
|
||||
new "datastore remove leaf"
|
||||
expectfn "$clixon_util_datastore $conf put remove <config><x><y><a>1</a><b>3</b><c/></y></x></config>" 0 ""
|
||||
|
||||
new "datastore $name merge leaf"
|
||||
expectfn "$datastore $conf put merge <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore delete leaf"
|
||||
expectfn "$clixon_util_datastore $conf put delete <config><x><g/></x></config>" 0 ""
|
||||
|
||||
new "datastore $name replace leaf"
|
||||
expectfn "$datastore $conf put replace <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore merge leaf"
|
||||
expectfn "$clixon_util_datastore $conf put merge <config><x><g>nalle</g></x></config>" 0 ""
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><h><j>aaa</j></h></x></config>" 0 ""
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put replace <config><x><g>nalle</g></x></config>" 0 ""
|
||||
|
||||
new "datastore $name create leaf"
|
||||
expectfn "$datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
new "datastore merge leaf"
|
||||
expectfn "$clixon_util_datastore $conf put merge <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore other db init"
|
||||
expectfn "$datastore -d kalle -b $mydir -p ../datastore/$name/$name.so -y $dir/ietf-ip.yang init" 0 ""
|
||||
new "datastore replace leaf"
|
||||
expectfn "$clixon_util_datastore $conf put replace <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore other db copy"
|
||||
expectfn "$datastore $conf copy kalle" 0 ""
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><h><j>aaa</j></h></x></config>" 0 ""
|
||||
|
||||
diff $mydir/kalle_db $mydir/candidate_db
|
||||
new "datastore create leaf"
|
||||
expectfn "$clixon_util_datastore $conf put create <config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>" 0 ""
|
||||
|
||||
new "datastore lock"
|
||||
expectfn "$datastore $conf lock 756" 0 ""
|
||||
new "datastore other db init"
|
||||
expectfn "$clixon_util_datastore -d kalle -b $mydir -p $clixon_datastore_lib -y $dir/ietf-ip.yang init" 0 ""
|
||||
|
||||
new "datastore other db copy"
|
||||
expectfn "$clixon_util_datastore $conf copy kalle" 0 ""
|
||||
|
||||
diff $mydir/kalle_db $mydir/candidate_db
|
||||
|
||||
new "datastore lock"
|
||||
expectfn "$clixon_util_datastore $conf lock 756" 0 ""
|
||||
|
||||
#leaf-list
|
||||
|
||||
rm -rf $mydir
|
||||
}
|
||||
|
||||
run text
|
||||
rm -rf $mydir
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang features. if-feature. and schema resources according to RFC7895
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Identity and identityref tests
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/example-my-crypto.yang
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
# Install test
|
||||
# Install system test
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
new "Set up installdir $dir"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@
|
|||
# Test: JSON parser tests
|
||||
# Note that nmbers shouldnot be quoted. See test_restconf2.sh for typed
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_json"
|
||||
PROG=../util/clixon_util_json
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
: ${clixon_util_json:=clixon_util_json}
|
||||
|
||||
new "json parse to xml"
|
||||
expecteofx "$PROG" 0 '{"foo": -23}' "<foo>-23</foo>"
|
||||
expecteofx "$clixon_util_json" 0 '{"foo": -23}' "<foo>-23</foo>"
|
||||
|
||||
new "json parse to json" # should be {"foo": -23}
|
||||
expecteofx "$PROG -j" 0 '{"foo": -23}' '{"foo": "-23"}'
|
||||
expecteofx "$clixon_util_json -j" 0 '{"foo": -23}' '{"foo": "-23"}'
|
||||
|
||||
new "json parse list xml"
|
||||
expecteofx "$PROG" 0 '{"a":[0,1,2,3]}' "<a>0</a><a>1</a><a>2</a><a>3</a>"
|
||||
expecteofx "$clixon_util_json" 0 '{"a":[0,1,2,3]}' "<a>0</a><a>1</a><a>2</a><a>3</a>"
|
||||
|
||||
new "json parse list json" # should be {"a":[0,1,2,3]}
|
||||
expecteofx "$PROG -j" 0 '{"a":[0,1,2,3]}' '{"a": "0"}{"a": "1"}{"a": "2"}{"a": "3"}'
|
||||
expecteofx "$clixon_util_json -j" 0 '{"a":[0,1,2,3]}' '{"a": "0"}{"a": "1"}{"a": "2"}{"a": "3"}'
|
||||
|
||||
rm -rf $dir
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Test7: Yang specifics: leafref
|
||||
# Yang leafref test
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/leafref.yang
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang list / leaf-list operations. min/max-elements
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
# See RFC 8341 A.2
|
||||
# But replaced ietf-netconf-monitoring with *
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
# See RFC 8341 A.2
|
||||
# But replaced ietf-netconf-monitoring with *
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -18,9 +18,12 @@
|
|||
# all content in the server. No subsequent rule will match for the
|
||||
# "admin" group because of this module rule
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -20,9 +20,12 @@
|
|||
# update | p/d | p/d | p/d
|
||||
# delete | p/d | p/d | p/d
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
# Which means that restconf -X DELETE /data translates to edit-config + commit
|
||||
# which is allowed.
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
# Common NACM scripts
|
||||
. ./nacm.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Test2: backend and netconf basic functionality
|
||||
# Basic Netconf functionality
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
tmp=$dir/tmp.x
|
||||
|
|
|
|||
|
|
@ -7,15 +7,11 @@
|
|||
# - Env-var MODELS should be 1
|
||||
# - Env-var OPENCONFIG should point to checkout place. (define it in site.sh for example)
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
if [ $MODELS -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
||||
|
|
@ -104,7 +100,7 @@ for f in $files; do
|
|||
exit
|
||||
fi
|
||||
done
|
||||
echo "m:$ms s:$ss"
|
||||
|
||||
new "Openconfig test: $clixon_cli -1f $cfg -y $f show version ($m modules)"
|
||||
for f in $files; do
|
||||
if [ -n "$(head -1 $f|grep '^module')" ]; then
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
# 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).
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/order.yang
|
||||
tmp=$dir/tmp.x
|
||||
|
|
@ -36,7 +39,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
|
||||
<CLICON_XMLDB_DIR>$dbdir</CLICON_XMLDB_DIR>
|
||||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
EOF
|
||||
|
||||
|
|
@ -152,7 +154,7 @@ EOF
|
|||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "$(cat $tmp)" '<rpc-reply><data><state xmlns="urn:example:clixon"><op>42</op><op>41</op><op>43</op></state></data></rpc-reply>]]>]]>'
|
||||
|
||||
# Check as file
|
||||
new "verify running from start, should be: c,l,y0,y1,y2,y3; y1 and y3 sorted. Note this fails if CLICON_XML_SORT set to false"
|
||||
new "verify running from start, should be: c,l,y0,y1,y2,y3; y1 and y3 sorted."
|
||||
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><get-config><source><running/></source></get-config></rpc>]]>]]>' '^<rpc-reply><data><c xmlns="urn:example:order"><d>hej</d></c><l xmlns="urn:example:order">hopp</l><y0 xmlns="urn:example:order">d</y0><y0 xmlns="urn:example:order">b</y0><y0 xmlns="urn:example:order">c</y0><y0 xmlns="urn:example:order">a</y0><y1 xmlns="urn:example:order">a</y1><y1 xmlns="urn:example:order">b</y1><y1 xmlns="urn:example:order">c</y1><y1 xmlns="urn:example:order">d</y1><y2 xmlns="urn:example:order"><k>d</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>a</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>c</k><a>bar</a></y2><y2 xmlns="urn:example:order"><k>b</k><a>bar</a></y2><y3 xmlns="urn:example:order"><k>a</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>b</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>c</k><a>bar</a></y3><y3 xmlns="urn:example:order"><k>d</k><a>bar</a></y3><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>lo</name><type>ex:loopback</type><enabled>true</enabled></interface></interfaces></data></rpc-reply>]]>]]>$'
|
||||
|
||||
new "get each ordered-by user leaf-list"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
# Scaling test
|
||||
# Scaling/ performance tests
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
number=5000
|
||||
req=100
|
||||
|
|
@ -15,8 +18,6 @@ else
|
|||
exit 1 # Scaling
|
||||
fi
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/scaling-conf.xml
|
||||
fyang=$dir/scaling.yang
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/bash
|
||||
# Restconf basic functionality
|
||||
# Assume http server setup, such as nginx described in apps/restconf/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
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#!/bin/bash
|
||||
# Restconf basic functionality
|
||||
# Assume http server setup, such as nginx described in apps/restconf/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
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
fyang=$dir/restconf.yang
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@
|
|||
# Use the example application that has one mandatory input arg,
|
||||
# At the end is an alternative Yang without mandatory arg for
|
||||
# valid empty input and output.
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
cfg=$dir/conf.xml
|
||||
|
||||
# Use yang in example
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@
|
|||
# - An extra xml configuration file starts with an "extra" interface
|
||||
# - running db starts with a "run" interface
|
||||
# - startup db starts with a "start" interface
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_startup.xml
|
||||
|
||||
cat <<EOF > $cfg
|
||||
|
|
@ -29,7 +32,6 @@ cat <<EOF > $cfg
|
|||
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||
<CLICON_XML_SORT>true</CLICON_XML_SORT>
|
||||
</config>
|
||||
|
||||
EOF
|
||||
|
|
|
|||
|
|
@ -20,16 +20,15 @@
|
|||
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications
|
||||
# Note the sleeps are mainly for valgrind usage
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
UTIL=../util/clixon_util_stream
|
||||
: ${clixon_util_stream:=clixon_util_stream}
|
||||
NCWAIT=5 # Wait (netconf valgrind may need more time)
|
||||
|
||||
if [ ! -x $UTIL ]; then
|
||||
(cd ../util; make clixon_util_stream)
|
||||
fi
|
||||
DATE=$(date +"%Y-%m-%d")
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf.xml
|
||||
fyang=$dir/stream.yang
|
||||
xml=$dir/xml.xml
|
||||
|
|
@ -181,7 +180,7 @@ expectwait 'curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-
|
|||
|
||||
# 2a) start subscription 8s - expect 1-2 notifications
|
||||
new "2a) start subscriptions 8s - expect 1-2 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
|
|
@ -197,7 +196,7 @@ sleep 2
|
|||
|
||||
# 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications
|
||||
new "2b) start subscriptions 8s - stoptime after 5s - expect 1-2 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8 -e +10)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8 -e +10)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -210,7 +209,7 @@ fi
|
|||
|
||||
# 2c
|
||||
new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -223,7 +222,7 @@ fi
|
|||
|
||||
# 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications
|
||||
new "2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -30 -e +4)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -30 -e +4)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -236,7 +235,7 @@ fi
|
|||
|
||||
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications
|
||||
new "2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 10 -s -90 -e +0)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -90 -e +0)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
if [ -z "$match" ]; then
|
||||
|
|
@ -254,7 +253,7 @@ curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "
|
|||
PID=$!
|
||||
|
||||
new "Start subscriptions in parallell"
|
||||
ret=$($UTIL -u http://localhost/streams/EXAMPLE -t 8)
|
||||
ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8)
|
||||
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"
|
||||
|
||||
match=$(echo "$ret" | grep -Eo "$expect")
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
# Advanced union types and generated code
|
||||
# and enum w values
|
||||
# XXX NO SUPPORT FOR lists of ranges and lengths !!!
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/type.yang
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Advanced union types and generated code
|
||||
# and enum w values
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/type.yang
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
# Yang when and must conditional xpath specification
|
||||
# Testing of validation phase.
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
|
|
|||
|
|
@ -3,43 +3,42 @@
|
|||
# @see https://www.w3.org/TR/2008/REC-xml-20081126
|
||||
# https://www.w3.org/TR/2009/REC-xml-names-20091208
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xml"
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
PROG="../util/clixon_util_xml -D $DBG"
|
||||
: ${clixon_util_xml:=clixon_util_xml}
|
||||
|
||||
new "xml parse"
|
||||
expecteof "$PROG" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
expecteof "$clixon_util_xml" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
|
||||
new "xml parse to json"
|
||||
expecteof "$PROG -j" 0 "<a><b/></a>" '{"a": {"b": null}}'
|
||||
expecteof "$clixon_util_xml -j" 0 "<a><b/></a>" '{"a": {"b": null}}'
|
||||
|
||||
new "xml parse strange names"
|
||||
expecteof "$PROG" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
expecteof "$clixon_util_xml" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<-a/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<-a/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<9/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<9/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$PROG" 255 "<a%/>" ""
|
||||
expecteof "$clixon_util_xml" 255 "<a%/>" ""
|
||||
|
||||
LF='
|
||||
'
|
||||
new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)"
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $PROG)
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $clixon_util_xml)
|
||||
if [ "$ret" != "<x>a${LF}b${LF}c${LF}d</x>" ]; then
|
||||
err '<x>a$LFb$LFc</x>' "$ret"
|
||||
fi
|
||||
|
||||
new "xml simple CDATA"
|
||||
expecteofx "$PROG" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
expecteofx "$clixon_util_xml" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
|
||||
new "xml simple CDATA to json"
|
||||
expecteofx "$PROG -j" 0 '<a><![CDATA[a text]]></a>' '{"a": "a text"}'
|
||||
expecteofx "$clixon_util_xml -j" 0 '<a><![CDATA[a text]]></a>' '{"a": "a text"}'
|
||||
|
||||
new "xml complex CDATA"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -56,7 +55,7 @@ XML=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
|
||||
expecteof "$PROG" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
<![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]>
|
||||
</sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$"
|
||||
|
||||
|
|
@ -65,89 +64,89 @@ JSON=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
new "xml complex CDATA to json"
|
||||
expecteofx "$PROG -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>Less than: < , greater than: > ampersand: & </message>
|
||||
EOF
|
||||
)
|
||||
new "xml encode <>&"
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
new "xml encode <>& to json"
|
||||
expecteof "$PROG -j" 0 "$XML" '{"message": "Less than: < , greater than: > ampersand: & "}'
|
||||
expecteof "$clixon_util_xml -j" 0 "$XML" '{"message": "Less than: < , greater than: > ampersand: & "}'
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>single-quote character ' represented as ' and double-quote character as "</message>
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quote"
|
||||
expecteof "$PROG" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
|
||||
JSON=$(cat <<EOF
|
||||
{"message": "single-quote character ' represented as ' and double-quote character as \""}
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quotes to json"
|
||||
expecteofx "$PROG -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
|
||||
new "xml backspace"
|
||||
expecteofx "$PROG" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
expecteofx "$clixon_util_xml" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
|
||||
new "xml backspace to json"
|
||||
expecteofx "$PROG -j" 0 "<a>a\b</a>" '{"a": "a\\b"}'
|
||||
expecteofx "$clixon_util_xml -j" 0 "<a>a\b</a>" '{"a": "a\\b"}'
|
||||
|
||||
new "Double quotes for attributes"
|
||||
expecteof "$PROG" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
|
||||
new "Single quotes for attributes (returns double quotes but at least parses right)"
|
||||
expecteof "$PROG" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
|
||||
new "Mixed quotes"
|
||||
expecteof "$PROG" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
|
||||
new "XMLdecl version"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version, single quotes"
|
||||
expecteof "$PROG" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
|
||||
new "XMLdecl version no element"
|
||||
expecteof "$PROG" 255 '<?xml version="1.0"?>' ''
|
||||
expecteof "$clixon_util_xml" 255 '<?xml version="1.0"?>' ''
|
||||
|
||||
new "XMLdecl no version"
|
||||
expecteof "$PROG" 255 '<?xml ?><a/>' ''
|
||||
expecteof "$clixon_util_xml" 255 '<?xml ?><a/>' ''
|
||||
|
||||
new "XMLdecl misspelled version"
|
||||
expecteof "$PROG -l o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
|
||||
new "XMLdecl version + encoding"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version + misspelled encoding"
|
||||
expecteof "$PROG -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
|
||||
new "XMLdecl version + standalone"
|
||||
expecteof "$PROG" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
|
||||
new "PI - Processing instruction empty"
|
||||
expecteof "$PROG" 0 '<?foo ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo ?><a/>' '<a/>'
|
||||
|
||||
new "PI some content"
|
||||
expecteof "$PROG" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
|
||||
new "prolog element misc*"
|
||||
expecteof "$PROG" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
|
||||
# We allow it as an internal necessity for parsing of xml fragments
|
||||
#new "double element error"
|
||||
#expecteof "$PROG" 255 '<a/><b/>' ''
|
||||
#expecteof "$clixon_util_xml" 255 '<a/><b/>' ''
|
||||
|
||||
new "namespace: DefaultAttName"
|
||||
expecteof "$PROG" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
|
||||
new "namespace: PrefixedAttName"
|
||||
expecteof "$PROG" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
|
||||
new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -161,7 +160,7 @@ XML=$(cat <<EOF
|
|||
</html:html>
|
||||
EOF
|
||||
)
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -174,7 +173,7 @@ XML=$(cat <<EOF
|
|||
</bk:book>
|
||||
EOF
|
||||
)
|
||||
expecteof "$PROG" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/bash
|
||||
# Test: XPATH tests
|
||||
#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xpath"
|
||||
PROG=../util/clixon_util_xpath
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
: ${clixon_util_xpath:=clixon_util_xpath}
|
||||
|
||||
# XML file (alt provide it in stdin after xpath)
|
||||
xml=$dir/xml.xml
|
||||
|
|
@ -76,117 +77,117 @@ cat <<EOF > $xml3
|
|||
EOF
|
||||
|
||||
new "xpath /"
|
||||
expecteof "$PROG -f $xml -p /" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
|
||||
new "xpath /aaa"
|
||||
expecteof "$PROG -f $xml -p /aaa" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /aaa" 0 "" "^nodeset:0:<aaa><bbb x=\"hello\"><ccc>42</ccc></bbb><bbb x=\"bye\"><ccc>99</ccc></bbb><ddd><ccc>22</ccc></ddd></aaa>$"
|
||||
|
||||
new "xpath /bbb"
|
||||
expecteof "$PROG -f $xml -p /bbb" 0 "" "^nodeset:$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p /bbb" 0 "" "^nodeset:$"
|
||||
|
||||
new "xpath /aaa/bbb"
|
||||
expecteof "$PROG -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
expecteof "$clixon_util_xpath -f $xml -p /aaa/bbb" 0 "" "^0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
|
||||
new "xpath //bbb"
|
||||
expecteof "$PROG -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb" 0 "" "0:<bbb x=\"hello\"><ccc>42</ccc></bbb>
|
||||
1:<bbb x=\"bye\"><ccc>99</ccc></bbb>"
|
||||
|
||||
new "xpath //b?b"
|
||||
#expecteof "$PROG -f $xml" 0 "//b?b" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b?b" ""
|
||||
|
||||
new "xpath //b*"
|
||||
#expecteof "$PROG -f $xml" 0 "//b*" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b*" ""
|
||||
|
||||
new "xpath //b*/ccc"
|
||||
#expecteof "$PROG -f $xml" 0 "//b*/ccc" ""
|
||||
#expecteof "$clixon_util_xpath -f $xml" 0 "//b*/ccc" ""
|
||||
|
||||
new "xpath //bbb[0]"
|
||||
expecteof "$PROG -f $xml -p //bbb[0]" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>42</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb[0]" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>42</ccc></bbb>$"
|
||||
|
||||
new "xpath //bbb[ccc=99]"
|
||||
expecteof "$PROG -f $xml -p //bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml -p //bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc></bbb>$"
|
||||
|
||||
new "xpath ../connection-type = 'responder-only'"
|
||||
expecteof "$PROG -f $xml2 -p ../connection-type='responder-only' -i /aaa/bbb/here" 0 "" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p ../connection-type='responder-only' -i /aaa/bbb/here" 0 "" "^bool:true$"
|
||||
|
||||
new "xpath ../connection-type = 'no-responder'"
|
||||
expecteof "$PROG -f $xml2 -p ../connection-type='no-responder' -i /aaa/bbb/here" 0 "" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p ../connection-type='no-responder' -i /aaa/bbb/here" 0 "" "^bool:false$"
|
||||
|
||||
new "xpath . <= 0.75 * ../max-rtr-adv-interval"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". <= 0.75 * ../max-rtr-adv-interval" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". <= 0.75 * ../max-rtr-adv-interval" "^bool:true$"
|
||||
|
||||
new "xpath . > 0.75 * ../max-rtr-adv-interval"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". > 0.75 * ../max-rtr-adv-interval" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". > 0.75 * ../max-rtr-adv-interval" "^bool:false$"
|
||||
|
||||
new "xpath . <= ../valid-lifetime"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 ". <= ../valid-lifetime" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 ". <= ../valid-lifetime" "^bool:true$"
|
||||
|
||||
new "xpath ../../rt:address-family = 'v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 "../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 "../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath ../../../rt:address-family = 'v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here2/here" 0 "../../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here2/here" 0 "../../../rt:address-family = 'v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath /if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'"
|
||||
expecteof "$PROG -f $xml2" 0 "/if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2" 0 "/if:interfaces/if:interface[if:name=current()/rt:name]/ip:ipv6/ip:enabled='true'" "^bool:true$"
|
||||
|
||||
new "xpath rt:address-family='v6ur:ipv6-unicast'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa" 0 "rt:address-family='v6ur:ipv6-unicast'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa" 0 "rt:address-family='v6ur:ipv6-unicast'" "^bool:true$"
|
||||
|
||||
new "xpath ../type='rt:static'"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb/here" 0 "../type='rt:static'" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb/here" 0 "../type='rt:static'" "^bool:true$"
|
||||
|
||||
new "xpath rib-name != ../../name"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "rib-name != ../../name" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "rib-name != ../../name" "^bool:true$"
|
||||
|
||||
new "xpath routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "routing/ribs/rib[name=current()/rib-name]/address-family=../../address-family" "^bool:true$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" or ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" or ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" or ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1400" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" or ifMTU = 1400" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" or ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" or ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" and ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1500" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1500" "^bool:true$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" and ifMTU = 1500"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1500" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1500" "^bool:false$"
|
||||
|
||||
new "xpath ifType = \"ethernet\" and ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType = \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType != \"ethernet\" and ifMTU = 1400"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"ethernet\" and ifMTU = 1400" "^bool:false$"
|
||||
|
||||
new "xpath ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)"
|
||||
expecteof "$PROG -f $xml2 -i /aaa/bbb" 0 "ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)" "^bool:true$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -i /aaa/bbb" 0 "ifType != \"atm\" or (ifMTU <= 17966 and ifMTU >= 64)" "^bool:true$"
|
||||
|
||||
new "xpath .[name='bar']"
|
||||
expecteof "$PROG -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
||||
expecteof "$clixon_util_xpath -f $xml2 -p .[name='bar'] -i /aaa/bbb/routing/ribs/rib" 0 "" "^nodeset:0:<rib><name>bar</name><address-family>myfamily</address-family></rib>$"
|
||||
|
||||
new "Multiple entries"
|
||||
new "xpath bbb[ccc='foo']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='foo']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>1:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='42']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='42']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='42']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc=99] (number w/o quotes)"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc=99]" 0 "" "^nodeset:0:<bbb x=\"bye\"><ccc>99</ccc><ccc>foo</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='bar']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='bar']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='bar']" 0 "" "^nodeset:0:<bbb x=\"hello\"><ccc>foo</ccc><ccc>42</ccc><ccc>bar</ccc></bbb>$"
|
||||
|
||||
new "xpath bbb[ccc='fie']"
|
||||
expecteof "$PROG -f $xml3 -p bbb[ccc='fie']" 0 "" "^nodeset:$"
|
||||
expecteof "$clixon_util_xpath -f $xml3 -p bbb[ccc='fie']" 0 "" "^nodeset:$"
|
||||
|
||||
rm -rf $dir
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#!/bin/bash
|
||||
# Yang specifics: multi-keys and empty type
|
||||
# Yang test: multi-keys and empty type
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/$APPNAME.yang
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
# as well as revisions
|
||||
# Test is made by having different config files and then try to set configure
|
||||
# options available in specific modules
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang1=$dir/$APPNAME@2018-12-02.yang
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
APPNAME=example
|
||||
# test two modules example1 and example2 with overlapping statements x.
|
||||
# Test two modules example1 and example2 with overlapping statements x.
|
||||
# x is leaf in example1 and list on example2.
|
||||
# Test netconf and restconf
|
||||
# BTW, this is not supported in generated CLI
|
||||
|
||||
. ./lib.sh
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
APPNAME=example
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang1=$dir/example1.yang
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Parse yangmodels from https://github.com/YangModels/yang
|
||||
# Notes:
|
||||
# - Env-var MODELS should be 1
|
||||
# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example)
|
||||
# - Only cisco/nx/9.2-2 # Many other versions
|
||||
# - Only cisco/xe/1631 # Many other versions
|
||||
|
|
@ -17,16 +16,12 @@
|
|||
#./vendor/cisco/xe/check.sh
|
||||
#./vendor/cisco/nx/check.sh
|
||||
|
||||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
# Yang specifics: multi-keys and empty type
|
||||
APPNAME=example
|
||||
|
||||
# include err() and new() functions and creates $dir
|
||||
. ./lib.sh
|
||||
|
||||
if [ $MODELS -eq 0 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cfg=$dir/conf_yang.xml
|
||||
fyang=$dir/test.yang
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ libexecdir = @libexecdir@
|
|||
localstatedir = @localstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
HOST_VENDOR = @host_vendor@
|
||||
with_restconf = @with_restconf@
|
||||
|
||||
SH_SUFFIX = @SH_SUFFIX@
|
||||
|
||||
|
|
@ -70,12 +71,14 @@ APPSRC = clixon_util_xml.c
|
|||
APPSRC += clixon_util_json.c
|
||||
APPSRC += clixon_util_yang.c
|
||||
APPSRC += clixon_util_xpath.c
|
||||
# APPSRC += clixon_util_stream.c # Needs curl
|
||||
APPSRC += clixon_util_datastore.c
|
||||
ifeq ($(with_restconf),yes)
|
||||
APPSRC += clixon_util_stream.c # Needs curl
|
||||
endif
|
||||
|
||||
APPS = $(APPSRC:.c=)
|
||||
|
||||
all: $(APPS)
|
||||
@echo "You may want to make clixon_util_stream separately (curl dependency)"
|
||||
|
||||
clean:
|
||||
rm -f $(APPS) clixon_util_stream *.core
|
||||
|
|
@ -96,13 +99,15 @@ clixon_util_xpath: clixon_util_xpath.c $(MYLIB)
|
|||
clixon_util_stream: clixon_util_stream.c $(MYLIB)
|
||||
$(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $(LDFLAGS) $^ $(LIBS) -lcurl -o $@
|
||||
|
||||
clixon_util_datastore: clixon_util_datastore.c $(MYLIB)
|
||||
$(CC) $(INCLUDES) $(CPPFLAGS) @CFLAGS@ $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile *~ .depend
|
||||
|
||||
install:
|
||||
# install -d -m 0755 $(DESTDIR)$(bindir)
|
||||
# install -m 0755 $(INSTALLFLAGS) $(APPS) $(DESTDIR)$(bindir)
|
||||
|
||||
install -d -m 0755 $(DESTDIR)$(bindir)
|
||||
install -m 0755 $(INSTALLFLAGS) $(APPS) $(DESTDIR)$(bindir)
|
||||
|
||||
install-include:
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ main(int argc, char **argv)
|
|||
cbuf *cbret = NULL;
|
||||
|
||||
/* In the startup, logs to stderr & debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, CLICON_LOG_STDERR);
|
||||
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
|
||||
|
||||
argv0 = argv[0];
|
||||
/* Defaults */
|
||||
|
|
@ -157,7 +157,7 @@ main(int argc, char **argv)
|
|||
/*
|
||||
* Logs, error and debug to stderr, set debug level
|
||||
*/
|
||||
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_STDERR);
|
||||
clicon_log_init(__FILE__, debug?LOG_DEBUG:LOG_INFO, CLICON_LOG_STDERR);
|
||||
clicon_debug_init(debug, NULL);
|
||||
|
||||
argc -= optind;
|
||||
Loading…
Add table
Add a link
Reference in a new issue