Skip to content

Commit 3d0f9ab

Browse files
committed
test: load test with 1000 file RW 1KB-16KB serially and in parallel and timings
1 parent 8d89a11 commit 3d0f9ab

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

test/test-file.browser.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ function _setupTests(testType) {
518518

519519
async function _testLargeFileRW(filePath, sizeBytes, isBinary) {
520520
console.log("creating random string of size", sizeBytes);
521-
let timerLabel = "random data generated " + sizeBytes/1024/1024 +"MB";
521+
let timerLabel = "random data generated " + sizeBytes/1024/1024 +"MB" + filePath;
522522
console.time(timerLabel);
523523
let contentWrittenToFile = createRandomString(sizeBytes);
524524
const binaryConversion = stringToArrayBuffer(contentWrittenToFile);
@@ -527,7 +527,7 @@ function _setupTests(testType) {
527527
}
528528
console.timeEnd(timerLabel);
529529

530-
timerLabel = "File write completed " + sizeBytes/1024/1024 +"MB";
530+
timerLabel = "File write completed " + sizeBytes/1024/1024 +"MB" + filePath;
531531
console.time(timerLabel);
532532
let resolveP, rejectP;
533533
const writePromise = new Promise((resolve, reject) => {resolveP = resolve; rejectP = reject;});
@@ -541,7 +541,7 @@ function _setupTests(testType) {
541541
await writePromise;
542542
console.timeEnd(timerLabel);
543543

544-
timerLabel = "File read completed " + sizeBytes/1024/1024 +"MB";
544+
timerLabel = "File read completed " + sizeBytes/1024/1024 +"MB" + filePath;
545545
console.time(timerLabel);
546546

547547
const readPromise = new Promise((resolve, reject) => {resolveP = resolve; rejectP = reject;});
@@ -555,7 +555,7 @@ function _setupTests(testType) {
555555
const dataReadFromFile = await readPromise;
556556
console.timeEnd(timerLabel);
557557

558-
timerLabel = "File verify completed " + sizeBytes/1024/1024 +"MB";
558+
timerLabel = "File verify completed " + sizeBytes/1024/1024 +"MB" + filePath;
559559
console.time(timerLabel);
560560

561561
expect(dataReadFromFile).to.eql(contentWrittenToFile);
@@ -580,6 +580,22 @@ function _setupTests(testType) {
580580
const filePath = `${testPath}/browserWrite.txt`;
581581
await _testLargeFileRW(filePath, sizeMB * 1024 * 1024, true); // Roughly 4MB considering 1 byte per char
582582
}).timeout(60000);
583+
584+
it(`Should phoenix ${testType} read and write 1000 Binary files of size ${sizeMB} KB serially`, async function () {
585+
for(let j=0;j<1000;j++){
586+
const filePath = `${testPath}/browserWrite.txt`;
587+
await _testLargeFileRW(filePath, sizeMB * 1024, true); // Roughly 4MB considering 1 byte per char
588+
}
589+
}).timeout(120000);
590+
591+
it(`Should phoenix ${testType} read and write 1000 Binary files of size ${sizeMB} KB in parallel`, async function () {
592+
let fileVerifyPromises = [];
593+
for(let j=0;j<1000;j++){
594+
const filePath = `${testPath}/browserWrite_${j}.txt`;
595+
fileVerifyPromises.push(_testLargeFileRW(filePath, sizeMB * 1024, true)); // Roughly 4MB considering 1 byte per char
596+
}
597+
await Promise.all(fileVerifyPromises);
598+
}).timeout(120000);
583599
}
584600
}
585601

0 commit comments

Comments
 (0)