fix: apply BecomeLeader() to all cluster test fixtures after stepdown
Extended the BecomeLeader() fix to JetStreamClusterFixture, ClusterFailoverFixture, and LeaderFailoverParityFixture. All three fixtures now auto-simulate leader election after stepdown, matching the MetaControllerFixture fix from the previous commit.
This commit is contained in:
@@ -223,7 +223,17 @@ internal sealed class JetStreamClusterFixture : IAsyncDisposable
|
||||
/// Go ref: nc.Request() in cluster test helpers.
|
||||
/// </summary>
|
||||
public Task<JetStreamApiResponse> RequestAsync(string subject, string payload)
|
||||
=> Task.FromResult(_router.Route(subject, Encoding.UTF8.GetBytes(payload)));
|
||||
{
|
||||
var response = _router.Route(subject, Encoding.UTF8.GetBytes(payload));
|
||||
|
||||
// In a real cluster, after stepdown a new leader is elected.
|
||||
// Simulate this node becoming the new leader so subsequent
|
||||
// mutating operations through the router succeed.
|
||||
if (subject.Equals(JetStreamApiSubjects.MetaLeaderStepdown, StringComparison.Ordinal) && response.Success)
|
||||
_metaGroup.BecomeLeader();
|
||||
|
||||
return Task.FromResult(response);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Leader operations
|
||||
@@ -241,7 +251,13 @@ internal sealed class JetStreamClusterFixture : IAsyncDisposable
|
||||
/// Go ref: c.leader().Shutdown() in jetstream_helpers_test.go.
|
||||
/// </summary>
|
||||
public void StepDownMetaLeader()
|
||||
=> _metaGroup.StepDown();
|
||||
{
|
||||
_metaGroup.StepDown();
|
||||
// In a real cluster, a new leader is elected after stepdown.
|
||||
// Simulate this node becoming the new leader so subsequent
|
||||
// mutating operations through the router succeed.
|
||||
_metaGroup.BecomeLeader();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current meta-group state snapshot.
|
||||
|
||||
Reference in New Issue
Block a user