0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-11-18 07:40:53 +01:00
dendrite/.github
kegsay ea92f80c12
Add database namespacing for unit tests (#2340)
* Add database namespacing for unit tests

Background: Running `go test ./...` will run tests in different packages concurrently.
This can be stopped or limited by using `-p 1` (no concurrency). We want concurrency,
but this causes problems when running Postgres DBs in CI. The problem is that, in CI,
we have 1x postgres server exposing 1x postgres DB, which we wipe clean at the end of
each test via `defer close()`. When tests run concurrently, calls to `close()` will
delete data/tables which other tests are currently using, causing havoc.

Fix this by:
 - Creating a database per package.
 - Namespacing the database name by a hash of the current working directory (the directory containing those `_test.go` files)

This is exactly what SQLite does, quite unintentionally, via the use of `file:dendrite_test.db`,
which dumps the file into the current working directory which is the package running the tests,
hence deleting the file is safe when running concurrently.

* Linting

* Don't create the database in a txn

* dupe db is not an error
2022-04-11 10:23:01 +01:00
..
ISSUE_TEMPLATE Expand issue template (#2103) 2022-01-21 16:24:31 +00:00
workflows Add database namespacing for unit tests (#2340) 2022-04-11 10:23:01 +01:00
CODEOWNERS Set @matrix-org/dendrite-core as repository code owner 2021-12-09 13:29:49 +00:00
FUNDING.yml Create FUNDING.yml 2020-07-15 11:30:32 +01:00
PULL_REQUEST_TEMPLATE.md Update PR template (#2294) 2022-03-23 11:41:48 +00:00