From afe64cbd5e25ffc29fe1cc686cf513fea7fc6d74 Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Mon, 7 Sep 2020 16:15:12 +0000 Subject: [PATCH] cicd tests --- docker/base/README.md | 25 ------------------------- test/cicd/Makefile.in | 6 ++++-- test/cicd/cicd.sh | 15 +++++++++++---- test/cicd/clixon-config.sh | 16 ++++++++++++---- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/docker/base/README.md b/docker/base/README.md index a44e611e..9f468ece 100644 --- a/docker/base/README.md +++ b/docker/base/README.md @@ -18,28 +18,3 @@ You may also do `make push` if you want to push the image, but you may then cons (You may have to login for push with sudo docker login -u ) -## Example run - -The base container is a minimal and primitive example. Look at the [clixon-system](../main) 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 --rm --name cli -d clixon/clixon clixon_backend -Fs init -``` -Then a CLI is started, and finally the container is removed: -``` - $ sudo docker exec -it hello clixon_cli - cli> set ? - hello - cli> set hello world - cli> show configuration - hello world; - > q - $ sudo docker kill hello -``` - -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. diff --git a/test/cicd/Makefile.in b/test/cicd/Makefile.in index 251390f6..7ff3f4ab 100644 --- a/test/cicd/Makefile.in +++ b/test/cicd/Makefile.in @@ -46,6 +46,8 @@ SHELL = /bin/sh # eg : # HOSTS += vandal.hagsand.com # i86_32 ubuntu # ... +# You can also set RESTCONF to fcgi or evhtp +RESTCONF=fcgi HOSTS= -include site.mk @@ -56,9 +58,9 @@ all: $(HOSTS) # Real hosts reachable by ssh $(HOSTS): ifdef LOGDIR - ./cicd.sh $@ 2>&1 > $(LOGDIR)/$@.log + ./cicd.sh $@ $(RESTCONF) 2>&1 > $(LOGDIR)/$@-$(RESTCONF).log else - ./cicd.sh $@ 2>&1 | tee /$@.log + ./cicd.sh $@ $(RESTCONF) 2>&1 | tee /$@-$(RESTCONF).log endif clean: diff --git a/test/cicd/cicd.sh b/test/cicd/cicd.sh index 0929e2e6..6d99d842 100755 --- a/test/cicd/cicd.sh +++ b/test/cicd/cicd.sh @@ -21,12 +21,14 @@ set -eux # x -if [ $# -ne 1 ]; then - echo "usage: $0 " +if [ $# -ne 2 ]; then + echo "usage: $0 " + echo " where is fcgi or evhtp" exit -1 fi -h=$1 +h=$1 # Host +restconf=$2 SCRIPTS="cligen-mk.sh clixon-mk.sh clixon-config.sh" @@ -43,8 +45,13 @@ ssh -t $h "(cd src/cligen; /tmp/cligen-mk.sh)" # pull git changes and build clixon ssh -t $h "test -d src/clixon || (cd src;git clone https://github.com/clicon/clixon.git)" ssh -t $h "(cd src/clixon;git pull)" -ssh -t $h "(cd src/clixon; /tmp/clixon-config.sh)" +ssh -t $h "(cd src/clixon; /tmp/clixon-config.sh $evhtp)" ssh -t $h "(cd src/clixon; /tmp/clixon-mk.sh)" ssh -t $h sudo ldconfig # Run clixon test suite +if [ "$restconf" = "fcgi" ]; then + ssh -t $h sudo systemctl start nginx +else + ssh -t $h sudo systemctl stop nginx +fi ssh -t $h "(cd src/clixon/test; ./sum.sh)" diff --git a/test/cicd/clixon-config.sh b/test/cicd/clixon-config.sh index 8bb0f046..ec90ea06 100644 --- a/test/cicd/clixon-config.sh +++ b/test/cicd/clixon-config.sh @@ -1,8 +1,16 @@ #!/bin/sh # A top-level configurer for clixon set -eux -if [ $(uname) = "FreeBSD" ]; then - ./configure --with-cligen=/usr/local --with-wwwuser=www --enable-optyangs -else - ./configure --enable-optyangs + +if [ $# -ne 1 ]; then + echo "usage: $0 " + echo " where is fcgi or evhtp" + exit -1 +fi +restconf=$1 + +if [ $(uname) = "FreeBSD" ]; then + ./configure --with-cligen=/usr/local --with-wwwuser=www --enable-optyangs --with-restconf=$restconf +else + ./configure --enable-optyangs --with-restconf=$restconf fi