chore(tests): performance improvements for backend tests
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (javascript) (push) Has been cancelled
Run tests & build / Test and build with NodeJS 24 (push) Has been cancelled

The backend end-to-end tests run with many parallel workers that
each start a full NestJS application including database connection
pools, HTTP server and so on. This can easily result in performance
bottlenecks - which is even the reason why we added the --runInBand
option for the CI. The performance can be improved by constraining
the number of workers and memory allocated per worker in our jest
config. Furthermore, we can forcefully close open HTTP connections
in the test cleanup. This terminates connections with a keepalive
flag, that would persist for a while longer otherwise. The following
`this.app.close()` waits for keepalive requests, so this reduces the
wait time.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson
2026-04-13 17:51:08 +02:00
committed by Philip Molares
parent 8d0e89f49f
commit 95f28442c3
2 changed files with 4 additions and 1 deletions
+3 -1
View File
@@ -19,5 +19,7 @@
},
"coverageDirectory": "./coverage-e2e",
"testTimeout": 15000,
"reporters": ["default", "github-actions"]
"reporters": ["default", "github-actions"],
"maxWorkers": 4,
"workerIdleMemoryLimit": "1GB"
}
+1
View File
@@ -150,6 +150,7 @@ export class TestSetup {
* Cleans up Fastify, NestJS, and the database from a test run.
*/
public async cleanup(): Promise<void> {
this.app.getHttpServer().closeAllConnections();
await this.app.close();
if (this.knexInstance) {
await this.knexInstance.destroy();