Skip to content

Commit 1dc6687

Browse files
committed
add snapshot stress test
1 parent d6a6ea9 commit 1dc6687

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { before, after, fs, sudo } from "./setup";
2+
import { readFile, writeFile, unlink } from "fs/promises";
3+
import { join } from "path";
4+
import { wait } from "@cocalc/backend/conat/test/util";
5+
import { randomBytes } from "crypto";
6+
7+
beforeAll(before);
8+
//const log = console.log;
9+
const log = (..._args) => {};
10+
11+
describe("stress test creating many snapshots", () => {
12+
let vol;
13+
it("creates a volume and write a file to it", async () => {
14+
vol = await fs.subvolume("stress");
15+
});
16+
17+
const count = 25;
18+
it(`create file and snapshot the volume ${count} times`, async () => {
19+
const snaps: string[] = [];
20+
const start = Date.now();
21+
for (let i = 0; i < count; i++) {
22+
await writeFile(join(vol.path, `${i}.txt`), "world");
23+
await vol.createSnapshot(`snap${i}`);
24+
snaps.push(`snap${i}`);
25+
}
26+
log(
27+
`created ${Math.round((count / (Date.now() - start)) * 1000)} snapshots per second in serial`,
28+
);
29+
snaps.sort();
30+
expect(await vol.snapshots()).toEqual(snaps);
31+
});
32+
33+
it(`delete our ${count} snapshots`, async () => {
34+
for (let i = 0; i < count; i++) {
35+
await vol.deleteSnapshot(`snap${i}`);
36+
}
37+
expect(await vol.snapshots()).toEqual([]);
38+
});
39+
});
40+
41+
afterAll(after);

src/packages/file-server/btrfs/test/subvolume.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ describe("test snapshots", () => {
8787
expect(await vol.snapshotExists("snap1")).toBe(false);
8888
expect(await vol.snapshots()).toEqual([]);
8989
});
90-
91-
9290
});
9391

92+
// describe("test bup backups", ()=>{
93+
// let vol;
94+
// it('creates a volume')
95+
// })
96+
9497
afterAll(after);

0 commit comments

Comments
 (0)