-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
49 additions
and
44 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
4 changes: 4 additions & 0 deletions
4
posts/standardized-health-checks/enums/resource-health.enum.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,4 @@ | ||
export enum ResourceHealth { | ||
'HEALTHY', | ||
'UNHEALTHY' | ||
} |
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
20 changes: 9 additions & 11 deletions
20
posts/standardized-health-checks/services/health-service.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
3 changes: 2 additions & 1 deletion
3
posts/standardized-health-checks/tests/health-check.integration.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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import axios from 'axios'; | ||
import { ResourceHealth } from '../enums/resource-health.enum'; | ||
|
||
// Service MUST be running! | ||
describe('Health Checks - Integration', () => { | ||
it('should return healthy if all downstream dependencies are healthy', async () => { | ||
const result = await axios.get('http://localhost:8080/health'); | ||
expect(result.status).toBe(200); | ||
expect(result.data.dependencies[0].status).toEqual('HEALTHY'); | ||
expect(result.data.dependencies[0].status).toEqual(ResourceHealth.HEALTHY); | ||
}); | ||
}); |
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
4 changes: 2 additions & 2 deletions
4
posts/standardized-health-checks/tests/mocks/mock-indicator.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
12 changes: 6 additions & 6 deletions
12
posts/standardized-health-checks/tests/mocks/mock-toggle-indicator.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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { HealthIndicator } from '../../health/health-indicator'; | ||
import { ResourceHealth } from '../../types/resource-health.type'; | ||
import { ResourceHealth } from '../../enums/resource-health.enum'; | ||
|
||
export class MockToggleIndicator extends HealthIndicator { | ||
name = 'Mock Toggle Indicator'; | ||
|
||
constructor(health?: ResourceHealth) { | ||
super(); | ||
this.status = health || 'HEALTHY'; | ||
this.status = health || ResourceHealth.HEALTHY; | ||
} | ||
|
||
checkHealth(): Promise<void> { | ||
this.status = this.status === 'HEALTHY' | ||
? 'UNHEALTHY' | ||
: 'HEALTHY'; | ||
this.status = this.status === ResourceHealth.HEALTHY | ||
? ResourceHealth.UNHEALTHY | ||
: ResourceHealth.HEALTHY; | ||
|
||
return new Promise((resolve) => { | ||
resolve(); | ||
}); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.