Skip to content

Testing Delivery Bash script

Scott Staniewicz edited this page Nov 27, 2024 · 1 revision
#/bin/bash
# test_final_delivery.sh
set -e
set -x # echo on

readonly HELP="usage: $0 test_location
Run the SAS workflow on a small or large dataset and compare the output against
a golden dataset.
positional arguments:
test_location   the location to put the test data and run the workflow
"

if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
    echo "$HELP"
    exit 0
elif [[ "$#" -lt 1 ]]; then
    echo 'Illegal number of parameters' >&2
    echo "$HELP"
    exit 1
fi

test_location="$1"
test_location=$(realpath $test_location)
mkdir -p $test_location
cd $test_location

# Clone the source.
git clone [email protected]:opera-adt/disp-s1.git
cd disp-s1
git checkout release/0.5

TAG=${TAG:-"$(whoami)/disp-s1:0.5.2"}
# Build the docker image.
BASE="cae-artifactory.jpl.nasa.gov:16003/gov/nasa/jpl/iems/sds/infrastructure/base/jplsds-oraclelinux:8.4.230101"
./docker/build-docker-image.sh --tag "$TAG" --base "$BASE"

s5cmd --numworkers 5 sync 's3://opera-adt/disp/disp-s1-final-delivery/*' $test_location
cd $test_location/delivery_data_small

# Run the SAS workflow.
cfg_file="config_files/runconfig_historical.yaml"

docker run --rm -u $(id -u):$(id -g) \
    -v $PWD:/work \
    $TAG disp-s1 run $cfg_file

# Loop through all .nc files in output/historical/
for file in output/historical/*.nc; do
    # Extract the filename without the path
    filename=$(basename "$file")

    # Construct the path for the golden file
    golden_file="golden_output/historical/$filename"

    # Check if the golden file exists
    if [ -f "$golden_file" ]; then
        echo "Comparing $file with $golden_file"

        # Run the Docker command
        docker run --rm -v $PWD:/work $TAG disp-s1 validate "$golden_file" "$file"
    else
        echo "Warning: Golden file not found for $file"
    fi
done
Clone this wiki locally