chore(ci): substitute v2 placeholders for tests, move setup to run-tests, fix env variables and broken use of parse_yaml

pull/5556/head
Jason Stirnaman 2024-08-07 13:58:43 -05:00
parent 26105f05e4
commit 67e4084cf0
2 changed files with 30 additions and 11 deletions

View File

@ -84,8 +84,12 @@ function substitute_placeholders {
s/example-db/$INFLUX_DATABASE/g;
s/get-started/$INFLUX_DATABASE/g;
/os.getenv("MANAGEMENT_TOKEN")/! s/INFLUX_MANAGEMENT_TOKEN/$MANAGEMENT_TOKEN/g;
/os.getenv("ORG_NAME")/! s/ORG_NAME/$INFLUX_ORG_NAME/g;
/os.getenv("ORG_ID")/! s/ORG_ID/$INFLUX_ORG/g;
/os.getenv("PASSWORD")/! s/PASSWORD/$INFLUX_PASSWORD/g;
/os.getenv("ORG_ID")/! s/ORG_ID/$INFLUX_ORG/g;
/os.getenv("RETENTION_POLICY")/! s/RETENTION_POLICY_NAME\|RETENTION_POLICY/$INFLUX_RETENTION_POLICY/g;
/os.getenv("USERNAME")/! s/USERNAME/$INFLUX_USERNAME/g;
s/CONFIG_NAME/CONFIG_$(shuf -i 0-100 -n1)/g;
s/TEST_RUN/TEST_RUN_$(date +%s)/g;
s|/path/to/custom/assets-dir|/app/custom-assets|g;' \
@ -109,16 +113,6 @@ function substitute_placeholders {
done
}
setup() {
# Set up the environment for the tests.
# Parse YAML config files into dotenv files to be used by tests.
mkdir -p /app/appdata && (parse_yaml /src/data/products.yml > /app/appdata/.env.products)
# Miscellaneous test setup.
# For macOS samples.
mkdir -p ~/Downloads && rm -rf ~/Downloads/*
}
prepare_tests() {
echo "Preparing test files: $*"
SRC_FILES="$*"
@ -130,7 +124,6 @@ prepare_tests() {
done
cd /app
substitute_placeholders
setup
}
prepare_tests "$*"

View File

@ -23,6 +23,32 @@ tests="${*:2}"
rm -rf /app/"${CONTENT_PATH}"/*
bash /src/test/scripts/prepare-content.sh $tests
setup() {
# Set up the environment for the tests.
## Store test configuration in /app/appdata.
mkdir -p /app/appdata
## Parse YAML config files into dotenv files to be used by tests.
## You must source the parse_yaml function before you can use it.
source /usr/local/bin/parse_yaml
parse_yaml /src/data/products.yml > /app/appdata/.env.products
chmod -R +x /app/appdata/
## Source non-sensitive environment variables for all test runners.
set -a
source /app/appdata/.env.*
set +a
# Miscellaneous test setup.
# For macOS samples.
mkdir -p ~/Downloads && rm -rf ~/Downloads/*
}
setup
if [[ $runner == "pytest" ]]; then
pytest \
-s \