mirror of
https://github.com/Drop-OSS/droplet.git
synced 2026-06-22 04:11:40 +10:00
feat: work on version backend system
This commit is contained in:
@@ -52,4 +52,38 @@ test("numerous small file", async (t) => {
|
||||
}
|
||||
|
||||
fs.rmSync(dirName, { recursive: true });
|
||||
});
|
||||
});
|
||||
|
||||
test.skip("performance test", async (t) => {
|
||||
t.timeout(5 * 60 * 1000);
|
||||
const dirName = "./.test/pt";
|
||||
if (fs.existsSync(dirName)) fs.rmSync(dirName, { recursive: true });
|
||||
fs.mkdirSync(dirName, { recursive: true });
|
||||
|
||||
const fileSize = 1 * 1000 * 1000 * 1000; // 1GB
|
||||
|
||||
const randomStream = fs.createReadStream("/dev/random", {
|
||||
start: 0,
|
||||
end: fileSize,
|
||||
});
|
||||
const outputStream = fs.createWriteStream(path.join(dirName, "file.bin"));
|
||||
await new Promise((r) => {
|
||||
randomStream.pipe(outputStream);
|
||||
randomStream.on("end", r);
|
||||
});
|
||||
|
||||
const start = Date.now();
|
||||
await new Promise((r, e) =>
|
||||
generateManifest(
|
||||
dirName,
|
||||
(_, __) => {},
|
||||
(_, __) => {},
|
||||
(err, manifest) => (err ? e(err) : r(manifest))
|
||||
)
|
||||
);
|
||||
const end = Date.now();
|
||||
|
||||
t.pass(`Took ${end - start}ms to process ${fileSize / (1000 * 1000)}MB`);
|
||||
|
||||
fs.rmSync(dirName, { recursive: true });
|
||||
});
|
||||
|
||||
@@ -52,7 +52,6 @@ test("read file offset", async (t) => {
|
||||
fs.mkdirSync(dirName, { recursive: true });
|
||||
|
||||
const testString = "0123456789";
|
||||
|
||||
fs.writeFileSync(dirName + "/TESTFILE", testString);
|
||||
|
||||
const stream = droplet.readFile(dirName, "TESTFILE", 1, 4);
|
||||
@@ -64,7 +63,7 @@ test("read file offset", async (t) => {
|
||||
finalString += String.fromCharCode.apply(null, chunk);
|
||||
}
|
||||
|
||||
const expectedString = testString.slice(1, 5);
|
||||
const expectedString = testString.slice(1, 4);
|
||||
|
||||
t.assert(finalString == expectedString, "file strings don't match");
|
||||
fs.rmSync(dirName, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user