Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/core/Akka.Remote.Tests/AccrualFailureDetectorSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Akka.TestKit;
using Akka.Util.Internal;
using Xunit;

namespace Akka.Remote.Tests
{

public class AccrualFailureDetectorSpec : AkkaSpec
public class AccrualFailureDetectorSpec
{
public static IEnumerable<(T, T)> Slide<T>(IEnumerable<T> values)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.Tests/AckedDeliverySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Akka.Remote.Tests
{

public class AckedDeliverySpec : AkkaSpec
public class AckedDeliverySpec
{
sealed class Sequenced : IHasSequenceNumber
{
Expand Down
3 changes: 1 addition & 2 deletions src/core/Akka.Remote.Tests/DeadlineFailureDetectorSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Akka.TestKit;
using FluentAssertions;
using FluentAssertions.Extensions;
using Xunit;

namespace Akka.Remote.Tests
{
public class DeadlineFailureDetectorSpec : AkkaSpec
public class DeadlineFailureDetectorSpec
{
[Fact]
public void DeadlineFailureDetector_must_mark_node_as_monitored_after_a_series_of_successful_heartbeats()
Expand Down
3 changes: 1 addition & 2 deletions src/core/Akka.Remote.Tests/FailureDetectorRegistrySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

using System;
using System.Collections.Generic;
using Akka.TestKit;
using Xunit;

namespace Akka.Remote.Tests
{

public class FailureDetectorRegistrySpec : AkkaSpec
public class FailureDetectorRegistrySpec
{
[Fact]
public void FailureDetectorRegistry_must_mark_node_as_available_after_a_series_of_successful_heartbeats()
Expand Down
28 changes: 13 additions & 15 deletions src/core/Akka.Remote.Tests/Transport/AkkaProtocolSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,18 @@ private Collaborators GetCollaborators()
private class TestFailureDetector : FailureDetector
{
#pragma warning disable CS0420
// ReSharper disable once InconsistentNaming
internal volatile bool isAvailable = true;
public override bool IsAvailable => Volatile.Read(ref isAvailable);

// ReSharper disable once InconsistentNaming
internal volatile bool called;
public override bool IsMonitoring => Volatile.Read(ref called);
#pragma warning restore CS0420
private volatile bool _isAvailable = true;
public override bool IsAvailable => Volatile.Read(ref _isAvailable);
public void SetAvailable(bool available) => Volatile.Write(ref _isAvailable, available);

private volatile bool _called;
public override bool IsMonitoring => Volatile.Read(ref _called);

public override void HeartBeat()
{
called = true;
Volatile.Write(ref _called, true);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Volatile is being accessed inconsistently, make sure that all volatile are accessed properly.

}
#pragma warning restore CS0420
}

private readonly Config _config;
Expand Down Expand Up @@ -167,7 +166,7 @@ public async Task ProtocolStateActor_must_in_inbound_mode_accept_payload_after_A

reader.Tell(TestAssociate(33), TestActor);

await AwaitConditionAsync(() => collaborators.FailureDetector.called, DefaultTimeout);
await AwaitConditionAsync(() => collaborators.FailureDetector.IsMonitoring, DefaultTimeout);

var wrappedHandle = await ExpectMsgOfAsync(DefaultTimeout, "expected InboundAssociation", o =>
{
Expand All @@ -181,7 +180,7 @@ public async Task ProtocolStateActor_must_in_inbound_mode_accept_payload_after_A

wrappedHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(TestActor));

Assert.True(collaborators.FailureDetector.called);
Assert.True(collaborators.FailureDetector.IsMonitoring);

@Arkatufus Arkatufus Apr 28, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to change this to the same assertion if the last change proven to fix the racy condition


// Heartbeat was sent in response to Associate
await AwaitConditionAsync(() => LastActivityIsHeartbeat(collaborators.Registry), DefaultTimeout);
Expand Down Expand Up @@ -236,7 +235,8 @@ public async Task ProtocolStateActor_must_in_outbound_mode_delay_readiness_until
failureDetector: collaborators.FailureDetector));

await AwaitConditionAsync(() => LastActivityIsAssociate(collaborators.Registry, 42), DefaultTimeout);
Assert.True(collaborators.FailureDetector.called);

await AwaitConditionAsync(() => collaborators.FailureDetector.IsMonitoring, DefaultTimeout);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, its safer to await the condition instead


//keeps sending heartbeats
await AwaitConditionAsync(() => LastActivityIsHeartbeat(collaborators.Registry), DefaultTimeout);
Expand Down Expand Up @@ -393,9 +393,7 @@ public async Task ProtocolStateActor_must_disassociate_when_failure_detector_sig
//wait for one heartbeat
await AwaitConditionAsync(() => LastActivityIsHeartbeat(collaborators.Registry), DefaultTimeout);

#pragma warning disable CS0420
Volatile.Write(ref collaborators.FailureDetector.isAvailable, false);
#pragma warning restore CS0420
collaborators.FailureDetector.SetAvailable(false);

await ExpectMsgOfAsync("expected Disassociated(DisassociateInfo.Unknown", o =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.Tests/Transport/ThrottleModeSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Akka.Remote.Tests.Transport
{
public class ThrottleModeSpec : AkkaSpec
public class ThrottleModeSpec
{
static readonly long HalfSecond = TimeSpan.FromSeconds(0.5).Ticks.ToNanos();

Expand Down