fix inadvertantly reverted changes (#5219)

pull/5220/head
Scott Anderson 2023-11-06 16:55:00 -07:00 committed by GitHub
parent 01950cee64
commit b823be2f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 216 additions and 80 deletions

View File

@ -1,47 +1,47 @@
# syntax=docker/dockerfile:1
# If you need more help, visit the Dockerfile reference guide at # If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/ # https://docs.docker.com/engine/reference/builder/
ARG PYTHON_VERSION=3.11.5 FROM python:3.12.0-slim-bookworm
FROM python:${PYTHON_VERSION}-slim as base
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
curl \ curl \
git \ git \
gpg \
wget \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
ARG SOURCE_DIR ARG SOURCE_DIR
ARG TESTS_DIR
COPY test ./test
COPY data ./test/data
RUN chmod -R 755 .
# Prevents Python from writing pyc files. # Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE=1
@@ -22,26 +28,23 @@ ENV PYTHONDONTWRITEBYTECODE=1
# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering. # the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
COPY $SOURCE_DIR /app/$SOURCE_DIR WORKDIR /usr/src/app/${SOURCE_DIR}
WORKDIR /app/$SOURCE_DIR COPY test/run-tests.sh /usr/local/bin/run-tests.sh
RUN chmod -R 755 /app/$SOURCE_DIR
COPY $SOURCE_DIR/run-tests.sh /usr/local/bin/run-tests.sh
RUN chmod +x /usr/local/bin/run-tests.sh RUN chmod +x /usr/local/bin/run-tests.sh
# Download dependencies as a separate step to take advantage of Docker's caching. # Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. # Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into # Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer. # this layer.
RUN --mount=type=cache,target=/root/.cache/pip \ RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=${SOURCE_DIR}/requirements.txt,target=requirements.txt \ --mount=type=bind,source=test/requirements.txt,target=./requirements.txt \
python -m pip install -r requirements.txt python -m pip install -r ./requirements.txt
# RUN --mount=type=cache,target=/root/.cache/node_modules \ # RUN --mount=type=cache,target=/root/.cache/node_modules \
# --mount=type=bind,source=package.json,target=package.json \ # --mount=type=bind,source=package.json,target=package.json \
# npm install # npm install
WORKDIR $TESTS_DIR ENV TEMP_DIR=./tmp
ENTRYPOINT ["run-tests.sh"] ENTRYPOINT [ "run-tests.sh" ]
CMD [""] CMD [""]

View File

@ -3,15 +3,19 @@
services: services:
test: test:
image: docs-v2-tests image: docs-v2-tests
container_name: docs-v2-tests
env_file: env_file:
- ./test/.env.influxdbv2
- ./test/.env.influxdbv3 - ./test/.env.influxdbv3
volumes: volumes:
- type: bind - type: bind
source: ./test/tmp source: ./test
target: /app/test/tmp target: /usr/src/app/test
- type: bind
source: ./data
target: /usr/src/app/test/data
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
args: args:
- SOURCE_DIR=test - SOURCE_DIR=test
- TESTS_DIR=tmp

View File

@ -51,6 +51,9 @@ Do one of the following:
- [Manually download and install](#manually-download-and-install) - [Manually download and install](#manually-download-and-install)
### Use Homebrew ### Use Homebrew
<!--pytest.mark.skip-->
```sh ```sh
brew install influxdb-cli brew install influxdb-cli
``` ```
@ -62,6 +65,8 @@ If you used Homebrew to install **InfluxDB {{< current-version >}}**, the `influ
formula was downloaded as a dependency and should already be installed. formula was downloaded as a dependency and should already be installed.
If installed, `influxdb-cli` will appear in the output of the following command: If installed, `influxdb-cli` will appear in the output of the following command:
<!--pytest.mark.skip-->
```sh ```sh
brew list | grep influxdb-cli brew list | grep influxdb-cli
``` ```
@ -71,39 +76,67 @@ brew list | grep influxdb-cli
### Manually download and install ### Manually download and install
1. **Download the `influx` CLI package.** 1. Download the `influx` CLI package [from your browser](#download-from-your-browser)
or [from the command line](#download-from-the-command-line).
#### Download from your browser
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64.tar.gz" download>influx CLI v{{< latest-patch cli=true >}} (macOS)</a> <a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64.tar.gz" download>influx CLI v{{< latest-patch cli=true >}} (macOS)</a>
2. **Unpackage the downloaded package.** #### Download from the command line
```sh
curl -O https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64.tar.gz \
--output-dir ~/Downloads
```
2. Unpackage the downloaded binary.
Do one of the following: Do one of the following:
- Double-click the downloaded package file in **Finder**. - In **Finder**, double-click the downloaded package file.
- Run the following command in a macOS command prompt application such - In your terminal (for example, **Terminal** or **[iTerm2](https://www.iterm2.com/)**) use `tar` to extract the package--for example, enter the following command to extract it into `~/Downloads`:
**Terminal** or **[iTerm2](https://www.iterm2.com/)**:
```sh ```sh
# Unpackage contents to the current working directory tar zxvf ~/Downloads/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64.tar.gz \
tar zxvf ~/Downloads/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64.tar.gz --directory ~/Downloads
``` ```
3. **(Optional) Place the binary in your `$PATH`.** 3. Optional: Place the `influx` binary in your `$PATH`--for example, copy the binary to `/usr/local/bin`:
```sh ```sh
# (Optional) Copy the influx binary to your $PATH sudo cp ~/Downloads/influx /usr/local/bin/
sudo cp ~/Downloads/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64/influx /usr/local/bin/
``` ```
If you do not move the `influx` binary into your `$PATH`, prefix the executable With the `influx` binary in your `$PATH` (`/usr/local/bin`), you can enter `influx` in your terminal to run the CLI.
`./` to run it in place.
4. **(macOS Catalina and newer) Authorize the `influx` binary.** If you do not move the `influx` binary into your `$PATH`, enter the path to the binary to run the CLI--for example:
<!--pytest.mark.xfail-->
```sh
~/Downloads/influx
```
4. (macOS Catalina and newer) Authorize the `influx` binary.
macOS requires downloaded binaries to be signed by registered Apple developers. macOS requires downloaded binaries to be signed by registered Apple developers.
When you first attempt to run `influx`, macOS will prevent it from running. When you first attempt to run `influx`, macOS prevents it from running.
To authorize the `influx` binary: To authorize the `influx` binary:
**Allow the binary on macOS Ventura**
1. Follow the preceding instructions to attempt to start `influx`.
2. Open **System Settings** and click **Privacy & Security**.
3. Under the **Security** heading, there is a message about "influxd" being blocked, click **Allow Anyway**.
5. When prompted, enter your password to allow the setting.
6. Close **System Settings**.
7. Attempt to start `influx`.
8. A prompt appears with the message _"macOS cannot verify the developer of "influx"...""_.
Click **Open**.
**Allow the binary on macOS Catalina**
1. Attempt to run an `influx` command. 1. Attempt to run an `influx` command.
2. Open **System Preferences** and click **Security & Privacy**. 2. Open **System Preferences** and click **Security & Privacy**.
3. Under the **General** tab, there is a message about `influx` being blocked. 3. Under the **General** tab, there is a message about `influx` being blocked.
@ -115,9 +148,7 @@ brew list | grep influxdb-cli
<!-------------------------------- BEGIN Linux --------------------------------> <!-------------------------------- BEGIN Linux -------------------------------->
{{% tab-content %}} {{% tab-content %}}
1. **Download the influx CLI package.** 1. Download the `influx` CLI package [from your browser](#download-from-your-browser)
Download the `influx` CLI package [from your browser](#download-from-your-browser)
or [from the command line](#download-from-the-command-line). or [from the command line](#download-from-the-command-line).
#### Download from your browser #### Download from your browser
@ -130,35 +161,46 @@ brew list | grep influxdb-cli
```sh ```sh
# amd64 # amd64
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz
```
```sh
# arm # arm
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64.tar.gz wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64.tar.gz
``` ```
4. **Unpackage the downloaded package.** 2. Unpackage the downloaded binary.
_**Note:** The following commands are examples. Adjust the filenames, paths, and utilities if necessary._ _**Note:** The following commands are examples. Adjust the filenames, paths, and utilities if necessary._
```sh ```sh
# amd64 # amd64
tar xvzf path/to/influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz tar xvzf ./influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz
# arm
tar xvzf path/to/influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64.tar.gz
``` ```
3. **(Optional) Place the unpackaged `influx` executable in your system `$PATH`.** ```sh
# arm
tar xvzf ./influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64.tar.gz
```
3. Optional: Place the unpackaged `influx` executable in your system `$PATH`.
```sh ```sh
# amd64 # amd64
sudo cp influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64/influx /usr/local/bin/ sudo cp ./influx /usr/local/bin/
# arm
sudo cp influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64/influx /usr/local/bin/
``` ```
If you do not move the `influx` binary into your `$PATH`, prefix the executable ```sh
`./` to run it in place. # arm
sudo cp ./influx /usr/local/bin/
```
If you do not move the `influxd` binary into your `$PATH`, enter the path to the binary to start the server--for example:
<!--pytest.mark.xfail-->
```sh
./influx
```
{{% /tab-content %}} {{% /tab-content %}}
<!--------------------------------- END Linux ---------------------------------> <!--------------------------------- END Linux --------------------------------->
@ -171,20 +213,22 @@ We recommend running `influx` CLI commands in Powershell.
Command Prompt is not fully compatible. Command Prompt is not fully compatible.
{{% /note %}} {{% /note %}}
1. **Download the `influx` CLI package.** 1. Download the `influx` CLI package.
<a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64.zip" download>influx CLI v{{< latest-patch cli=true >}} (Windows)</a> <a class="btn download" href="https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64.zip" download>influx CLI v{{< latest-patch cli=true >}} (Windows)</a>
2. **Expand the downloaded archive.** 2. Expand the downloaded archive.
Expand the downloaded archive into `C:\Program Files\InfluxData\` and rename it if desired. Expand the downloaded archive into `C:\Program Files\InfluxData\` and rename it if desired.
<!--pytest.mark.skip-->
```powershell ```powershell
> Expand-Archive .\influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64.zip -DestinationPath 'C:\Program Files\InfluxData\' > Expand-Archive .\influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64.zip -DestinationPath 'C:\Program Files\InfluxData\'
> mv 'C:\Program Files\InfluxData\influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64' 'C:\Program Files\InfluxData\influx' > mv 'C:\Program Files\InfluxData\influxdb2-client-{{< latest-patch cli=true >}}-windows-amd64' 'C:\Program Files\InfluxData\influx'
``` ```
3. **Grant network access to the `influx` CLI.** 3. Grant network access to the `influx` CLI.
When using the `influx` CLI for the first time, **Windows Defender** displays When using the `influx` CLI for the first time, **Windows Defender** displays
the following message: the following message:
@ -214,13 +258,22 @@ credentials from the active config.
Use the [`influx config create` command](/influxdb/v2/reference/cli/influx/config/create/) Use the [`influx config create` command](/influxdb/v2/reference/cli/influx/config/create/)
to create an `influx` CLI config and set it as active: to create an `influx` CLI config and set it as active:
{{% code-placeholders "API_TOKEN|ORG|http://localhost:8086|CONFIG_NAME" %}}
```sh ```sh
influx config create --config-name <config-name> \ influx config create --config-name CONFIG_NAME \
--host-url http://localhost:8086 \ --host-url http://localhost:8086 \
--org <your-org> \ --org ORG \
--token <your-auth-token> \ --token API_TOKEN \
--active --active
``` ```
{{% /code-placeholders %}}
Replace the following:
- {{% code-placeholder-key %}}`CONFIG_NAME`{{% /code-placeholder-key %}}: Connection configuration name.
- {{% code-placeholder-key %}}`ORG_NAME`{{% /code-placeholder-key %}}: your InfluxDB [organization](/influxdb/v2/admin/organizations/).
- {{% code-placeholder-key %}}`API_TOKEN`{{% /code-placeholder-key %}}: your [API token](/influxdb/v2/admin/tokens/).
For more information about managing CLI configurations, see the For more information about managing CLI configurations, see the
[`influx config` documentation](/influxdb/v2/reference/cli/influx/config/). [`influx config` documentation](/influxdb/v2/reference/cli/influx/config/).
@ -239,16 +292,24 @@ The CLI retrieves a session cookie and stores it, unencrypted, in your
Use the `--username-password`, `-p` option to provide your username and password Use the `--username-password`, `-p` option to provide your username and password
using the `<username>:<password>` syntax. using the `<username>:<password>` syntax.
If no password is provided, the CLI will prompt for a password after each If no password is provided, the CLI prompts for a password after each
command that requires authentication. command that requires authentication.
{{% code-placeholders "API_TOKEN|ORG|http://localhost:8086|CONFIG_NAME|USERNAME|PASSWORD" %}}
```sh ```sh
influx config create \ influx config create \
-n config-name \ -n CONFIG_NAME \
-u http://localhost:8086 \ -u http://localhost:8086 \
-p example-user:example-password \ -p USERNAME:PASSWORD \
-o example-org -o ORG
``` ```
{{% /code-placeholders %}}
Replace the following:
- {{% code-placeholder-key %}}`CONFIG_NAME`{{% /code-placeholder-key %}}: Connection configuration name.
- {{% code-placeholder-key %}}`ORG`{{% /code-placeholder-key %}}: [your organization name](/influxdb/v2/admin/organizations/).
- {{% code-placeholder-key %}}`USERNAME:PASSWORD`{{% /code-placeholder-key %}}: your UI username and password combination.
{{% /oss-only %}} {{% /oss-only %}}

15
test.sh
View File

@ -30,7 +30,7 @@ rm -rf "$target"/*
# Check if the user provided a path to copy. # Check if the user provided a path to copy.
if [ -z "$paths" ]; then if [ -z "$paths" ]; then
echo "No path provided. Running tests for *.md files that have been added or modified in the current branch." echo "No path provided. Running tests for *.md files that have been added or modified in the current branch."
paths=$(git diff --name-only --diff-filter=AM --relative master | \ paths=$(git diff --name-only --diff-filter=AM --relative origin/master | \
grep -E '\.md$') grep -E '\.md$')
else else
paths=$(find "$paths" -type f -name '*.md') paths=$(find "$paths" -type f -name '*.md')
@ -39,5 +39,14 @@ fi
# Log the list of files to be tested and copy them to the test directory. # Log the list of files to be tested and copy them to the test directory.
echo "$paths" >> "$testrun" echo "$paths" >> "$testrun"
echo "$paths" | rsync -arv --files-from=- . "$target" echo "$paths" | rsync -arv --files-from=- . "$target"
# Start a new container and run the tests.
docker compose run --no-TTY test # Build the test image, run the tests, and then remove the container after it exits.
docker compose run --build --rm test
# To help debug test failures, run the container and pass additional flags to be used by the container's entrypoint and the test runners it executes--for example:
# docker compose run --rm test -v
# docker compose run --rm test --entrypoint /bin/bash
# If you want to examine files or run commands for debugging tests,
# start the container and use `exec` to open an interactive shell--for example:
# docker start test && docker exec -it test /bin/bash

4
test/.gitignore vendored
View File

@ -1,7 +1,9 @@
/target /target
/Cargo.lock /Cargo.lock
content
node_modules node_modules
tmp
.env* .env*
.pytest_cache .pytest_cache
.test-run.txt .test-run.txt
tmp parse_yaml.sh

View File

@ -1,6 +1,5 @@
## Code sample dependencies ## Code sample dependencies
# Temporary fork for passing headers in query options. influxdb3-python
influxdb3-python @ git+https://github.com/jstirnaman/influxdb3-python@4abd41c710e79f85333ba81258b10daff54d05b0
pandas pandas
## Tabulate for printing pandas DataFrames. ## Tabulate for printing pandas DataFrames.
tabulate tabulate

View File

@ -1,10 +1,44 @@
#!/bin/bash #!/bin/bash
# Function to check if an option is present in the arguments
has_option() {
local target="$1"
shift
for arg in "$@"; do
if [ "$arg" == "$target" ]; then
return 0
fi
done
return 1
}
verbose=0
# Check if "--option" is present in the CMD arguments
if has_option "-v" "$@"; then
verbose=1
echo "Using verbose mode..."
fi
if [ -z "$TEMP_DIR" ]; then
TEMP_DIR=./tmp
fi
# Parse YAML config files into dotenv files
curl -sO https://raw.githubusercontent.com/mrbaseman/parse_yaml/master/src/parse_yaml.sh
source ./parse_yaml.sh && parse_yaml ./data/products.yml > .env.products
# Load shell environment variables from .env files generated in the build (not provided at build-time.
# To provide .env files available at build-time, set them in the docker compose file).
set -a && source .env.products && set +a
cd $TEMP_DIR
for file in `find . -type f` ; do for file in `find . -type f` ; do
if [ -f "$file" ]; then if [ -f "$file" ]; then
echo "PROCESSING $file" echo "PROCESSING $file"
# Replace placeholder values with environment variables. # Replaces placeholder values with environment variable references.
# Non-language-specific replacements. # Non-language-specific replacements.
sed -i 's|https:\/\/{{< influxdb/host >}}|$INFLUX_HOST|g; sed -i 's|https:\/\/{{< influxdb/host >}}|$INFLUX_HOST|g;
' $file ' $file
@ -23,13 +57,40 @@ for file in `find . -type f` ; do
# Shell-specific replacements. # Shell-specific replacements.
sed -i 's/API_TOKEN/$INFLUX_TOKEN/g; sed -i 's/API_TOKEN/$INFLUX_TOKEN/g;
s/ORG_ID/$INFLUX_ORG/g; s/ORG_ID/$INFLUX_ORG/g;
s/ORG/$INFLUX_ORG/g;
s/DATABASE_TOKEN/$INFLUX_TOKEN/g; s/DATABASE_TOKEN/$INFLUX_TOKEN/g;
s/BUCKET_NAME/$INFLUX_DATABASE/g; s/BUCKET_NAME/$INFLUX_DATABASE/g;
s/DATABASE_NAME/$INFLUX_DATABASE/g; s/DATABASE_NAME/$INFLUX_DATABASE/g;
s/get-started/$INFLUX_DATABASE/g;' \ s/get-started/$INFLUX_DATABASE/g;
s/CONFIG_NAME/CONFIG_$(shuf -i 0-100 -n1)/g;' \
$file
# v2-specific replacements.
sed -i 's|https:\/\/us-west-2-1.aws.cloud2.influxdata.com|$INFLUX_HOST|g;
s|{{< latest-patch >}}|${influxdb_latest_patches_v2}|g;
s|{{< latest-patch cli=true >}}|${influxdb_latest_cli_v2}|g;' \
$file
# Skip package manager commands.
sed -i 's|sudo dpkg.*$||g;
s|sudo yum.*$||g;' \
$file
# Environment-specific replacements.
sed -i 's|sudo ||g;' \
$file $file
fi fi
if [ $verbose -eq 1 ]; then
echo "FILE CONTENTS:"
cat $file cat $file
fi
done done
pytest --codeblocks . # Miscellaneous test setup.
# For macOS samples.
mkdir -p ~/Downloads && rm -rf ~/Downloads/*
# Clean up installed files from previous runs.
gpg -q --batch --yes --delete-key D8FF8E1F7DF8B07E > /dev/null 2>&1
# Run test commands with options provided in the CMD of the Dockerfile.
pytest --codeblocks ./content "$@"