Skip to content

Commit 33a3ad9

Browse files
committed
* Finish removing IRecoveryConfiguration, etc
1 parent 15812ce commit 33a3ad9

File tree

4 files changed

+55
-28
lines changed

4 files changed

+55
-28
lines changed

Tests/ConnectionRecoveryTests.cs

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ namespace Tests;
1515

1616
internal class FakeBackOffDelayPolicyDisabled : BackOffDelayPolicy
1717
{
18-
public int Delay()
18+
public new int Delay()
1919
{
2020
return 1;
2121
}
2222

23-
public void Reset()
23+
public new void Reset()
2424
{
2525
}
2626

27-
public bool IsActive() => false;
28-
public int CurrentAttempt => 1;
27+
public new bool IsActive() => false;
28+
public new int CurrentAttempt => 1;
2929
}
3030

3131
internal class FakeFastBackOffDelay : BackOffDelayPolicy
3232
{
33-
public int Delay()
33+
public new int Delay()
3434
{
3535
return 200;
3636
}
3737

38-
public void Reset()
38+
public new void Reset()
3939
{
4040
}
4141

42-
public bool IsActive() => true;
43-
public int CurrentAttempt => 1;
42+
public new bool IsActive() => true;
43+
public new int CurrentAttempt => 1;
4444
}
4545

4646
public class ConnectionRecoveryTests(ITestOutputHelper testOutputHelper)
@@ -345,11 +345,13 @@ public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
345345
Assert.Null(_connection);
346346
Assert.Null(_management);
347347

348+
var recoveryConfiguration = new RecoveryConfiguration();
349+
recoveryConfiguration.BackOffDelayPolicy(new FakeFastBackOffDelay());
350+
recoveryConfiguration.Topology(topologyEnabled);
351+
348352
IConnection connection = await AmqpConnection.CreateAsync(
349353
ConnectionSettingBuilder.Create()
350-
.RecoveryConfiguration(RecoveryConfiguration.Create()
351-
.BackOffDelayPolicy(new FakeFastBackOffDelay())
352-
.Topology(topologyEnabled))
354+
.RecoveryConfiguration(recoveryConfiguration)
353355
.ContainerId(_containerId)
354356
.Build());
355357
TaskCompletionSource<bool> twoRecoveryEventsSeenTcs = CreateTaskCompletionSource<bool>();
@@ -403,11 +405,13 @@ public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
403405
Assert.Null(_connection);
404406
Assert.Null(_management);
405407

408+
var recoveryConfiguration = new RecoveryConfiguration();
409+
recoveryConfiguration.BackOffDelayPolicy(new FakeFastBackOffDelay());
410+
recoveryConfiguration.Topology(topologyEnabled);
411+
406412
IConnection connection = await AmqpConnection.CreateAsync(
407413
ConnectionSettingBuilder.Create()
408-
.RecoveryConfiguration(RecoveryConfiguration.Create()
409-
.BackOffDelayPolicy(new FakeFastBackOffDelay())
410-
.Topology(topologyEnabled))
414+
.RecoveryConfiguration(recoveryConfiguration)
411415
.ContainerId(_containerId)
412416
.Build());
413417
TaskCompletionSource<bool> twoRecoveryEventsSeenTcs = CreateTaskCompletionSource<bool>();
@@ -486,11 +490,13 @@ public async Task RemoveAQueueShouldRemoveTheBindings()
486490

487491
string wontDeleteQueueName = _queueName + "-wont-delete";
488492

493+
var recoveryConfiguration = new RecoveryConfiguration();
494+
recoveryConfiguration.BackOffDelayPolicy(new FakeFastBackOffDelay());
495+
recoveryConfiguration.Topology(true);
496+
489497
IConnection connection = await AmqpConnection.CreateAsync(
490498
ConnectionSettingBuilder.Create()
491-
.RecoveryConfiguration(RecoveryConfiguration.Create()
492-
.BackOffDelayPolicy(new FakeFastBackOffDelay())
493-
.Topology(true))
499+
.RecoveryConfiguration(recoveryConfiguration)
494500
.ContainerId(_containerId)
495501
.Build());
496502

@@ -546,11 +552,13 @@ public async Task RemoveAnExchangeShouldRemoveTheBindings()
546552

547553
string wontDeleteExchangeName = _exchangeName + "-wont-delete";
548554

555+
var recoveryConfiguration = new RecoveryConfiguration();
556+
recoveryConfiguration.BackOffDelayPolicy(new FakeFastBackOffDelay());
557+
recoveryConfiguration.Topology(true);
558+
549559
IConnection connection = await AmqpConnection.CreateAsync(
550560
ConnectionSettingBuilder.Create()
551-
.RecoveryConfiguration(RecoveryConfiguration.Create()
552-
.BackOffDelayPolicy(new FakeFastBackOffDelay())
553-
.Topology(true))
561+
.RecoveryConfiguration(recoveryConfiguration)
554562
.ContainerId(_containerId)
555563
.Build());
556564

@@ -615,11 +623,13 @@ public async Task RemoveAnExchangeBoundToAnotherExchangeShouldRemoveTheBindings(
615623

616624
string destinationExchangeName = _exchangeName + "-destination";
617625

626+
var recoveryConfiguration = new RecoveryConfiguration();
627+
recoveryConfiguration.BackOffDelayPolicy(new FakeFastBackOffDelay());
628+
recoveryConfiguration.Topology(true);
629+
618630
IConnection connection = await AmqpConnection.CreateAsync(
619631
ConnectionSettingBuilder.Create()
620-
.RecoveryConfiguration(RecoveryConfiguration.Create()
621-
.BackOffDelayPolicy(new FakeFastBackOffDelay())
622-
.Topology(true))
632+
.RecoveryConfiguration(recoveryConfiguration)
623633
.ContainerId(_containerId)
624634
.Build());
625635

Tests/Recovery/CustomPublisherConsumerRecoveryTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ public async Task PublisherAndConsumerShouldNotRestartIfRecoveryIsDisabled()
8888

8989
// Here we need a second _connection since the RecoveryConfiguration is disabled
9090
// and the _connection is closed. So we can't use the same _connection to delete the queue
91+
92+
var recoveryConfiguration1 = new RecoveryConfiguration();
93+
recoveryConfiguration1.Activated(false);
94+
9195
IConnection connection2 = await AmqpConnection.CreateAsync(
92-
ConnectionSettingBuilder.Create().RecoveryConfiguration(RecoveryConfiguration.Create().Activated(false))
96+
ConnectionSettingBuilder.Create()
97+
.RecoveryConfiguration(recoveryConfiguration1)
9398
.ContainerId(_containerId).Build());
9499

95100
IQueueSpecification queueSpec2 = connection2.Management().Queue(_queueName);

Tests/Recovery/PublisherConsumerRecoveryTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public async Task PublisherAndConsumerShouldNotRestartIfRecoveryIsDisabled()
262262
await _connection.CloseAsync();
263263
_connection.Dispose();
264264

265-
IRecoveryConfiguration recoveryConfiguration = RecoveryConfiguration.Create().Activated(false);
265+
RecoveryConfiguration recoveryConfiguration = new RecoveryConfiguration().Activated(false);
266266
ConnectionSettings connectionSettings =
267267
ConnectionSettingBuilder.Create().RecoveryConfiguration(recoveryConfiguration)
268268
.ContainerId(_containerId).Build();
@@ -324,8 +324,13 @@ public async Task PublisherAndConsumerShouldNotRestartIfRecoveryIsDisabled()
324324

325325
// Here we need a second _connection since the RecoveryConfiguration is disabled
326326
// and the _connection is closed. So we can't use the same _connection to delete the queue
327+
328+
var recoveryConfiguration1 = new RecoveryConfiguration();
329+
recoveryConfiguration1.Activated(false);
330+
327331
IConnection connection2 = await AmqpConnection.CreateAsync(
328-
ConnectionSettingBuilder.Create().RecoveryConfiguration(RecoveryConfiguration.Create().Activated(false))
332+
ConnectionSettingBuilder.Create()
333+
.RecoveryConfiguration(recoveryConfiguration1)
329334
.ContainerId(_containerId).Build());
330335

331336
IQueueSpecification queueSpec2 = connection2.Management().Queue(_queueName);

Tests/Rpc/RecoveryRPCTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@ public async Task RpcServerAndClientShouldRecoverAfterKillConnection()
2222
Assert.Null(_management);
2323

2424
string containerId = $"rpc-server-client-recovery-{DateTime.Now}";
25-
IConnection connection = await AmqpConnection.CreateAsync(ConnectionSettingBuilder.Create()
26-
.ContainerId(containerId).RecoveryConfiguration(RecoveryConfiguration.Create().Topology(true)).Build());
25+
26+
var recoveryConfiguration = new RecoveryConfiguration();
27+
recoveryConfiguration.Topology(true);
28+
29+
IConnection connection = await AmqpConnection.CreateAsync(
30+
ConnectionSettingBuilder.Create()
31+
.ContainerId(containerId)
32+
.RecoveryConfiguration(recoveryConfiguration).Build());
33+
2734
IManagement management = connection.Management();
2835
string rpcRequestQueueName = $"rpc-server-client-recovery-queue-request-{DateTime.Now}";
2936
IQueueSpecification requestQueue = management.Queue(rpcRequestQueueName)

0 commit comments

Comments
 (0)