Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/frontend/platform-health-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ Rows expand from the health badge to show details.

Those details come from:

- informational row context: API URL, transport type, error/audit queue names, forward error messages setting, and error/audit retention periods (when available from instance configuration)
- informational row context: API URL, transport type, error/audit queue names, forward error messages setting, error/audit retention periods, and persistence type (when available from instance configuration)
- matching internal platform custom checks when available
- fallback page-specific messages when no custom-check detail is available

The information table shows the persistence type as reported by the API under the `Storage type` label. Primary and remote error instances use `storage.storage_type`; audit instances use the raw setting in `persistence.persistence_type`. Remote rows prefer `storage.storage_type` when both fields are present. Responses without a persistence type produce no persistence line. The platform model excludes `persistence_settings`, which can contain connection strings and certificate secrets. The support export includes only the mapped persistence type.

Built-in custom-check `healthDetails` can include both the failure summary and a `Reported at: <timestamp>` line.

## Severity Model
Expand Down Expand Up @@ -181,26 +183,26 @@ The support export includes both the current Platform health payload and the cur
| File | Type | Description |
|------|------|-------------|
| `src/Frontend/src/stores/PlatformHealthStore.spec.ts` | Component/unit | Platform health severity, row derivation, and internal check inference |
| `src/Frontend/src/stores/PlatformModelStore.spec.ts` | Unit | Mapping of ServiceControl configuration responses into platform instances |
| `src/Frontend/src/views/PlatformHealthView.spec.ts` | Component | Page rendering, upgrade cues, row expansion, and support modal behavior |
| `src/Frontend/test/mocks/platform-health-state.spec.ts` | Unit | Runtime mock helper behavior and custom-check preset switching |

### Running Automated Tests

Use the shared commands in `docs/frontend/testing-basics.md`, then run these Platform health-specific specs:

```bash
npx vitest run src/stores/PlatformHealthStore.spec.ts
npx vitest run src/stores/PlatformModelStore.spec.ts
npx vitest run src/views/PlatformHealthView.spec.ts
npx vitest run test/mocks/platform-health-state.spec.ts
```

### Test Coverage

| Area | Covered behavior |
|------|------------------|
| Platform health store | warning/danger severity, unavailable audit remotes, remote error instance danger, monitoring presence, version fallback, internal custom-check health inference, transport and retention details in infoDetails |
| Platform health view | support download gating, known-version-only upgrade cue rendering, plain-text names, API-in-details rendering, monitoring row rendering, always-expandable health badges |
| Mock helpers | independent topology and custom-check switching |
| Platform health store | warning/danger severity, unavailable audit remotes, remote error instance danger, monitoring presence, version fallback, internal custom-check health inference, transport, retention, and persistence details in infoDetails |
| Platform health view | support download gating, known-version-only upgrade cue rendering, plain-text names, API-in-details rendering, monitoring row rendering, always-expandable health badges, persistence type in expanded details |
| Platform model store | persistence type mapping from the primary `storage`, remote error `storage`, and remote audit `persistence` shapes, `storage` precedence, absence on older responses, clearing on refresh, support JSON that includes the type and omits `persistence_settings` |

## Key Source Files

Expand Down
1 change: 1 addition & 0 deletions src/Frontend/src/resources/PlatformModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface PlatformInstance {
errorRetentionPeriod?: string;
auditRetentionPeriod?: string;
storageType?: string;
persistenceType?: string;
}

export interface PlatformModel {
Expand Down
2 changes: 2 additions & 0 deletions src/Frontend/src/resources/RemoteInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface RemoteInstanceHostConfiguration {
export interface RemoteInstanceConfiguration {
host?: RemoteInstanceHostConfiguration;
data_retention?: RemoteInstanceDataRetention;
storage?: { storage_type?: string };
persistence?: { persistence_type?: string };
}

export enum RemoteInstanceType {
Expand Down
4 changes: 4 additions & 0 deletions src/Frontend/src/stores/PlatformHealthStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ describe("PlatformHealthStore", () => {
expect(primaryRow.infoDetails).toContain("Error log queue: error.log");
expect(primaryRow.infoDetails).toContain("Forward error messages: Yes");
expect(primaryRow.infoDetails).toContain("Error retention: 14 days");
expect(primaryRow.infoDetails).toContain("Storage type: SQLServer");

const auditRow = store.rows[1];
expect(auditRow.infoDetails).toContain("API: http://Particular.ServiceControl.Audit/api/");
expect(auditRow.infoDetails).toContain("Audit retention: 7 days");
expect(auditRow.infoDetails).toContain("Storage type: PostgreSQL");
expect(auditRow.infoDetails).not.toContain(expect.stringContaining("Transport"));
});

Expand Down Expand Up @@ -510,6 +512,7 @@ const primaryWithTransportModel: PlatformModel = {
errorLogQueue: "error.log",
forwardErrorMessages: true,
errorRetentionPeriod: "14.00:00:00",
persistenceType: "SQLServer",
},
remotes: [
{
Expand All @@ -521,6 +524,7 @@ const primaryWithTransportModel: PlatformModel = {
health: "healthy",
apiUrl: "http://Particular.ServiceControl.Audit/api/",
auditRetentionPeriod: "7.00:00:00",
persistenceType: "PostgreSQL",
},
],
monitoring: null,
Expand Down
4 changes: 4 additions & 0 deletions src/Frontend/src/stores/PlatformHealthStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ function toRow(instance: PlatformInstance, latestVersion: string, upgradeLink: s
infoDetails.push(`Audit retention: ${formatTimeSpan(instance.auditRetentionPeriod)}`);
}

if (instance.persistenceType) {
infoDetails.push(`Storage type: ${instance.persistenceType}`);
}

return {
id: instance.id,
type: formatRowType(instance),
Expand Down
70 changes: 70 additions & 0 deletions src/Frontend/src/stores/PlatformModelStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { beforeEach, describe, expect, test, vi } from "vitest";
import { createPinia, setActivePinia } from "pinia";
import { usePlatformModelStore } from "@/stores/PlatformModelStore";
import { usePlatformHealthStore } from "@/stores/PlatformHealthStore";
import { useCustomChecksStore } from "@/stores/CustomChecksStore";
import { RemoteInstanceType } from "@/resources/RemoteInstance";

const getRoot = vi.fn();
Expand Down Expand Up @@ -204,6 +206,74 @@ describe("PlatformModelStore", () => {
expect(store.primary?.storageType).toBeUndefined();
});

test("maps the persistence type from the primary and from error and audit remotes", async () => {
getRoot.mockResolvedValue(rootResponse({ name: "Particular.ServiceControl", health: "healthy", version: "6.19.3" }));
getConfiguration.mockResolvedValue({ json: () => Promise.resolve({ storage: { storage_type: "SQLServer" } }) } as never);
getRemoteInstances.mockResolvedValue([
{ api_uri: "http://localhost:33334/api/", version: "6.19.3", status: "online", configuration: { data_retention: { error_retention_period: "14.00:00:00" }, storage: { storage_type: "RavenDB" } } },
{ api_uri: "http://localhost:33335/api/", version: "6.19.3", status: "online", configuration: { data_retention: { audit_retention_period: "7.00:00:00" }, persistence: { persistence_type: "PostgreSQL" } } },
]);
getMonitoringRoot.mockResolvedValue(null);

const store = usePlatformModelStore();
await store.refresh();

expect(store.primary?.persistenceType).toBe("SQLServer");
expect(store.remotes[0].persistenceType).toBe("RavenDB");
expect(store.remotes[1].persistenceType).toBe("PostgreSQL");
});

test("prefers storage.storage_type over persistence.persistence_type on a remote", async () => {
getRoot.mockResolvedValue(rootResponse({ name: "Particular.ServiceControl", health: "healthy", version: "6.19.3" }));
getRemoteInstances.mockResolvedValue([{ api_uri: "http://localhost:33334/api/", version: "6.19.3", status: "online", configuration: { storage: { storage_type: "RavenDB" }, persistence: { persistence_type: "raw" } } }]);
getMonitoringRoot.mockResolvedValue(null);

const store = usePlatformModelStore();
await store.refresh();

expect(store.remotes[0].persistenceType).toBe("RavenDB");
});

test("leaves the persistence type undefined when responses omit it and clears it on refresh", async () => {
getRoot.mockResolvedValue(rootResponse({ name: "Particular.ServiceControl", health: "healthy", version: "6.19.3" }));
getConfiguration.mockResolvedValueOnce({ json: () => Promise.resolve({ storage: { storage_type: "RavenDB" } }) } as never);
getRemoteInstances.mockResolvedValueOnce([{ api_uri: "http://localhost:33334/api/", version: "6.19.3", status: "online", configuration: { persistence: { persistence_type: "PostgreSQL" } } }]);
getMonitoringRoot.mockResolvedValue(null);

const store = usePlatformModelStore();
await store.refresh();
expect(store.primary?.persistenceType).toBe("RavenDB");
expect(store.remotes[0].persistenceType).toBe("PostgreSQL");

getConfiguration.mockResolvedValueOnce({ json: () => Promise.resolve({ host: {} }) } as never);
getRemoteInstances.mockResolvedValueOnce([{ api_uri: "http://localhost:33334/api/", version: "6.19.3", status: "online", configuration: {} }]);
await store.refresh();

expect(store.primary?.persistenceType).toBeUndefined();
expect(store.remotes[0].persistenceType).toBeUndefined();
});

test("includes the persistence type but not persistence_settings in the support JSON", async () => {
getRoot.mockResolvedValue(rootResponse({ name: "Particular.ServiceControl", health: "healthy", version: "6.19.3" }));
getConfiguration.mockResolvedValue({
json: () =>
Promise.resolve({
storage: { storage_type: "SQLServer" },
persistence_settings: { connection_string: "SENTINEL_CONNECTION_STRING", client_certificate_password: "SENTINEL_CERT_PASSWORD", client_certificate_base64: "SENTINEL_CERT_BASE64" },
}),
} as never);
getRemoteInstances.mockResolvedValue([]);
getMonitoringRoot.mockResolvedValue(null);
useCustomChecksStore().refresh = vi.fn(() => Promise.resolve());

const healthStore = usePlatformHealthStore();
await healthStore.refresh();

expect(healthStore.supportDownloadJson).toContain("SQLServer");
expect(healthStore.supportDownloadJson).not.toContain("SENTINEL");
expect(healthStore.supportDownloadJson).not.toContain("persistence_settings");
});

test("skips remote discovery when the primary root is unavailable", async () => {
getRoot.mockRejectedValue(new Error("primary unavailable"));
getRemoteInstances.mockResolvedValue([
Expand Down
2 changes: 2 additions & 0 deletions src/Frontend/src/stores/PlatformModelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function mapPrimary(primaryRoot: PrimaryRootResult | null, configuration: Config
forwardErrorMessages: configuration?.transport?.forward_error_messages,
errorRetentionPeriod: configuration?.data_retention?.error_retention_period,
storageType: configuration?.storage?.storage_type,
persistenceType: configuration?.storage?.storage_type,
};
}

Expand All @@ -133,6 +134,7 @@ function mapRemotes(remotes: RemoteInstance[]): PlatformInstance[] {
apiUrl: remote.api_uri,
errorRetentionPeriod: remote.configuration?.data_retention?.error_retention_period,
auditRetentionPeriod: remote.configuration?.data_retention?.audit_retention_period,
persistenceType: remote.configuration?.storage?.storage_type ?? remote.configuration?.persistence?.persistence_type,
};
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/Frontend/src/views/PlatformHealthView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ describe("PlatformHealthView", () => {
version: "6.19.3",
health: "healthy",
apiUrl: "http://localhost:33333/api/",
persistenceType: "SQLServer",
},
remotes: [
{
Expand Down Expand Up @@ -251,6 +252,8 @@ describe("PlatformHealthView", () => {
await user.click(screen.getAllByRole("button", { name: /Healthy/i })[0]);
expect(screen.getByText("API")).toBeInTheDocument();
expect(screen.getByText("http://localhost:33333/api/")).toBeInTheDocument();
expect(screen.getByText("Storage type")).toBeInTheDocument();
expect(screen.getByText("SQLServer")).toBeInTheDocument();
});

test("renders monitoring when present alongside remote error instances", () => {
Expand Down
3 changes: 3 additions & 0 deletions src/Frontend/test/mocks/platform-health-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export function getPlatformHealthConfiguration() {
data_retention: {
error_retention_period: "15.00:00:00",
},
storage: {
storage_type: "SQLServer",
},
};
}

Expand Down
1 change: 1 addition & 0 deletions src/Frontend/test/mocks/platform-topology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function toRemoteInstances(topology: Pick<PlatformTopology, "remotes">):
instance_name: remote.name,
},
data_retention: remote.instanceType === "error" ? { error_retention_period: "14.00:00:00" } : { audit_retention_period: "7.00:00:00" },
...(remote.instanceType === "error" ? { storage: { storage_type: "RavenDB" } } : { persistence: { persistence_type: "PostgreSQL" } }),
},
platform_health_status: remote.status,
platform_health_id: remote.id,
Expand Down
Loading