This commit is contained in:
Andras Schmelczer 2025-03-15 17:15:44 +00:00
parent 2987afb20a
commit d5112a7d0f
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
7 changed files with 147 additions and 272 deletions

View file

@ -63,7 +63,11 @@ export class MockClient implements FileSystemOperations {
`Creating file ${path} with content ${new TextDecoder().decode(newContent)}`
);
this.localFiles.set(path, newContent);
void this.client.syncer.syncLocallyCreatedFile(path);
// we aren't the best client and it takes some time to notice changes
setImmediate(() => {
void this.client.syncer.syncLocallyCreatedFile(path);
});
}
public async createDirectory(_path: RelativePath): Promise<void> {
@ -101,8 +105,11 @@ export class MockClient implements FileSystemOperations {
`Updated file ${path} with:\n current content: ${currentContent}\n new content: ${newContent}`
);
void this.client.syncer.syncLocallyUpdatedFile({
relativePath: path
// we aren't the best client and it takes some time to notice changes
setImmediate(() => {
void this.client.syncer.syncLocallyUpdatedFile({
relativePath: path
});
});
return newContent;
@ -116,13 +123,16 @@ export class MockClient implements FileSystemOperations {
`Updated file ${path} with:\n new content: ${new TextDecoder().decode(content)}`
);
if (hasExisted) {
void this.client.syncer.syncLocallyUpdatedFile({
relativePath: path
});
} else {
void this.client.syncer.syncLocallyCreatedFile(path);
}
// we aren't the best client and it takes some time to notice changes
setImmediate(() => {
if (hasExisted) {
void this.client.syncer.syncLocallyUpdatedFile({
relativePath: path
});
} else {
void this.client.syncer.syncLocallyCreatedFile(path);
}
});
}
public async delete(path: RelativePath): Promise<void> {
@ -130,7 +140,10 @@ export class MockClient implements FileSystemOperations {
`Deleting file: ${path} with:\n content ${new TextDecoder().decode(this.localFiles.get(path))}`
);
this.localFiles.delete(path);
void this.client.syncer.syncLocallyDeletedFile(path);
// we aren't the best client and it takes some time to notice changes
setImmediate(() => {
void this.client.syncer.syncLocallyDeletedFile(path);
});
}
public async rename(
@ -150,9 +163,12 @@ export class MockClient implements FileSystemOperations {
`Renamed file: ${oldPath} -> ${newPath} with:\n content ${new TextDecoder().decode(file)}`
);
void this.client.syncer.syncLocallyUpdatedFile({
oldPath,
relativePath: newPath
// we aren't the best client and it takes some time to notice changes
setImmediate(() => {
void this.client.syncer.syncLocallyUpdatedFile({
oldPath,
relativePath: newPath
});
});
}
}

View file

@ -91,26 +91,24 @@ async function runTest({
async function runTests(): Promise<void> {
const agentCounts = [2, 8];
const jitterScaleInSeconds = [0.5, 0, 2];
const concurrencies = [16, 1];
const iterations = [200];
const networkJitterScaleInSeconds = [0.5, 2];
const concurrencies = [
16,
1 // test with concurrency 1 to check for deadlocks
];
const doDeletes = [true, false];
for (const agentCount of agentCounts) {
for (const concurrency of concurrencies) {
for (const jitter of jitterScaleInSeconds) {
for (const iteration of iterations) {
for (const deleteFiles of doDeletes) {
for (let i = 0; i < 3; i++) {
await runTest({
agentCount,
concurrency,
iterations: iteration,
doDeletes: deleteFiles,
jitterScaleInSeconds: jitter
});
}
}
for (const jitter of networkJitterScaleInSeconds) {
for (const deleteFiles of doDeletes) {
await runTest({
agentCount,
concurrency,
iterations: 200,
doDeletes: deleteFiles,
jitterScaleInSeconds: jitter
});
}
}
}