-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Containerize integration tests. (#809)
This adds the needed files to containerize the integration tests. It can be run as follows: `docker compose -f tests/integration/docker-compose.yml run -it integration-tests`. Fixes: [SYNC-4118](https://mozilla-hub.atlassian.net/browse/SYNC-4118) [SYNC-4118]: https://mozilla-hub.atlassian.net/browse/SYNC-4118?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
Showing
5 changed files
with
134 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
FROM python:3.12-slim-bookworm | ||
|
||
LABEL org.opencontainers.image.authors="[email protected]" | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
ENV PATH=$PATH:/root/.cargo/bin | ||
ENV PYTHON_VENV=/venv | ||
ENV PYTEST_ARGS="" | ||
ENV RUST_LOG="autopush=debug,autopush_common=debug,autoendpoint=debug,autoconnect=debug,slog_mozlog_json=info,warn" | ||
ENV DB_DSN=grpc://localhost:8086 | ||
|
||
# Add gcc since there are no wheels for some packages for arm64/aarch64 | ||
# (g++/make for gevent on pypy) | ||
RUN apt-get update && apt install -y --no-install-recommends \ | ||
git \ | ||
gpg \ | ||
build-essential \ | ||
python3-dev \ | ||
curl \ | ||
libstdc++6 \ | ||
libstdc++-12-dev \ | ||
libssl-dev \ | ||
pkg-config \ | ||
cmake | ||
|
||
RUN python -m venv ${PYTHON_VENV} | ||
ENV PATH="${PYTHON_VENV}/bin:${PATH}" | ||
|
||
RUN python -m pip install --upgrade pip | ||
|
||
# Install Rust | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.81 -y | ||
RUN rustc --version | ||
|
||
# Setup poetry and install requirements | ||
ENV POETRY_VIRTUALENVS_CREATE=false \ | ||
POETRY_VERSION=1.7.0 | ||
RUN python -m pip install --no-cache-dir --quiet poetry | ||
COPY ./tests/pyproject.toml ./tests/poetry.lock ./ | ||
RUN poetry install --only=integration --no-interaction --no-ansi | ||
|
||
# Setup cloud big table | ||
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg | ||
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | ||
RUN apt-get update -y && apt install google-cloud-cli-cbt -y | ||
|
||
COPY . /code | ||
|
||
WORKDIR /code | ||
|
||
# Build app | ||
RUN cargo build --features=emulator | ||
|
||
RUN chmod +x scripts/setup_bt.sh | ||
|
||
CMD ["sh", "-c", "./scripts/setup_bt.sh && poetry run pytest tests/integration/test_integration_all_rust.py --junit-xml=integration_test_results.xml -v -m 'not stub' ${PYTEST_ARGS}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
services: | ||
google_cbt: | ||
image: google/cloud-sdk:latest | ||
network_mode: host | ||
platform: linux/amd64 | ||
command: gcloud beta emulators bigtable start --host-port=localhost:8086 | ||
tests: | ||
environment: | ||
- BIGTABLE_EMULATOR_HOST=localhost:8086 | ||
- DB_DSN=grpc://localhost:8086 | ||
build: | ||
context: ../.. | ||
dockerfile: tests/integration/Dockerfile | ||
depends_on: | ||
- google_cbt | ||
network_mode: host | ||
platform: linux/amd64 |