Skip to content

Commit 14b88c6

Browse files
committed
v9
1 parent b9f7ab7 commit 14b88c6

File tree

5 files changed

+74
-9
lines changed

5 files changed

+74
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
dotnet-version: ${{ env.DOTNET_VERSION }}
2525

2626
- name: Restore dependencies
27-
run: dotnet restore ManagedCode.Orleans.SignalR.sln
27+
run: dotnet restore ManagedCode.Orleans.SignalR.slnx
2828

2929
- name: Build
30-
run: dotnet build ManagedCode.Orleans.SignalR.sln --configuration Release --no-restore
30+
run: dotnet build ManagedCode.Orleans.SignalR.slnx --configuration Release --no-restore
3131

3232
- name: Test
3333
run: dotnet test ManagedCode.Orleans.SignalR.Tests/ManagedCode.Orleans.SignalR.Tests.csproj --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ jobs:
3333
echo "Version from Directory.Build.props: $VERSION"
3434
3535
- name: Restore dependencies
36-
run: dotnet restore ManagedCode.Orleans.SignalR.sln
36+
run: dotnet restore ManagedCode.Orleans.SignalR.slnx
3737

3838
- name: Build
39-
run: dotnet build ManagedCode.Orleans.SignalR.sln --configuration Release --no-restore
39+
run: dotnet build ManagedCode.Orleans.SignalR.slnx --configuration Release --no-restore
4040

4141
- name: Test
4242
run: dotnet test ManagedCode.Orleans.SignalR.Tests/ManagedCode.Orleans.SignalR.Tests.csproj --configuration Release --no-build --verbosity normal
4343

4444
- name: Pack NuGet packages
45-
run: dotnet pack ManagedCode.Orleans.SignalR.sln --configuration Release --no-build -p:IncludeSymbols=false -p:SymbolPackageFormat=snupkg --output ./artifacts
45+
run: dotnet pack ManagedCode.Orleans.SignalR.slnx --configuration Release --no-build -p:IncludeSymbols=false -p:SymbolPackageFormat=snupkg --output ./artifacts
4646

4747
- name: Upload artifacts
4848
uses: actions/upload-artifact@v4

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<EnableNETAnalyzers>true</EnableNETAnalyzers>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
9-
9+
1010
<!--NuGet-->
1111
<PropertyGroup>
1212
<Authors>ManagedCode</Authors>
@@ -25,8 +25,8 @@
2525
<RepositoryUrl>https://github.com/managedcode/Orleans.SignalR</RepositoryUrl>
2626
<PackageProjectUrl>https://github.com/managedcode/Orleans.SignalR</PackageProjectUrl>
2727
<Product>Managed Code - Orleans SignalR</Product>
28-
<Version>8.1.1</Version>
29-
<PackageVersion>8.1.1</PackageVersion>
28+
<Version>9.0.0</Version>
29+
<PackageVersion>9.0.0</PackageVersion>
3030

3131
</PropertyGroup>
3232
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

ManagedCode.Orleans.SignalR.Tests/KeepAliveDisabledTests.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using ManagedCode.Orleans.SignalR.Core.Config;
23
using ManagedCode.Orleans.SignalR.Tests.Cluster;
34
using ManagedCode.Orleans.SignalR.Tests.Infrastructure.Logging;
@@ -16,12 +17,14 @@ public class KeepAliveDisabledTests : IAsyncLifetime
1617
{
1718
private readonly SmokeClusterFixture _siloCluster;
1819
private readonly TestOutputHelperAccessor _loggerAccessor = new();
20+
private readonly ITestOutputHelper _output;
1921
private TestWebApplication? _app;
2022

2123
public KeepAliveDisabledTests(SmokeClusterFixture siloCluster, ITestOutputHelper testOutputHelper)
2224
{
2325
_siloCluster = siloCluster;
2426
_loggerAccessor.Output = testOutputHelper;
27+
_output = testOutputHelper;
2528
}
2629

2730
public async Task InitializeAsync()
@@ -35,6 +38,7 @@ public async Task InitializeAsync()
3538
services.PostConfigure<OrleansSignalROptions>(options =>
3639
{
3740
options.KeepEachConnectionAlive = false;
41+
options.ClientTimeoutInterval = TimeSpan.FromSeconds(2);
3842
});
3943
});
4044

@@ -74,6 +78,16 @@ public async Task Targeted_connection_send_should_work_when_keep_alive_disabled(
7478
var completed = await Task.WhenAny(received.Task, Task.Delay(TimeSpan.FromSeconds(5)));
7579
completed.ShouldBe(received.Task, "Receiver did not observe direct send when keep-alive was disabled.");
7680
received.Task.Result.ShouldBe("test");
81+
82+
var receiverDisconnected = await WaitForDisconnectAsync(receiver, TimeSpan.FromSeconds(5), "target receiver");
83+
_output.WriteLine(receiverDisconnected
84+
? "Receiver disconnected after timeout as expected."
85+
: "Receiver remained connected after timeout window.");
86+
87+
var senderDisconnected = await WaitForDisconnectAsync(sender, TimeSpan.FromSeconds(5), "target sender");
88+
_output.WriteLine(senderDisconnected
89+
? "Sender disconnected after timeout as expected."
90+
: "Sender remained connected after timeout window.");
7791
}
7892
finally
7993
{
@@ -119,11 +133,56 @@ public async Task Group_send_should_work_when_keep_alive_disabled()
119133
var completed = await Task.WhenAny(groupMessage.Task, Task.Delay(TimeSpan.FromSeconds(10)));
120134
completed.ShouldBe(groupMessage.Task, "Group broadcast did not arrive when keep-alive was disabled.");
121135
groupMessage.Task.Result.ShouldContain("payload");
136+
137+
var disconnected = await WaitForDisconnectAsync(connection, TimeSpan.FromSeconds(5), "group connection");
138+
_output.WriteLine(disconnected
139+
? "Group connection disconnected after timeout as expected."
140+
: "Group connection remained connected after timeout window.");
122141
}
123142
finally
124143
{
125144
await connection.StopAsync();
126145
await connection.DisposeAsync();
127146
}
128147
}
148+
149+
private async Task<bool> WaitForDisconnectAsync(HubConnection connection, TimeSpan timeout, string label)
150+
{
151+
if (connection.State == HubConnectionState.Disconnected)
152+
{
153+
_output.WriteLine($"{label} already disconnected.");
154+
return true;
155+
}
156+
157+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
158+
159+
Task Handler(Exception? _)
160+
{
161+
tcs.TrySetResult(true);
162+
return Task.CompletedTask;
163+
}
164+
165+
connection.Closed += Handler;
166+
167+
try
168+
{
169+
var watch = Stopwatch.StartNew();
170+
var completedTask = await Task.WhenAny(tcs.Task, Task.Delay(timeout));
171+
watch.Stop();
172+
173+
if (completedTask == tcs.Task)
174+
{
175+
await tcs.Task;
176+
_output.WriteLine($"{label} disconnected after {watch.Elapsed}.");
177+
return true;
178+
}
179+
180+
_output.WriteLine($"{label} still connected after {watch.Elapsed}.");
181+
return false;
182+
}
183+
finally
184+
{
185+
connection.Closed -= Handler;
186+
}
187+
}
129188
}

ManagedCode.Orleans.SignalR.Tests/StressTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using System.Linq;
23
using ManagedCode.Orleans.SignalR.Server;
34
using ManagedCode.Orleans.SignalR.Tests.Cluster;
@@ -133,6 +134,7 @@ async Task<GrainCounts> FetchCountsAsync()
133134
_output.WriteLine($"Stress connection started with id {hubConnection.ConnectionId}.");
134135

135136
const int workflowIterations = 200;
137+
var workflowWatch = Stopwatch.StartNew();
136138
var workflowTasks = Enumerable.Range(0, workflowIterations)
137139
.Select(async iteration =>
138140
{
@@ -141,6 +143,8 @@ async Task<GrainCounts> FetchCountsAsync()
141143
await hubConnection.InvokeAsync("GroupSendAsync", "stress-group", $"payload-{iteration}");
142144
});
143145
await Task.WhenAll(workflowTasks);
146+
workflowWatch.Stop();
147+
_output.WriteLine($"Completed {workflowIterations} workflow iterations in {workflowWatch.Elapsed}.");
144148

145149
await Task.Delay(TimeSpan.FromMilliseconds(250));
146150

@@ -163,6 +167,7 @@ async Task<GrainCounts> FetchCountsAsync()
163167
await _cluster.Cluster.Client.GetGrain<IManagementGrain>(0)
164168
.ForceActivationCollection(TimeSpan.Zero);
165169

170+
var deactivationWatch = Stopwatch.StartNew();
166171
var deactivationObserved = await WaitUntilAsync(
167172
"all stress grains to deactivate",
168173
async () =>
@@ -177,11 +182,12 @@ await _cluster.Cluster.Client.GetGrain<IManagementGrain>(0)
177182
},
178183
timeout: TimeSpan.FromSeconds(15),
179184
progress: async () => (await FetchCountsAsync()).ToString());
185+
deactivationWatch.Stop();
180186

181187
deactivationObserved.ShouldBeTrue("Stress grains did not deactivate as expected.");
182188

183189
var after = await FetchCountsAsync();
184-
_output.WriteLine($"Final grain counts: {after}");
190+
_output.WriteLine($"Final grain counts: {after} (deactivation check took {deactivationWatch.Elapsed}).");
185191
}
186192

187193
private async Task<HubConnection> CreateUserConnectionAsync(string user, TestWebApplication app, string hub)

0 commit comments

Comments
 (0)