- Restconf native: Fixed ssl/non-ssl read/write behaviour for data that is different in freebsd than in linux

- test: removed sed -i in tests since it is not portable between linux and bsd
This commit is contained in:
Olof Hagsand 2021-06-25 10:46:53 +00:00
parent 940f4d4fb9
commit b31107f646
4 changed files with 64 additions and 15 deletions

View file

@ -105,6 +105,9 @@ expectpart "$($clixon_cli -1 -f $cfg -l o debug restconf 1)" 0 "^$"
new "get and put config using restconf"
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:table":{"parameter":{"name":"local0","value":"foo"}}}')" 0 "HTTP/$HVER 200" '<data>' "HTTP/$HVER 201"
# In freebsd, backend dies in stop_restconf below unless sleep
sleep $DEMSLEEP
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
@ -115,7 +118,7 @@ if [ $BE -ne 0 ]; then
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
err1 "backend pid !=0" 0
fi
# kill backend
stop_backend -f $cfg

View file

@ -32,6 +32,7 @@ ftest=$dir/test.xml
fconfig=$dir/large.xml
fconfig2=$dir/large2.xml # leaf-list
foutput=$dir/output.xml
foutput2=$dir/output2.xml
cat <<EOF > $fyang
module scaling{
@ -132,15 +133,20 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><co
new "Check running-db contents"
curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=config > $foutput
r=$?
if [ $r -ne 0 ]; then
err1 "retval 0" $r
fi
# Remove Content-Length line (depends on size)
sed -i '/Content-Length:/d' $foutput
sed -i '/content-length:/d' $foutput
# 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 -i '/Server:/d' $foutput
sed -i '/Date:/d' $foutput
sed -i '/Transfer-Encoding:/d' $foutput
sed -i '/Connection:/d' $foutput
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
@ -165,7 +171,7 @@ echo "</data> " >> $ftest
ret=$(diff -i $ftest $foutput)
if [ $? -ne 0 ]; then
echo "$ret"
echo "diff -i $ftest $foutput"
err1 "Matching running-db with $fconfigonly"
fi