-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
porting Cluster heartbeat timings, hardened Akka.Cluster serialization (
#4934) * porting Cluster heartbeat timings, hardened Akka.Cluster serialization port akka/akka#27281 port akka/akka#25183 port akka/akka#24625 * increased ClusterLogSpec join timespan Increased the `TimeSpan` here to 10 seconds in order to prevent this spec from failing racily, since even an Akka.Cluster self-join can take more than the default 3 seconds due to some of the timings involved in node startup et al.
- Loading branch information
1 parent
fc5b043
commit 97628d4
Showing
11 changed files
with
855 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/core/Akka.Cluster.Tests/ClusterHeartbeatReceiverSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ClusterHeartbeatReceiverSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2021 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2021 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.TestKit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static Akka.Cluster.ClusterHeartbeatSender; | ||
|
||
namespace Akka.Cluster.Tests | ||
{ | ||
public class ClusterHeartbeatReceiverSpec : AkkaSpec | ||
{ | ||
public static Config Config = @"akka.actor.provider = cluster"; | ||
|
||
public ClusterHeartbeatReceiverSpec(ITestOutputHelper output) | ||
: base(Config, output) | ||
{ | ||
|
||
} | ||
|
||
[Fact] | ||
public void ClusterHeartbeatReceiver_should_respond_to_heartbeats_with_same_SeqNo_and_SendTime() | ||
{ | ||
var heartbeater = Sys.ActorOf(ClusterHeartbeatReceiver.Props(() => Cluster.Get(Sys))); | ||
heartbeater.Tell(new Heartbeat(Cluster.Get(Sys).SelfAddress, 1, 2)); | ||
ExpectMsg<HeartbeatRsp>(new HeartbeatRsp(Cluster.Get(Sys).SelfUniqueAddress, 1, 2)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ClusterHeartbeatSenderSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2021 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2021 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System.Collections.Immutable; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.TestKit; | ||
using Akka.Util; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static Akka.Cluster.ClusterHeartbeatSender; | ||
|
||
namespace Akka.Cluster.Tests | ||
{ | ||
public class ClusterHeartbeatSenderSpec : AkkaSpec | ||
{ | ||
class TestClusterHeartbeatSender : ClusterHeartbeatSender | ||
{ | ||
private readonly TestProbe _probe; | ||
|
||
public TestClusterHeartbeatSender(TestProbe probe) | ||
{ | ||
_probe = probe; | ||
} | ||
|
||
protected override void PreStart() | ||
{ | ||
// don't register for cluster events | ||
} | ||
|
||
protected override ActorSelection HeartbeatReceiver(Address address) | ||
{ | ||
return Context.ActorSelection(_probe.Ref.Path); | ||
} | ||
} | ||
|
||
public static readonly Config Config = @" | ||
akka.loglevel = DEBUG | ||
akka.actor.provider = cluster | ||
akka.cluster.failure-detector.heartbeat-interval = 0.2s | ||
"; | ||
|
||
public ClusterHeartbeatSenderSpec(ITestOutputHelper output) | ||
: base(Config, output){ } | ||
|
||
[Fact] | ||
public void ClusterHeartBeatSender_must_increment_heartbeat_SeqNo() | ||
{ | ||
var probe = CreateTestProbe(); | ||
var underTest = Sys.ActorOf(Props.Create(() => new TestClusterHeartbeatSender(probe))); | ||
|
||
underTest.Tell(new ClusterEvent.CurrentClusterState()); | ||
underTest.Tell(new ClusterEvent.MemberUp(new Member( | ||
new UniqueAddress(new Address("akka", Sys.Name), 1), 1, | ||
MemberStatus.Up, ImmutableHashSet<string>.Empty, AppVersion.Zero))); | ||
|
||
probe.ExpectMsg<Heartbeat>().SequenceNr.Should().Be(1L); | ||
probe.ExpectMsg<Heartbeat>().SequenceNr.Should().Be(2L); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.