Skip to content

Commit

Permalink
DAS-1970: bugfix (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingbear committed Sep 25, 2023
1 parent 5e123ee commit 65babaa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
20 changes: 20 additions & 0 deletions script/image_name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

## Returns the correct image name to run a notebook.
## If the test name's environmental variable exists, return that.
## otherwise:
## if the second argument passed is 'true' return the tag value for the image read from the version.txt file.
## else returns 'latest'
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

function image_name () {
base="regression-tests-$1"
if [ "$2" = true ]; then
recent_tag=$(<"$SCRIPT_DIR/../test/$1/version.txt")
else
recent_tag="latest"
fi
env_image_name=$(echo "${base}_IMAGE" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
default_image="ghcr.io/nasa/${base}:${recent_tag}"
echo "${!env_image_name:-${default_image}}"
}
25 changes: 9 additions & 16 deletions script/test-in-bamboo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@
set -ex


## Returns the image name to pull from docker. If the test name's
## environmental variable exists, return that, otherwise return the default
## value for the image read from the version.txt file.
function image_name () {
base="regression-tests-$1"
recent_tag=$(<"./test/$1/version.txt")
env_image_name=$(echo "${base}_IMAGE" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
default_image="ghcr.io/nasa/${base}:${recent_tag}"
echo "${!env_image_name:-${default_image}}"
}
## Import function image_name that determines the images to pull from docker.
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "${SCRIPT_DIR}/image_name.sh"

if [[ -z "${HARMONY_ENVIRONMENT}" ]]; then
echo "HARMONY_ENVIRONMENT must be set to run this script"
Expand Down Expand Up @@ -51,7 +44,7 @@ echo "harmony host url: ${harmony_host_url}"
image_names=()
all_tests=(harmony harmony-regression hoss hga n2z swath-projector trajectory-subsetter variable-subsetter regridder hybig)
for image in "${all_tests[@]}"; do
image_names+=($(image_name "$image"))
image_names+=($(image_name "$image" true))
done

# download all of the images and output their names
Expand All @@ -65,11 +58,11 @@ done
## run the tests
cd test \
&& export HARMONY_HOST_URL="${harmony_host_url}" \
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
EDL_USER="${EDL_USER}" \
EDL_PASSWORD="${EDL_PASSWORD}" \
&& ./run_notebooks.sh
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
EDL_USER="${EDL_USER}" \
EDL_PASSWORD="${EDL_PASSWORD}" \
&& ./run_notebooks.sh --use-versions

# Copy the notebook artefacts up to S3:
if [[ -z "${REGRESSION_TEST_OUTPUT_BUCKET}" ]]; then
Expand Down
44 changes: 27 additions & 17 deletions test/run_notebooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,34 @@ RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

## Returns the correct image name. If the test name's
## environmental variable exists, return that, otherwise return the default
## value for the image.
function image_name () {
base="regression-tests-$1"
env_image_name=$(echo "${base}_IMAGE" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
default_image="ghcr.io/nasa/${base}:latest"
echo "${!env_image_name:-${default_image}}"
}

## Import function that returns correct image names. if flag --use-versions is
## set when this script is called, it will use names form versions.txt
## otherwise it will default to "latest"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "${SCRIPT_DIR}/../script/image_name.sh"

echo "Running regression tests"


# Specify the test images to run, by default all built by the Makefile. If
# the script is invoked with a list of images, only run those.
all_images=(harmony harmony-regression hoss hga n2z swath-projector trajectory-subsetter variable-subsetter regridder hybig)
specified_images=("$@")
specified_images=()
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--use-versions)
use_versions=true
shift
;;
*)
specified_images+=("$1")
shift
;;
esac
done

## use the user supplied images or the default list of all images.
images=("${specified_images[@]:-${all_images[@]}}")

# launch all the docker containers and store their process IDs
Expand All @@ -30,17 +40,17 @@ for image in "${images[@]}"; do

# insert AWS Credential variables for n2z only
if [[ $image == "n2z" ]]; then
creds="--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} --env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}"
creds="--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} --env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}"
else
creds=""
creds=""
fi

full_image=$(image_name "$image")
full_image=$(image_name "$image" "$use_versions")
echo "running test with $full_image"
PIDS+=(${image},$(docker run -d -v ${PWD}/output:/workdir/output \
${creds} \
--env EDL_PASSWORD="${EDL_PASSWORD}" --env EDL_USER="${EDL_USER}" \
--env harmony_host_url="${HARMONY_HOST_URL}" "${full_image}"))
${creds} \
--env EDL_PASSWORD="${EDL_PASSWORD}" --env EDL_USER="${EDL_USER}" \
--env harmony_host_url="${HARMONY_HOST_URL}" "${full_image}"))
done

trap ctrl_c SIGINT SIGTERM
Expand Down

0 comments on commit 65babaa

Please sign in to comment.