Skip to content

Commit

Permalink
Adds testing infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-russell committed Feb 23, 2024
1 parent 4a139ca commit de1a1f8
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# syntax=docker/dockerfile:1
FROM python:3.11.4

ENV PYTHONUNBUFFERED=1
ENV PYTHON_BIN=python

WORKDIR /code

# install system dependencies
RUN apt update && apt install git -y

# cleanup apt cache
RUN rm -rf /var/lib/apt/lists/*

COPY test-config /test-config
COPY fractal /code/fractal
COPY pyproject.toml README.md /code/
COPY tests /code/tests

COPY .coveragerc conftest.py /code/

# install modules
RUN pip3 install -e /code[dev]

ENTRYPOINT [ "/test-config/entrypoint.sh" ]
37 changes: 37 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
services:
synapse:
image: fractal-matrix-client-synapse:latest
build:
context: ./synapse/config
dockerfile: Dockerfile.synapse
args:
SYNAPSE_SERVER_NAME: "localhost"
SYNAPSE_REPORT_STATS: "no"
healthcheck:
test: curl localhost:8008/health
interval: 1s
timeout: 10s
retries: 10
labels:
- "org.homeserver.test=true"
# --timeout on up doesn't work with --exit-code-from. This ensures the synapse
# container is stopped immediately when the device exits
stop_signal: SIGKILL
test:
image: fractal-matrix-client-test:test
build:
context: ./
dockerfile: Dockerfile.test
depends_on:
synapse:
condition: service_healthy
environment:
ENV: test
TEST_CONFIG_DIR: /test-config
TEST_HOMESERVER_URL: http://synapse:8008
# not actually running a second synapse currently
TEST_ALTERNATE_HOMESERVER_URL: https://synapse2:8008
SYNAPSE_DOCKER_LABEL: "org.homeserver.test=true"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
working_dir: /code
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ sh = "^2.0.6"
aiofiles = "^23.1.0"
PyYAML = "^6.0.1"
docker = "^6.1.3"
pytest = { version = "^7.4.3", optional = true }
pytest-asyncio = { version = "^0.21.1", optional = true }
pytest-cov = { version = "^4.1.0", optional = true }
pytest-mock = { version = "^3.11.1", optional = true }
aioresponses = {version = "^0.7.6", optional = true}
ipython = { version = "^8.17.2", optional = true }


[tool.poetry.extras]
dev = ["pytest-django", "pytest", "pytest-cov", "pytest-mock", "pytest-asyncio", "ipython"]

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit de1a1f8

Please sign in to comment.