Introducing a new way to review your PRs.

Read the announcement

frappe / frappe_docker

Docker environment for developing, deploying, and running Frappe applications (ERPNext and custom apps) in production and development

View on GitHub

15 documents · Updated Nov 23, 2026

docs / integration-test-suite

Integration test suite

The integration test suite checks Frappe Docker as a working group of containers. It starts Compose projects, creates sites against supported data stores, checks links between services, and verifies that users can reach Frappe through direct and proxied HTTP paths. See container stack architecture for the runtime model and repository quality automation for the wider check process.

Test environment

The test environment combines the base Frappe services with database, Redis, and proxy layers. The same service shape runs in local and CI environments, while CI replaces application images with images from its local registry.

Compose service model

The Compose project provides one application path from the proxy to the frontend and backend. The backend shares site data with the websocket, queue, and scheduler services. A configurator writes database and Redis settings before those services start.

flowchart LR
    Client[HTTP client] --> Proxy[Proxy]
    Proxy --> Frontend[Frontend]
    Frontend --> Backend[Backend]
    Frontend --> Websocket[Websocket]
    Backend --> Database[(Database)]
    Backend --> Cache[(Redis cache)]
    Backend --> Queue[(Redis queue)]
    Queue --> Workers[Queue workers]
    Scheduler[Scheduler] --> Queue
    Configurator[Configurator] --> Backend
    Configurator --> Database
    Configurator --> Cache
    Configurator --> Queue

References: compose.yaml• L9-18 compose.yaml• L19-96 overrides/compose.mariadb.yaml• L1-29 overrides/compose.redis.yaml• L1-21

Environment selection

The session fixture creates a temporary environment file from example.env. It adds the three test host names to the proxy rule and applies requested Frappe or ERPNext versions. It also binds HTTP and HTTPS to loopback and allows forwarded requests inside the controlled test network.

The Compose helper uses the test project name by default so cleanup does not affect another Compose project. In CI, it adds tests/compose.ci.yaml, which keeps the service layout but directs application services to registry images and selects a known image platform.

References: tests/conftest.py• L13-68 tests/utils.py• L19-46 tests/compose.ci.yaml• L1-28

Compose configuration coverage

The test configuration matrix defines the Compose combinations that the repository treats as supported deployment shapes. Each named configuration combines a base service set with a database choice and an optional proxy, TLS, migration, backup, or multi-bench layer. A shared environment block supplies the values needed to render these combinations with stable test inputs.

The matrix extends coverage beyond the default application path. It includes no-proxy database variants, Traefik and Nginx proxy modes, HTTP and HTTPS paths, scheduled backup and migration services, shared database use, standalone proxy stacks, multi-bench routing, and custom domains. See Compose service topology variants for the wider service shapes and configuration and environment inputs for the values that select them.

References: tests/compose-configs.json• L1-167

Test lifecycle

Pytest controls the environment through fixtures with different lifetimes. A session starts the default stack once, while scenario fixtures stop it and bring up the stack needed for ERPNext or PostgreSQL checks.

Stack startup and cleanup

The session setup first removes containers, volumes, and orphan services from the test project. It then starts the stack in detached mode and stops it after the session. Cleanup also removes resources introduced by the HTTPS override.

The Compose helper centralizes the project name, environment file, Compose files, non-interactive execution, and calls into the backend container for Bench commands. This makes tests check the running container system instead of calling host-side application code.

References: tests/conftest.py• L64-80 tests/utils.py• L22-71

Site creation

The default site fixture creates tests.localhost with MariaDB and then restarts the backend. A separate ERPNext fixture creates test-erpnext-site.localhost and installs ERPNext during site creation. A PostgreSQL fixture starts the PostgreSQL override and sets the database login used by the site creation check.

These site names also act as host names in HTTP requests. The proxy therefore tests both site routing and application behavior in the same request.

References: tests/conftest.py• L82-135 tests/test_frappe_docker.py• L59-75 tests/test_frappe_docker.py• L307-335

Connectivity checks

Connectivity checks validate the links that must work before an application request can succeed. They cover both raw service ports and Frappe operations that use the configured database and Redis services.

Database and Redis ports

Each backend-related container receives a small check script. The script reads the shared Frappe site configuration, extracts the database and Redis addresses, and waits until every distinct address accepts a connection. A five-second limit per address turns a missing service link into a failed test instead of an endless wait.

The check runs for the backend, both queue workers, and the scheduler. This matters because all four containers must resolve the same service links, not only the web request path.

References: tests/test_frappe_docker.py• L17-42 tests/_check_connections.py• L11-47

Frappe data and cache operations

The Frappe-level check connects to tests.localhost, reads a system settings record, and writes then reads a cache value. These actions prove that Frappe can use the database and Redis through its own configured clients. The check runs in the backend and in each queue or scheduler container after the site exists.

References: tests/test_frappe_docker.py• L123-136 tests/_ping_frappe_connections.py• L1-22

End-to-end assertions

End-to-end tests send requests through a published proxy and assert useful responses from a named site. The URL helper retries while the proxy or application is starting, and it accepts temporary 404, 502, or 503 responses during that wait.

HTTP endpoints and assets

The default site must return a non-error index page, a JSON response from the Frappe ping method, and a framework asset. The asset assertion skips versions that do not provide that asset. The ERPNext scenario adds an ERPNext API response and an ERPNext JavaScript asset to confirm that the installed app is available through the same route.

The request sends the site name in the Host header. This checks the proxy rule that maps a request to the correct Frappe site rather than checking only a container-local endpoint.

References: tests/utils.py• L74-116 tests/test_frappe_docker.py• L44-75 tests/test_frappe_docker.py• L307-323

File delivery and response headers

The suite copies a text file into the site's public files area and confirms that the file can be read through the proxy. It also serves HTML-like files and checks download and browser-safety headers. These checks cover the boundary between shared site files, frontend delivery, and HTTP response policy.

References: tests/test_frappe_docker.py• L79-121

Runtime tool availability

The suite checks that the backend image provides wkhtmltopdf when the test environment requires it. This protects document and page rendering paths that depend on the tool while allowing configurations that explicitly disable its installation.

References: tests/test_frappe_docker.py• L25-35

OAuth URL handling

The proxy checks preserve the public scheme and the full OAuth query when Frappe redirects a client to login. The helper follows the redirect response without following the redirect itself, then checks the login path, return URL host, scheme, path, and query values.

The checks cover direct frontend access with several forwarded-protocol policies. They also verify that an invalid proxy mode is rejected and that generated Compose JSON remains clean when Compose emits warnings on stderr.

References: tests/utils.py• L119-155 tests/test_frappe_docker.py• L158-245 tests/test_frappe_docker.py• L248-295

HTTPS and object storage backup

The HTTPS check adds the HTTPS override to the running project and confirms that the site remains reachable over TLS. The test client does not validate the test certificate, because the assertion targets routing and response behavior.

The backup check starts a SeaweedFS S3-compatible service on the Compose network. A backend-side readiness helper uses the S3 client to confirm that the endpoint and bucket are ready before the test creates a site backup with files. Restic then initializes a repository, uploads the backup, lists a snapshot, and checks the stored data. This verifies the path from a Frappe backup to an S3-style target.

References: tests/test_frappe_docker.py• L139-156 tests/test_frappe_docker.py• L297-305 tests/conftest.py• L138-201 tests/_wait_for_s3.py• L15-51

Database variants

The PostgreSQL scenario proves that the alternate database override can start and that Bench can create a PostgreSQL-backed site. The MariaDB path is exercised by the default site and remains the normal baseline for the other checks.

References: tests/conftest.py• L123-131 tests/test_frappe_docker.py• L325-335 overrides/compose.postgres.yaml• L1-23

Container runtime identity

The suite checks that the backend and frontend can start under the arbitrary user and group settings used by restricted container platforms. It confirms the expected runtime identity, shared write access for required paths, safe system-file permissions, and frontend configuration validity without starting dependent services.

References: tests/test_frappe_docker.py• L338-397

Public Nginx proxy

The Nginx proxy scenario runs a separate Compose project with its own database and proxy resources. It checks the public edge rather than only the internal frontend path, so protocol metadata from the client cannot override the scheme selected by the edge.

The scenario creates a short-lived certificate for the test host and checks both public HTTP and HTTPS. It verifies OAuth return URLs and login cookies. HTTP requests must produce HTTP return URLs and non-secure session cookies. HTTPS requests must produce HTTPS return URLs and secure session cookies even when clients send conflicting forwarded-protocol headers.

This diagram shows how the public edge controls protocol metadata before requests reach Frappe.

sequenceDiagram
    participant Client
    participant Nginx as Nginx proxy
    participant Frontend
    participant Frappe
    Client->>Nginx: HTTP or HTTPS request with protocol headers
    Nginx->>Frontend: Request with edge-selected scheme
    Frontend->>Frappe: Site request
    Frappe-->>Client: OAuth redirect or login cookie

References: tests/test_nginx_proxy.py• L15-131 tests/test_nginx_proxy.py• L134-201

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the site host names in the proxy rules aligned with the host names used by the site fixtures and HTTP requests.
  • Keep database and Redis service names aligned across Compose environment values, generated Frappe settings, and the port check script.
  • Keep the CI image override in step with every application service that the base Compose file starts, including its selected image platform.
  • Keep each named Compose configuration aligned with the override files and environment values that define the supported service shape.
  • If the shared site volume or backend path changes, update both container file-copy targets and the URL assertions that read those files.
  • If forwarded-protocol handling changes, keep the allowed proxy modes, trusted addresses, OAuth return schemes, and login-cookie security checks aligned.
  • If the public Nginx proxy stack changes, keep its site host, certificate mount, published ports, and cleanup project aligned.
  • If backup settings change, keep the S3 service network name, bucket name, endpoint, and Restic repository target compatible with the S3 setup.
  • If container user or group rules change, keep the backend path checks and frontend configuration check aligned with the supported restricted runtime.

Important failure modes

TriggerConsequenceGuard
A database or Redis service name differs from the generated Frappe configurationBackend-related containers cannot reach a required servicePort checks read the shared configuration and run in every backend-related container
A test site name is missing from the proxy host ruleRequests reach the proxy but do not route to the intended siteThe environment fixture builds the rule from the same set of test host names used by the fixtures
The application stack is not ready when an endpoint is checkedA temporary proxy or application response fails an end-to-end testURL checks retry and allow only the startup responses 404, 502, and 503
The CI override misses an application service or selects an incompatible platformCI starts a mixed image set or cannot run the selected imagetests/compose.ci.yaml overrides every application service and sets the test platform
A supported Compose combination is missing or lists the wrong overrideA deployment shape can lose coverage or start with the wrong service settests/compose-configs.json records named combinations and their Compose files
The HTTPS override or Nginx certificate mount is not applied to the active projectThe TLS request cannot reach the siteHTTPS scenarios apply the TLS override and provide a test certificate before the request
A client-supplied protocol header is trusted at the public edgeOAuth links or session cookies use the wrong schemePublic-edge checks send conflicting headers and assert the scheme and cookie flags
The S3 endpoint or bucket is not ready within the wait periodThe backup path cannot start its object-store checkThe readiness helper polls the bucket from the backend network and fails after 60 seconds
A restricted runtime cannot write to a required path or validate the frontend configurationThe image fails on platforms that assign an arbitrary userThe runtime identity test runs both container entry paths with the supported user and group

Key files

FileWhy to read it
tests/test_frappe_docker.pyShows the main service, endpoint, file, proxy, rendering-tool, backup, HTTPS, ERPNext, PostgreSQL, and restricted-runtime assertions.
tests/test_nginx_proxy.pyShows the separate public Nginx proxy lifecycle and HTTP/HTTPS protocol and cookie checks.
tests/conftest.pyDefines environment creation, Compose lifecycle, site setup, database variants, and the S3 test service.
tests/utils.pyDefines the Compose command boundary, startup retry behavior, and OAuth redirect assertions.
tests/compose-configs.jsonDefines the named Compose combinations and shared inputs used to describe configuration coverage.
compose.yamlDescribes the main application flow and the shared site data used by the test stack.
overrides/compose.mariadb.yamlDefines the default database service and its readiness contract.
overrides/compose.redis.yamlDefines the cache and queue services used by Frappe.
overrides/compose.postgres.yamlDefines the alternate database path covered by the PostgreSQL scenario.
tests/_check_connections.pyShows the raw port checks for database and Redis links.
tests/_ping_frappe_connections.pyShows the Frappe-level database and cache checks.
tests/_wait_for_s3.pyWaits for the S3-compatible endpoint and bucket from the backend network before backup assertions run.
tests/compose.ci.yamlMaps every application service to CI registry images and sets the image platform without changing the service topology.