Fix testing setup
This commit is contained in:
parent
0897f7a545
commit
3784418567
11 changed files with 266 additions and 119 deletions
|
|
@ -333,16 +333,19 @@ export class MockAgent extends MockClient {
|
|||
.includes(content);
|
||||
});
|
||||
|
||||
if (
|
||||
!this.useSlowFileEvents
|
||||
|
||||
) {
|
||||
if (!this.useSlowFileEvents) {
|
||||
assert(
|
||||
found.length <= 1,
|
||||
`[${this.name}] Binary content ${content} found in multiple files: ${found.join(", ")}`
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.useSlowFileEvents && !this.doDeletes) {
|
||||
assert(
|
||||
found.length >= 1,
|
||||
`[${this.name}] Binary content ${content} not found in any files`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -510,9 +513,7 @@ export class MockAgent extends MockClient {
|
|||
`Decided to update binary file ${file}`
|
||||
);
|
||||
this.doNotTouchWhileOffline.push(file);
|
||||
this.files.set(file, bytes);
|
||||
|
||||
|
||||
await this.write(file, bytes);
|
||||
}
|
||||
|
||||
private async deleteFileAction(): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -45,10 +45,18 @@ export class MockClient extends debugging.InMemoryFileSystem {
|
|||
path: RelativePath,
|
||||
content: Uint8Array
|
||||
): Promise<void> {
|
||||
const isNew = !this.files.has(path);
|
||||
|
||||
this.files.set(path, content);
|
||||
this.executeFileOperation(
|
||||
async () => this.client.syncLocallyUpdatedFile({ relativePath: path }),
|
||||
);
|
||||
|
||||
if (isNew) {
|
||||
this.executeFileOperation(async () => { this.client.syncLocallyCreatedFile(path); }
|
||||
);
|
||||
} else {
|
||||
this.executeFileOperation(
|
||||
async () => { this.client.syncLocallyUpdatedFile({ relativePath: path }); },
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +74,7 @@ export class MockClient extends debugging.InMemoryFileSystem {
|
|||
this.files.set(path, newContentUint8Array);
|
||||
|
||||
this.executeFileOperation(
|
||||
async () => this.client.syncLocallyUpdatedFile({ relativePath: path }),
|
||||
async () => { this.client.syncLocallyUpdatedFile({ relativePath: path }); },
|
||||
);
|
||||
|
||||
return newContent;
|
||||
|
|
@ -77,7 +85,7 @@ export class MockClient extends debugging.InMemoryFileSystem {
|
|||
public override async delete(path: RelativePath): Promise<void> {
|
||||
this.files.delete(path);
|
||||
this.executeFileOperation(
|
||||
async () => this.client.syncLocallyDeletedFile(path),
|
||||
async () => { this.client.syncLocallyDeletedFile(path); },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -94,10 +102,10 @@ export class MockClient extends debugging.InMemoryFileSystem {
|
|||
this.files.delete(oldPath);
|
||||
}
|
||||
this.executeFileOperation(
|
||||
async () => this.client.syncLocallyUpdatedFile({
|
||||
async () => { this.client.syncLocallyUpdatedFile({
|
||||
oldPath,
|
||||
relativePath: newPath
|
||||
}),
|
||||
}); },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,11 +104,8 @@ async function runTest({
|
|||
}
|
||||
}
|
||||
|
||||
// Settling rounds to drain cascading broadcasts between agents.
|
||||
// Completing work on agent A can trigger broadcasts to agent B,
|
||||
// which can cascade further. With N agents the worst case is N
|
||||
// hops, so N+1 passes guarantees all cascades are drained.
|
||||
for (let round = 0; round <= clients.length; round++) {
|
||||
// Settling rounds: drain cascading broadcasts between agents
|
||||
for (let round = 0; round < 10; round++) {
|
||||
for (const client of clients) {
|
||||
try {
|
||||
await client.waitUntilSynced();
|
||||
|
|
@ -118,8 +115,13 @@ async function runTest({
|
|||
}
|
||||
}
|
||||
}
|
||||
// TODO: it's very ugly, let's remove this
|
||||
await sleep(2000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (const client of clients) {
|
||||
try {
|
||||
logger.info(`Destroying ${client.name}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue