Test: vagrant update

This commit is contained in:
Olof hagsand 2024-06-22 16:30:27 +02:00
parent a80c9b0f8e
commit 5351ac0ffc
5 changed files with 33 additions and 14 deletions

View file

@ -309,7 +309,9 @@ myerror(clixon_handle h,
goto done; goto done;
#endif #endif
retval = 0; retval = 0;
#ifdef DYNAMICLINKAGE
done: done:
#endif
_errmsg_callback_fn = oldfn; _errmsg_callback_fn = oldfn;
if (xret) if (xret)
xml_free(xret); xml_free(xret);

View file

@ -58,7 +58,6 @@ function memonce(){
;; ;;
esac esac
memerr=0 memerr=0
for test in $pattern; do for test in $pattern; do
# Can happen if no pattern, eg pattern=foo but "foo" does not exist # Can happen if no pattern, eg pattern=foo but "foo" does not exist

View file

@ -9,6 +9,13 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example APPNAME=example
# linux stat <- freebsd gnustat in coreutils
if [ -n "$(type gnustat 2> /dev/null)" ]; then
stat=gnustat
else
stat=stat
fi
# include err() and new() functions and creates $dir # include err() and new() functions and creates $dir
cfg=$dir/conf_yang.xml cfg=$dir/conf_yang.xml
@ -153,8 +160,8 @@ function check_db()
dbname=$1 dbname=$1
subfile=$2 subfile=$2
sudo chmod o+r $dir/${dbname}.d/0.xml sudo chmod 755 $dir/${dbname}.d/
sudo chmod o+r $dir/${dbname}.d/$subfile sudo chmod 755 $dir/${dbname}.d/*.xml
sudo rm -f $dir/x_db sudo rm -f $dir/x_db
cat <<EOF > $dir/x_db cat <<EOF > $dir/x_db
@ -218,14 +225,14 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
new "Check candidate after edit" new "Check candidate after edit"
check_db candidate ${subfilename} check_db candidate ${subfilename}
s0=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s0=$($stat -c "%Y" $dir/candidate.d/${subfilename})
sleep 1 sleep 1
new "Add 2nd data to mount x" new "Add 2nd data to mount x"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x2</name1><value1>x2value</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x2</name1><value1>x2value</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check candidate subfile changed" new "Check candidate subfile changed"
s1=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s1=$($stat -c "%Y" $dir/candidate.d/${subfilename})
if [ $s0 -eq $s1 ]; then if [ $s0 -eq $s1 ]; then
err "Timestamp changed" "$s0 = $s1" err "Timestamp changed" "$s0 = $s1"
fi fi
@ -236,7 +243,7 @@ new "Change existing value in mount x"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x2</name1><value1>x2new</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x2</name1><value1>x2new</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check candidate subfile changed" new "Check candidate subfile changed"
s2=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s2=$($stat -c "%Y" $dir/candidate.d/${subfilename})
if [ $s1 -eq $s2 ]; then if [ $s1 -eq $s2 ]; then
err "Timestamp changed" "$s1 = $s2" err "Timestamp changed" "$s1 = $s2"
fi fi
@ -247,7 +254,7 @@ new "Add data to top-level (not mount)"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>y</name></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>y</name></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check candidate subfile not changed" new "Check candidate subfile not changed"
s3=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s3=$($stat -c "%Y" $dir/candidate.d/${subfilename})
if [ $s2 -ne $s3 ]; then if [ $s2 -ne $s3 ]; then
err "Timestamp not changed" "$s2 != $s3" err "Timestamp not changed" "$s2 != $s3"
fi fi
@ -258,7 +265,7 @@ new "Delete leaf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\" xmlns:nc=\"${BASENS}\"><mylist1><name1>x2</name1><value1 nc:operation=\"delete\">x2new</value1></mylist1></mount1></root></mylist></top></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\" xmlns:nc=\"${BASENS}\"><mylist1><name1>x2</name1><value1 nc:operation=\"delete\">x2new</value1></mylist1></mount1></root></mylist></top></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check candidate subfile changed" new "Check candidate subfile changed"
s4=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s4=$($stat -c "%Y" $dir/candidate.d/${subfilename})
if [ $s4 -eq $s3 ]; then if [ $s4 -eq $s3 ]; then
err "Timestamp changed" "$s4 = $s3" err "Timestamp changed" "$s4 = $s3"
fi fi
@ -269,7 +276,7 @@ new "Delete node"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\" xmlns:nc=\"${BASENS}\"><mylist1 nc:operation=\"delete\"><name1>x2</name1></mylist1></mount1></root></mylist></top></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\" xmlns:nc=\"${BASENS}\"><mylist1 nc:operation=\"delete\"><name1>x2</name1></mylist1></mount1></root></mylist></top></config><default-operation>none</default-operation></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check candidate subfile changed" new "Check candidate subfile changed"
s4=$(stat -c "%Y" $dir/candidate.d/${subfilename}) s4=$($stat -c "%Y" $dir/candidate.d/${subfilename})
if [ $s4 -eq $s3 ]; then if [ $s4 -eq $s3 ]; then
err "Timestamp changed" "$s4 = $s3" err "Timestamp changed" "$s4 = $s3"
fi fi
@ -289,7 +296,7 @@ check_db running ${subfilename}
new "cli show config" new "cli show config"
expectpart "$($clixon_cli -1 -f $cfg show config xml -- -m clixon-mount1 -M urn:example:mount1)" 0 "<top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1></mylist1></mount1><extra xmlns=\"urn:example:mount1\"><extraval>foo</extraval></extra></root></mylist></top>" expectpart "$($clixon_cli -1 -f $cfg show config xml -- -m clixon-mount1 -M urn:example:mount1)" 0 "<top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1></mylist1></mount1><extra xmlns=\"urn:example:mount1\"><extraval>foo</extraval></extra></root></mylist></top>"
s0=$(stat -c "%Y" $dir/running.d/${subfilename}) s0=$($stat -c "%Y" $dir/running.d/${subfilename})
new "Change mount data" new "Change mount data"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1><value1>foo</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><top xmlns=\"urn:example:clixon\"><mylist><name>x</name><root><mount1 xmlns=\"urn:example:mount1\"><mylist1><name1>x1</name1><value1>foo</value1></mylist1></mount1></root></mylist></top></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
@ -299,7 +306,7 @@ new "netconf commit 3"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Check running subfile changed" new "Check running subfile changed"
s1=$(stat -c "%Y" $dir/running.d/${subfilename}) s1=$($stat -c "%Y" $dir/running.d/${subfilename})
if [ $s0 -eq $s1 ]; then if [ $s0 -eq $s1 ]; then
err "Timestamp changed" "$s0 = $s1" err "Timestamp changed" "$s0 = $s1"
fi fi
@ -313,7 +320,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
sleep 1 sleep 1
new "Check running subfile not changed" new "Check running subfile not changed"
s2=$(stat -c "%Y" $dir/running.d/${subfilename}) s2=$($stat -c "%Y" $dir/running.d/${subfilename})
if [ $s1 -ne $s2 ]; then # XXX Sometimes fails if [ $s1 -ne $s2 ]; then # XXX Sometimes fails
err "Timestamp not changed" "$s1 != $s2" err "Timestamp not changed" "$s1 != $s2"
fi fi

View file

@ -146,7 +146,13 @@ function runtest()
LB=$((5/${PERIOD} - 1)) LB=$((5/${PERIOD} - 1))
UB=$((5/${PERIOD} + 1)) UB=$((5/${PERIOD} + 1))
# date differs between -d and -v for declaring a later date
if [ $(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ' 2> /dev/null) ]; then
time1=$(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ')
else
time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ') time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ')
fi
new "2b) start $extra timeout:${TIMEOUT} stop after 5s - expect ${LB}-${UB} notifications" new "2b) start $extra timeout:${TIMEOUT} stop after 5s - expect ${LB}-${UB} notifications"
ret=$(curl $CURLOPTS $extra -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" $RCPROTO://localhost/streams/EXAMPLE?stop-time=${time1}) ret=$(curl $CURLOPTS $extra -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" $RCPROTO://localhost/streams/EXAMPLE?stop-time=${time1})
@ -160,7 +166,11 @@ function runtest()
fi fi
if false; then # Does not work yet if false; then # Does not work yet
time1=$(date -u -d"-5 second now" +'%Y-%m-%dT%H:%M:%SZ') if [ $(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ' 2> /dev/null) ]; then
time1=$(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ')
else
time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ')
fi
LB=$(((5+${TIMEOUT})/${PERIOD} - 1)) LB=$(((5+${TIMEOUT})/${PERIOD} - 1))
UB=$(((5+${TIMEOUT})/${PERIOD} + 1)) UB=$(((5+${TIMEOUT})/${PERIOD} + 1))
new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications" new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications"

View file

@ -145,6 +145,7 @@ case $release in
native) native)
;; ;;
esac esac
$sshcmd sudo pkg install -y coreutils # gnustat
;; ;;
centos) centos)
# enable ipv6 # enable ipv6