test(mesh): stampede callers on dedicated threads — arrival gate must not depend on thread-pool injection
This commit is contained in:
+5
-2
@@ -296,13 +296,16 @@ public sealed class MeshPskProviderTests
|
|||||||
var resolver = new FakeSecretResolver { Value = "stored-psk", ResolveDelay = TimeSpan.FromMilliseconds(50) };
|
var resolver = new FakeSecretResolver { Value = "stored-psk", ResolveDelay = TimeSpan.FromMilliseconds(50) };
|
||||||
var provider = CreateProvider(resolver);
|
var provider = CreateProvider(resolver);
|
||||||
|
|
||||||
var callers = Enumerable.Range(0, Callers).Select(_ => Task.Run(() =>
|
// LongRunning gives each caller a dedicated thread: reaching the arrival gate must not
|
||||||
|
// depend on thread-pool injection, which is rate-limited and made this flake on a
|
||||||
|
// contended box (the gate timed out before all 16 pool threads existed).
|
||||||
|
var callers = Enumerable.Range(0, Callers).Select(_ => Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
arrived.Signal();
|
arrived.Signal();
|
||||||
start.Wait();
|
start.Wait();
|
||||||
provider.TryGetPsk("SITE-A", out var psk).ShouldBeTrue();
|
provider.TryGetPsk("SITE-A", out var psk).ShouldBeTrue();
|
||||||
return psk;
|
return psk;
|
||||||
})).ToArray();
|
}, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)).ToArray();
|
||||||
|
|
||||||
arrived.Wait(TimeSpan.FromSeconds(10)).ShouldBeTrue("all callers should reach the start gate");
|
arrived.Wait(TimeSpan.FromSeconds(10)).ShouldBeTrue("all callers should reach the start gate");
|
||||||
start.Set();
|
start.Set();
|
||||||
|
|||||||
Reference in New Issue
Block a user