docker base and system images, and trigger docker test from travis.

This commit is contained in:
Olof Hagsand 2019-02-11 15:47:12 +01:00
parent 84d2efdedc
commit dc173e0b4c
14 changed files with 72 additions and 54 deletions

View file

@ -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; \

View file

@ -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)

View file

@ -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?

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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`.

View file

@ -43,9 +43,6 @@ SHELL = /bin/sh
.PHONY: all clean distclean depend install uninstall
all:
./test_xml.sh
./test_json.sh
# ./all.sh
clean:

View file

@ -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 "<rpc><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/x/y[a=$rnd][b=$rnd]\" /></get-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
;;
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 "<rpc><edit-config><target><candidate/></target><config><x><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
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 "<rpc><edit-config><target><candidate/></target><config><x><c>$rnd</c></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null

View file

@ -94,52 +94,52 @@ echo "</x></config></edit-config></rpc>]]>]]>" >> $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" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
#echo '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' | $clixon_netconf -qf $cfg -y $fyang
new "netconf write large config again"
expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
#echo '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' | $clixon_netconf -qf $cfg -y $fyang
rm $fconfig
new "netconf commit large config"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf commit large config again"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf add small (1 entry) config"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><y><a>x</a><b>y</b></y></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><y><a>x</a><b>y</b></y></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
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 "<rpc><get-config><source><candidate/></source><filter type=\"xpath\" select=\"/x/y[a=$rnd][b=$rnd]\" /></get-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
new "netconf get $req restconf small config"
time -p for (( i=0; i<$req; i++ )); do
/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 "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><y><a>$rnd</a><b>$rnd</b></y></x></config></edit-config></rpc>]]>]]>"
done | $clixon_netconf -qf $cfg -y $fyang > /dev/null
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 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b>'
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b>'
new "generate large leaf-list config"
echo -n "<rpc><edit-config><target><candidate/></target><default-operation>replace</default-operation><config><x xmlns=\"urn:example:clixon\">" > $fconfig
@ -149,27 +149,27 @@ done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig
new "netconf replace large list-leaf config"
expecteof_file "time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
rm $fconfig
new "netconf commit large leaf-list config"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf add $req small leaf-list config"
time -p for (( i=0; i<$req; i++ )); do
/usr/bin/time -p for (( i=0; i<$req; i++ )); do
rnd=$(( ( RANDOM % $number ) ))
echo "<rpc><edit-config><target><candidate/></target><config><x xmlns=\"urn:example:clixon\"><c>$rnd</c></x></config></edit-config></rpc>]]>]]>"
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 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf commit small leaf-list config"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf get large leaf-list config"
expecteof "time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>'
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>'
new "Kill restconf daemon"
sudo pkill -u www-data -f "/www-data/clixon_restconf"

View file

@ -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)