Skip to content

Commit ef383bc

Browse files
authored
Fix MNTK specs for DData: DurablePruningSpec (#4933)
1 parent 950f824 commit ef383bc

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/contrib/cluster/Akka.DistributedData.Tests.MultiNode/DurablePruningSpec.cs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
using System;
99
using System.Collections.Immutable;
10+
using System.Linq;
1011
using Akka.Actor;
12+
using Akka.Cluster;
1113
using Akka.Cluster.TestKit;
1214
using Akka.Configuration;
1315
using Akka.Remote.TestKit;
@@ -48,31 +50,41 @@ public class DurablePruningSpec : MultiNodeClusterSpec
4850
private readonly GCounterKey keyA = new GCounterKey("A");
4951
private readonly IActorRef replicator;
5052

51-
protected DurablePruningSpec() : this(new DurablePruningSpecConfig())
53+
public DurablePruningSpec() : this(new DurablePruningSpecConfig())
5254
{
5355
}
5456

5557
protected DurablePruningSpec(DurablePruningSpecConfig config) : base(config, typeof(DurablePruningSpec))
5658
{
57-
InitialParticipantsValueFactory = Roles.Count;
5859
cluster = Akka.Cluster.Cluster.Get(Sys);
60+
replicator = StartReplicator(Sys);
5961
timeout = Dilated(TimeSpan.FromSeconds(5));
6062
}
6163

62-
protected override int InitialParticipantsValueFactory { get; }
64+
protected override int InitialParticipantsValueFactory => Roles.Count;
6365

64-
[MultiNodeFact(Skip = "FIXME")]
66+
[MultiNodeFact]
6567
public void Pruning_of_durable_CRDT_should_move_data_from_removed_node()
6668
{
6769
Join(first, first);
6870
Join(second, first);
6971

7072
var sys2 = ActorSystem.Create(Sys.Name, Sys.Settings.Config);
7173
var cluster2 = Akka.Cluster.Cluster.Get(sys2);
74+
var distributedData2 = DistributedData.Get(sys2);
7275
var replicator2 = StartReplicator(sys2);
7376
var probe2 = new TestProbe(sys2, new XunitAssertions());
7477
cluster2.Join(Node(first).Address);
7578

79+
AwaitAssert(() =>
80+
{
81+
cluster.State.Members.Count.ShouldBe(4);
82+
cluster.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBe(true);
83+
cluster2.State.Members.Count.ShouldBe(4);
84+
cluster2.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBe(true);
85+
}, TimeSpan.FromSeconds(10));
86+
EnterBarrier("joined");
87+
7688
Within(TimeSpan.FromSeconds(5), () => AwaitAssert(() =>
7789
{
7890
replicator.Tell(Dsl.GetReplicaCount);
@@ -81,10 +93,10 @@ public void Pruning_of_durable_CRDT_should_move_data_from_removed_node()
8193
probe2.ExpectMsg(new ReplicaCount(4));
8294
}));
8395

84-
replicator.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster)));
96+
replicator.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster, 3)));
8597
ExpectMsg(new UpdateSuccess(keyA, null));
8698

87-
replicator2.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster2, 2)), probe2.Ref);
99+
replicator2.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster2.SelfUniqueAddress, 2)), probe2.Ref);
88100
probe2.ExpectMsg(new UpdateSuccess(keyA, null));
89101

90102
EnterBarrier("updates-done");
@@ -135,8 +147,9 @@ public void Pruning_of_durable_CRDT_should_move_data_from_removed_node()
135147

136148
RunOn(() =>
137149
{
138-
var addr = cluster2.SelfAddress;
139-
var sys3 = ActorSystem.Create(Sys.Name, ConfigurationFactory.ParseString(@"
150+
var address = cluster2.SelfAddress;
151+
var sys3 = ActorSystem.Create(Sys.Name, ConfigurationFactory.ParseString($@"
152+
akka.remote.dot-netty.tcp.port = {address.Port}
140153
").WithFallback(Sys.Settings.Config));
141154
var cluster3 = Akka.Cluster.Cluster.Get(sys3);
142155
var replicator3 = StartReplicator(sys3);
@@ -151,20 +164,28 @@ public void Pruning_of_durable_CRDT_should_move_data_from_removed_node()
151164
replicator3.Tell(Dsl.Get(keyA, ReadLocal.Instance), probe3.Ref);
152165
var counter4 = probe3.ExpectMsg<GetSuccess>().Get(keyA);
153166
var value = counter4.Value;
154-
values.Add((int) value);
167+
values = values.Add((int) value);
155168
value.ShouldBe(10UL);
156169
counter4.State.Count.ShouldBe(3);
157170
});
158171
values.ShouldBe(ImmutableHashSet.Create(10));
159172
});
160173

174+
// all must at least have seen it as joining
175+
AwaitAssert(() =>
176+
{
177+
cluster3.State.Members.Count.ShouldBe(4);
178+
cluster3.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBeTrue();
179+
}, TimeSpan.FromSeconds(10));
180+
161181
// after merging with others
162182
replicator3.Tell(Dsl.Get(keyA, new ReadAll(RemainingOrDefault)));
163183
var counter5 = ExpectMsg<GetSuccess>().Get(keyA);
164184
counter5.Value.ShouldBe(10UL);
165185
counter5.State.Count.ShouldBe(3);
166186

167187
}, first);
188+
168189
EnterBarrier("sys3-started");
169190

170191
replicator.Tell(Dsl.Get(keyA, new ReadAll(RemainingOrDefault)));

0 commit comments

Comments
 (0)