back: very basic e2e for diagnostics (#762)

This commit is contained in:
Eric Doughty-Papassideris
2024-12-08 22:53:43 +01:00
parent 7c0f359759
commit dab4d0e3ff
3 changed files with 55 additions and 0 deletions
@@ -0,0 +1,51 @@
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";
describe("The diagnostics infrastucture", () => {
let platform: TestPlatform;
const diagnosticConfig = getDiagnosticsConfig();
beforeEach(async () => {
platform = await init({
services: [
"webserver",
"database",
"applications",
"search",
"storage",
"diagnostics",
"message-queue",
"user",
"files",
"auth",
"statistics",
"platform-services",
"documents",
],
});
});
afterAll(async () => {
await platform?.tearDown();
// @ts-ignore
platform = null;
});
const getDiagnosticTags = (tag: string, secret: string) =>
platform.app.inject({
method: "GET",
url: `/api/diagnostics/t/${encodeURIComponent(tag)}?secret=${encodeURIComponent(secret)}`,
});
it("should refuse invalid probe secrets", async () => {
const result = await getDiagnosticTags("ready", "ooooh look at me ! I'm like totally such an invalid probeSecret value");
expect(result.statusCode).toBe(403);
});
it("should at least report alive", async () => {
const result = await getDiagnosticTags("ready", diagnosticConfig.probeSecret!);
expect(result.statusCode).toBe(200);
expect(result.json().ok).toBe(true);
});
});
@@ -68,6 +68,8 @@ services:
- SEARCH_OS_PASSWORD=admin - SEARCH_OS_PASSWORD=admin
- SEARCH_OS_USE_AUTH=true - SEARCH_OS_USE_AUTH=true
- SEARCH_OS_USERNAME=admin - SEARCH_OS_USERNAME=admin
- DIAG_PROBE_SECRET=super_diagnostic_probe_secret
- DIAG_SECRET=super_diagnostic_secret
depends_on: depends_on:
- postgres - postgres
- opensearch-node1 - opensearch-node1
+2
View File
@@ -84,6 +84,8 @@ services:
- STORAGE_S3_ENDPOINT=minio - STORAGE_S3_ENDPOINT=minio
- STORAGE_S3_ACCESS_KEY=admin - STORAGE_S3_ACCESS_KEY=admin
- STORAGE_S3_SECRET_KEY=adminminio - STORAGE_S3_SECRET_KEY=adminminio
- DIAG_PROBE_SECRET=super_diagnostic_probe_secret
- DIAG_SECRET=super_diagnostic_secret
depends_on: depends_on:
minio: minio:
condition: service_healthy condition: service_healthy