From 9341904b0b0d656f25665365732d173decf964ed Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Sat, 10 Jun 2023 20:11:26 -0600 Subject: [PATCH] Add earthdata test case --- configure.ac | 2 ++ dap4_test/CMakeLists.txt | 13 ++++++++++++- dap4_test/Makefile.am | 20 ++++++++++++++++---- dap4_test/test_earthdata.sh | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 dap4_test/test_earthdata.sh diff --git a/configure.ac b/configure.ac index 1c49a0cb2..d45a5d224 100644 --- a/configure.ac +++ b/configure.ac @@ -2140,6 +2140,8 @@ AC_SUBST([ISCMAKE], []) # Provide conditional to temporarily suppress tests and such AM_CONDITIONAL([AX_IGNORE], [test xno = xyes]) +# Provide conditional to identify tests that must be run manually +AM_CONDITIONAL([AX_MANUAL], [test xno = xyes]) AC_MSG_NOTICE([generating header files and makefiles]) AC_CONFIG_FILES(test_common.sh:test_common.in) diff --git a/dap4_test/CMakeLists.txt b/dap4_test/CMakeLists.txt index 6837176f3..12248914c 100644 --- a/dap4_test/CMakeLists.txt +++ b/dap4_test/CMakeLists.txt @@ -53,8 +53,19 @@ ENDIF() IF(ENABLE_DAP_REMOTE_TESTS) add_sh_test(dap4_test test_remote) add_sh_test(dap4_test test_hyrax) -# add_sh_test(dap4_test test_thredds) add_sh_test(dap4_test test_dap4url) + IF(RUN_MANUAL_TESTS) + # The following test can only be run by hand. + # It tests earthdata authorization. + # Before running it, one needs to do the following: + # export USERPWD=":" + # where the username and password are registered + # with urs.earthdata.nasa.gov. + add_sh_test(dap4_test test_earthdata) + ENDIF() + IF(RUN_IGNORED_TESTS) + add_sh_test(dap4_test test_thredds) + ENDIF ENDIF(ENABLE_DAP_REMOTE_TESTS) ENDIF(ENABLE_TESTS) diff --git a/dap4_test/Makefile.am b/dap4_test/Makefile.am index 434e0530a..e12845675 100644 --- a/dap4_test/Makefile.am +++ b/dap4_test/Makefile.am @@ -48,9 +48,21 @@ if ENABLE_DAP_REMOTE_TESTS TESTS += test_remote.sh TESTS += test_constraints.sh TESTS += test_hyrax.sh -#TESTS += test_thredds.sh TESTS += test_dap4url.sh +# The following test can only be run by hand. +# It tests earthdata authorization. +# Before running it, one needs to do the following: +# export USERPWD=":" +# where the username and password are registered with urs.earthdata.nasa.gov. +if AX_MANUAL +TESTS += test_earthdata.sh +endif + +if AX_MANUAL +TESTS += test_thredds.sh +endif + endif endif @@ -59,7 +71,7 @@ EXTRA_DIST = CMakeLists.txt test_common.h build.sh \ test_curlopt.sh test_data.sh test_hyrax.sh test_meta.sh \ test_parse.sh test_raw.sh \ test_remote.sh test_constraints.sh test_thredds.sh \ - test_dap4url.sh \ + test_dap4url.sh run test_earthdata.sh \ cdltestfiles rawtestfiles \ baseline baselineraw baselineremote baselinehyrax baselinethredds @@ -81,8 +93,8 @@ clean-local: clean-local-check .PHONY: clean-local-check clean-local-check: - -rm -rf results results_test_* - -rm -f .dodsrc .daprc + -rm -rf results results_* + -rm -f .dodsrc .daprc .ncrc .netrc # The shell file maketests.sh is used to build the testdata # for dap4 testing. It creates and fills the directories diff --git a/dap4_test/test_earthdata.sh b/dap4_test/test_earthdata.sh new file mode 100644 index 000000000..fd138df14 --- /dev/null +++ b/dap4_test/test_earthdata.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +if test "x$srcdir" = x ; then srcdir=`pwd`; fi +. ../test_common.sh + +set -e + +isolate "results_earthdata_dap4" +THISDIR=`pwd` +cd $ISOPATH + +# This shell script tests reading of +# publically accessible DAP4 datasets on earthdata + +# Setup +# Assume environment variable USERPWD="username:password" +USR=`echo "$USERPWD" | cut -d':' -f1 | tr -d '\n\r'` +PWD=`echo "$USERPWD" | cut -d':' -f2 | tr -d '\n\r'` +rm -fr ./.netrc ./.ncrc ./urscookies +echo "machine urs.earthdata.nasa.gov login $USR password $PWD" > ./.netrc +echo "HTTP.COOKIEJAR=${ISOPATH}/urscookies" > ./.ncrc +echo "HTTP.NETRC=${ISOPATH}/.netrc" >> ./.ncrc + +TESTCASES="opendap1;dap4://opendap.earthdata.nasa.gov/collections/C2532426483-ORNL_CLOUD/granules/Daymet_Daily_V4R1.daymet_v4_daily_hi_tmax_2010.nc" + +testcase() { +NM=`echo "$1" | cut -d';' -f1` +URL=`echo "$1" | cut -d';' -f2` +echo "*** Test: $NM = $URL" +rm -f "tmp_$NM.cdl" +${NCDUMP} -h -n $NM $URL > "tmp_${NM}.cdl" +} + +for t in $TESTCASES ; do +testcase "$t" +done