✅ back: diagnostics e2e adding aggregate failure result (#762)
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import diagnostics from "../../../framework/api/diagnostics";
|
||||
|
||||
export const e2eTestOverride = {
|
||||
// Set to true to force fail to test diagnostic aggregation
|
||||
forceFail: false,
|
||||
};
|
||||
|
||||
export default () =>
|
||||
diagnostics.registerProviders({
|
||||
key: "process",
|
||||
tags: ["live", "ready"],
|
||||
async get() {
|
||||
return {
|
||||
ok: true,
|
||||
ok: !e2eTestOverride.forceFail,
|
||||
gc: !!global.gc,
|
||||
pid: process.pid,
|
||||
mem: process.memoryUsage(),
|
||||
|
||||
@@ -2,6 +2,7 @@ import "reflect-metadata";
|
||||
import { afterAll, beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||
import { init, TestPlatform } from "../setup";
|
||||
import { getConfig as getDiagnosticsConfig } from "../../../src/core/platform/framework/api/diagnostics";
|
||||
import { e2eTestOverride as processDiagnosticProviderE2EOverride } from "../../../src/core/platform/services/diagnostics/providers/process";
|
||||
|
||||
describe("The diagnostics infrastucture", () => {
|
||||
let platform: TestPlatform;
|
||||
@@ -48,4 +49,15 @@ describe("The diagnostics infrastucture", () => {
|
||||
expect(result.statusCode).toBe(200);
|
||||
expect(result.json().ok).toBe(true);
|
||||
});
|
||||
|
||||
it("should aggregate failure", async () => {
|
||||
try {
|
||||
processDiagnosticProviderE2EOverride.forceFail = true;
|
||||
const result = await getDiagnosticTags("ready", diagnosticConfig.probeSecret!);
|
||||
expect(result.statusCode).toBe(503);
|
||||
expect(result.json().ok).toBe(false);
|
||||
} finally {
|
||||
processDiagnosticProviderE2EOverride.forceFail = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user