Skip to content

Commit

Permalink
Fix Multinode spec ClusterShardingSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus committed Apr 28, 2021
1 parent 8b738cb commit 80897e5
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<IActorRef> _region;
Expand All @@ -399,7 +397,7 @@ protected ClusterShardingSpec(ClusterShardingSpecConfig config, Type type)
{
_config = config;

_region = new Lazy<IActorRef>(() => CreateRegion(TestCounterShardingTypeName, false));
_region = new Lazy<IActorRef>(() => CreateRegion("counter", false));
_rebalancingRegion = new Lazy<IActorRef>(() => CreateRegion("rebalancingCounter", false));

_persistentEntitiesRegion = new Lazy<IActorRef>(() => CreateRegion("RememberCounterEntities", true));
Expand Down Expand Up @@ -456,7 +454,7 @@ private void CreateCoordinator()
{
var typeNames = new[]
{
TestCounterShardingTypeName, "rebalancingCounter", "RememberCounterEntities", "AnotherRememberCounter",
"counter", "rebalancingCounter", "RememberCounterEntities", "AnotherRememberCounter",
"RememberCounter", "RebalancingRememberCounter", "AutoMigrateRememberRegionTest"
};

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
});
});
Expand All @@ -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);
Expand Down

0 comments on commit 80897e5

Please sign in to comment.