fix(ci): test content:

- Add python replacement for get-started database/bucket name
- Fixes race condition when deleting previous content:
  - Assign each product it's own test content volume instead of sharing a volume.
  - Delete existing content in the volume before copying test files.
  - Pros and cons, but I suspect a similar approach will be better when ported to Circle CI.
pull/5505/head
Jason Stirnaman 2024-06-26 10:26:52 -05:00
parent 922e48182a
commit ea9b786b83
5 changed files with 21 additions and 7 deletions

View File

@ -6,14 +6,26 @@ function testStagedContent(paths, productPath) {
const TEST = `pytest-${productName}`;
return [
// Remove any existing test container and volume
// Remove existing containers
`sh -c "docker rm -f ${CONTENT} || true"`,
`sh -c "docker rm -f ${TEST} || true"`,
`docker build . -f Dockerfile.tests -t influxdata-docs/tests:latest`,
// Remove any existing Docker volume for staged content
`sh -c "docker volume rm -f ${CONTENT} || true"`,
// Create a Docker volume for product staged content
`sh -c "docker volume create \
--label tag=influxdata-docs \
--label stage=test \
--name ${CONTENT} || true"`,
// Copy staged content to a volume and run the prepare script
// to remove the existing
`docker run --name ${CONTENT}
--label tag=influxdata-docs
--label stage=test
--mount type=volume,source=staged-content,target=/app/content
--mount type=bind,src=./content,dst=/src/content
--mount type=bind,src=./static/downloads,dst=/app/data
@ -38,7 +50,10 @@ function testStagedContent(paths, productPath) {
echo 'No tests to run.'; \
exit 0; \
else \
docker run --rm --name ${TEST} \
docker run --rm \
--label tag=influxdata-docs \
--label stage=test \
--name ${TEST} \
--env-file ${productPath}/.env.test \
--volumes-from ${CONTENT} \
influxdata-docs/pytest --codeblocks --exitfirst ${productPath}/;

View File

@ -1014,7 +1014,7 @@ _This tutorial assumes using Maven version 3.9, Java version >= 15, and an `infl
- The `App`, `Write`, and `Query` classes belong to the `com.influxdbv3` package (your project **groupId**).
- `App` defines a `main()` function that calls `Write.writeLineProtocol()` and `Query.querySQL()`.
4. In your terminal or editor, use Maven to to install dependencies and compile the project code--for example:
4. In your terminal or editor, use Maven to install dependencies and compile the project code--for example:
<!--pytest.mark.skip-->

View File

@ -1008,7 +1008,7 @@ _This tutorial assumes using Maven version 3.9, Java version >= 15, and an `infl
- The `App`, `Write`, and `Query` classes belong to the `com.influxdbv3` package (your project **groupId**).
- `App` defines a `main()` function that calls `Write.writeLineProtocol()` and `Query.querySQL()`.
4. In your terminal or editor, use Maven to to install dependencies and compile the project code--for example:
4. In your terminal or editor, use Maven to install dependencies and compile the project code--for example:
<!--pytest.mark.skip-->

View File

@ -1010,7 +1010,7 @@ _This tutorial assumes using Maven version 3.9, Java version >= 15, and an `infl
- The `App`, `Write`, and `Query` classes belong to the `com.influxdbv3` package (your project **groupId**).
- `App` defines a `main()` function that calls `Write.writeLineProtocol()` and `Query.querySQL()`.
4. In your terminal or editor, use Maven to to install dependencies and compile the project code--for example:
4. In your terminal or editor, use Maven to install dependencies and compile the project code--for example:
<!--pytest.mark.skip-->

View File

@ -24,6 +24,7 @@ function substitute_placeholders {
s/f"API_TOKEN"/os.getenv("INFLUX_TOKEN")/g;
s/f"BUCKET_NAME"/os.getenv("INFLUX_DATABASE")/g;
s/f"DATABASE_NAME"/os.getenv("INFLUX_DATABASE")/g;
s/f"get-started"/os.getenv("INFLUX_DATABASE")/g;
s|f"{{< influxdb/host >}}"|os.getenv("INFLUX_HOSTNAME")|g;
s|f"RETENTION_POLICY_NAME\|RETENTION_POLICY"|"autogen"|g;
' $file
@ -76,8 +77,6 @@ setup() {
prepare_tests() {
TEST_FILES="$*"
# Remove files from the previous run.
rm -rf "$TEST_CONTENT"/*
# Copy the test files to the target directory while preserving the directory structure.
for FILE in $TEST_FILES; do
# Create the parent directories of the destination file