netcdf-c/ncdap_test/testurl.sh
Dennis Heimbigner 7223c4a5aa Avoid spurious test failures when servers fail.
re: https://github.com/Unidata/netcdf-c/issues/1451

The situation with the various DAP (and other) remote test
servers is currently in a state of flux.  For example, Unidata
admin is planning to forcibly shift the remote test server to
remotetest.unidata.ucar.edu soon.  In addition, the server
test.opendap.org has shown some recent instability.

The result is that various DAP (and byterange) tests can fail
unexpectedly. This is an irritant to users and reveals nothing
about test sucess or failure.

Solve by modifying tests to report server inaccessibility and
otherwise pretend to succeed.

This puts an onus on Unidata to detect such server failures, but
will not cause users to see spurious failures. [Note. Do similar
fix for netcdf-java]. The check is:
1. export SETX=1 to cause all the shell scripts to trace
2. search the log files for the phrase "WARNING" (in upper case)
and see if it is complaining about not finding a server.

Misc. Changes
-------------
1. Added a pingurl program to see if a server was up.
2. modified some test case url targets
2019-12-31 15:42:58 -07:00

116 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
#NOP=1
#NOS=1
#NOB=1
#SHOW=1
#DBG=1
#GDB=1
# if this is part of a distcheck action, then this script
# will be executed in a different directory
# than the one containing it; so capture the path to this script
# as the location of the source directory.
# capture the build directory
# Do a hack to remove e.g. c: for CYGWIN
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Figure our dst server; if none, then just stop
DTS=`${execdir}/findtestserver dap2 dts`
if test "x$DTS" = "x" ; then
echo "WARNING: Cannot locate test server for dts"
exit 0
fi
OCLOGFILE=stderr
if test "x$DBG" = x1 ; then
SHOW=1
fi
URL="$DTS/test.03"
PREFIX="[log][show=fetch]"
SUFFIX="log&show=fetch"
BOTHP="[log][show=fetch]"
BOTHS="noprefetch&fetch=disk"
STRLEN="[maxstrlen=16]"
locreset () {
rm -f ./tmp_testurl ./errtmp_testurl
}
buildurl () {
front="$1"
back="$2"
url="${front}${URL}"
if test "x$back" != x ; then
url="${url}#${back}"
fi
}
pass=1
if test "x$GDB" = x1 ; then
NCDUMP="gdb --args $NCDUMP"
fi
# Initialize
locreset
if test "x$NOP" != x1 ; then
echo "***Testing url prefix parameters"
buildurl "$PREFIX" ""
# Invoke ncdump to extract the URL
echo "command: ${NCDUMP} -h $url"
${NCDUMP} -h "$url" >./tmp_testurl 2> ./errtmp_testurl
if test "x${SHOW}" = x1 ; then cat ./tmp ; fi
# Test that maxstrlen works as alias for stringlength
echo "***Testing maxstrlen=stringlength alias"
buildurl "$STRLEN" ""
# Invoke ncdump to extract the URL
echo "command: ${NCDUMP} -h $url"
${NCDUMP} "$url" >./tmp_testurl 2> ./errtmp_testurl
if test "x${SHOW}" = x1 ; then cat ./tmp_testurl ; fi
# Look for the value of maxStrlen in output cdl
if ! fgrep -i "maxstrlen = 16" ./tmp_testurl ; then
echo "***Fail: maxStrlen not recognized"
fgrep -i "maxstrlen16 = 16" ./tmp_testurl > ./errtmp_testurl
fi
fi
locreset
if test "x$NOS" != x1 ; then
echo "***Testing url suffix parameters"
buildurl "" "$SUFFIX"
# Invoke ncdump to extract the URL
${NCDUMP} -h "$url" >./tmp_testurl 2> ./errtmp_testurl
if test "x${SHOW}" = x1 ; then cat ./tmp_testurl ; fi
fi
locreset
if test "x$NOB" != x1 ; then
echo "***Testing url prefix+suffix parameters"
buildurl "$BOTHP" "$BOTHS"
# Invoke ncdump to extract the URL
${NCDUMP} -h "$url" >./tmp_testurl 2> ./errtmp_testurl
if test "x${SHOW}" = x1 ; then cat ./tmp_testurl ; fi
fi
locreset
if test "x$pass" = x0 ; then
echo "***FAIL"
exit 1
fi
echo "***PASS"
exit 0