Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Containerize integration tests. #809

Merged
merged 6 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions tests/integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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
Trinaa marked this conversation as resolved.
Show resolved Hide resolved

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
Trinaa marked this conversation as resolved.
Show resolved Hide resolved
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 ${PYTEST_ARGS}"]
20 changes: 20 additions & 0 deletions tests/integration/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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
integration-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