-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Introduce DB health check (#10661)
- Loading branch information
Showing
6 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/cli/test/integration/healthcheck.controller.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as testDb from './shared/test-db'; | ||
import { setupTestServer } from '@test-integration/utils'; | ||
|
||
const testServer = setupTestServer({ endpointGroups: ['health'] }); | ||
|
||
describe('HealthcheckController', () => { | ||
it('should return ok when DB is connected and migrated', async () => { | ||
const response = await testServer.restlessAgent.get('/healthz/readiness'); | ||
|
||
expect(response.statusCode).toBe(200); | ||
expect(response.body).toEqual({ status: 'ok' }); | ||
}); | ||
|
||
it('should return error when DB is not connected', async () => { | ||
await testDb.terminate(); | ||
|
||
const response = await testServer.restlessAgent.get('/healthz/readiness'); | ||
|
||
expect(response.statusCode).toBe(503); | ||
expect(response.body).toEqual({ status: 'error' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters