netcdf-c/ncdump/test_rcmerge.sh
Dennis Heimbigner 74b40fd788 Upgrade the nczarr code to match Zarr V2
Re: https://github.com/zarr-developers/zarr-python/pull/716

The Zarr version 2 spec has been extended to include the ability
to choose the dimension separator in chunk name keys. The legal
separators has been extended from {'.'} to {'.' '/'}.  So now it
is possible to use a key like "0/1/2/0" for chunk names.

This PR implements this for NCZarr. The V2 spec now says that
this separator can be set on a per-variable basis. For now, I
have chosen to allow this be set only globally by adding a key
named "ZARR.DIMENSION_SEPARATOR=<char>" in the
.daprc/.dodsrc/ncrc file. Currently, the only legal separator
characters are '.' (the default) and '/'. On writing, this key
will only be written if its value is different than the default.
This change caused problems because supporting a separator of '/'
is difficult to parse when keys/paths use '/' as the path separator.
A test case was added for this.

Additionally, make nczarr be enabled default by default. This required
some additional changes so that if zip and/or AWS S3 sdk are unavailable,
then they are disabled for NCZarr.

In addition the following unrelated changes were made.

1. Tested that pure-zarr mode could read an nczarr formatted store.
1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added.
1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl
   is not found then the other options that depend upon it properly
   are disabled.
1. I decided that xarray support should be enabled by default for pure
   zarr. In order to allow disabling, I added a new mode flag "noxarray".
1. Certain test in nczarr_test depend on use of .dodsrc. In order for these
   to work when testing in parallel, some inter-test dependencies needed to
   be added.
1. Improved authorization testing to use changes in thredds.ucar.edu
2021-04-24 19:48:15 -06:00

94 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Test that all available .rc files are merged and overrides are handled.
# The internal .rc is constructed as follows:
#
# 1. Use NCRCENV_RC environment variable exclusively if defined
# 2. If NCRCENV_RC is not defined then merge the set of rc files in this order:
# 1. $HOME/.ncrc
# 2. $HOME/.daprc
# 3. $HOME/.docsrc
# 4. $CWD/.ncrc
# 5. $CWD/.daprc
# 6. $CWD/.docsrc
# Entries in later files override any of the >earlier >files
if test "x$NCAUTH_HOMETEST" != x ; then
RCHOME=1
fi
WD=`pwd`
HOMERCFILES="$HOME/.ncrc $HOME/.daprc $HOME/.dodsrc"
LOCALRCFILES="$WD/.ncrc $WD/.daprc $WD/.dodsrc"
resetrc() {
if test "x$RCHOME" = x1 ; then
rm -f $HOMERCFILES
fi
rm -f $LOCALRCFILES
unset NCRCENV_RC
}
mergecase1() {
# create everything with different keys to test merge
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
for r in "ncrc" "daprc" "dodsrc" ; do
if test "x$RCHOME" = x1 ; then echo "${r}_home=${r}" >> $HOME/".${r}"; fi
echo "${r}_local=${r}" >> $WD/".${r}"
done;
${execdir}/tst_rcmerge > tmpoutput.txt
if test "x$RCHOME" = x1 ; then
cp ${srcdir}/ref_rcmerge1.txt tmp_rcmerge1.txt
else
sed -e '/_local/p' -e d <${srcdir}/ref_rcmerge1.txt > tmp_rcmerge1.txt
fi
diff -b tmp_rcmerge1.txt tmpoutput.txt
}
mergecase2() {
# create with some same keys to test override
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
for r in "ncrc" "daprc" "dodsrc" ; do
if test "x$RCHOME" = x1 ; then echo "${r}=${r}" >> $HOME/".${r}"; fi
echo "${r}=${r}" >> $WD/".${r}"
done;
${execdir}/tst_rcmerge > tmpoutput.txt
diff -b ${srcdir}/ref_rcmerge2.txt tmpoutput.txt
}
mergecase3() {
# Test cross file overrides
resetrc
rm -f tmp_rcmerge.txt tmpoutput.txt
if test "x$RCHOME" = x1 ; then
echo "ncrc=ncrc1" >> $HOME/.ncrc
echo "ncrcx=ncrcx" >> $HOME/.ncrc
echo "ncrc=ncrc2" >> $HOME/.dodsrc
echo "daprc=daprc" >> $HOME/.daprc
else
echo "ncrc=ncrc1" >> $WD/.ncrc
echo "ncrcx=ncrcx" >> $WD/.ncrc
echo "ncrc=ncrc2" >> $WD/.dodsrc
echo "daprc=daprc" >> $WD/.daprc
fi
echo "daprc=daprc" >> $WD/.dodsrc
echo "ncrcx=ncrcy" >> $WD/.dodsrc
${execdir}/tst_rcmerge > tmpoutput.txt
diff -b ${srcdir}/ref_rcmerge3.txt tmpoutput.txt
}
resetrc
mergecase1
mergecase2
mergecase3
resetrc