Files
wekan/docs/Databases/FerretDB/1/Conformance.md
T
Lauri Ojansivu fea58e1312 Document which databases WeKan supports, and how each is tested.
docs/Databases/Supported.md is the one list: FerretDB v1 with SQLite (the
default everywhere), PostgreSQL (works), MySQL, MariaDB and SAP HANA
(experimental), FerretDB 2 (not tested), and MongoDB 6, 7, 8 and 9 - with
what checks each: the 110-query conformance catalogue answers the same on
all of them, and WeKan's own tests run on Meteor's bundled MongoDB 8 and on
FerretDB. It also says what to know about MongoDB versions: the Linux
kernel 6.19-7.0.13 refusal and its fixes, AVX, the driver, and upgrades.

The README and the Status section of CHANGELOG.md gain a Databases list,
docs/Databases/README.md links the page, the Meteor 2.14 compatibility guide
is marked historical, and the conformance page counts 110 cases and the
MongoDB backends. CLAUDE.md and AGENTS.md describe the new Status block.

Thanks to xet7 !
2026-10-10 19:07:14 +03:00

118 lines
5.7 KiB
Markdown

# Do all the backends answer the same?
FerretDB v1 translates one MongoDB query into five different SQL dialects, and
WeKan can also run on MongoDB itself (see [../../Supported.md](../../Supported.md)). That
`{n: {$gt: 5}}` *runs* on PostgreSQL, MySQL, MariaDB and SAP HANA says very
little; whether it returns **the same documents, in the same order** as on SQLite
is the question that decides whether a backend can be trusted with a board.
```sh
./build.sh # -> Tests -> All databases (sequential)
./releases/db-conformance.sh # the same thing, without the menu
```
`build.bat` has the same entry on Windows (it runs the same script through bash).
## What it does
1. **Builds FerretDB v1 from source.** If the `FerretDB` subdirectory is not
there it is cloned from `git@github.com:wekan/FerretDB` (falling back to
HTTPS), then updated, then built through its own `build.sh`, which installs
the Go toolchain and the module dependencies if they are missing. The tests
run against **that** binary — the newest code — not a downloaded release.
2. **Picks the databases this CPU can actually run.** `docker manifest inspect`
is asked whether the image has a build for this architecture, so the answer
stays true as images change. On amd64 and arm64 that is SQLite, PostgreSQL,
MySQL and MariaDB through FerretDB, and MongoDB 6, 7, 8 and 9; on ppc64le and
s390x, SQLite, PostgreSQL and MariaDB; on riscv64, SQLite and PostgreSQL.
MongoDB 7 is the `mongo:7` image of
[docker-compose-mongodb-v7.yml](../../../../docker-compose-mongodb-v7.yml);
6, 8 and 9 are `mongo:6.0`, `mongo:8.0` and `mongo:9.0`. On a Linux kernel
MongoDB refuses (6.19 to 7.0.13) its backend is a skip with the reason.
3. **Runs the query catalogue against each, one at a time.** Sequential on
purpose: they all use the same FerretDB port, and a database under test should
not be competing for CPU and disk with three others. MongoDB is queried
directly, with no FerretDB in between, so a fault every FerretDB backend
shares still shows up as a difference - the first such run found three, in
FerretDB's `$group`, `$min`/`$max` and capped collections.
4. **Compares the answers** against SQLite as the reference, and fails when any
database answers a case differently.
## What is asked
One catalogue of 110 cases in 15 groups, taken from FerretDB v1's own source
rather than from MongoDB's manual — the point is to cover what *this* FerretDB
implements:
- comparison, logical, element, evaluation, array, bitwise and nested-path
operators;
- projection (including `$slice` and `$elemMatch`), sorting, `skip`/`limit`;
- `count`, `distinct`;
- aggregation: `$match`, `$group` with every accumulator, `$project`,
`$addFields`, `$facet`, `$bucket`, `$lookup`, `$replaceRoot`, `$sortByCount`;
- every update operator, `findAndModify`, `replaceOne`, the delete commands;
- index creation, listing, uniqueness and dropping;
- capped collections — which is how the OpLog exists at all;
- `explain`, `collStats`, `dbStats`, `listCollections`, `buildInfo`.
The seed data is deliberately awkward: a null, a missing field, a negative
number, a zero, an empty array, an array of documents, mixed-case strings. Tidy
data lets a broken translation pass.
## What "the same" means
Answers are normalised — types spelled out, key order sorted — and compared byte
for byte, so **document order counts**: a sort that returns the right documents in
a different order is a difference, not a detail.
Three cases are compared more loosely, and they say so in the report: an `explain`
plan is a different plan on every engine (only its shape is compared), and
`collStats`/`dbStats` are sizes a different storage engine is entitled to answer
differently (they only have to answer). Everything else must match exactly.
Two backends failing the **same** way is agreement about a limitation, not a
difference. One answering where the other fails is a difference.
## Ports: it runs beside other tests, not instead of them
FerretDB listens on **37017** here, not 27017 — 27017 is where a dev server's
database lives and where the compose files publish FerretDB, so binding it would
either fail or, worse, point these tests at somebody else's database and rewrite
it. The database server it starts is published on **35432** rather than its usual
5432/3306. Both defaults move on if something is already listening, and both can
be set:
```sh
WEKAN_CONFORMANCE_PORT=47017 WEKAN_CONFORMANCE_DB_PORT=45432 ./releases/db-conformance.sh
```
Its containers are named per run (`wekan-conformance-db-<datetime>`), so a stack
started with `docker compose up` — whose containers are `wekan-postgres`,
`wekan-ferretdb` — is never stopped or reused by this.
## Where the results go
`../log/<datetime>/`, with every other WeKan test run:
| File | What is in it |
| --- | --- |
| `db-conformance-build.log` | Cloning, updating and building FerretDB |
| `db-conformance-<backend>.json` | Every answer that backend gave |
| `db-conformance-<backend>.log` | That backend's database and FerretDB output |
| `db-conformance-report.md` | Where they agree, and every case where they do not |
| `db-conformance-summary.txt` | One line per backend: ran, skipped, or why not |
The script exits non-zero when a backend disagrees with the reference.
## SAP HANA
Not run unless `WEKAN_CONFORMANCE_HANA=1` is set. Its image is amd64-only, wants
~16 GB of RAM and tens of GB of disk, and needs SAP's licence accepted — not
something to start because somebody picked a menu entry.
## See also
- [README.md](.) — the five backends and their compose files
- [Alternatives.md](Alternatives.md) — what other databases would need
- `tests/dbConformance/` — the catalogue, the runner and the comparison