Integration tests - Backend
What is the role of integration tests?
Integration tests verify the correctness of the main application scenarios. Thanks to these tests, Backend developers can be confident in changes to the codebase
WARNING
The test scenarios validate only the business logic; they do not attempt to verify how any specific API layer works
The tests talk to an already running Backend. Names of created entities contain a hash of PU_DOMAIN so that several instances do not collide. Starting the run from the Frontend and inspecting the log are described in the integration tests guide.
Run from the console
- Configure the Backend ENV variables, including the variables below
- Start the Backend using one of the commands below; the number of
workerscan be arbitrary:uvicorn app.main:app --host 0.0.0.0 --port 8555 --log-level info --workers 4 gunicorn app.main:app -b 0.0.0.0:8555 --workers=4 -k uvicorn.workers.UvicornWorker --log-level=info - Run integration tests:or directly:
make test-integrationuv run pytest tests -v
An Administrator can start the same run with the Integration Tests button on the Domain node or with the /control command in the Telegram Bot. The Backend creates an Operation Task and runs uv run pytest tests -v in the background.
Integration testing variables
| Variable | Default | Values | Purpose |
|---|---|---|---|
PU_TEST_INTEGRATION_CLEAR_DATA | True | True / False | Test data is always deleted at the start of a run. If True, the same cleanup runs at the end. If False, the data stays, the instance's own Instance is restored, and if Grafana is enabled a demo Dashboard test0_* is kept for manual debugging |
PU_TEST_INTEGRATION_GITHUB_PUBLIC_REPO_URL | https://github.com/w7a8n1y4a/github_unit_pub_test.git | http / https, not empty, ≤ 512 chars | Public GitHub test repository |
PU_TEST_INTEGRATION_GITLAB_PUBLIC_REPO_URL | https://git.pepemoss.com/pepe/pepeunit/units/gitlab_unit_pub_test.git | http / https, not empty, ≤ 512 chars | Public GitLab test repository |
PU_TEST_INTEGRATION_UNIVERSAL_REPO_URL | https://git.pepemoss.com/pepe/pepeunit/units/universal_test_unit.git | http / https, not empty, ≤ 512 chars | Universal test Unit |
WARNING
The PU_FF_* feature-flag set also affects coverage: scenarios for disabled features are removed from the run
WARNING
A run from the Frontend or the Telegram Bot creates an Operation Task: the full pytest log is written to result, and the public instance state updates the state.integration_tests_* fields in GET /pepeunit/api/v1/instances/current. The log can be attached to an issue