Why not copy production to the tests
A copy of the production database contains first and last names, card numbers, qualifications and, sometimes, health data. A test environment usually has weaker protection than production: broader access, no monitoring, default passwords. That is a bad combination from the point of view of GDPR and the principle of data minimisation.
An integrator working on a plant installation does not need real people to test a webhook, a printout or a login. It needs a working system that behaves like production but contains artificial data.
One command on a fresh clone
The local stack of the system starts with a single docker compose command on a fresh clone, without a database dump and without files from other people. The JWT keys, the TLS certificate and the Firebase data are generated at start. There is no need to ask anyone to send files with secrets, which is a security benefit in itself.
The stack consists of a TLS-terminating reverse proxy, a PHP 8.4 application with Apache, a MySQL 8.0 database, an S3-compatible object store, Redis, a mail catcher, a PDF generation service and a .NET helper service. The data sits in named volumes.
Personal data in the test environment
The database comes from the migration chain, not from an SQL dump
A new installation receives its database exclusively from the migration chain, without an SQL dump. The starting data, meaning companies, the service account and the facility, is created by a separate init command rather than by the migrations. As a result the schema always matches the code, and the test data is clearly separated from the structure.
A CI job runs the whole migration chain on an empty database on every change and requires the database to match the code. Earlier the chain broke at the seventh migration of a fresh database, which surfaced only when someone tried such a start. Now every change is checked along the same path the integrator will take.
How long it takes: the start time of a clean environment
A clean environment started from an empty database to a working login took about 8 minutes in the test, mainly because of running 380 migrations. The test ended with a correct login and the issue of a JWT token. For the integrator this means a new test environment can be set up during one coffee break, not during a working day.
The time depends on the machine and the disk, so on your own hardware it is worth measuring it once and recording the result.
Artificial data: how to test without real people
After the start the init command creates the companies, the service account and the facility. The integrator adds the rest of the test data: a few accounts with artificial names, a few permits, a few events from the KD system sent to the webhook. The rule: no names or card numbers of real employees, even of those whose owners have agreed.
Such an environment is a good place to test the integration with the plant's KD system, because it does not endanger production and it can be deleted with one command.
Checklist
Video
Frequently asked questions
Do I need a production dump for testing?
No. A new installation receives its database from the migration chain, and the init command creates the starting data. You add the test data yourself, in an artificial form.
How long does the start take?
In the test, the start from an empty database to a working login took about 8 minutes, mainly because of running 380 migrations.
Where do the environment's keys and certificates come from?
The JWT keys, the TLS certificate and the Firebase data are generated at start, so there is no need to send them anywhere.
Does such an environment replace preproduction?
No. The local environment serves the integrator for tests, while the plant's twin preproduction serves for trying updates and restoring backups.
Sources
Let's set up the test environment together
We will show the integrator and the plant's IT team the start of a clean environment from an empty database and a test of the webhook from your KD system.
Let's talk