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 CompleteGatewayHandshakeAsync(pipePair, cancellation.Token);
await pipePair.GatewayWriter await pipePair.GatewayWriter
.WriteAsync(CreatePingCommandEnvelope("ping-1", "hello-worker"), cancellation.Token) .WriteAsync(CreatePingCommandEnvelope("ping-1", "hello-worker"), cancellation.Token);
.ConfigureAwait(false);
WorkerEnvelope replyEnvelope = await ReadUntilAsync( WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader, pipePair.GatewayReader,
@@ -341,8 +340,7 @@ public sealed class WorkerPipeSessionTests
"state-1", "state-1",
MxCommandKind.GetSessionState, MxCommandKind.GetSessionState,
command => command.GetSessionState = new GetSessionStateCommand()), command => command.GetSessionState = new GetSessionStateCommand()),
cancellation.Token) cancellation.Token);
.ConfigureAwait(false);
WorkerEnvelope replyEnvelope = await ReadUntilAsync( WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader, pipePair.GatewayReader,
@@ -377,8 +375,7 @@ public sealed class WorkerPipeSessionTests
"info-1", "info-1",
MxCommandKind.GetWorkerInfo, MxCommandKind.GetWorkerInfo,
command => command.GetWorkerInfo = new GetWorkerInfoCommand()), command => command.GetWorkerInfo = new GetWorkerInfoCommand()),
cancellation.Token) cancellation.Token);
.ConfigureAwait(false);
WorkerEnvelope replyEnvelope = await ReadUntilAsync( WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader, pipePair.GatewayReader,
@@ -423,8 +420,7 @@ public sealed class WorkerPipeSessionTests
"drain-1", "drain-1",
MxCommandKind.DrainEvents, MxCommandKind.DrainEvents,
command => command.DrainEvents = new DrainEventsCommand { MaxEvents = 0 }), command => command.DrainEvents = new DrainEventsCommand { MaxEvents = 0 }),
cancellation.Token) cancellation.Token);
.ConfigureAwait(false);
WorkerEnvelope replyEnvelope = await ReadUntilAsync( WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader, pipePair.GatewayReader,
@@ -465,8 +461,7 @@ public sealed class WorkerPipeSessionTests
{ {
GracePeriod = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)), GracePeriod = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)),
}), }),
cancellation.Token) cancellation.Token);
.ConfigureAwait(false);
WorkerEnvelope replyEnvelope = await ReadUntilAsync( WorkerEnvelope replyEnvelope = await ReadUntilAsync(
pipePair.GatewayReader, pipePair.GatewayReader,
@@ -487,10 +482,9 @@ public sealed class WorkerPipeSessionTests
Assert.Equal(ProtocolStatusCode.Ok, ack.WorkerShutdownAck.Status.Code); Assert.Equal(ProtocolStatusCode.Ok, ack.WorkerShutdownAck.Status.Code);
Task completedTask = await Task Task completedTask = await Task
.WhenAny(runTask, Task.Delay(TimeSpan.FromSeconds(5), cancellation.Token)) .WhenAny(runTask, Task.Delay(TimeSpan.FromSeconds(5), cancellation.Token));
.ConfigureAwait(false);
Assert.Same(runTask, completedTask); Assert.Same(runTask, completedTask);
await runTask.ConfigureAwait(false); await runTask;
Assert.True(runtime.Disposed, "ShutdownWorker must dispose the runtime session."); Assert.True(runtime.Disposed, "ShutdownWorker must dispose the runtime session.");
} }
@@ -1073,6 +1067,20 @@ public sealed class WorkerPipeSessionTests
() => 1234); () => 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( private static WorkerPipeSession CreatePipeSession(
Stream stream, Stream stream,
FakeRuntimeSession runtime, FakeRuntimeSession runtime,