From 80897e5bcc17be7176e424b6607fb4f62482318a Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 29 Apr 2021 00:41:23 +0700 Subject: [PATCH] Fix Multinode spec ClusterShardingSpec --- .../ClusterShardingSpec.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs index 7b9b04a6e9b..5cd57c924be 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests.MultiNode/ClusterShardingSpec.cs @@ -379,8 +379,6 @@ protected DDataClusterShardingWithEntityRecoverySpec(DDataClusterShardingWithEnt public abstract class ClusterShardingSpec : MultiNodeClusterSpec { // must use different unique name for some tests than the one used in API tests - public static string TestCounterShardingTypeName => $"Test{Counter.ShardingTypeName}"; - #region Setup private readonly Lazy _region; @@ -399,7 +397,7 @@ protected ClusterShardingSpec(ClusterShardingSpecConfig config, Type type) { _config = config; - _region = new Lazy(() => CreateRegion(TestCounterShardingTypeName, false)); + _region = new Lazy(() => CreateRegion("counter", false)); _rebalancingRegion = new Lazy(() => CreateRegion("rebalancingCounter", false)); _persistentEntitiesRegion = new Lazy(() => CreateRegion("RememberCounterEntities", true)); @@ -456,7 +454,7 @@ private void CreateCoordinator() { var typeNames = new[] { - TestCounterShardingTypeName, "rebalancingCounter", "RememberCounterEntities", "AnotherRememberCounter", + "counter", "rebalancingCounter", "RememberCounterEntities", "AnotherRememberCounter", "RememberCounter", "RebalancingRememberCounter", "AutoMigrateRememberRegionTest" }; @@ -491,6 +489,10 @@ private Props CoordinatorProps(string typeName, bool rebalanceEntities, bool rem .WithFallback(Sys.Settings.Config.GetConfig("akka.cluster.sharding")); var settings = ClusterShardingSettings.Create(config, Sys.Settings.Config.GetConfig("akka.cluster.singleton")) .WithRememberEntities(rememberEntities); + var majorityMinCap = Sys.Settings.Config.GetInt("akka.cluster.sharding.distributed-data.majority-min-cap"); + if (IsDDataMode) + return DDataShardCoordinator.Props(typeName, settings, allocationStrategy, ReplicatorRef, + majorityMinCap, rememberEntities); return PersistentShardCoordinator.Props(typeName, settings, allocationStrategy); } @@ -634,7 +636,7 @@ public void ClusterSharding_should_use_second_node() r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance)); r.Tell(new Counter.Get(2)); ExpectMsg(3); - LastSender.Path.Should().Be(Node(_config.Second) / "user" / $"{TestCounterShardingTypeName}Region" / "2" / "2"); + LastSender.Path.Should().Be(Node(_config.Second) / "user" / "counterRegion" / "2" / "2"); r.Tell(new Counter.Get(11)); ExpectMsg(1); @@ -694,9 +696,9 @@ public void ClusterSharding_should_support_proxy_only_mode() var settings = ClusterShardingSettings.Create(cfg, Sys.Settings.Config.GetConfig("akka.cluster.singleton")); var proxy = Sys.ActorOf(ShardRegion.ProxyProps( - typeName: TestCounterShardingTypeName, + typeName: "counter", settings: settings, - coordinatorPath: $"/user/{TestCounterShardingTypeName}Coordinator/singleton/coordinator", + coordinatorPath: $"/user/counterCoordinator/singleton/coordinator", extractEntityId: Counter.ExtractEntityId, extractShardId: Counter.ExtractShardId, replicator: Sys.DeadLetters, @@ -795,12 +797,12 @@ public void ClusterSharding_should_use_third_and_fourth_node() r.Tell(new Counter.EntityEnvelope(3, Counter.Increment.Instance)); r.Tell(new Counter.Get(3)); ExpectMsg(11); - LastSender.Path.Should().Be(Node(_config.Third) / "user" / $"{TestCounterShardingTypeName}Region" / "3" / "3"); + LastSender.Path.Should().Be(Node(_config.Third) / "user" / "counterRegion" / "3" / "3"); r.Tell(new Counter.EntityEnvelope(4, Counter.Increment.Instance)); r.Tell(new Counter.Get(4)); ExpectMsg(21); - LastSender.Path.Should().Be(Node(_config.Fourth) / "user" / $"{TestCounterShardingTypeName}Region" / "4" / "4"); + LastSender.Path.Should().Be(Node(_config.Fourth) / "user" / "counterRegion" / "4" / "4"); }, _config.First); EnterBarrier("first-update"); @@ -843,7 +845,7 @@ public void ClusterSharding_should_recover_coordinator_state_after_coordinator_c { _region.Value.Tell(new Counter.Get(3), probe3.Ref); probe3.ExpectMsg(11); - probe3.LastSender.Path.Should().Be(Node(_config.Third) / "user" / $"{TestCounterShardingTypeName}Region" / "3" / "3"); + probe3.LastSender.Path.Should().Be(Node(_config.Third) / "user" / "counterRegion" / "3" / "3"); }); }); @@ -854,7 +856,7 @@ public void ClusterSharding_should_recover_coordinator_state_after_coordinator_c { _region.Value.Tell(new Counter.Get(4), probe4.Ref); probe4.ExpectMsg(21); - probe4.LastSender.Path.Should().Be(Node(_config.Fourth) / "user" / $"{TestCounterShardingTypeName}Region" / "4" / "4"); + probe4.LastSender.Path.Should().Be(Node(_config.Fourth) / "user" / "counterRegion" / "4" / "4"); }); }); }, _config.Fifth);