test(worker): fix control-command test helpers (CreatePipeSession overload, drop ConfigureAwait)

This commit is contained in:
Joseph Doherty
2026-06-15 10:23:45 -04:00
parent bf72cd8961
commit 72e1aca716
@@ -304,8 +304,7 @@ public sealed class WorkerPipeSessionTests
await CompleteGatewayHandshakeAsync(pipePair, cancellation.Token);
await pipePair.GatewayWriter
.WriteAsync(CreatePingCommandEnvelope("ping-1", "hello-worker"), cancellation.Token)
.ConfigureAwait(false);
.WriteAsync(CreatePingCommandEnvelope("ping-1", "hello-worker"), cancellation.Token);
WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader,
@@ -341,8 +340,7 @@ public sealed class WorkerPipeSessionTests
"state-1",
MxCommandKind.GetSessionState,
command => command.GetSessionState = new GetSessionStateCommand()),
cancellation.Token)
.ConfigureAwait(false);
cancellation.Token);
WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader,
@@ -377,8 +375,7 @@ public sealed class WorkerPipeSessionTests
"info-1",
MxCommandKind.GetWorkerInfo,
command => command.GetWorkerInfo = new GetWorkerInfoCommand()),
cancellation.Token)
.ConfigureAwait(false);
cancellation.Token);
WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader,
@@ -423,8 +420,7 @@ public sealed class WorkerPipeSessionTests
"drain-1",
MxCommandKind.DrainEvents,
command => command.DrainEvents = new DrainEventsCommand { MaxEvents = 0 }),
cancellation.Token)
.ConfigureAwait(false);
cancellation.Token);
WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader,
@@ -465,8 +461,7 @@ public sealed class WorkerPipeSessionTests
{
GracePeriod = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)),
}),
cancellation.Token)
.ConfigureAwait(false);
cancellation.Token);
WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader,
@@ -487,10 +482,9 @@ public sealed class WorkerPipeSessionTests
Assert.Equal(ProtocolStatusCode.Ok, ack.WorkerShutdownAck.Status.Code);
Task completedTask = await Task
.WhenAny(runTask, Task.Delay(TimeSpan.FromSeconds(5), cancellation.Token))
.ConfigureAwait(false);
.WhenAny(runTask, Task.Delay(TimeSpan.FromSeconds(5), cancellation.Token));
Assert.Same(runTask, completedTask);
await runTask.ConfigureAwait(false);
await runTask;
Assert.True(runtime.Disposed, "ShutdownWorker must dispose the runtime session.");
}
@@ -1073,6 +1067,20 @@ public sealed class WorkerPipeSessionTests
() => 1234);
}
private static WorkerPipeSession CreatePipeSession(
Stream stream,
FakeRuntimeSession runtime)
{
return CreatePipeSession(
stream,
runtime,
new WorkerPipeSessionOptions
{
HeartbeatInterval = TimeSpan.FromMilliseconds(100),
HeartbeatGrace = TimeSpan.FromSeconds(5),
});
}
private static WorkerPipeSession CreatePipeSession(
Stream stream,
FakeRuntimeSession runtime,