Skip to content

Commit 911ee75

Browse files
authored
chore: add work log (#2366)
1 parent 11bb1f6 commit 911ee75

File tree

7 files changed

+60
-27
lines changed

7 files changed

+60
-27
lines changed

logs/exceptions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
### Proto.Cluster.Tests (Timeout)
88
`System.TimeoutException: Request timed out` in `InMemoryPartitionActivatorClusterTests.HandlesSlowResponsesCorrectly`.
9+
10+
### Proto.Actor.Tests.EscalateFailureTests
11+
`System.TimeoutException: The condition was not met within the timeout of 00:00:00.1000000` in `Proto.Mailbox.Tests.EscalateFailureTests.GivenNonCompletedSystemMessageTaskThrewException_ShouldEscalateFailure`.
12+
913
### Proto.Mailbox.Tests.EscalateFailureTests.GivenNonCompletedUserMessageTaskGotCancelled_ShouldEscalateFailure
1014
`System.TimeoutException: The condition was not met within the timeout of 00:00:00.1000000` when waiting for mailbox failure escalation.
1115

1216
### Proto.Tests.SupervisionTestsAllForOne.AllForOneStrategy_Should_PassExceptionOnRestart
1317
`System.InvalidOperationException: Collection was modified; enumeration operation may not execute.` during enumeration of mailbox statistics.
14-
### Proto.Tests.SupervisionTestsAllForOne.AllForOneStrategy_Should_PassExceptionOnRestart
15-
`System.InvalidOperationException: Collection was modified; enumeration operation may not execute.` during enumeration of mailbox statistics.

logs/log1755977337.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Task Log
2+
3+
## Summary
4+
- Added reusable `GossipNetworkPartition` middleware under `tests/Proto.TestKit`.
5+
- Refactored `PartitionConsensusTests` to consume the shared middleware.
6+
- Wired the helper into `Proto.Cluster.Tests` so future partition tests can reuse it.
7+
8+
## Motivation
9+
Centralizing the gossip partition helper avoids duplication and makes partition scenarios easier to express in tests, improving maintainability and clarity.

logs/log1755978126.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Summary
2+
- move GossipNetworkPartition helper into Proto.TestKit project
3+
- remove file link from Proto.Cluster.Tests project and reference Proto.Cluster from Proto.TestKit
4+
5+
## Testing
6+
- `dotnet test --no-build tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj`
7+
- `dotnet test tests/Proto.Remote.Tests/Proto.Remote.Tests.csproj`
8+
- `dotnet test tests/Proto.Cluster.Tests/Proto.Cluster.Tests.csproj`
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Immutable;
3+
using Proto;
4+
using Proto.Cluster.Gossip;
5+
6+
namespace Proto.TestKit;
7+
8+
// Middleware to simulate network partitions for gossip messages in tests
9+
public static class GossipNetworkPartition
10+
{
11+
private static ImmutableHashSet<string> _isolated = ImmutableHashSet<string>.Empty;
12+
13+
// Prevent gossip between the given address and any other nodes
14+
public static void Isolate(string address) => _isolated = _isolated.Add(address);
15+
16+
// Clear all simulated partitions
17+
public static void Clear() => _isolated = ImmutableHashSet<string>.Empty;
18+
19+
// Middleware that drops gossip requests to or from isolated nodes
20+
public static Func<Sender, Sender> Middleware => next => async (ctx, target, envelope) =>
21+
{
22+
if (envelope.Message is GossipRequest && target.Id == Gossiper.GossipActorName)
23+
{
24+
var from = ctx.System.Address;
25+
var to = target.Address;
26+
27+
if (_isolated.Contains(from) || _isolated.Contains(to))
28+
{
29+
// message dropped due to simulated partition
30+
return;
31+
}
32+
}
33+
34+
await next(ctx, target, envelope);
35+
};
36+
}

src/Proto.TestKit/Proto.TestKit.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<ProjectReference Include="..\Proto.Actor\Proto.Actor.csproj" />
11+
<ProjectReference Include="..\Proto.Cluster\Proto.Cluster.csproj" />
1112
</ItemGroup>
1213

1314
<ItemGroup>

tests/Proto.Cluster.Tests/PartitionConsensusTests.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Threading.Tasks;
43
using ClusterTest.Messages;
54
using FluentAssertions;
65
using Proto;
76
using Proto.Cluster;
87
using Proto.Cluster.Gossip;
8+
using Proto.TestKit;
99
using Xunit;
1010
using static Proto.TestKit.TestKit;
1111

@@ -87,28 +87,4 @@ protected override ActorSystemConfig GetActorSystemConfig()
8787
.WithConfigureSystemProps((name, p) => baseConfig.ConfigureSystemProps(name, p).WithSenderMiddleware(GossipNetworkPartition.Middleware));
8888
}
8989
}
90-
91-
private static class GossipNetworkPartition
92-
{
93-
private static readonly HashSet<string> Dropped = new();
94-
95-
public static void Isolate(string address) => Dropped.Add(address);
96-
public static void Clear() => Dropped.Clear();
97-
98-
public static Func<Sender, Sender> Middleware => next => async (ctx, target, envelope) =>
99-
{
100-
if (envelope.Message is GossipRequest && target.Id == Gossiper.GossipActorName)
101-
{
102-
var from = ctx.System.Address;
103-
var to = target.Address;
104-
105-
if (Dropped.Contains(from) || Dropped.Contains(to))
106-
{
107-
return;
108-
}
109-
}
110-
111-
await next(ctx, target, envelope);
112-
};
113-
}
11490
}

tests/Proto.Cluster.Tests/Proto.Cluster.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ProjectReference Include="..\..\src\Proto.Remote\Proto.Remote.csproj" />
1414
<ProjectReference Include="..\..\src\Proto.TestKit\Proto.TestKit.csproj" />
1515
</ItemGroup>
16+
1617
<ItemGroup>
1718
<PackageReference Include="Grpc.Tools" PrivateAssets="All" />
1819
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" />

0 commit comments

Comments
 (0)