feat(updater): support updates after verified SeaweedFS migration
This commit is contained in:
@@ -128,6 +128,20 @@ test("Unix client bounds response size, deadline, and protocol shape", async t =
|
||||
});
|
||||
}
|
||||
});
|
||||
test("provider status and plan cross the socket boundary without private storage configuration", async t => {
|
||||
const client = await socketFixture(t, (_req, res) => res.end(JSON.stringify({
|
||||
apiVersion: 1, acceptingRequests: true, engine: { status: "recovered", phase: "resolved" }, installed: {},
|
||||
storage: { provider: "seaweedfs", migrationPending: false, service: { secret: "hidden" } },
|
||||
request: { status: "checked", plan: { updateAvailable: true, requiresComposeAdoption: false, retiredServices: [],
|
||||
storageProvider: "seaweedfs", storageImageRetained: true, storageBackupPaths: ["/private/path"] } },
|
||||
})));
|
||||
const { body } = await client("GET", "/v1/status") as { body: any };
|
||||
assert.deepEqual(body.storage, { provider: "seaweedfs", migrationPending: false });
|
||||
assert.equal(body.request.plan.storageProvider, "seaweedfs");
|
||||
assert.equal(body.request.plan.storageImageRetained, true);
|
||||
assert.ok(!JSON.stringify(body).includes("hidden"));
|
||||
assert.ok(!JSON.stringify(body).includes("private/path"));
|
||||
});
|
||||
test("Unix client validates bounded log responses and their request association", async t => {
|
||||
let payload: any = { requestId: id, logs: [{ source: "commands", content: "pull access denied", truncated: true,
|
||||
path: "/private/commands.log" }], private: "omitted" };
|
||||
|
||||
29
backend/tests/systemStatusStorage.test.ts
Normal file
29
backend/tests/systemStatusStorage.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { HeadBucketCommand } from "@aws-sdk/client-s3";
|
||||
import { checkFileStorage } from "../src/modules/system-status.service";
|
||||
|
||||
test("file storage health uses an authenticated S3 bucket request for every provider", async () => {
|
||||
const client = { send: async (command: any, options: any) => {
|
||||
assert.ok(command instanceof HeadBucketCommand);
|
||||
assert.deepEqual(command.input, { Bucket: "fedeo" });
|
||||
assert.ok(options.abortSignal instanceof AbortSignal);
|
||||
} };
|
||||
assert.equal((await checkFileStorage(client, "fedeo")).ok, true);
|
||||
});
|
||||
|
||||
test("unconfigured or denied S3 access is unhealthy and does not disclose SDK details", async () => {
|
||||
assert.equal((await checkFileStorage(null, "fedeo")).ok, false);
|
||||
const result = await checkFileStorage({ send: async () => { throw new Error("secret@private-host"); } }, "fedeo");
|
||||
assert.equal(result.ok, false);
|
||||
assert.ok(!JSON.stringify(result).includes("private-host"));
|
||||
});
|
||||
|
||||
test("S3 health aborts a hung request at its deadline", async () => {
|
||||
const client = { send: (_command: any, options: any) => new Promise((_resolve, reject) => {
|
||||
options.abortSignal.addEventListener("abort", () => reject(new Error("aborted")), { once: true });
|
||||
}) };
|
||||
const result = await checkFileStorage(client, "fedeo", 10);
|
||||
assert.equal(result.ok, false);
|
||||
assert.match(result.error, /Zeitlimit/);
|
||||
});
|
||||
Reference in New Issue
Block a user