fix inadvertantly reverted changes (#5219)
parent
01950cee64
commit
b823be2f63
38
Dockerfile
38
Dockerfile
|
@ -1,47 +1,47 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
# If you need more help, visit the Dockerfile reference guide at
|
||||
# https://docs.docker.com/engine/reference/builder/
|
||||
|
||||
ARG PYTHON_VERSION=3.11.5
|
||||
|
||||
FROM python:${PYTHON_VERSION}-slim as base
|
||||
FROM python:3.12.0-slim-bookworm
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
gpg \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
ARG SOURCE_DIR
|
||||
ARG TESTS_DIR
|
||||
|
||||
COPY test ./test
|
||||
COPY data ./test/data
|
||||
|
||||
RUN chmod -R 755 .
|
||||
|
||||
# Prevents Python from writing pyc files.
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Keeps Python from buffering stdout and stderr to avoid situations where
|
||||
@@ -22,26 +28,23 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
||||
# the application crashes without emitting any logs due to buffering.
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
COPY $SOURCE_DIR /app/$SOURCE_DIR
|
||||
WORKDIR /usr/src/app/${SOURCE_DIR}
|
||||
|
||||
WORKDIR /app/$SOURCE_DIR
|
||||
RUN chmod -R 755 /app/$SOURCE_DIR
|
||||
|
||||
COPY $SOURCE_DIR/run-tests.sh /usr/local/bin/run-tests.sh
|
||||
COPY test/run-tests.sh /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.
|
||||
# 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
|
||||
# into this layer.
|
||||
# this layer.
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=bind,source=${SOURCE_DIR}/requirements.txt,target=requirements.txt \
|
||||
python -m pip install -r requirements.txt
|
||||
--mount=type=bind,source=test/requirements.txt,target=./requirements.txt \
|
||||
python -m pip install -r ./requirements.txt
|
||||
|
||||
# RUN --mount=type=cache,target=/root/.cache/node_modules \
|
||||
# --mount=type=bind,source=package.json,target=package.json \
|
||||
# npm install
|
||||
|
||||
WORKDIR $TESTS_DIR
|
||||
ENTRYPOINT ["run-tests.sh"]
|
||||
CMD [""]
|
||||
ENV TEMP_DIR=./tmp
|
||||
ENTRYPOINT [ "run-tests.sh" ]
|
||||
CMD [""]
|
12
compose.yaml
12
compose.yaml
|
@ -3,15 +3,19 @@
|
|||
services:
|
||||
test:
|
||||
image: docs-v2-tests
|
||||
container_name: docs-v2-tests
|
||||
env_file:
|
||||
- ./test/.env.influxdbv2
|
||||
- ./test/.env.influxdbv3
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./test/tmp
|
||||
target: /app/test/tmp
|
||||
source: ./test
|
||||
target: /usr/src/app/test
|
||||
- type: bind
|
||||
source: ./data
|
||||
target: /usr/src/app/test/data
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- SOURCE_DIR=test
|
||||
- TESTS_DIR=tmp
|
||||
- SOURCE_DIR=test
|
|
@ -1024,4 +1024,4 @@ Because [Operator tokens](/influxdb/v2/admin/tokens/#operator-token)
|
|||
have full read and write access to all organizations in the database,
|
||||
we recommend
|
||||
[creating an All-Access token](/influxdb/v2/admin/tokens/create-token/)
|
||||
for each organization and using those tokens to manage InfluxDB.
|
||||
for each organization and using those tokens to manage InfluxDB.
|
|
@ -51,6 +51,9 @@ Do one of the following:
|
|||
- [Manually download and install](#manually-download-and-install)
|
||||
|
||||
### Use Homebrew
|
||||
|
||||
<!--pytest.mark.skip-->
|
||||
|
||||
```sh
|
||||
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.
|
||||
If installed, `influxdb-cli` will appear in the output of the following command:
|
||||
|
||||
<!--pytest.mark.skip-->
|
||||
|
||||
```sh
|
||||
brew list | grep influxdb-cli
|
||||
```
|
||||
|
@ -71,39 +76,67 @@ brew list | grep influxdb-cli
|
|||
|
||||
### 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>
|
||||
|
||||
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:
|
||||
|
||||
- Double-click the downloaded package file in **Finder**.
|
||||
- Run the following command in a macOS command prompt application such
|
||||
**Terminal** or **[iTerm2](https://www.iterm2.com/)**:
|
||||
- In **Finder**, double-click the downloaded package file.
|
||||
- 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`:
|
||||
|
||||
```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
|
||||
# (Optional) Copy the influx binary to your $PATH
|
||||
sudo cp ~/Downloads/influxdb2-client-{{< latest-patch cli=true >}}-darwin-amd64/influx /usr/local/bin/
|
||||
sudo cp ~/Downloads/influx /usr/local/bin/
|
||||
```
|
||||
|
||||
If you do not move the `influx` binary into your `$PATH`, prefix the executable
|
||||
`./` to run it in place.
|
||||
With the `influx` binary in your `$PATH` (`/usr/local/bin`), you can enter `influx` in your terminal to run the CLI.
|
||||
|
||||
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.
|
||||
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:
|
||||
|
||||
**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.
|
||||
2. Open **System Preferences** and click **Security & Privacy**.
|
||||
3. Under the **General** tab, there is a message about `influx` being blocked.
|
||||
|
@ -115,9 +148,7 @@ brew list | grep influxdb-cli
|
|||
<!-------------------------------- BEGIN Linux -------------------------------->
|
||||
{{% tab-content %}}
|
||||
|
||||
1. **Download the influx CLI package.**
|
||||
|
||||
Download the `influx` CLI package [from your browser](#download-from-your-browser)
|
||||
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
|
||||
|
@ -127,38 +158,49 @@ brew list | grep influxdb-cli
|
|||
|
||||
#### Download from the command line
|
||||
|
||||
```sh
|
||||
# amd64
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz
|
||||
```sh
|
||||
# amd64
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
# arm
|
||||
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64.tar.gz
|
||||
```
|
||||
```sh
|
||||
# arm
|
||||
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._
|
||||
|
||||
```sh
|
||||
# amd64
|
||||
tar xvzf path/to/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
|
||||
tar xvzf ./influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64.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
|
||||
# amd64
|
||||
sudo cp influxdb2-client-{{< latest-patch cli=true >}}-linux-amd64/influx /usr/local/bin/
|
||||
|
||||
# arm
|
||||
sudo cp influxdb2-client-{{< latest-patch cli=true >}}-linux-arm64/influx /usr/local/bin/
|
||||
sudo cp ./influx /usr/local/bin/
|
||||
```
|
||||
|
||||
If you do not move the `influx` binary into your `$PATH`, prefix the executable
|
||||
`./` to run it in place.
|
||||
```sh
|
||||
# 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 %}}
|
||||
<!--------------------------------- END Linux --------------------------------->
|
||||
|
@ -171,20 +213,22 @@ We recommend running `influx` CLI commands in Powershell.
|
|||
Command Prompt is not fully compatible.
|
||||
{{% /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>
|
||||
|
||||
2. **Expand the downloaded archive.**
|
||||
2. Expand the downloaded archive.
|
||||
|
||||
Expand the downloaded archive into `C:\Program Files\InfluxData\` and rename it if desired.
|
||||
|
||||
<!--pytest.mark.skip-->
|
||||
|
||||
```powershell
|
||||
> 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'
|
||||
```
|
||||
|
||||
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
|
||||
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/)
|
||||
to create an `influx` CLI config and set it as active:
|
||||
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG|http://localhost:8086|CONFIG_NAME" %}}
|
||||
```sh
|
||||
influx config create --config-name <config-name> \
|
||||
influx config create --config-name CONFIG_NAME \
|
||||
--host-url http://localhost:8086 \
|
||||
--org <your-org> \
|
||||
--token <your-auth-token> \
|
||||
--org ORG \
|
||||
--token API_TOKEN \
|
||||
--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
|
||||
[`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
|
||||
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.
|
||||
|
||||
{{% code-placeholders "API_TOKEN|ORG|http://localhost:8086|CONFIG_NAME|USERNAME|PASSWORD" %}}
|
||||
```sh
|
||||
influx config create \
|
||||
-n config-name \
|
||||
-n CONFIG_NAME \
|
||||
-u http://localhost:8086 \
|
||||
-p example-user:example-password \
|
||||
-o example-org
|
||||
-p USERNAME:PASSWORD \
|
||||
-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 %}}
|
||||
|
||||
|
@ -259,4 +320,4 @@ To install `influx` shell completion scripts, see
|
|||
|
||||
## Use influx CLI commands
|
||||
_For information about `influx` CLI commands, see the
|
||||
[`influx` CLI reference documentation](/influxdb/v2/reference/cli/influx/)._
|
||||
[`influx` CLI reference documentation](/influxdb/v2/reference/cli/influx/)._
|
15
test.sh
15
test.sh
|
@ -30,7 +30,7 @@ rm -rf "$target"/*
|
|||
# Check if the user provided a path to copy.
|
||||
if [ -z "$paths" ]; then
|
||||
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$')
|
||||
else
|
||||
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.
|
||||
echo "$paths" >> "$testrun"
|
||||
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
|
|
@ -1,7 +1,9 @@
|
|||
/target
|
||||
/Cargo.lock
|
||||
content
|
||||
node_modules
|
||||
tmp
|
||||
.env*
|
||||
.pytest_cache
|
||||
.test-run.txt
|
||||
tmp
|
||||
parse_yaml.sh
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
## Code sample dependencies
|
||||
# Temporary fork for passing headers in query options.
|
||||
influxdb3-python @ git+https://github.com/jstirnaman/influxdb3-python@4abd41c710e79f85333ba81258b10daff54d05b0
|
||||
influxdb3-python
|
||||
pandas
|
||||
## Tabulate for printing pandas DataFrames.
|
||||
tabulate
|
||||
|
|
|
@ -1,10 +1,44 @@
|
|||
#!/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
|
||||
if [ -f "$file" ]; then
|
||||
echo "PROCESSING $file"
|
||||
|
||||
# Replace placeholder values with environment variables.
|
||||
# Replaces placeholder values with environment variable references.
|
||||
|
||||
# Non-language-specific replacements.
|
||||
sed -i 's|https:\/\/{{< influxdb/host >}}|$INFLUX_HOST|g;
|
||||
' $file
|
||||
|
@ -23,13 +57,40 @@ for file in `find . -type f` ; do
|
|||
# Shell-specific replacements.
|
||||
sed -i 's/API_TOKEN/$INFLUX_TOKEN/g;
|
||||
s/ORG_ID/$INFLUX_ORG/g;
|
||||
s/ORG/$INFLUX_ORG/g;
|
||||
s/DATABASE_TOKEN/$INFLUX_TOKEN/g;
|
||||
s/BUCKET_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
|
||||
fi
|
||||
cat $file
|
||||
if [ $verbose -eq 1 ]; then
|
||||
echo "FILE CONTENTS:"
|
||||
cat $file
|
||||
fi
|
||||
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 "$@"
|
Loading…
Reference in New Issue