Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using EventStore.Core.Data;
using EventStore.Core.Tests.Helpers;
Expand All @@ -8,11 +9,13 @@
namespace EventStore.Core.Tests.Integration;

[TestFixture(typeof(LogFormat.V2), typeof(string))]
[NonParallelizable]
public class when_restarting_one_node_at_a_time<TLogFormat, TStreamId> : specification_with_cluster<TLogFormat, TStreamId>
{
private static readonly TimeSpan InitialStabilizationTimeout = TimeSpan.FromMinutes(5);
private static readonly TimeSpan RestartTimeout = TimeSpan.FromMinutes(3);
protected override TimeSpan GivenTimeout { get; } = TimeSpan.FromMinutes(10);
private static readonly bool IsArm64 = RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
private static readonly TimeSpan InitialStabilizationTimeout = TimeSpan.FromMinutes(IsArm64 ? 8 : 5);
private static readonly TimeSpan RestartTimeout = TimeSpan.FromMinutes(IsArm64 ? 5 : 3);
protected override TimeSpan GivenTimeout { get; } = TimeSpan.FromMinutes(IsArm64 ? 20 : 10);

protected override async Task Given()
{
Expand All @@ -23,24 +26,26 @@ protected override async Task Given()
var restartedNodeIndex = i % 3;

AssertEx.IsOrBecomesTrue(
() => {
() =>
{
var states = _nodes.Select(x => x.NodeState).ToArray();
return states.Count(x => x == VNodeState.Leader) == 1 &&
states.Count(x => x == VNodeState.Follower) == 2;
states.Count(x => x == VNodeState.Follower) == 2;
},
i == 0 ? InitialStabilizationTimeout : RestartTimeout,
$"Cluster did not stabilize before restarting node {restartedNodeIndex}",
MiniNodeLogging.WriteLogs);

await _nodes[restartedNodeIndex].Shutdown(keepDb: true);
AssertEx.IsOrBecomesTrue(
() => {
() =>
{
var states = _nodes
.Where((_, index) => index != restartedNodeIndex)
.Select(x => x.NodeState)
.ToArray();
return states.Count(x => x == VNodeState.Leader) == 1 &&
states.Count(x => x == VNodeState.Follower) == 1;
states.Count(x => x == VNodeState.Follower) == 1;
},
RestartTimeout,
$"Remaining cluster did not stabilize after shutting down node {restartedNodeIndex}",
Expand All @@ -54,10 +59,11 @@ protected override async Task Given()
await Task.WhenAll(_nodes.Select(x => x.Started))
.WithTimeout(RestartTimeout, MiniNodeLogging.WriteLogs);
AssertEx.IsOrBecomesTrue(
() => {
() =>
{
var states = _nodes.Select(x => x.NodeState).ToArray();
return states.Count(x => x == VNodeState.Leader) == 1 &&
states.Count(x => x == VNodeState.Follower) == 2;
states.Count(x => x == VNodeState.Follower) == 2;
},
RestartTimeout,
$"Cluster did not stabilize after restarting node {restartedNodeIndex}",
Expand Down
Loading