Skip to content

Commit

Permalink
fix flaky test by increasing dispatcher allocate timeout (#7755)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej authored Nov 13, 2024
1 parent 91ce187 commit b1b7330
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task HealBigSqueezedRandomTree()

dbContext.LocalStateTree.RootHash = dbContext.RemoteStateTree.RootHash;

await using IContainer container = PrepareDownloader(dbContext);
await using IContainer container = PrepareDownloader(dbContext, syncDispatcherAllocateTimeoutMs: 1000);
SafeContext ctx = container.Resolve<SafeContext>();
await ActivateAndWait(ctx, dbContext, 9, timeout: 20000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected static StorageTree SetStorage(ITrieStore trieStore, byte i, Address ad
return remoteStorageTree;
}

protected IContainer PrepareDownloader(DbContext dbContext, Action<SyncPeerMock>? mockMutator = null)
protected IContainer PrepareDownloader(DbContext dbContext, Action<SyncPeerMock>? mockMutator = null, int syncDispatcherAllocateTimeoutMs = 10)
{
SyncPeerMock[] syncPeers = new SyncPeerMock[_defaultPeerCount];
for (int i = 0; i < _defaultPeerCount; i++)
Expand All @@ -97,7 +97,7 @@ protected IContainer PrepareDownloader(DbContext dbContext, Action<SyncPeerMock>
syncPeers[i] = mock;
}

ContainerBuilder builder = BuildTestContainerBuilder(dbContext)
ContainerBuilder builder = BuildTestContainerBuilder(dbContext, syncDispatcherAllocateTimeoutMs)
.AddSingleton<SyncPeerMock[]>(syncPeers);

builder.RegisterBuildCallback((ctx) =>
Expand All @@ -112,13 +112,13 @@ protected IContainer PrepareDownloader(DbContext dbContext, Action<SyncPeerMock>
return builder.Build();
}

protected ContainerBuilder BuildTestContainerBuilder(DbContext dbContext)
protected ContainerBuilder BuildTestContainerBuilder(DbContext dbContext, int syncDispatcherAllocateTimeoutMs = 10)
{
ContainerBuilder containerBuilder = new ContainerBuilder()
.AddModule(new TestSynchronizerModule(new SyncConfig()
{
SyncDispatcherEmptyRequestDelayMs = 1,
SyncDispatcherAllocateTimeoutMs = 10, // there is a test for requested nodes which get affected if allocate timeout
SyncDispatcherAllocateTimeoutMs = syncDispatcherAllocateTimeoutMs, // there is a test for requested nodes which get affected if allocate timeout
FastSync = true
}))
.AddKeyedSingleton<IDb>(DbNames.Code, dbContext.LocalCodeDb)
Expand Down

0 comments on commit b1b7330

Please sign in to comment.