Currently, when running the tests for my application each run a couple tests fail with the error
warning codes.vapor.application : [AppTests] PSQLError(code: server, serverInfo: [sqlState: 57P03, file: postmaster.c, line: 2334, message: the database system is starting up, routine: ProcessStartupPacket, localizedSeverity: FATAL, severity: FATAL])
Upon retry the specific tests always works. (Each run different tests fail)
I was able to reproduce this error by creating a new vapor application from the template with postgres and then just adding the following test:
func testGetExistingTodo() async throws {
let app = Application(.testing)
do {
defer { app.shutdown() }
try await configure(app)
try await app.autoMigrate()
let todo = Todo(title: UUID().uuidString)
try await todo.create(on: app.db)
try app.test(.GET, "todos") { res in
XCTAssertEqual(res.status, .ok)
XCTAssertContent(Array<Todo>.self, res) { content in
XCTAssert(content.contains { $0.id == todo.id! })
}
}
} catch {
app.logger.report(error: error)
throw error
}
}
If I now start the database in the docker compose file with docker compose up db and run the test repeatedly until failure (right click on the test diamond on the left in XCode) one in about five hundred tests fails with the above error message.
What can I do about this error? Maybe a postgres configuration, or another way to solve this? Should I create an issue on Github?
!