forked from mtusi2026/mtusi2026lab7
110 lines
3.6 KiB
TypeScript
110 lines
3.6 KiB
TypeScript
import { test, expect } from "bun:test";
|
|
import { manifest, gatewayConfigs } from "../scripts/topology";
|
|
test("telemetry storage is a single OpenObserve instead of Prometheus Loki Tempo and their gateways", () => {
|
|
const services = manifest().services;
|
|
expect(services.openobserve).toBeDefined();
|
|
for (const name of [
|
|
"prometheus",
|
|
"loki",
|
|
"tempo",
|
|
"prometheus-gateway",
|
|
"loki-gateway",
|
|
"tempo-gateway",
|
|
])
|
|
expect(services[name]).toBeUndefined();
|
|
});
|
|
test("OpenObserve has its own persistent data and a closed private gateway namespace", () => {
|
|
const service = manifest().services.openobserve;
|
|
expect(service).toBeDefined();
|
|
expect(service.network_mode).toBe("service:openobserve-gateway");
|
|
expect(service.ports).toBeUndefined();
|
|
expect(
|
|
service.volumes.some(
|
|
(mount: any) =>
|
|
mount.source === "./.local/data/openobserve" &&
|
|
mount.target === "/data" &&
|
|
!mount.read_only,
|
|
),
|
|
).toBe(true);
|
|
});
|
|
test("storage migration retains required neighbors and existing app OTLP contract without OpenObserve secrets", () => {
|
|
const services = manifest().services;
|
|
for (const name of [
|
|
"api1",
|
|
"api2",
|
|
"worker",
|
|
"postgres",
|
|
"broker",
|
|
"s3",
|
|
"collector",
|
|
"grafana",
|
|
"openbao",
|
|
])
|
|
expect(services[name]).toBeDefined();
|
|
for (const name of ["api1", "api2", "worker"]) {
|
|
expect(services[name].environment.OTEL_EXPORTER_OTLP_ENDPOINT).toBe(
|
|
"http://127.0.0.1:14318",
|
|
);
|
|
expect(
|
|
JSON.stringify({
|
|
environment: services[name].environment,
|
|
volumes: services[name].volumes,
|
|
})
|
|
.toLowerCase()
|
|
.includes("openobserve"),
|
|
).toBe(false);
|
|
}
|
|
});
|
|
test("Collector and Grafana storage transport targets OpenObserve through the verified gateway", () => {
|
|
const configs = gatewayConfigs();
|
|
for (const name of ["collector-gateway", "grafana"]) {
|
|
expect(configs[name]).toContain("openobserve-gateway:");
|
|
for (const old of [
|
|
"prometheus-gateway:",
|
|
"loki-gateway:",
|
|
"tempo-gateway:",
|
|
])
|
|
expect(configs[name]).not.toContain(old);
|
|
}
|
|
});
|
|
test("Grafana query gateway permits actual editor metadata and guards native request fields", () => {
|
|
const query = gatewayConfigs()["openobserve-gateway"];
|
|
for (const path of [
|
|
"/api/organizations",
|
|
"/api/default/messenger/_values",
|
|
"/api/default/streams/",
|
|
])
|
|
expect(query).toContain(path);
|
|
expect(query).toContain("req.body_len gt 65536");
|
|
expect(query).toContain("acl duplicate_query query,url_dec");
|
|
expect(query).toContain("var(txn.window_s) -m int 1:3599");
|
|
});
|
|
|
|
test("Grafana can use an own verified immutable cache alias without changing the canonical image pin", () => {
|
|
expect(manifest().services.grafana.image).toBe(
|
|
"${VP7_GRAFANA_IMAGE:-grafana/grafana@sha256:1c88285f1dd391a62232c010e6c224846e6a73bdc583b3365be2eba614b7919e}",
|
|
);
|
|
});
|
|
|
|
test("Grafana uses its own file-delivered encryption key and secure HTTPS cookies", () => {
|
|
const service = manifest().services.grafana;
|
|
expect(service.environment.GF_SECURITY_SECRET_KEY__FILE).toBe(
|
|
"/run/admin/secret-key",
|
|
);
|
|
expect(service.environment.GF_SECURITY_COOKIE_SECURE).toBe("true");
|
|
expect(
|
|
service.volumes.some(
|
|
(mount: any) =>
|
|
mount.source === "./.local/operator/grafana-secret-key" &&
|
|
mount.target === "/run/admin/secret-key" &&
|
|
mount.read_only,
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
test("Grafana cannot fetch extra plugin packages outside the approved cached artifacts", () => {
|
|
expect(
|
|
manifest().services.grafana.environment.GF_PLUGINS_PREINSTALL_DISABLED,
|
|
).toBe("true");
|
|
});
|