fix(volumes): unmount existing mounts before remounting
This commit is contained in:
parent
694f1c212f
commit
118a67e230
2 changed files with 25 additions and 0 deletions
|
|
@ -131,6 +131,30 @@ describe("volumeService.listFiles security", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("volumeService.mountVolume", () => {
|
||||||
|
test("unmounts any existing mount before mounting", async () => {
|
||||||
|
const { organizationId, user } = await createTestSession();
|
||||||
|
const volume = await createTestVolume({ organizationId, status: "mounted" });
|
||||||
|
const unmount = vi.fn().mockResolvedValue({ status: "unmounted" });
|
||||||
|
const mount = vi.fn().mockResolvedValue({ status: "mounted" });
|
||||||
|
|
||||||
|
vi.spyOn(backendModule, "createVolumeBackend").mockImplementation(() => ({
|
||||||
|
mount,
|
||||||
|
unmount,
|
||||||
|
checkHealth: vi.fn().mockResolvedValue({ status: "mounted" }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
await withContext({ organizationId, userId: user.id }, async () => {
|
||||||
|
const result = await volumeService.mountVolume(volume.shortId);
|
||||||
|
|
||||||
|
expect(result.status).toBe("mounted");
|
||||||
|
expect(unmount).toHaveBeenCalledOnce();
|
||||||
|
expect(mount).toHaveBeenCalledOnce();
|
||||||
|
expect(unmount.mock.invocationCallOrder[0]).toBeLessThan(mount.mock.invocationCallOrder[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("volumeService.ensureHealthyVolume", () => {
|
describe("volumeService.ensureHealthyVolume", () => {
|
||||||
test("returns ready when the mounted volume passes its health check", async () => {
|
test("returns ready when the mounted volume passes its health check", async () => {
|
||||||
const { organizationId, user } = await createTestSession();
|
const { organizationId, user } = await createTestSession();
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ const mountVolume = async (shortId: ShortId) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const backend = createVolumeBackend(volume);
|
const backend = createVolumeBackend(volume);
|
||||||
|
await backend.unmount();
|
||||||
const { error, status } = await backend.mount();
|
const { error, status } = await backend.mount();
|
||||||
|
|
||||||
await db
|
await db
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue