-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25e03d1
commit d82131f
Showing
9 changed files
with
752 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
set(test_name fdb_list) | ||
# get test data for the list tests | ||
ecbuild_get_test_multidata( TARGET get_fdb_test_data_list LABELS list NAMES "od.oper.grib" ) | ||
|
||
configure_file( ${test_name}.sh.in ${test_name}.sh @ONLY ) | ||
# list of tests | ||
list( APPEND fdb_tools_list_tests | ||
all | ||
all_full | ||
location | ||
masking | ||
minimum_keys | ||
porcelain | ||
ranges | ||
depth | ||
) | ||
|
||
ecbuild_add_test( | ||
TYPE SCRIPT | ||
CONDITION HAVE_FDB_BUILD_TOOLS | ||
COMMAND ${test_name}.sh) | ||
# add the tests | ||
foreach( _test ${fdb_tools_list_tests} ) | ||
|
||
configure_file( list_${_test}.sh.in list_${_test}.sh @ONLY ) | ||
|
||
ecbuild_add_test( | ||
TARGET test_fdb_tools_list_${_test} | ||
TYPE SCRIPT | ||
LABELS list | ||
CONDITION HAVE_FDB_BUILD_TOOLS | ||
TEST_DEPENDS get_fdb_test_data_list | ||
COMMAND list_${_test}.sh ) | ||
|
||
endforeach( ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ux | ||
|
||
yell() { printf "$(basename "$0"): \033[0;31m%s\033[0m\\n" "$*" >&2; } | ||
die() { yell "$*"; exit 1; } | ||
try() { "$@" || die "Errored HERE => '$*'"; } | ||
|
||
export PATH=@CMAKE_BINARY_DIR@/bin:$PATH | ||
export FDB5_CONFIG_FILE="local.yaml" | ||
export FDB_HOME=@PROJECT_BINARY_DIR@ | ||
|
||
test_name=all | ||
src_data="od.oper.grib" | ||
src_dir=@CMAKE_CURRENT_SOURCE_DIR@ | ||
bin_dir=@CMAKE_CURRENT_BINARY_DIR@ | ||
|
||
######################################################################################################################## | ||
|
||
echo "running test '$test_name' on $(hostname)" | ||
|
||
try cd $bin_dir | ||
|
||
rm -rf $test_name || true | ||
mkdir -p $test_name/localroot | ||
|
||
try cd $test_name | ||
|
||
try cp "$src_dir/local.yaml" ./ | ||
try cp "$bin_dir/$src_data" ./ | ||
|
||
######################################################################################################################## | ||
|
||
count() { | ||
[[ $# -eq 1 ]] || die "count requires 1 argument; expected count" | ||
val=$(wc -l < out) && val=$((val + 0)) | ||
[[ $val -eq $1 ]] || die "Incorrect count => [$val != $1]" | ||
} | ||
|
||
grep_count() { | ||
[[ $# -eq 2 ]] || die "grep_count requires 2; regex and expected count" | ||
val=$(grep -E "$1" out | wc -l) && val=$((val + 0)) | ||
[[ $val -eq $2 ]] || die "Incorrect count [$val != $2] for regex [$1]" | ||
} | ||
|
||
######################################################################################################################## | ||
|
||
# Ensure that listing finds the correct data, but excludes duplicates. | ||
|
||
# Set up the data for the test | ||
|
||
try grib_set -s class=rd,expver=xxxx,type=fc,step=0 "$src_data" data.xxxx.0.grib | ||
try grib_set -s class=rd,expver=xxxx,type=fc,step=1 "$src_data" data.xxxx.1.grib | ||
try grib_set -s class=rd,expver=xxxx,type=fc,step=2 "$src_data" data.xxxx.2.grib | ||
try grib_set -s class=rd,expver=xxxy,type=fc,step=0 "$src_data" data.xxxy.0.grib | ||
try grib_set -s class=rd,expver=xxxy,type=fc,step=1 "$src_data" data.xxxy.1.grib | ||
try grib_set -s class=rd,expver=xxxy,type=fc,step=2 "$src_data" data.xxxy.2.grib | ||
|
||
# Set up some regexes for later testing | ||
|
||
regex_x0="{class=rd,expver=xxxx,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=0,levelist=[0-9]+,param=[0-9]+}" | ||
regex_x1="{class=rd,expver=xxxx,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=1,levelist=[0-9]+,param=[0-9]+}" | ||
regex_x2="{class=rd,expver=xxxx,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=2,levelist=[0-9]+,param=[0-9]+}" | ||
regex_y0="{class=rd,expver=xxxy,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=0,levelist=[0-9]+,param=[0-9]+}" | ||
regex_y1="{class=rd,expver=xxxy,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=1,levelist=[0-9]+,param=[0-9]+}" | ||
regex_y2="{class=rd,expver=xxxy,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=2,levelist=[0-9]+,param=[0-9]+}" | ||
|
||
# We loop over all these tests twice. We should get the same listing results both times | ||
# as the default behaviour is to only show the data that would be retrieved (i.e. that matches a MARS request.) | ||
|
||
sum=0 | ||
for i in 1 2; do | ||
|
||
echo "============ Loop $i ============" | ||
|
||
try fdb-write data.xxxx.0.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
if [[ $i = 1 ]]; then | ||
sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_x1" 0 | ||
grep_count "$regex_x2" 0 | ||
grep_count "$regex_y0" 0 | ||
grep_count "$regex_y1" 0 | ||
grep_count "$regex_y2" 0 | ||
fi | ||
grep_count "$regex_x0" 24 | ||
|
||
try fdb-write data.xxxy.0.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
if [[ $i = 1 ]]; then | ||
sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_x1" 0 | ||
grep_count "$regex_x2" 0 | ||
grep_count "$regex_y1" 0 | ||
grep_count "$regex_y2" 0 | ||
fi | ||
grep_count "$regex_x0" 24 | ||
grep_count "$regex_y0" 24 | ||
|
||
|
||
try fdb-write data.xxxx.1.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
if [[ $i = 1 ]]; then | ||
sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_x2" 0 | ||
grep_count "$regex_y1" 0 | ||
grep_count "$regex_y2" 0 | ||
fi | ||
grep_count "$regex_x0" 24 | ||
grep_count "$regex_y0" 24 | ||
grep_count "$regex_x1" 24 | ||
|
||
try fdb-write data.xxxy.1.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
if [[ $i = 1 ]]; then | ||
sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_x2" 0 | ||
grep_count "$regex_y2" 0 | ||
fi | ||
grep_count "$regex_x0" 24 | ||
grep_count "$regex_y0" 24 | ||
grep_count "$regex_x1" 24 | ||
grep_count "$regex_y1" 24 | ||
|
||
|
||
try fdb-write data.xxxx.2.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
if [[ $i = 1 ]]; then | ||
sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_y2" 0 | ||
fi | ||
grep_count "$regex_x0" 24 | ||
grep_count "$regex_y0" 24 | ||
grep_count "$regex_x1" 24 | ||
grep_count "$regex_y1" 24 | ||
grep_count "$regex_x2" 24 | ||
|
||
try fdb-write data.xxxy.2.grib | ||
try fdb-list --all --minimum-keys="" --porcelain > out | ||
[[ $i = 1 ]] && sum=$((sum + 24)) | ||
count $sum | ||
grep_count "$regex_x0" 24 | ||
grep_count "$regex_y0" 24 | ||
grep_count "$regex_x1" 24 | ||
grep_count "$regex_y1" 24 | ||
grep_count "$regex_x2" 24 | ||
grep_count "$regex_y2" 24 | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ux | ||
|
||
yell() { printf "$(basename "$0"): \033[0;31m%s\033[0m\\n" "$*" >&2; } | ||
die() { yell "$*"; exit 1; } | ||
try() { "$@" || die "Errored HERE => '$*'"; } | ||
|
||
export PATH=@CMAKE_BINARY_DIR@/bin:$PATH | ||
export FDB5_CONFIG_FILE="local.yaml" | ||
export FDB_HOME=@PROJECT_BINARY_DIR@ | ||
|
||
test_name=all_full | ||
src_data="od.oper.grib" | ||
src_dir=@CMAKE_CURRENT_SOURCE_DIR@ | ||
bin_dir=@CMAKE_CURRENT_BINARY_DIR@ | ||
|
||
######################################################################################################################## | ||
|
||
echo "running test '$test_name' on $(hostname)" | ||
|
||
try cd $bin_dir | ||
|
||
rm -rf $test_name || true | ||
mkdir -p $test_name/localroot | ||
|
||
try cd $test_name | ||
|
||
try cp "$src_dir/local.yaml" ./ | ||
try cp "$bin_dir/$src_data" ./ | ||
|
||
######################################################################################################################## | ||
|
||
count() { | ||
[[ $# -eq 1 ]] || die "count requires 1 argument; expected count" | ||
val=$(wc -l < out) && val=$((val + 0)) | ||
[[ $val -eq $1 ]] || die "Incorrect count => [$val != $1]" | ||
} | ||
|
||
grep_count() { | ||
[[ $# -eq 2 ]] || die "grep_count requires 2; regex and expected count" | ||
val=$(grep -E "$1" out | wc -l) && val=$((val + 0)) | ||
[[ $val -eq $2 ]] || die "Incorrect count [$val != $2] for regex [$1]" | ||
} | ||
|
||
######################################################################################################################## | ||
|
||
# Ensure that listing finds the correct data, but excludes duplicates. | ||
# This is the same data as in the all test, but with a full enumeration | ||
|
||
# Set up the data for the test | ||
|
||
try grib_set -s class=rd,expver=xxxx,type=fc,step=0 "$src_data" data.xxxx.0.grib | ||
try grib_set -s class=rd,expver=xxxx,type=fc,step=1 "$src_data" data.xxxx.1.grib | ||
try grib_set -s class=rd,expver=xxxy,type=fc,step=0 "$src_data" data.xxxy.0.grib | ||
try grib_set -s class=rd,expver=xxxy,type=fc,step=1 "$src_data" data.xxxy.1.grib | ||
|
||
# Set up some regexes for later testing | ||
|
||
regex_x0="{class=rd,expver=xxxx,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=0,levelist=[0-9]+,param=[0-9]+}" | ||
regex_x1="{class=rd,expver=xxxx,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=1,levelist=[0-9]+,param=[0-9]+}" | ||
regex_y0="{class=rd,expver=xxxy,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=0,levelist=[0-9]+,param=[0-9]+}" | ||
regex_y1="{class=rd,expver=xxxy,stream=oper,date=[0-9]+,time=(12|00)00,domain=g}{type=fc,levtype=pl}{step=1,levelist=[0-9]+,param=[0-9]+}" | ||
|
||
# We loop over all these tests twice. We should get the same listing results both times | ||
# as the default behaviour is to only show the data that would be retrieved (i.e. that matches a MARS request.) | ||
|
||
for i in 0 1; do | ||
|
||
try fdb-write data.xxxx.0.grib | ||
try fdb-list --all --minimum-keys="" --porcelain --full > out | ||
count $((24+(i*96))) | ||
grep_count "$regex_x0" $((24+(24*i))) | ||
grep_count "$regex_x1" $((0+(24*i))) | ||
grep_count "$regex_y0" $((0+(24*i))) | ||
grep_count "$regex_y1" $((0+(24*i))) | ||
|
||
try fdb-write data.xxxy.0.grib | ||
try fdb-list --all --minimum-keys="" --porcelain --full > out | ||
count $((48+(i*96))) | ||
grep_count "$regex_x0" $((24+(24*i))) | ||
grep_count "$regex_x1" $((0+(24*i))) | ||
grep_count "$regex_y0" $((24+(24*i))) | ||
grep_count "$regex_y1" $((0+(24*i))) | ||
|
||
try fdb-write data.xxxx.1.grib | ||
try fdb-list --all --minimum-keys="" --porcelain --full > out | ||
count $((72+(i*96))) | ||
grep_count "$regex_x0" $((24+(24*i))) | ||
grep_count "$regex_x1" $((24+(24*i))) | ||
grep_count "$regex_y0" $((24+(24*i))) | ||
grep_count "$regex_y1" $((0+(24*i))) | ||
|
||
try fdb-write data.xxxy.1.grib | ||
try fdb-list --all --minimum-keys="" --porcelain --full > out | ||
count $((96+(i*96))) | ||
grep_count "$regex_x0" $((24+(24*i))) | ||
grep_count "$regex_x1" $((24+(24*i))) | ||
grep_count "$regex_y0" $((24+(24*i))) | ||
grep_count "$regex_y1" $((24+(24*i))) | ||
|
||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.