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