Changed libevhtp tests to compile from clicon instead of criticalstack

This commit is contained in:
Olof hagsand 2021-03-03 16:01:29 +01:00
parent b2f9c59a34
commit e8cd587ded
9 changed files with 117 additions and 32 deletions

View file

@ -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 <<EOF > /tmp/my.yang

View file

@ -94,7 +94,7 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
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

View file

@ -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/<sys\/queue.h>/<evhtp\/sys\/queue.h>/' 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

View file

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

View file

@ -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 <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<!--CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR-->
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR/acl</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR/aft</CLICON_YANG_DIR>
@ -60,14 +69,13 @@ cat <<EOF > $cfg
<CLICON_YANG_DIR>$OCDIR/wifi/mac</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR/wifi/phy</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$OCDIR/wifi/types</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>
EOF
@ -104,5 +112,52 @@ for f in $files; do
fi
done
if false; then # NYI
# Example system
cat <<EOF > $dir/startup_db
<config>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>eth0</name>
<config2>
<type>ianaift:usb</type>
</config2>
</interface>
</interfaces>
</config>
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

View file

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

View file

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

View file

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

View file

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