-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
porting Cluster heartbeat timings, hardened Akka.Cluster serialization #4934
Merged
Aaronontheweb
merged 4 commits into
akkadotnet:dev
from
Aaronontheweb:cluster/heartbeat-serialization-upgrades
Apr 13, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dd0f6b2
porting Cluster heartbeat timings, hardened Akka.Cluster serialization
Arkatufus 0455bc7
Merge branch 'dev' into cluster/heartbeat-serialization-upgrades
Aaronontheweb e2fc938
added updated API Spec
Aaronontheweb 026d922
increased ClusterLogSpec join timespan
Aaronontheweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So even though this is part of the public API, I don't think this is much of a "breaking change" as the serializer isn't called directly from user code (that I'm aware of) and it's really meant to be an internal api.