Skip to content

Commit

Permalink
SBR fix & update (#5147)
Browse files Browse the repository at this point in the history
* configuration for SBR lease release (migrated from akka/akka#30092)

* Simplified reverse in lease majority (migrated from akka/akka#30155)

* shared TestLease objects moved to Akka.Coordination.Tests

* Gossip verbose log fix

* SBR fix

* SBR missing multinode tests added

* lease test fix
  • Loading branch information
zbynek001 authored Aug 3, 2021
1 parent 23aead4 commit e873ecb
Show file tree
Hide file tree
Showing 25 changed files with 1,169 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<AssemblyTitle>Akka.Cluster.Sharding.Tests</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Coordination.Tests\Akka.Coordination.Tests.csproj" />
<ProjectReference Include="..\Akka.Cluster.Sharding\Akka.Cluster.Sharding.csproj" />
<ProjectReference Include="..\..\..\core\Akka.Persistence\Akka.Persistence.csproj" />
<ProjectReference Include="..\..\persistence\Akka.Persistence.Sql.Common\Akka.Persistence.Sql.Common.csproj" />
<ProjectReference Include="..\..\..\core\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
<ProjectReference Include="..\Akka.Cluster.Tools.Tests\Akka.Cluster.Tools.Tests.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Tools.Singleton;
using Akka.Cluster.Tools.Tests;
using Akka.Configuration;
using Akka.Coordination.Tests;
using Akka.TestKit;
using Akka.TestKit.TestActors;
using Akka.Util;
Expand Down
4 changes: 2 additions & 2 deletions src/contrib/cluster/Akka.Cluster.Sharding.Tests/ShardSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Tools.Singleton;
using Akka.Cluster.Tools.Tests;
using Akka.Configuration;
using Akka.Coordination;
using Akka.Coordination.Tests;
using Akka.Event;
using Akka.TestKit;
using Akka.Util;
Expand Down Expand Up @@ -51,7 +51,7 @@ static ShardSpec()
akka.actor.provider = ""cluster""
akka.remote.dot-netty.tcp.port = 0
test-lease {
lease-class = ""Akka.Cluster.Tools.Tests.TestLease, Akka.Cluster.Tools.Tests""
lease-class = ""Akka.Coordination.Tests.TestLease, Akka.Coordination.Tests""
heartbeat-interval = 1s
heartbeat-timeout = 120s
lease-operation-timeout = 3s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />

<PropertyGroup>
<AssemblyTitle>Akka.Cluster.Tools.Tests.MultiNode</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Coordination.Tests\Akka.Coordination.Tests.csproj" />
<ProjectReference Include="..\Akka.Cluster.Tools\Akka.Cluster.Tools.csproj" />
<ProjectReference Include="..\..\..\core\Akka.Cluster.TestKit\Akka.Cluster.TestKit.csproj" />
<ProjectReference Include="..\..\..\core\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Akka.Cluster.TestKit;
using Akka.Cluster.Tools.Singleton;
using Akka.Configuration;
using Akka.Coordination.Tests;
using Akka.Event;
using Akka.Remote.TestKit;
using Akka.TestKit;
Expand Down Expand Up @@ -45,7 +46,7 @@ public ClusterSingletonManagerLeaseSpecConfig()
akka.cluster.auto-down-unreachable-after = 0s
akka.cluster.testkit.auto-down-unreachable-after = 0s
test-lease {
lease-class = ""Akka.Cluster.Tools.Tests.MultiNode.TestLeaseActorClient, Akka.Cluster.Tools.Tests.MultiNode""
lease-class = ""Akka.Coordination.Tests.TestLeaseActorClient, Akka.Coordination.Tests""
heartbeat-interval = 1s
heartbeat-timeout = 120s
lease-operation-timeout = 3s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Coordination.Tests\Akka.Coordination.Tests.csproj" />
<ProjectReference Include="..\Akka.Cluster.Tools\Akka.Cluster.Tools.csproj" />
<ProjectReference Include="..\..\..\core\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Akka.Actor;
using Akka.Cluster.Tools.Singleton;
using Akka.Configuration;
using Akka.Coordination.Tests;
using Akka.Event;
using Akka.TestKit;
using Akka.TestKit.TestActors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,15 @@ namespace Akka.Cluster.SBR
}
public sealed class LeaseMajoritySettings
{
[System.ObsoleteAttribute()]
public LeaseMajoritySettings(string leaseImplementation, System.TimeSpan acquireLeaseDelayForMinority, string role) { }
[System.ObsoleteAttribute()]
public LeaseMajoritySettings(string leaseImplementation, System.TimeSpan acquireLeaseDelayForMinority, string role, string leaseName) { }
public LeaseMajoritySettings(string leaseImplementation, System.TimeSpan acquireLeaseDelayForMinority, System.TimeSpan releaseAfter, string role, string leaseName) { }
public System.TimeSpan AcquireLeaseDelayForMinority { get; }
public string LeaseImplementation { get; }
public string LeaseName { get; }
public System.TimeSpan ReleaseAfter { get; }
public string Role { get; }
public string SafeLeaseName(string systemName) { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@

<ItemGroup>
<ProjectReference Include="..\Akka.Cluster.TestKit\Akka.Cluster.TestKit.csproj" />
<ProjectReference Include="..\Akka.Coordination.Tests\Akka.Coordination.Tests.csproj" />
<ProjectReference Include="..\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//-----------------------------------------------------------------------
// <copyright file="DownAllIndirectlyConnected5NodeSpec.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;
using System.Linq;
using Akka.Cluster.TestKit;
using Akka.Configuration;
using Akka.Remote.TestKit;
using Akka.Remote.Transport;
using Akka.TestKit;
using FluentAssertions;

namespace Akka.Cluster.Tests.MultiNode.SBR
{
public class DownAllIndirectlyConnected5NodeSpecConfig : MultiNodeConfig
{
public RoleName Node1 { get; }
public RoleName Node2 { get; }
public RoleName Node3 { get; }
public RoleName Node4 { get; }
public RoleName Node5 { get; }


public DownAllIndirectlyConnected5NodeSpecConfig()
{
Node1 = Role("node1");
Node2 = Role("node2");
Node3 = Role("node3");
Node4 = Role("node4");
Node5 = Role("node5");

CommonConfig = ConfigurationFactory.ParseString(@"
akka {
loglevel = INFO
cluster {
downing-provider-class = ""Akka.Cluster.SBR.SplitBrainResolverProvider""
split-brain-resolver.active-strategy = keep-majority
split-brain-resolver.stable-after = 6s
run-coordinated-shutdown-when-down = off
}
actor.provider = cluster
test.filter-leeway = 10s
}")
.WithFallback(MultiNodeLoggingConfig.LoggingConfig)
.WithFallback(DebugConfig(true))
.WithFallback(MultiNodeClusterSpec.ClusterConfig());

TestTransport = true;
}
}

public class DownAllIndirectlyConnected5NodeSpec : MultiNodeClusterSpec
{
private readonly DownAllIndirectlyConnected5NodeSpecConfig _config;

public DownAllIndirectlyConnected5NodeSpec()
: this(new DownAllIndirectlyConnected5NodeSpecConfig())
{
}

protected DownAllIndirectlyConnected5NodeSpec(DownAllIndirectlyConnected5NodeSpecConfig config)
: base(config, typeof(DownAllIndirectlyConnected5NodeSpec))
{
_config = config;
}

[MultiNodeFact]
public void DownAllIndirectlyConnected5NodeSpecTests()
{
A_5_node_cluster_with_keep_one_indirectly_connected_off_should_down_all_when_indirectly_connected_combined_with_clean_partition();
}

public void A_5_node_cluster_with_keep_one_indirectly_connected_off_should_down_all_when_indirectly_connected_combined_with_clean_partition()
{
var cluster = Cluster.Get(Sys);

RunOn(() =>
{
cluster.Join(cluster.SelfAddress);
}, _config.Node1);
EnterBarrier("node1 joined");
RunOn(() =>
{
cluster.Join(Node(_config.Node1).Address);
}, _config.Node2, _config.Node3, _config.Node4, _config.Node5);
Within(TimeSpan.FromSeconds(10), () =>
{
AwaitAssert(() =>
{
cluster.State.Members.Count.Should().Be(5);
foreach (var m in cluster.State.Members)
{
m.Status.Should().Be(MemberStatus.Up);
}
});
});
EnterBarrier("Cluster formed");

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(() =>
{
TestConductor.Blackhole(_config.Node2, _config.Node3, ThrottleTransportAdapter.Direction.Both).Wait();
}, _config.Node1);
EnterBarrier("blackholed-indirectly-connected");

Within(TimeSpan.FromSeconds(10), () =>
{
AwaitAssert(() =>
{
RunOn(() =>
{
cluster.State.Unreachable.Select(i => i.Address).Should().BeEquivalentTo(new[] { _config.Node2, _config.Node3, _config.Node4, _config.Node5 }.Select(i => Node(i).Address));
}, _config.Node1);
RunOn(() =>
{
cluster.State.Unreachable.Select(i => i.Address).Should().BeEquivalentTo(new[] { _config.Node3, _config.Node4, _config.Node5 }.Select(i => Node(i).Address));
}, _config.Node2);
RunOn(() =>
{
cluster.State.Unreachable.Select(i => i.Address).Should().BeEquivalentTo(new[] { _config.Node2, _config.Node4, _config.Node5 }.Select(i => Node(i).Address));
}, _config.Node3);
RunOn(() =>
{
cluster.State.Unreachable.Select(i => i.Address).Should().BeEquivalentTo(new[] { _config.Node1, _config.Node2, _config.Node3 }.Select(i => Node(i).Address));
}, _config.Node4, _config.Node5);
});
});
EnterBarrier("unreachable");

RunOn(() =>
{
Within(TimeSpan.FromSeconds(15), () =>
{
AwaitAssert(() =>
{
cluster.State.Members.Select(i => i.Address).Should().BeEquivalentTo(Node(_config.Node1).Address);
foreach (var m in cluster.State.Members)
{
m.Status.Should().Be(MemberStatus.Up);
}
});
});
}, _config.Node1);

RunOn(() =>
{
// downed
AwaitCondition(() => cluster.IsTerminated, max: TimeSpan.FromSeconds(15));
}, _config.Node2, _config.Node3, _config.Node4, _config.Node5);

EnterBarrier("done");
}
}
}
Loading

0 comments on commit e873ecb

Please sign in to comment.