Skip to content

Commit 9eeb54a

Browse files
committed
test(quic): update specs for pooling, batching and migration timer changes
1 parent b616fac commit 9eeb54a

7 files changed

Lines changed: 186 additions & 168 deletions

File tree

src/Servus.Akka.Tests/Transport/Quic/Client/QuicConnectionLeaseSpec.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,35 +182,34 @@ public void ActiveStreams_should_reflect_busy_idle_balance()
182182
}
183183

184184
[Fact(Timeout = 5000)]
185-
public void LastActivity_should_update_on_MarkBusy()
185+
public void LastActivityTicks_should_update_on_MarkBusy()
186186
{
187187
var handle = CreateTestHandle();
188188
var lease = new QuicConnectionLease(handle, 10);
189189

190-
var initialActivity = lease.LastActivity;
190+
var initialTicks = lease.LastActivityTicks;
191191

192-
// Wait a bit to ensure time difference
193192
Thread.Sleep(10);
194193

195194
lease.MarkBusy();
196-
var afterBusy = lease.LastActivity;
195+
var afterBusy = lease.LastActivityTicks;
197196

198-
Assert.True(afterBusy > initialActivity);
197+
Assert.True(afterBusy > initialTicks);
199198
}
200199

201200
[Fact(Timeout = 5000)]
202-
public void LastActivity_should_update_on_MarkIdle()
201+
public void LastActivityTicks_should_update_on_MarkIdle()
203202
{
204203
var handle = CreateTestHandle();
205204
var lease = new QuicConnectionLease(handle, 10);
206205

207206
lease.MarkBusy();
208-
var afterBusy = lease.LastActivity;
207+
var afterBusy = lease.LastActivityTicks;
209208

210209
Thread.Sleep(10);
211210

212211
lease.MarkIdle();
213-
var afterIdle = lease.LastActivity;
212+
var afterIdle = lease.LastActivityTicks;
214213

215214
Assert.True(afterIdle > afterBusy);
216215
}

src/Servus.Akka.Tests/Transport/Quic/Client/QuicConnectionMigrationSpec.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void CheckForConnectionMigration_should_detect_endpoint_change()
6363

6464
var lease = new QuicConnectionLease(handle, 100);
6565

66-
sm.HandlePush(new ConnectTransport(new QuicTransportOptions { Host = "example.com", Port = 443 }));
66+
sm.HandlePush([new ConnectTransport(new QuicTransportOptions { Host = "example.com", Port = 443 })]);
6767
sm.Dispatch(new ConnectionLeaseAcquired(lease));
6868

6969
ops.PushedInbound.Clear();
@@ -105,7 +105,7 @@ public void CheckForConnectionMigration_should_not_detect_when_endpoint_unchange
105105

106106
var lease = new QuicConnectionLease(handle, 100);
107107

108-
sm.HandlePush(new ConnectTransport(new QuicTransportOptions { Host = "example.com", Port = 443 }));
108+
sm.HandlePush([new ConnectTransport(new QuicTransportOptions { Host = "example.com", Port = 443 })]);
109109
sm.Dispatch(new ConnectionLeaseAcquired(lease));
110110

111111
ops.PushedInbound.Clear();

src/Servus.Akka.Tests/Transport/Quic/Client/QuicConnectionStageSpec.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Stage_should_materialize_without_error()
2323
var flow = Flow.FromGraph(stage);
2424

2525
var (sourceQueue, sinkQueue) = Source
26-
.Queue<ITransportOutbound>(1, OverflowStrategy.Fail)
26+
.Queue<List<ITransportOutbound>>(1, OverflowStrategy.Fail)
2727
.ViaMaterialized(flow, Keep.Left)
2828
.ToMaterialized(Sink.Queue<ITransportInbound>(), Keep.Both)
2929
.Run(_materializer);
@@ -55,13 +55,13 @@ public async Task Stage_should_pass_ConnectTransport_to_state_machine()
5555
var flow = Flow.FromGraph(stage);
5656

5757
var (sourceQueue, _) = Source
58-
.Queue<ITransportOutbound>(1, OverflowStrategy.Fail)
58+
.Queue<List<ITransportOutbound>>(1, OverflowStrategy.Fail)
5959
.ViaMaterialized(flow, Keep.Left)
6060
.ToMaterialized(Sink.Queue<ITransportInbound>(), Keep.Both)
6161
.Run(_materializer);
6262

6363
// Push ConnectTransport
64-
await sourceQueue.OfferAsync(new ConnectTransport(options));
64+
await sourceQueue.OfferAsync(new List<ITransportOutbound> { new ConnectTransport(options) });
6565

6666
// Expect Acquire message on TestActor from state machine
6767
var msg = ExpectMsg<QuicConnectionManagerActor.Acquire>(TimeSpan.FromSeconds(2),
@@ -89,16 +89,16 @@ public async Task Stage_should_queue_inbound_when_outlet_not_pulled()
8989
var flow = Flow.FromGraph(stage);
9090

9191
var (sourceQueue, sinkQueue) = Source
92-
.Queue<ITransportOutbound>(2, OverflowStrategy.Fail)
92+
.Queue<List<ITransportOutbound>>(2, OverflowStrategy.Fail)
9393
.ViaMaterialized(flow, Keep.Left)
9494
.ToMaterialized(Sink.Queue<ITransportInbound>(), Keep.Both)
9595
.Run(_materializer);
9696

97-
await sourceQueue.OfferAsync(new ConnectTransport(new QuicTransportOptions
97+
await sourceQueue.OfferAsync([new ConnectTransport(new QuicTransportOptions
9898
{
9999
Host = "localhost",
100100
Port = 443
101-
}));
101+
})]);
102102

103103
var msg = ExpectMsg<QuicConnectionManagerActor.Acquire>(TimeSpan.FromSeconds(2),
104104
cancellationToken: TestContext.Current.CancellationToken);
@@ -116,18 +116,18 @@ public async Task Stage_should_handle_downstream_finish_signal()
116116
var flow = Flow.FromGraph(stage);
117117

118118
var (sourceQueue, _) = Source
119-
.Queue<ITransportOutbound>(1, OverflowStrategy.Fail)
119+
.Queue<List<ITransportOutbound>>(1, OverflowStrategy.Fail)
120120
.ViaMaterialized(flow, Keep.Left)
121121
.ToMaterialized(Sink.Queue<ITransportInbound>(), Keep.Both)
122122
.Run(_materializer);
123123

124124
// Test that the stage properly initializes and can handle lifecycle
125125
// The OnDownstreamFinish handler is called when downstream cancels
126-
await sourceQueue.OfferAsync(new ConnectTransport(new QuicTransportOptions
126+
await sourceQueue.OfferAsync([new ConnectTransport(new QuicTransportOptions
127127
{
128128
Host = "localhost",
129129
Port = 443
130-
}));
130+
})]);
131131

132132
var msg = ExpectMsg<QuicConnectionManagerActor.Acquire>(TimeSpan.FromSeconds(2),
133133
cancellationToken: TestContext.Current.CancellationToken);
@@ -141,16 +141,16 @@ public async Task Stage_should_pull_inlet_after_inbound_push()
141141
var flow = Flow.FromGraph(stage);
142142

143143
var (sourceQueue, _) = Source
144-
.Queue<ITransportOutbound>(1, OverflowStrategy.Fail)
144+
.Queue<List<ITransportOutbound>>(1, OverflowStrategy.Fail)
145145
.ViaMaterialized(flow, Keep.Left)
146146
.ToMaterialized(Sink.Queue<ITransportInbound>(), Keep.Both)
147147
.Run(_materializer);
148148

149-
await sourceQueue.OfferAsync(new ConnectTransport(new QuicTransportOptions
149+
await sourceQueue.OfferAsync([new ConnectTransport(new QuicTransportOptions
150150
{
151151
Host = "localhost",
152152
Port = 443
153-
}));
153+
})]);
154154

155155
var msg = ExpectMsg<QuicConnectionManagerActor.Acquire>(TimeSpan.FromSeconds(2),
156156
cancellationToken: TestContext.Current.CancellationToken);

0 commit comments

Comments
 (0)