docs-v2/test.Dockerfile

78 lines
3.2 KiB
Plaintext
Raw Normal View History

5156 Writes: add v1 to Serverless get-started (#5233) * chore(ci): Install Telegraf to test container * chore(v3): test telegraf config and startup: - creates the config file for the test run. TODO: remove the duplication and use the content for test setup. - fix placeholder name * fix(v3): make test pass for curl API example * chore(ci): make tests pass for write. Add dependencies to Dockerfile. * chore(tests): update test build - Compose metadata: Add profile to test service. We can decouple services later and apply the profile to each. Rename. Pass the image name to the container. - Fetch the parse_yaml.sh script during docker build, so we only fetch when necessary. Track the script in git. This is still a little janky, but better. - test.sh: Use `HEAD` for diff (duh). Go back to using docker compose up so we're rebuilding only as needed and reusing the container - much faster, but the output isn't as pretty as `run`. - pytest.ini, requirements.txt: Use pytest-dotenv to load env.products variables. * fix(write): update JS instructions and pass tests. * chore(ci): Install influx v2 CLI into the Docker test container. * chore(ci): move .env file loading to pytest and run product tests separately with the proper .env file: - Moves .env configs to be loaded by the test runner instead of by Docker. I'd prefer to ignore any product divergence and have them run interchangeably, but the pros outweigh the cons for now. - Add example for passing custom commands in the compose file. * fix(v3): replace curl example with v1 and v2, simplify JS example, pass tests. feat(v3): add v1 write, test, update text: - adds Serverless v1 /write example with note about autogen behavior - adds link from v1 examples to Migrate guide - adds description of autogen behavior to v1-compat guide - updates "powered by..." text - adapts examples to make them more testable, asserts `/write` status code - replace "shared" examples (only used once) with inline to make them testable fix(v3): promote migrate link * Update content/influxdb/cloud-dedicated/get-started/write.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * chore(v3): Write: fix wording for curl success (#5156) --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2023-11-15 20:41:29 +00:00
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/
FROM python:3.12.0-slim-bookworm
RUN apt-get update && apt-get install -y \
curl \
git \
golang \
gpg \
maven \
nodejs \
npm \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
ARG SOURCE_DIR
COPY test ./test
COPY data ./test/data
RUN chmod -R 755 .
# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1
WORKDIR /usr/src/app/test
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
# this layer.
RUN --mount=type=cache,target=/root/.cache/pip \
--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
# Install parse_yaml.sh and parse YAML config files into dotenv files to be used by tests.
RUN /bin/bash -c 'curl -sO https://raw.githubusercontent.com/mrbaseman/parse_yaml/master/src/parse_yaml.sh'
RUN /bin/bash -c 'source ./parse_yaml.sh && parse_yaml ./data/products.yml > .env.products'
# Install Telegraf for use in tests.
# Follow the install instructions (https://docs.influxdata.com/telegraf/v1/install/?t=curl), except for sudo (which isn't available in Docker).
# influxdata-archive_compat.key GPG Fingerprint: 9D539D90D3328DC7D6C8D3B9D8FF8E1F7DF8B07E
RUN curl -s https://repos.influxdata.com/influxdata-archive.key > influxdata-archive.key \
5156 Writes: add v1 to Serverless get-started (#5233) * chore(ci): Install Telegraf to test container * chore(v3): test telegraf config and startup: - creates the config file for the test run. TODO: remove the duplication and use the content for test setup. - fix placeholder name * fix(v3): make test pass for curl API example * chore(ci): make tests pass for write. Add dependencies to Dockerfile. * chore(tests): update test build - Compose metadata: Add profile to test service. We can decouple services later and apply the profile to each. Rename. Pass the image name to the container. - Fetch the parse_yaml.sh script during docker build, so we only fetch when necessary. Track the script in git. This is still a little janky, but better. - test.sh: Use `HEAD` for diff (duh). Go back to using docker compose up so we're rebuilding only as needed and reusing the container - much faster, but the output isn't as pretty as `run`. - pytest.ini, requirements.txt: Use pytest-dotenv to load env.products variables. * fix(write): update JS instructions and pass tests. * chore(ci): Install influx v2 CLI into the Docker test container. * chore(ci): move .env file loading to pytest and run product tests separately with the proper .env file: - Moves .env configs to be loaded by the test runner instead of by Docker. I'd prefer to ignore any product divergence and have them run interchangeably, but the pros outweigh the cons for now. - Add example for passing custom commands in the compose file. * fix(v3): replace curl example with v1 and v2, simplify JS example, pass tests. feat(v3): add v1 write, test, update text: - adds Serverless v1 /write example with note about autogen behavior - adds link from v1 examples to Migrate guide - adds description of autogen behavior to v1-compat guide - updates "powered by..." text - adapts examples to make them more testable, asserts `/write` status code - replace "shared" examples (only used once) with inline to make them testable fix(v3): promote migrate link * Update content/influxdb/cloud-dedicated/get-started/write.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * chore(v3): Write: fix wording for curl success (#5156) --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2023-11-15 20:41:29 +00:00
&& \
echo '943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key' | sha256sum -c && cat influxdata-archive.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null \
5156 Writes: add v1 to Serverless get-started (#5233) * chore(ci): Install Telegraf to test container * chore(v3): test telegraf config and startup: - creates the config file for the test run. TODO: remove the duplication and use the content for test setup. - fix placeholder name * fix(v3): make test pass for curl API example * chore(ci): make tests pass for write. Add dependencies to Dockerfile. * chore(tests): update test build - Compose metadata: Add profile to test service. We can decouple services later and apply the profile to each. Rename. Pass the image name to the container. - Fetch the parse_yaml.sh script during docker build, so we only fetch when necessary. Track the script in git. This is still a little janky, but better. - test.sh: Use `HEAD` for diff (duh). Go back to using docker compose up so we're rebuilding only as needed and reusing the container - much faster, but the output isn't as pretty as `run`. - pytest.ini, requirements.txt: Use pytest-dotenv to load env.products variables. * fix(write): update JS instructions and pass tests. * chore(ci): Install influx v2 CLI into the Docker test container. * chore(ci): move .env file loading to pytest and run product tests separately with the proper .env file: - Moves .env configs to be loaded by the test runner instead of by Docker. I'd prefer to ignore any product divergence and have them run interchangeably, but the pros outweigh the cons for now. - Add example for passing custom commands in the compose file. * fix(v3): replace curl example with v1 and v2, simplify JS example, pass tests. feat(v3): add v1 write, test, update text: - adds Serverless v1 /write example with note about autogen behavior - adds link from v1 examples to Migrate guide - adds description of autogen behavior to v1-compat guide - updates "powered by..." text - adapts examples to make them more testable, asserts `/write` status code - replace "shared" examples (only used once) with inline to make them testable fix(v3): promote migrate link * Update content/influxdb/cloud-dedicated/get-started/write.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * chore(v3): Write: fix wording for curl success (#5156) --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2023-11-15 20:41:29 +00:00
&& \
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list \
5156 Writes: add v1 to Serverless get-started (#5233) * chore(ci): Install Telegraf to test container * chore(v3): test telegraf config and startup: - creates the config file for the test run. TODO: remove the duplication and use the content for test setup. - fix placeholder name * fix(v3): make test pass for curl API example * chore(ci): make tests pass for write. Add dependencies to Dockerfile. * chore(tests): update test build - Compose metadata: Add profile to test service. We can decouple services later and apply the profile to each. Rename. Pass the image name to the container. - Fetch the parse_yaml.sh script during docker build, so we only fetch when necessary. Track the script in git. This is still a little janky, but better. - test.sh: Use `HEAD` for diff (duh). Go back to using docker compose up so we're rebuilding only as needed and reusing the container - much faster, but the output isn't as pretty as `run`. - pytest.ini, requirements.txt: Use pytest-dotenv to load env.products variables. * fix(write): update JS instructions and pass tests. * chore(ci): Install influx v2 CLI into the Docker test container. * chore(ci): move .env file loading to pytest and run product tests separately with the proper .env file: - Moves .env configs to be loaded by the test runner instead of by Docker. I'd prefer to ignore any product divergence and have them run interchangeably, but the pros outweigh the cons for now. - Add example for passing custom commands in the compose file. * fix(v3): replace curl example with v1 and v2, simplify JS example, pass tests. feat(v3): add v1 write, test, update text: - adds Serverless v1 /write example with note about autogen behavior - adds link from v1 examples to Migrate guide - adds description of autogen behavior to v1-compat guide - updates "powered by..." text - adapts examples to make them more testable, asserts `/write` status code - replace "shared" examples (only used once) with inline to make them testable fix(v3): promote migrate link * Update content/influxdb/cloud-dedicated/get-started/write.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * chore(v3): Write: fix wording for curl success (#5156) --------- Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>
2023-11-15 20:41:29 +00:00
&& \
apt-get update && apt-get install telegraf
# Install influx v2 Cloud CLI for use in tests.
# Follow the install instructions(https://portal.influxdata.com/downloads/), except for sudo (which isn't available in Docker).
# influxdata-archive_compat.key GPG fingerprint:
# 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E
RUN wget -q https://repos.influxdata.com/influxdata-archive_compat.key \
&& \
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null \
&& \
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list \
&& \
apt-get update && apt-get install influxdb2-cli
ENV TEMP_DIR=/usr/src/app/test/tmp
ENTRYPOINT [ "run-tests.sh" ]
CMD [""]