Path: blob/master/src/packages/file-server/btrfs/test/filesystem-stress.test.ts
1543 views
import { before, after, fs } from "./setup";12beforeAll(before);34const DEBUG = false;5const log = DEBUG ? console.log : (..._args) => {};67describe("stress operations with subvolumes", () => {8const count1 = 10;9it(`create ${count1} subvolumes in serial`, async () => {10const t = Date.now();11for (let i = 0; i < count1; i++) {12await fs.subvolumes.get(`${i}`);13}14log(15`created ${Math.round((count1 / (Date.now() - t)) * 1000)} subvolumes per second serial`,16);17});1819it("list them and confirm", async () => {20const v = await fs.subvolumes.list();21expect(v.length).toBe(count1);22});2324let count2 = 10;25it(`create ${count2} subvolumes in parallel`, async () => {26const v: any[] = [];27const t = Date.now();28for (let i = 0; i < count2; i++) {29v.push(fs.subvolumes.get(`p-${i}`));30}31await Promise.all(v);32log(33`created ${Math.round((count2 / (Date.now() - t)) * 1000)} subvolumes per second in parallel`,34);35});3637it("list them and confirm", async () => {38const v = await fs.subvolumes.list();39expect(v.length).toBe(count1 + count2);40});4142it("write a file to each volume", async () => {43for (const name of await fs.subvolumes.list()) {44const vol = await fs.subvolumes.get(name);45await vol.fs.writeFile("a.txt", "hi");46}47});4849it("clone the first group in serial", async () => {50const t = Date.now();51for (let i = 0; i < count1; i++) {52await fs.subvolumes.clone(`${i}`, `clone-of-${i}`);53}54log(55`cloned ${Math.round((count1 / (Date.now() - t)) * 1000)} subvolumes per second serial`,56);57});5859it("clone the second group in parallel", async () => {60const t = Date.now();61const v: any[] = [];62for (let i = 0; i < count2; i++) {63v.push(fs.subvolumes.clone(`p-${i}`, `clone-of-p-${i}`));64}65await Promise.all(v);66log(67`cloned ${Math.round((count2 / (Date.now() - t)) * 1000)} subvolumes per second parallel`,68);69});7071it("delete the first batch serial", async () => {72const t = Date.now();73for (let i = 0; i < count1; i++) {74await fs.subvolumes.delete(`${i}`);75}76log(77`deleted ${Math.round((count1 / (Date.now() - t)) * 1000)} subvolumes per second serial`,78);79});8081it("delete the second batch in parallel", async () => {82const v: any[] = [];83const t = Date.now();84for (let i = 0; i < count2; i++) {85v.push(fs.subvolumes.delete(`p-${i}`));86}87await Promise.all(v);88log(89`deleted ${Math.round((count2 / (Date.now() - t)) * 1000)} subvolumes per second in parallel`,90);91});92});9394afterAll(after);959697