Skip to content

Commit 67e4084

Browse files
committed
chore(ci): substitute v2 placeholders for tests, move setup to run-tests, fix env variables and broken use of parse_yaml
1 parent 26105f0 commit 67e4084

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

test/scripts/prepare-content.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ function substitute_placeholders {
8484
s/example-db/$INFLUX_DATABASE/g;
8585
s/get-started/$INFLUX_DATABASE/g;
8686
/os.getenv("MANAGEMENT_TOKEN")/! s/INFLUX_MANAGEMENT_TOKEN/$MANAGEMENT_TOKEN/g;
87+
/os.getenv("ORG_NAME")/! s/ORG_NAME/$INFLUX_ORG_NAME/g;
88+
/os.getenv("ORG_ID")/! s/ORG_ID/$INFLUX_ORG/g;
89+
/os.getenv("PASSWORD")/! s/PASSWORD/$INFLUX_PASSWORD/g;
8790
/os.getenv("ORG_ID")/! s/ORG_ID/$INFLUX_ORG/g;
8891
/os.getenv("RETENTION_POLICY")/! s/RETENTION_POLICY_NAME\|RETENTION_POLICY/$INFLUX_RETENTION_POLICY/g;
92+
/os.getenv("USERNAME")/! s/USERNAME/$INFLUX_USERNAME/g;
8993
s/CONFIG_NAME/CONFIG_$(shuf -i 0-100 -n1)/g;
9094
s/TEST_RUN/TEST_RUN_$(date +%s)/g;
9195
s|/path/to/custom/assets-dir|/app/custom-assets|g;' \
@@ -109,16 +113,6 @@ function substitute_placeholders {
109113
done
110114
}
111115

112-
setup() {
113-
# Set up the environment for the tests.
114-
# Parse YAML config files into dotenv files to be used by tests.
115-
mkdir -p /app/appdata && (parse_yaml /src/data/products.yml > /app/appdata/.env.products)
116-
117-
# Miscellaneous test setup.
118-
# For macOS samples.
119-
mkdir -p ~/Downloads && rm -rf ~/Downloads/*
120-
}
121-
122116
prepare_tests() {
123117
echo "Preparing test files: $*"
124118
SRC_FILES="$*"
@@ -130,7 +124,6 @@ prepare_tests() {
130124
done
131125
cd /app
132126
substitute_placeholders
133-
setup
134127
}
135128

136129
prepare_tests "$*"

test/scripts/run-tests.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@ tests="${*:2}"
2323
rm -rf /app/"${CONTENT_PATH}"/*
2424
bash /src/test/scripts/prepare-content.sh $tests
2525

26+
27+
28+
setup() {
29+
# Set up the environment for the tests.
30+
31+
## Store test configuration in /app/appdata.
32+
mkdir -p /app/appdata
33+
34+
## Parse YAML config files into dotenv files to be used by tests.
35+
## You must source the parse_yaml function before you can use it.
36+
source /usr/local/bin/parse_yaml
37+
parse_yaml /src/data/products.yml > /app/appdata/.env.products
38+
chmod -R +x /app/appdata/
39+
40+
## Source non-sensitive environment variables for all test runners.
41+
set -a
42+
source /app/appdata/.env.*
43+
set +a
44+
45+
# Miscellaneous test setup.
46+
# For macOS samples.
47+
mkdir -p ~/Downloads && rm -rf ~/Downloads/*
48+
}
49+
50+
setup
51+
2652
if [[ $runner == "pytest" ]]; then
2753
pytest \
2854
-s \

0 commit comments

Comments
 (0)