#!/bin/bash
#
# Run acceptance tests.

# We intentionally don't set '-u' (error on unbound variables) or '-e' (exit on
# first failure) initially since DevStack is not designed to run with these
# flags and things crash and burn *spectacularly* 🔥🔥🔥
set -xo pipefail

# shellcheck disable=SC1091
source "$(dirname "$0")/stackenv"

# ...but we can do it after the fact
set -eu

timeout="60m"

LOG_DIR=${LOG_DIR:-}
if [[ -z "${LOG_DIR}" ]]; then
    echo "LOG_DIR not set, will set a temp directory"
    LOG_DIR=/tmp/devstack-logs
fi
mkdir -p "${LOG_DIR}"

# shellcheck disable=SC2068
go test -v -timeout $timeout -tags "fixtures acceptance" "${PACKAGE:-./internal/acceptance/openstack/...}" $@ |& tee -a "${LOG_DIR}/acceptance_tests.log"
