diff --git a/Makefile.in b/Makefile.in
index b5a833b1..ac14dc51 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -141,8 +141,10 @@ pkg-srpm: dist
example:
(cd $@ && $(MAKE) $(MFLAGS) all)
-test: #example
- (cd $@ && $(MAKE) $(MFLAGS) all)
+# Run a clixon test container.
+# Alt: cd test; ./all.sh
+test:
+ (cd docker/system && $(MAKE) $(MFLAGS) test)
docker:
for i in docker; \
diff --git a/README.md b/README.md
index 77ff632f..70155788 100644
--- a/README.md
+++ b/README.md
@@ -20,12 +20,12 @@ support.
* [Datastore](datastore/README.md)
* [Authentication](#auth)
* [NACM Access control](#nacm)
- * [Example](example/)
+ * [Example](example/README.md)
* [Changelog](CHANGELOG.md)
* [Runtime](#runtime)
* [Clixon project page](http://www.clicon.org)
- * [Tests](test/)
- * [Docker](docker/)
+ * [Tests](test/README.md)
+ * [Docker](docker/README.md)
* [Roadmap](ROADMAP.md)
* [Reference manual](#reference)
diff --git a/doc/FAQ.md b/doc/FAQ.md
index de8e7a74..260e951d 100644
--- a/doc/FAQ.md
+++ b/doc/FAQ.md
@@ -243,13 +243,20 @@ information on all modules and which features are enabled.
## Can I run Clixon as docker containers?
-Yes, the example works as docker containers as well. There should be a
-prepared container in docker hub for the example where the backend and
-CLI is bundled.
-```
-sudo docker run -td olofhagsand/clixon_example
-```
-Look in the example documentation for more info.
+Yes, Clixon has two examples on how to build docker containers. A [base](../docker/base) image and a complete [example system](../docker/system).
+
+The base image can only be used as a boilerplate for building clixon
+applications (it has no applications semantics); whereas the system is
+a complete example applications with CLI/Netconf/Restconf, and
+testing.
+
+For example, the clixon-system container can be used as follows:
+* CLI: `sudo docker exec -it clixon-system clixon_cli`
+* Netconf: `sudo docker exec -it clixon-system clixon_netconf`
+* Restconf: `curl -G http://localhost/restconf`
+* Run tests: `sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test; exec ./all.sh'`
+
+See [../docker](../docker) for more info.
## Does Clixon support event streams?
diff --git a/docker/README.md b/docker/README.md
index f6e404ac..f5d2ffca 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -1,6 +1,7 @@
-# Clixon base docker image
+# Clixon and dockers
This directory contains sub-directories with examples of Clixon docker images:
- * [base] Clixon base image (pulls code from github)
- * [system] Example and test application (builds from local dir)
+
+ * [base](base/README.md) Clixon base image
+ * [system](system/README.md) Example and test application
diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile
index a15c874b..031459dd 100644
--- a/docker/base/Dockerfile
+++ b/docker/base/Dockerfile
@@ -44,9 +44,8 @@ RUN apt-get update && apt-get install -y \
RUN mkdir /clixon
WORKDIR /clixon
-# Clone cligen and clixon
+# Clone cligen
RUN git clone https://github.com/olofhagsand/cligen.git
-RUN git clone https://github.com/clicon/clixon.git
# Build cligen
WORKDIR /clixon/cligen
@@ -54,8 +53,12 @@ RUN ./configure
RUN make
RUN make install
-# Build clixon
+# Copy Clixon from local dir
+RUN mkdir /clixon/clixon
WORKDIR /clixon/clixon
+COPY clixon .
+
+# Build clixon
RUN ./configure
RUN make
RUN make install
diff --git a/docker/base/Makefile.in b/docker/base/Makefile.in
index e7a051ce..d5984bbd 100644
--- a/docker/base/Makefile.in
+++ b/docker/base/Makefile.in
@@ -48,12 +48,16 @@ SHELL = /bin/sh
all:
echo "Run make docker to build docker image"
+# (recursively) clone the repo from top-level - NOTE changes must be committed
+clixon:
+ git clone file://$(realpath ${top_srcdir})
+
clean:
distclean: clean
rm -f Makefile *~ .depend
-docker: Dockerfile
+docker: clixon Dockerfile
sudo docker build -t $(IMG) . # --no-cache
push:
diff --git a/docker/base/README.md b/docker/base/README.md
index 14b40a4a..b9062bb5 100644
--- a/docker/base/README.md
+++ b/docker/base/README.md
@@ -6,15 +6,14 @@ 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
-downloads from git - it does not use local code (note it may even use
-develop branch).
+downloads from git.
-See [../system/README.md] for how to build the clixon example application using the base image.
+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`.
+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 run the container directly by going directly to example and
the docker runtime scripts there
diff --git a/docker/system/Dockerfile b/docker/system/Dockerfile
index 1a533c4c..1bcc0d76 100644
--- a/docker/system/Dockerfile
+++ b/docker/system/Dockerfile
@@ -45,8 +45,8 @@ RUN apt-get update && apt-get install -y \
# Application-specific
RUN apt-get update && apt-get install -y nginx
-# Test-specific
-RUN apt-get update && apt-get install -y sudo curl procps # for test scripts
+# 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
diff --git a/docker/system/Makefile.in b/docker/system/Makefile.in
index ddc36f46..b86620f0 100644
--- a/docker/system/Makefile.in
+++ b/docker/system/Makefile.in
@@ -43,7 +43,7 @@ IMG = clixon/clixon-system
SHELL = /bin/sh
-.PHONY: all clean depend install docker push clixon-system
+.PHONY: all clean distclean docker test push depend install-include install uninstall
all:
echo "Run make docker to build docker image"
@@ -61,6 +61,11 @@ distclean: clean
docker: clixon Dockerfile
sudo docker build -t $(IMG) . # --no-cache
+# Start the clixon system container and run the test script
+test: docker
+ ./start.sh
+ sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test; exec ./all.sh'
+
push:
depend:
diff --git a/docker/system/README.md b/docker/system/README.md
index 9c5901e4..483b0905 100644
--- a/docker/system/README.md
+++ b/docker/system/README.md
@@ -48,3 +48,5 @@ To check status and then kill it:
$ sudo docker ps --all
$ ./cleanup.sh
```
+
+You can also trigger the test scripts inside the container using `make test`.
\ No newline at end of file
diff --git a/test/Makefile.in b/test/Makefile.in
index 23465f93..aba38b55 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -43,9 +43,6 @@ SHELL = /bin/sh
.PHONY: all clean distclean depend install uninstall
all:
- ./test_xml.sh
- ./test_json.sh
-# ./all.sh
clean:
diff --git a/test/plot_perf.sh b/test/plot_perf.sh
index c5eaaa98..f04cf505 100755
--- a/test/plot_perf.sh
+++ b/test/plot_perf.sh
@@ -69,25 +69,25 @@ run(){
case $mode in
readlist)
- time -p for (( i=0; i<$reqs; i++ )); do
+ /usr/bin/time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
;;
writelist)
- time -p for (( i=0; i<$reqs; i++ )); do
+ /usr/bin/time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "$rnd$rnd]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
;;
restreadlist)
- time -p for (( i=0; i<$reqs; i++ )); do
+ /usr/bin/time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
curl -sSG http://localhost/restconf/data/x/y=$rnd,$rnd > /dev/null
done
;;
writeleaflist)
- time -p for (( i=0; i<$reqs; i++ )); do
+ /usr/bin/time -p for (( i=0; i<$reqs; i++ )); do
rnd=$(( ( RANDOM % $nr ) ))
echo "$rnd]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
diff --git a/test/test_perf.sh b/test/test_perf.sh
index 1d4c0cbf..30e0135f 100755
--- a/test/test_perf.sh
+++ b/test/test_perf.sh
@@ -94,52 +94,52 @@ echo "]]>]]>" >> $fconfig
echo "$clixon_netconf -qf $cfg -y $fyang"
new "netconf write large config"
-expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
+expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
#echo ']]>]]>' | $clixon_netconf -qf $cfg -y $fyang
new "netconf write large config again"
-expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
+expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
#echo ']]>]]>' | $clixon_netconf -qf $cfg -y $fyang
rm $fconfig
new "netconf commit large config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
new "netconf commit large config again"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
new "netconf add small (1 entry) config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 'xy]]>]]>' "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 'xy]]>]]>' "^]]>]]>$"
new "netconf get $req small config"
-time -p for (( i=0; i<$req; i++ )); do
+/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
echo "]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf get $req restconf small config"
-time -p for (( i=0; i<$req; i++ )); do
+/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
#XXX curl -sX PUT -d {"y":{"a":"$rnd","b":"$rnd"}} http://localhost/restconf/data/x/y=$rnd,$rnd
done
new "netconf add $req small config"
-time -p for (( i=0; i<$req; i++ )); do
+/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
echo "$rnd$rnd]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf add $req restconf small config"
-time -p for (( i=0; i<$req; i++ )); do
+/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
curl -sG http://localhost/restconf/data/x/y=$rnd,$rnd > /dev/null
done
new "netconf get large config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^0011'
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^0011'
new "generate large leaf-list config"
echo -n "replace" > $fconfig
@@ -149,27 +149,27 @@ done
echo "]]>]]>" >> $fconfig
new "netconf replace large list-leaf config"
-expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
+expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^]]>]]>$"
rm $fconfig
new "netconf commit large leaf-list config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
new "netconf add $req small leaf-list config"
-time -p for (( i=0; i<$req; i++ )); do
+/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
echo "$rnd]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf add small leaf-list config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 'x]]>]]>' "^]]>]]>$"
new "netconf commit small leaf-list config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$"
new "netconf get large leaf-list config"
-expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01'
+expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01'
new "Kill restconf daemon"
sudo pkill -u www-data -f "/www-data/clixon_restconf"
diff --git a/test/travis/before_script.sh b/test/travis/before_script.sh
index d2293763..948431c6 100755
--- a/test/travis/before_script.sh
+++ b/test/travis/before_script.sh
@@ -10,7 +10,5 @@ sudo make install-include
sudo groupadd clicon
sudo usermod -a -G clicon $(whoami)
sudo usermod -a -G clicon www-data
-# Build and start the system docker container
-(cd docker/system && make docker && ./start.sh)
-# Run clixon testcases
-(cd docker/system && sudo docker exec -it clixon-system bash -c 'cd /clixon/clixon/test; exec ./all.sh')
+# Build the system docker container (make test may trigger it)
+(cd docker/system && make docker)