diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md index 0dee9f2c..97bc60d0 100644 --- a/doc/DEVELOP.md +++ b/doc/DEVELOP.md @@ -68,6 +68,11 @@ How to debug CFLAGS="-g -Wall" INSTALLFLAGS="" ./configure ``` +### Set backend debug flag using curl + +curl -Ssik -X POST -H "Content-Type: application/yang-data+json" http://localhost/restconf/operations/clixon-lib:debug -d '{"clixon-lib:input":{"level":1}}' + + ### Make your own simplified yang and configuration file. ``` cat < /tmp/my.yang diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index 80f60af4..5bd5b304 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -94,7 +94,7 @@ MAINTAINER Olof Hagsand RUN apk add --update flex bison fcgi-dev # Test-specific (for test scripts) -RUN apk add --update sudo curl procps grep make bash +RUN apk add --update sudo curl procps grep make bash # iproute2 # contains ip # Create clicon user and group RUN adduser -D -H clicon diff --git a/docker/main/Dockerfile.evhtp b/docker/main/Dockerfile.evhtp index 7c99ae15..c11a3e1c 100644 --- a/docker/main/Dockerfile.evhtp +++ b/docker/main/Dockerfile.evhtp @@ -47,14 +47,18 @@ RUN apk add --update libevent cmake libevent-dev # clone libevhtp WORKDIR /clixon -RUN git clone https://github.com/clicon/libevhtp.git -WORKDIR /clixon/libevhtp/build -RUN cmake -DEVHTP_DISABLE_REGEX=ON -DEVHTP_DISABLE_EVTHR=ON -DBUILD_SHARED_LIBS=OFF .. -RUN make -RUN make install -# NOTE: Patch include queue.h to use the queue.h included in the evhtp release instead -RUN (cd /usr/local/include/evhtp/; sed -i -e 's///' evhtp.h) +#RUN git clone https://github.com/criticalstack/libevhtp.git +#WORKDIR /clixon/libevhtp/build +#RUN cmake -DEVHTP_DISABLE_REGEX=ON -DEVHTP_DISABLE_EVTHR=ON -DBUILD_SHARED_LIBS=OFF .. + +RUN git clone https://github.com/clicon/libevhtp.git +WORKDIR /clixon/libevhtp +RUN ./configure + +RUN make +RUN mkdir /usr/local/include +RUN make install RUN mkdir /clixon/build WORKDIR /clixon @@ -118,7 +122,7 @@ RUN adduser -D -H www-data RUN apk add --update openssl libevent # Test-specific (for test scripts) -RUN apk add --update sudo curl procps grep make bash +RUN apk add --update sudo curl procps grep make bash # iproute2 # contains ip - but CAP_SYS_ADMIN isssue # Expose https port for restconf EXPOSE 80/tcp @@ -130,6 +134,7 @@ RUN adduser www-data clicon COPY --from=0 /clixon/build/ /usr/local/ COPY --from=0 /www-data /www-data +COPY --from=0 /usr/local/lib/libevhtp.so* /usr/local/lib/ # Manually created RUN chown www-data /www-data diff --git a/docker/main/Dockerfile.fcgi b/docker/main/Dockerfile.fcgi index a2ae4508..90cc1c38 100644 --- a/docker/main/Dockerfile.fcgi +++ b/docker/main/Dockerfile.fcgi @@ -103,7 +103,7 @@ RUN adduser -D -H www-data RUN apk add --update nginx # Test-specific (for test scripts) -RUN apk add --update sudo curl procps grep make bash +RUN apk add --update sudo curl procps grep make bash # iproute2 # contains ip # Expose nginx port for restconf EXPOSE 80 diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index 6db95ab5..feb7c4fd 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -1,7 +1,13 @@ #!/usr/bin/env bash -# Parse yang openconfig yangs from https://github.com/openconfig/public +# Parse "all" openconfig yangs from https://github.com/openconfig/public # Notes: +# Notes: +# - A simple smoketest (CLI check) is made, essentially YANG parsing. +# - A full system is worked on # - Env-var OPENCONFIG should point to checkout place. (define it in site.sh for example) +# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example) +# - Some DIFFs are necessary in yangmodels +# release/models/wifi/openconfig-ap-interfaces.yang # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -23,6 +29,9 @@ OCDIR=$OPENCONFIG/release/models cat < $cfg $cfg + ietf-netconf:startup + /usr/local/share/clixon + $OCDIR $OCDIR/acl $OCDIR/aft @@ -60,14 +69,13 @@ cat < $cfg $OCDIR/wifi/mac $OCDIR/wifi/phy $OCDIR/wifi/types - /usr/local/share/clixon - $IETFRFC + /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile - /usr/local/var/$APPNAME + $dir true EOF @@ -104,5 +112,52 @@ for f in $files; do fi done +if false; then # NYI + +# Example system +cat < $dir/startup_db + + + + eth0 + + ianaift:usb + + + + +EOF + +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + sudo pkill -f clixon_backend # to be sure + + new "start backend -s startup -f $cfg -y openconfig-interfaces -p /usr/local/share/openconfig/public/release/models/interfaces" + start_backend -s startup -f $cfg -y /usr/local/share/openconfig/public/release/models/interfaces/openconfig-interfaces.yang + + new "wait backend" + wait_backend +fi + +new "$clixon_cli -D $DBG -1f $cfg -y $f show version" +expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "${CLIXON_VERSION}" + +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg +fi + +fi + rm -rf $dir diff --git a/test/test_privileges.sh b/test/test_privileges.sh index 71afe999..86d7dc89 100755 --- a/test/test_privileges.sh +++ b/test/test_privileges.sh @@ -71,6 +71,7 @@ function testrun(){ err fi sleep 1 # wait for backend to exit + pid=$(pgrep -f clixon_backend) if [ $? -ne 0 ]; then if [ $expecterr -eq 1 ]; then @@ -79,6 +80,12 @@ function testrun(){ err fi + new "Number of clixon_backend processes" + c=$(pgrep -c -f clixon_backend) + if [ $c -ne 1 ]; then + err 1 $c + fi + new "waiting" wait_backend diff --git a/test/test_yang_models_ieee.sh b/test/test_yang_models_ieee.sh index 71a06059..db621e08 100755 --- a/test/test_yang_models_ieee.sh +++ b/test/test_yang_models_ieee.sh @@ -1,10 +1,14 @@ #!/usr/bin/env bash # Parse "all" IEEE yangmodels from https://github.com/YangModels/yang/standard/ietf/RFC # Notes: -# - Only a simple smoketest (CLI check) is made, A full system may not work +# - Only a simple smoketest (CLI check) is made, essentially YANG parsing. A full system may not work # - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example) # - Some FEATURES are set to make it work -# - Some DIFFs are necessary in yangmodels (see end of script) +# - Some DIFFs are necessary in yangmodels +# - standard/ieee/published/802.3/ieee802-ethernet-pon.yang: +# - when "../ompe-mode = olt'"; +# + when "../ompe-mode = 'olt'"; + # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi diff --git a/test/test_yang_models_ietf.sh b/test/test_yang_models_ietf.sh index f9734633..f0aa8e3f 100755 --- a/test/test_yang_models_ietf.sh +++ b/test/test_yang_models_ietf.sh @@ -1,10 +1,29 @@ #!/usr/bin/env bash # Parse "all" IETF yangmodels from https://github.com/YangModels/yang/standard/ieee and experimental/ieee # Notes: -# - Only a simple smoketest (CLI check) is made, A full system may not work +# - Only a simple smoketest (CLI check) is made, essentially YANG parsing. A full system may not work # - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example) # - Some FEATURES are set to make it work -# - Some DIFFs are necessary in yangmodels (see end of script) +# - Some DIFFs are necessary in yangmodels +# - standard/ietf/RFC/ietf-mud@2019-01-28.yang +# - + "/acl:l4/acl:tcp/acl:tcp" { +# + + "/acl:l4/acl:tcp" { +# - standard/ietf/RFC/ietf-acldns@2019-01-28.yang +# augment "/acl:acls/acl:acl/acl:aces/acl:ace/acl:matches" +# - + "/acl:l3/acl:ipv4/acl:ipv4" { +# + + "/acl:l3/acl:ipv4" { +# description +# "Adding domain names to matching."; +# + if-feature acl:match-on-ipv4; +# uses dns-matches; +# } +# augment "/acl:acls/acl:acl/acl:aces/acl:ace/acl:matches" +# - + "/acl:l3/acl:ipv6/acl:ipv6" { +# + + "/acl:l3/acl:ipv6" { +# description +# "Adding domain names to matching."; +# + if-feature acl:match-on-ipv6; + # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -15,7 +34,6 @@ APPNAME=example cfg=$dir/conf_yang.xml fyang=$dir/test.yang -YANGMODELS=/home/olof/tmp/yang if [ ! -d "$YANGMODELS" ]; then # err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?" echo "...skipped: YANGMODELS not set" diff --git a/test/vagrant/vagrant.sh b/test/vagrant/vagrant.sh index 1750620e..c2e609ad 100755 --- a/test/vagrant/vagrant.sh +++ b/test/vagrant/vagrant.sh @@ -98,7 +98,6 @@ system=$($sshcmd uname) # we use the release "hack" instead # Some release have packages, some need to be built from source buildfcgi=false buildevhtp=false -buildcmake=false # Some releases (eg centos/7) has too old cmake to build libevhtp case $release in openbsd) # packages for building @@ -159,7 +158,6 @@ case $release in evhtp) $sshcmd sudo yum install -y libevent openssl buildevhtp=true - buildcmake=true # Actually, only necessary on centos/7 $sshcmd sudo yum install -y libevent-devel openssl-devel ;; esac @@ -259,19 +257,12 @@ case ${with_restconf} in . ./nginx.sh $dir $idfile $port $wwwuser ;; evhtp) - if $buildcmake; then - $sshcmd "test -d cmake || sudo git clone https://gitlab.kitware.com/cmake/cmake.git" - $sshcmd "(cd cmake; sudo ./bootstrap)" - $sshcmd "(cd cmake; sudo make)" - $sshcmd "(cd cmake; sudo make install)" - fi if $buildevhtp; then $sshcmd << 'EOF' - test -d libevhtp || sudo git clone https://github.com/clicon/libevhtp.git - cd libevhtp/build; - CMAKE=$(which cmake) - sudo $CMAKE -DEVHTP_DISABLE_REGEX=ON -DEVHTP_DISABLE_EVTHR=ON -DBUILD_SHARED_LIBS=OFF .. - sudo make + test -d libevhtp || git clone https://github.com/clicon/libevhtp.git + cd libevhtp; + ./configure + make sudo make install EOF fi