WIP test client
This commit is contained in:
parent
fde1fecbb6
commit
4872f6d3b3
7 changed files with 287 additions and 2 deletions
43
frontend/test-client/src/cli.ts
Normal file
43
frontend/test-client/src/cli.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { SyncSettings } from "sync-client";
|
||||
import { MockAgent } from "./agent/mock-agent";
|
||||
import { sleep } from "./utils/sleep";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const globalFiles: Record<string, Uint8Array> = {};
|
||||
const iterations = 100;
|
||||
|
||||
async function runTest(): Promise<void> {
|
||||
console.info("Starting test...");
|
||||
|
||||
const initialSettings: Partial<SyncSettings> = {
|
||||
isSyncEnabled: true,
|
||||
token: "token",
|
||||
vaultName: uuidv4()
|
||||
};
|
||||
|
||||
const clients = [
|
||||
new MockAgent(globalFiles, initialSettings, "agent-1"),
|
||||
new MockAgent(globalFiles, initialSettings, "agent-2"),
|
||||
new MockAgent(globalFiles, initialSettings, "agent-3"),
|
||||
new MockAgent(globalFiles, initialSettings, "agent-4"),
|
||||
new MockAgent(globalFiles, initialSettings, "agent-5")
|
||||
];
|
||||
|
||||
await Promise.all(clients.map((client) => client.init()));
|
||||
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
await Promise.all(clients.map((client) => client.act()));
|
||||
await sleep(100);
|
||||
}
|
||||
|
||||
await Promise.all(clients.map((client) => client.finish()));
|
||||
|
||||
clients.forEach((client) => {
|
||||
client.assertFileSystemIsConsistent();
|
||||
client.assertAllContentIsPresentOnce();
|
||||
});
|
||||
|
||||
console.info("Test completed successfully");
|
||||
}
|
||||
|
||||
runTest();
|
||||
Loading…
Add table
Add a link
Reference in a new issue