Restconf and http/1 modifications for http/1-only

This commit is contained in:
Olof hagsand 2022-02-15 15:48:37 +01:00
parent c006c6189d
commit 61661e6940
10 changed files with 77 additions and 75 deletions

View file

@ -44,7 +44,7 @@ WITH_RESTCONF=@with_restconf@ # native, fcgi or ""
# If set, curl options are set to use --http2 which may not be what you want, ie
# you may want to force it to http/1 for example
# If so, override before test
: ${HAVE_LIBNGHTTP2:=@HAVE_LIBNGHTTP2@}o
: ${HAVE_LIBNGHTTP2:=@HAVE_LIBNGHTTP2@}
HAVE_HTTP1=@HAVE_HTTP1@
# This is for libxml2 XSD regex engine

View file

@ -449,6 +449,7 @@ function wait_restconf(){
err1 "restconf timeout $DEMWAIT seconds"
fi
sleep $DEMSLEEP
# echo "curl $CURLOPTS -X GET $myproto://localhost/restconf"
hdr=$(curl $CURLOPTS -X GET $myproto://localhost/restconf 2> /dev/null)
# echo "hdr:\"$hdr\""
let i++;

View file

@ -2,14 +2,21 @@
# Scaling/ performance tests for non-ssl RESTCONF
# Lists (and leaf-lists)
# Add, get and delete entries
# If both HTTP/1 and /2, force to /1 to test native http/1 implementation
# Override default to use http/1.1, comment to use https/2
HAVE_LIBNGHTTP2=false
RCPROTO=http
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Pin to http/1
if [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = true ]; then
HAVE_LIBNGHTTP2=false
CURLOPTS="${CURLOPTS} --http1.1"
HVER=1.1
fi
# Which format to use as datastore format internally
: ${format:=xml}
@ -79,6 +86,7 @@ cat <<EOF > $cfg
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_LOG_STRING_LIMIT>128</CLICON_LOG_STRING_LIMIT>
<CLICON_RESTCONF_HTTP2_PLAIN>true</CLICON_RESTCONF_HTTP2_PLAIN>
$RESTCONFIG
</clixon-config>
EOF
@ -136,36 +144,11 @@ if [ $r -ne 0 ]; then
err1 "retval 0" $r
fi
# Remove Content-Length line (depends on size)
# Note: do not use sed -i since it is not portable between gnu and bsd
sed '/Content-Length:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/content-length:/d' $foutput > $foutput2 && mv $foutput2 $foutput
# Remove (nginx) web-server specific lines
sed '/Server:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Date:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Transfer-Encoding:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Connection:/d' $foutput > $foutput2 && mv $foutput2 $foutput
# Create a file to compare with
if ${HAVE_LIBNGHTTP2}; then
if [ ${HAVE_HTTP1} -a ${RCPROTO} = http ]; then
# Add 101 switch protocols for http 1->2 upgrade
echo "HTTP/1.1 101 Switching Protocols " > $ftest
echo "Upgrade: h2c " >> $ftest
echo " " >> $ftest
echo "HTTP/$HVER 200 " >> $ftest
else
echo "HTTP/$HVER 200 " > $ftest
fi
else
echo "HTTP/$HVER 200 OK " > $ftest
fi
echo "Content-Type: application/yang-data+xml " >> $ftest
echo "Cache-Control: no-cache " >> $ftest
echo " ">> $ftest
# Only compare relevant data line
echo -n "<data>">> $ftest
cat $fdataxml >> $ftest
echo "</data> " >> $ftest
sed -i '/<data>/!d' $foutput
ret=$(diff -i $ftest $foutput)
if [ $? -ne 0 ]; then

View file

@ -3,10 +3,6 @@
# Lists (and leaf-lists)
# Add, get and delete entries
# Override default to use http/1.1, comment to use https/2
HAVE_LIBNGHTTP2=false
RCPROTO=http
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -106,6 +102,7 @@ cat <<EOF > $cfg
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_LOG_STRING_LIMIT>128</CLICON_LOG_STRING_LIMIT>
<CLICON_RESTCONF_HTTP2_PLAIN>true</CLICON_RESTCONF_HTTP2_PLAIN>
$RESTCONFIG
</clixon-config>
EOF
@ -163,36 +160,11 @@ if [ $r -ne 0 ]; then
err1 "retval 0" $r
fi
# Remove Content-Length line (depends on size)
# Note: do not use sed -i since it is not portable between gnu and bsd
sed '/Content-Length:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/content-length:/d' $foutput > $foutput2 && mv $foutput2 $foutput
# Remove (nginx) web-server specific lines
sed '/Server:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Date:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Transfer-Encoding:/d' $foutput > $foutput2 && mv $foutput2 $foutput
sed '/Connection:/d' $foutput > $foutput2 && mv $foutput2 $foutput
# Create a file to compare with
if ${HAVE_LIBNGHTTP2}; then
if [ ${HAVE_HTTP1} -a ${RCPROTO} = http ]; then
# Add 101 switch protocols for http 1->2 upgrade
echo "HTTP/1.1 101 Switching Protocols " > $ftest
echo "Upgrade: h2c " >> $ftest
echo " " >> $ftest
echo "HTTP/$HVER 200 " >> $ftest
else
echo "HTTP/$HVER 200 " > $ftest
fi
else
echo "HTTP/$HVER 200 OK " > $ftest
fi
echo "Content-Type: application/yang-data+xml " >> $ftest
echo "Cache-Control: no-cache " >> $ftest
echo " ">> $ftest
# Only compare relevant data line
echo -n "<data>">> $ftest
cat $fdataxml >> $ftest
echo "</data> " >> $ftest
sed -i '/<data>/!d' $foutput
ret=$(diff -i $ftest $foutput)
if [ $? -ne 0 ]; then

View file

@ -1,16 +1,25 @@
#!/usr/bin/env bash
# Restconf HTTP/1.1 Expect/Continue functionality
# Trigger Expect by curl -H. Some curls seem to trigger one on large PUTs but not all
# Override default to use http/1.1
# In http/2 there is no explicit continue
HAVE_LIBNGHTTP2=false
# If both HTTP/1 and /2, force to /1 to test native http/1 implementation
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if ! ${HAVE_HTTP1}; then
echo "...skipped: Must run with http/1"
if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi
APPNAME=example
if [ ${HAVE_LIBNGHTTP2} = true ]; then
# Pin to http/1
HAVE_LIBNGHTTP2=false
CURLOPTS="${CURLOPTS} --http1.1"
HVER=1.1
fi
cfg=$dir/conf.xml
fyang=$dir/restconf.yang
fjson=$dir/large.json

View file

@ -21,19 +21,27 @@
# XXX does not test rpc-error from backend in api_return_err?
# Override default to use http/1.1
# Force to HTTP 1.1 no SSL due to netcat
RCPROTO=http
HAVE_LIBNGHTTP2=false
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Does not work with native http/2-only
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
#if ! ${HAVE_HTTP1}; then
echo "...skipped: must run with http/1"
if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi
# Pin to http/1
if [ ${HAVE_LIBNGHTTP2} = true -a ${HAVE_HTTP1} = true ]; then
HAVE_LIBNGHTTP2=false
CURLOPTS="${CURLOPTS} --http1.1"
HVER=1.1
fi
# Force to HTTP 1.1 no SSL due to netcat
RCPROTO=http
APPNAME=example
cfg=$dir/conf.xml

View file

@ -205,6 +205,7 @@ new "restconf DELETE whole datastore"
expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 204"
#--------------- Multiple request in single TCP tests
new "Multiple requests: GET + POST using --next"
expectpart "$(curl $CURLOPTS -H "Accept: application/yang-data+xml" -X GET $RCPROTO://localhost/restconf/data?content=config --next $CURLOPTS -H "Content-Type: application/yang-data+json" -X POST $RCPROTO://localhost/restconf/data -d '{"example:cont1":{"interface":{"name":"local0","type":"regular"}}}')" 0 "HTTP/$HVER 200" '<data/>' "HTTP/$HVER 201"
#--------------- json type tests