Skip to content

Commit 91da892

Browse files
committed
btrfs tests: create more loopback devices automatically so we can run btrfs unit tests in parallel
1 parent 346a484 commit 91da892

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
type Filesystem,
44
} from "@cocalc/file-server/btrfs/filesystem";
55
import process from "node:process";
6-
import { chmod, mkdtemp, mkdir, rm } from "node:fs/promises";
6+
import { chmod, mkdtemp, mkdir, rm, stat } from "node:fs/promises";
77
import { tmpdir } from "node:os";
88
import { join } from "path";
99
import { until } from "@cocalc/util/async-utils";
@@ -16,12 +16,29 @@ let tempDir;
1616

1717
const TEMP_PREFIX = "cocalc-test-btrfs-";
1818

19+
async function ensureMoreLoops() {
20+
// to run tests, this is helpful
21+
//for i in $(seq 8 63); do sudo mknod -m660 /dev/loop$i b 7 $i; sudo chown root:disk /dev/loop$i; done
22+
for (let i = 0; i < 64; i++) {
23+
try {
24+
await stat(`/dev/loop${i}`);
25+
continue;
26+
} catch {}
27+
await sudo({
28+
command: "mknod",
29+
args: ["-m660", `/dev/loop${i}`, "b", "7", `${i}`],
30+
});
31+
await sudo({ command: "chown", args: ["root:disk", `/dev/loop${i}`] });
32+
}
33+
}
34+
1935
export async function before() {
2036
try {
2137
const command = `umount ${join(tmpdir(), TEMP_PREFIX)}*/mnt`;
2238
// attempt to unmount any mounts left from previous runs
2339
await sudo({ command, bash: true });
2440
} catch {}
41+
await ensureMoreLoops();
2542
tempDir = await mkdtemp(join(tmpdir(), TEMP_PREFIX));
2643
// Set world read/write/execute
2744
await chmod(tempDir, 0o777);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,4 @@ describe("test bup backups", () => {
152152
});
153153
});
154154

155-
//afterAll(after);
155+
afterAll(after);

src/packages/file-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preinstall": "npx only-allow pnpm",
1111
"build": "pnpm exec tsc --build",
1212
"tsc": "pnpm exec tsc --watch --pretty --preserveWatchOutput",
13-
"test": "pnpm exec jest --runInBand",
13+
"test": "pnpm exec jest",
1414
"depcheck": "pnpx depcheck",
1515
"clean": "rm -rf node_modules dist"
1616
},

0 commit comments

Comments
 (0)