aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-04-11 10:23:01 +0100
committerGitHub <noreply@github.com>2022-04-11 10:23:01 +0100
commitea92f80c128bcff0fd4e02df40b272f7d90a97da (patch)
tree18882388247345842a9fcec75d421a6e6df7c586 /.github
parent69f2ff7c82abe0731a05febde88098f4cd34ab8d (diff)
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
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/dendrite.yml2
1 files changed, 1 insertions, 1 deletions
diff --git a/.github/workflows/dendrite.yml b/.github/workflows/dendrite.yml
index 8221bff9..4f337a86 100644
--- a/.github/workflows/dendrite.yml
+++ b/.github/workflows/dendrite.yml
@@ -111,7 +111,7 @@ jobs:
key: ${{ runner.os }}-go${{ matrix.go }}-test-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go }}-test-
- - run: go test -p 1 ./...
+ - run: go test ./...
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres