public ClusterSingletonLeaseSpec() : base(ConfigurationFactory.ParseString(@" #akka.loglevel = INFO akka.loglevel = DEBUG akka.actor.provider = ""cluster"" akka.cluster.singleton { use-lease = ""test-lease"" lease-retry-interval = 2000ms } akka.remote { dot-netty.tcp { hostname = ""127.0.0.1"" port = 0 } }").WithFallback(TestLease.Configuration)) { cluster = Cluster.Get(Sys); testLeaseExt = TestLeaseExt.Get(Sys); leaseOwner = cluster.SelfMember.Address.HostPort(); cluster.Join(cluster.SelfAddress); AwaitAssert(() => { cluster.SelfMember.Status.ShouldBe(MemberStatus.Up); }); }
public void LeaseMajority_in_a_5_node_cluster_should_keep_the_side_that_can_acquire_the_lease_round_2() { var lease = TestLeaseExt.Get(Sys).GetTestLease(testLeaseName); RunOn(() => { lease.SetNextAcquireResult(Task.FromResult(true)); }, _config.Node1); RunOn(() => { lease.SetNextAcquireResult(Task.FromResult(false)); }, _config.Node2, _config.Node3); EnterBarrier("lease-in-place-2"); RunOn(() => { foreach (var x in new[] { _config.Node1 }) { foreach (var y in new[] { _config.Node2, _config.Node3 }) { TestConductor.Blackhole(x, y, ThrottleTransportAdapter.Direction.Both).Wait(); } } }, _config.Node1); EnterBarrier("blackholed-clean-partition-2"); RunOn(() => { Within(TimeSpan.FromSeconds(20), () => { AwaitAssert(() => { Cluster.State.Members.Count.Should().Be(1); }); }); }, _config.Node1); RunOn(() => { Within(TimeSpan.FromSeconds(20), () => { AwaitAssert(() => { Cluster.IsTerminated.Should().BeTrue(); }); }); }, _config.Node2, _config.Node3); EnterBarrier("done-2"); }
public void LeaseMajority_in_a_5_node_cluster_should_keep_the_side_that_can_acquire_the_lease() { var lease = TestLeaseExt.Get(Sys).GetTestLease(testLeaseName); var leaseProbe = lease.Probe; RunOn(() => { lease.SetNextAcquireResult(Task.FromResult(true)); }, _config.Node1, _config.Node2, _config.Node3); RunOn(() => { lease.SetNextAcquireResult(Task.FromResult(false)); }, _config.Node4, _config.Node5); EnterBarrier("lease-in-place"); RunOn(() => { foreach (var x in new[] { _config.Node1, _config.Node2, _config.Node3 }) { foreach (var y in new[] { _config.Node4, _config.Node5 }) { TestConductor.Blackhole(x, y, ThrottleTransportAdapter.Direction.Both).Wait(); } } }, _config.Node1); EnterBarrier("blackholed-clean-partition"); RunOn(() => { Within(TimeSpan.FromSeconds(20), () => { AwaitAssert(() => { Cluster.State.Members.Count.Should().Be(3); }); }); RunOn(() => { leaseProbe.ExpectMsg <TestLease.AcquireReq>(); // after 2 * stable-after leaseProbe.ExpectMsg <TestLease.ReleaseReq>(TimeSpan.FromSeconds(14)); }, Leader(_config.Node1, _config.Node2, _config.Node3)); }, _config.Node1, _config.Node2, _config.Node3); RunOn(() => { Within(TimeSpan.FromSeconds(20), () => { AwaitAssert(() => { Cluster.IsTerminated.Should().BeTrue(); }); RunOn(() => { leaseProbe.ExpectMsg <TestLease.AcquireReq>(); }, Leader(_config.Node4, _config.Node5)); }); }, _config.Node4, _config.Node5); EnterBarrier("downed-and-removed"); leaseProbe.ExpectNoMsg(TimeSpan.FromSeconds(1)); EnterBarrier("done-1"); }