diff --git a/test/test_restconf_internal.sh b/test/test_restconf_internal.sh index 9eb4538da..6f760b296 100755 --- a/test/test_restconf_internal.sh +++ b/test/test_restconf_internal.sh @@ -96,33 +96,41 @@ function rpcstatus() active=$1 status=$2 - sleep $DEMSLEEP - new "send rpc status" - rpc=$(chunked_framing "restconfstatus") - retx=$($clixon_netconf -qef $cfg<restconfstatus") + retx=$($clixon_netconf -qef $cfg<]' '{print $3}') - fi - if [ -z "$pid" ]; then - err "No pid return value" "$retx" - fi - if $active; then - expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]*Z$pid$" - else - # inactive, no startime or pid - expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status$" - fi - - match=$(echo "$retx" | grep --null -Go "$expect") - if [ -z "$match" ]; then + # Check pid + expect="[0-9]*" + match=$(echo "$retx" | grep --null -Go "$expect") + if [ -z "$match" ]; then + pid=0 + else + pid=$(echo "$match" | awk -F'[<>]' '{print $3}') + fi + if [ -z "$pid" ]; then + err "No pid return value" "$retx" + fi + if $active; then + expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]*Z$pid$" + else + # inactive, no startime or pid + expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status$" + fi + + match=$(echo "$retx" | grep --null -Go "$expect") + if [ -z "$match" ]; then + echo "retry after sleep" + sleep $DEMSLEEP + continue + fi + break + done + if [ $j -eq $jmax ]; then err "$expect" "$retx" fi } diff --git a/test/test_restconf_internal_usecases.sh b/test/test_restconf_internal_usecases.sh index b857e57d5..d506c7812 100755 --- a/test/test_restconf_internal_usecases.sh +++ b/test/test_restconf_internal_usecases.sh @@ -111,34 +111,42 @@ function rpcstatus() active=$1 status=$2 - sleep $DEMSLEEP - new "send rpc status" - rpc=$(chunked_framing "restconfstatus") - retx=$($clixon_netconf -qef $cfg<restconfstatus") + retx=$($clixon_netconf -qef $cfg<]' '{print $3}') - fi - if [ -z "$pid" ]; then - err "No pid return value" "$retx" - fi - - if $active; then - # \- causes problems on some(alpine) - expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status20[0-9][0-9].[0-9][0-9].[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]*Z$pid$" - else - # inactive, no startime or pid - expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status$" - fi - match=$(echo "$retx" | grep --null -Go "$expect") - if [ -z "$match" ]; then + ) + # Check pid + expect="[0-9]*" + match=$(echo "$retx" | grep --null -Go "$expect") + if [ -z "$match" ]; then + pid=0 + else + pid=$(echo "$match" | awk -F'[<>]' '{print $3}') + fi + if [ -z "$pid" ]; then + err "No pid return value" "$retx" + fi + + if $active; then + # \- causes problems on some(alpine) + expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status20[0-9][0-9].[0-9][0-9].[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]*Z$pid$" + else + # inactive, no startime or pid + expect="^$activeClixon RESTCONF process/.*/clixon_restconf -f $cfg -D [0-9] .*$status$" + fi + match=$(echo "$retx" | grep --null -Go "$expect") + if [ -z "$match" ]; then + echo "retry after sleep" + sleep $DEMSLEEP + continue + fi + break + done + if [ $j -eq $jmax ]; then err "$expect" "$retx" fi }