Skip to content

Commit 07f1f5e

Browse files
authored
Merge pull request #5556 from influxdata/fix-test-product-environments
Fix test product environments
2 parents bd48f82 + 0df1466 commit 07f1f5e

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

compose.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ services:
3838
cloud-pytest:
3939
image: influxdata/docs-pytest
4040
build:
41-
args:
42-
- CONTENT_PATH=content/influxdb/cloud
4341
context: .
4442
dockerfile: Dockerfile.pytest
4543
entrypoint:
@@ -50,6 +48,8 @@ services:
5048
# In the command, pass file paths to test.
5149
# The container preprocesses the files for testing and runs the tests.
5250
- content/influxdb/cloud/**/*.md
51+
environment:
52+
- CONTENT_PATH=content/influxdb/cloud
5353
profiles:
5454
- test
5555
- v2
@@ -87,8 +87,6 @@ services:
8787
cloud-dedicated-pytest:
8888
image: influxdata/docs-pytest
8989
build:
90-
args:
91-
- CONTENT_PATH=content/influxdb/cloud-dedicated
9290
context: .
9391
dockerfile: Dockerfile.pytest
9492
entrypoint:
@@ -99,6 +97,8 @@ services:
9997
# In the command, pass file paths to test.
10098
# The container preprocesses the files for testing and runs the tests.
10199
- content/influxdb/cloud-dedicated/**/*.md
100+
environment:
101+
- CONTENT_PATH=content/influxdb/cloud-dedicated
102102
profiles:
103103
- test
104104
- v3
@@ -141,8 +141,6 @@ services:
141141
cloud-serverless-pytest:
142142
image: influxdata/docs-pytest
143143
build:
144-
args:
145-
- CONTENT_PATH=content/influxdb/cloud-serverless
146144
context: .
147145
dockerfile: Dockerfile.pytest
148146
entrypoint:
@@ -153,6 +151,8 @@ services:
153151
# In the command, pass file paths to test.
154152
# The container preprocesses the files for testing and runs the tests.
155153
- content/influxdb/cloud-serverless/**/*.md
154+
environment:
155+
- CONTENT_PATH=content/influxdb/cloud-serverless
156156
profiles:
157157
- test
158158
- v3
@@ -190,8 +190,6 @@ services:
190190
clustered-pytest:
191191
image: influxdata/docs-pytest
192192
build:
193-
args:
194-
- CONTENT_PATH=content/influxdb/clustered
195193
context: .
196194
dockerfile: Dockerfile.pytest
197195
entrypoint:
@@ -202,6 +200,8 @@ services:
202200
# In the command, pass file paths to test.
203201
# The container preprocesses the files for testing and runs the tests.
204202
- content/influxdb/clustered/**/*.md
203+
environment:
204+
- CONTENT_PATH=content/influxdb/clustered
205205
profiles:
206206
- test
207207
- v3
@@ -244,8 +244,6 @@ services:
244244
telegraf-pytest:
245245
image: influxdata/docs-pytest
246246
build:
247-
args:
248-
- CONTENT_PATH=content/telegraf
249247
context: .
250248
dockerfile: Dockerfile.pytest
251249
entrypoint:
@@ -256,6 +254,8 @@ services:
256254
# In the command, pass file paths to test.
257255
# The container preprocesses the files for testing and runs the tests.
258256
- content/telegraf/**/*.md
257+
environment:
258+
- CONTENT_PATH=content/telegraf
259259
profiles:
260260
- test
261261
stdin_open: true
@@ -292,8 +292,6 @@ services:
292292
v2-pytest:
293293
image: influxdata/docs-pytest
294294
build:
295-
args:
296-
- CONTENT_PATH=content/influxdb/v2
297295
context: .
298296
dockerfile: Dockerfile.pytest
299297
entrypoint:
@@ -304,6 +302,8 @@ services:
304302
# In the command, pass file paths to test.
305303
# The container preprocesses the files for testing and runs the tests.
306304
- content/influxdb/v2/**/*.md
305+
environment:
306+
- CONTENT_PATH=content/influxdb/v2
307307
profiles:
308308
- test
309309
- v2
@@ -348,7 +348,9 @@ services:
348348
DOCKER_INFLUXDB_INIT_PASSWORD_FILE: /run/secrets/influxdb2-admin-password
349349
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN_FILE: /run/secrets/influxdb2-admin-token
350350
DOCKER_INFLUXDB_INIT_ORG: docs
351-
DOCKER_INFLUXDB_INIT_BUCKET: home
351+
DOCKER_INFLUXDB_INIT_BUCKET: get-started
352+
INFLUX_ORG: docs
353+
INFLUX_BUCKET: get-started
352354
profiles:
353355
- v2
354356
- local
@@ -367,7 +369,7 @@ services:
367369
build:
368370
context: .
369371
dockerfile: .ci/Dockerfile.remark
370-
command: ["remark", "content/${PRODUCT_PATH}"]
372+
command: ["remark", "${CONTENT_PATH}"]
371373
profiles:
372374
- lint
373375
volumes:

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)