Skip to content

Commit c62acc8

Browse files
committed
* Update deps
* Modify `ConnectionRecoveryTests` to use `IntegrationTest` base class `_containerId` property.
1 parent 0a7fe2e commit c62acc8

File tree

5 files changed

+74
-51
lines changed

5 files changed

+74
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ InternalTrace*
1111
*.lock.json
1212
nunit-agent*
1313
*.pyc
14+
test-diag.log
1415
test-output.log
1516
TestResults.xml
1617
TestResult.xml

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<!-- HAClient -->
99
<PackageVersion Include="DotNext.Threading" Version="5.15.0" />
1010
<!-- Tests -->
11-
<PackageVersion Include="xunit" Version="2.9.0" />
11+
<PackageVersion Include="xunit" Version="2.9.2" />
1212
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
1313
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
1414
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
15+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
1616
<PackageVersion Include="EasyNetQ.Management.Client" Version="3.0.0" />
1717
</ItemGroup>
1818
<ItemGroup Condition="$(TargetFramework)=='netstandard2.0'">
@@ -37,6 +37,6 @@
3737
<ItemGroup Condition="'$(IsPackable)'=='true'">
3838
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
3939
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
40-
<GlobalPackageReference Include="MinVer" Version="5.0.0" />
40+
<GlobalPackageReference Include="MinVer" Version="6.0.0" />
4141
</ItemGroup>
4242
</Project>

Tests/ConnectionRecoveryTests.cs

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public void Reset()
4444
public int CurrentAttempt => 1;
4545
}
4646

47-
public class ConnectionRecoveryTests(ITestOutputHelper testOutputHelper) : IntegrationTest(testOutputHelper)
47+
public class ConnectionRecoveryTests(ITestOutputHelper testOutputHelper)
48+
: IntegrationTest(testOutputHelper, setupConnectionAndManagement: false)
4849
{
4950
/// <summary>
5051
/// The normal close the status should be correct and error null
@@ -57,10 +58,11 @@ public class ConnectionRecoveryTests(ITestOutputHelper testOutputHelper) : Integ
5758
[InlineData(false)]
5859
public async Task NormalCloseTheStatusShouldBeCorrectAndErrorNull(bool activeRecovery)
5960
{
60-
string localContainerId = $"{_containerId}_normal-close-connection-name";
61+
Assert.Null(_connection);
62+
Assert.Null(_management);
6163

6264
IConnection connection = await AmqpConnection.CreateAsync(
63-
ConnectionSettingBuilder.Create().ContainerId(localContainerId).RecoveryConfiguration(
65+
ConnectionSettingBuilder.Create().ContainerId(_containerId).RecoveryConfiguration(
6466
RecoveryConfiguration.Create().Activated(activeRecovery).Topology(false)).Build());
6567

6668
TaskCompletionSource<bool> connectionClosedStateTcs = CreateTaskCompletionSource<bool>();
@@ -104,11 +106,11 @@ public async Task NormalCloseTheStatusShouldBeCorrectAndErrorNull(bool activeRec
104106
[Fact]
105107
public async Task UnexpectedCloseTheStatusShouldBeCorrectAndErrorNotNull()
106108
{
107-
108-
string localContainerId = $"{_containerId}_unexpected-close-connection-name";
109+
Assert.Null(_connection);
110+
Assert.Null(_management);
109111

110112
IConnection connection = await AmqpConnection.CreateAsync(
111-
ConnectionSettingBuilder.Create().ContainerId(localContainerId).RecoveryConfiguration(
113+
ConnectionSettingBuilder.Create().ContainerId(_containerId).RecoveryConfiguration(
112114
RecoveryConfiguration.Create().Activated(true).Topology(false)
113115
.BackOffDelayPolicy(new FakeFastBackOffDelay())).Build());
114116

@@ -144,7 +146,7 @@ public async Task UnexpectedCloseTheStatusShouldBeCorrectAndErrorNotNull()
144146
};
145147

146148
Assert.Equal(State.Open, connection.State);
147-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
149+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
148150
await listErrorCountGreaterThanOrEqualToTwoTcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
149151

150152
Assert.Equal(State.Open, listFromStatus[0]);
@@ -177,10 +179,11 @@ public async Task UnexpectedCloseTheStatusShouldBeCorrectAndErrorNotNull()
177179
[Fact]
178180
public async Task OverrideTheBackOffWithBackOffDisabled()
179181
{
182+
Assert.Null(_connection);
183+
Assert.Null(_management);
180184

181-
string localContainerId = $"{_containerId}_override-backoff-disabled-connection-name";
182185
IConnection connection = await AmqpConnection.CreateAsync(
183-
ConnectionSettingBuilder.Create().ContainerId(localContainerId).RecoveryConfiguration(
186+
ConnectionSettingBuilder.Create().ContainerId(_containerId).RecoveryConfiguration(
184187
RecoveryConfiguration.Create().Activated(true).Topology(false).BackOffDelayPolicy(
185188
new FakeBackOffDelayPolicyDisabled())).Build());
186189

@@ -211,7 +214,7 @@ public async Task OverrideTheBackOffWithBackOffDisabled()
211214
};
212215

213216
Assert.Equal(State.Open, connection.State);
214-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
217+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
215218

216219
await listFromStatusCountGreaterOrEqualToTwo.Task.WaitAsync(TimeSpan.FromSeconds(5));
217220

@@ -239,14 +242,16 @@ public async Task OverrideTheBackOffWithBackOffDisabled()
239242
[Fact]
240243
public async Task RecoveryTopologyShouldRecoverTheTempQueues()
241244
{
242-
string localContainerId = $"{_containerId}_temp-queue-should-recover-connection-name";
245+
Assert.Null(_connection);
246+
Assert.Null(_management);
247+
243248
string queueName = $"temp-queue-should-recover-{true}";
244-
var connection = await AmqpConnection.CreateAsync(
249+
IConnection connection = await AmqpConnection.CreateAsync(
245250
ConnectionSettingBuilder.Create()
246251
.RecoveryConfiguration(RecoveryConfiguration.Create()
247252
.BackOffDelayPolicy(new FakeFastBackOffDelay())
248253
.Topology(true))
249-
.ContainerId(localContainerId)
254+
.ContainerId(_containerId)
250255
.Build());
251256
TaskCompletionSource<bool> twoRecoveryEventsSeenTcs = CreateTaskCompletionSource<bool>();
252257
int recoveryEvents = 0;
@@ -262,7 +267,7 @@ public async Task RecoveryTopologyShouldRecoverTheTempQueues()
262267
await management.Queue().Name(queueName).AutoDelete(true).Exclusive(true).DeclareAsync();
263268
Assert.Equal(1, topologyListener.QueueCount());
264269

265-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
270+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
266271
await twoRecoveryEventsSeenTcs.Task.WaitAsync(TimeSpan.FromSeconds(10));
267272
await SystemUtils.WaitUntilFuncAsync(() => recoveryEvents == 2);
268273

@@ -285,14 +290,16 @@ public async Task RecoveryTopologyShouldRecoverTheTempQueues()
285290
[Fact]
286291
public async Task RecoveryTopologyShouldNotRecoverTheTempQueues()
287292
{
293+
Assert.Null(_connection);
294+
Assert.Null(_management);
295+
288296
string queueName = $"temp-queue-should-recover-{false}";
289-
string localContainerId = $"{_containerId}_temp-queue-should-not-recover-connection-name";
290-
var connection = await AmqpConnection.CreateAsync(
297+
IConnection connection = await AmqpConnection.CreateAsync(
291298
ConnectionSettingBuilder.Create()
292299
.RecoveryConfiguration(RecoveryConfiguration.Create()
293300
.BackOffDelayPolicy(new FakeFastBackOffDelay())
294301
.Topology(false))
295-
.ContainerId(localContainerId)
302+
.ContainerId(_containerId)
296303
.Build());
297304
TaskCompletionSource<bool> oneRecoveryEventSeenTcs = CreateTaskCompletionSource<bool>();
298305
int recoveryEvents = 0;
@@ -308,7 +315,7 @@ public async Task RecoveryTopologyShouldNotRecoverTheTempQueues()
308315
await management.Queue().Name(queueName).AutoDelete(true).Exclusive(true).DeclareAsync();
309316
Assert.Equal(1, topologyListener.QueueCount());
310317

311-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
318+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
312319
await oneRecoveryEventSeenTcs.Task.WaitAsync(TimeSpan.FromSeconds(10));
313320

314321
await SystemUtils.WaitUntilQueueDeletedAsync(queueName);
@@ -322,14 +329,16 @@ public async Task RecoveryTopologyShouldNotRecoverTheTempQueues()
322329
[InlineData(false)]
323330
public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
324331
{
332+
Assert.Null(_connection);
333+
Assert.Null(_management);
334+
325335
const string exchangeName = "exchange-should-recover";
326-
string localContainerId = $"{_containerId}_exchange-should-recover-connection-name";
327336
IConnection connection = await AmqpConnection.CreateAsync(
328337
ConnectionSettingBuilder.Create()
329338
.RecoveryConfiguration(RecoveryConfiguration.Create()
330339
.BackOffDelayPolicy(new FakeFastBackOffDelay())
331340
.Topology(topologyEnabled))
332-
.ContainerId(localContainerId)
341+
.ContainerId(_containerId)
333342
.Build());
334343
TaskCompletionSource<bool> twoRecoveryEventsSeenTcs = CreateTaskCompletionSource<bool>();
335344
int recoveryEvents = 0;
@@ -351,7 +360,7 @@ public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
351360
// the exchange is recovered.
352361
await SystemUtils.DeleteExchangeAsync("exchange-should-recover");
353362

354-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
363+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
355364

356365
await twoRecoveryEventsSeenTcs.Task.WaitAsync(TimeSpan.FromSeconds(10));
357366

@@ -379,13 +388,15 @@ public async Task RecoveryTopologyShouldRecoverExchanges(bool topologyEnabled)
379388
[InlineData(false)]
380389
public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
381390
{
382-
string localContainerId = $"{_containerId}_binding-should-recover-connection-name";
383-
var connection = await AmqpConnection.CreateAsync(
391+
Assert.Null(_connection);
392+
Assert.Null(_management);
393+
394+
IConnection connection = await AmqpConnection.CreateAsync(
384395
ConnectionSettingBuilder.Create()
385396
.RecoveryConfiguration(RecoveryConfiguration.Create()
386397
.BackOffDelayPolicy(new FakeFastBackOffDelay())
387398
.Topology(topologyEnabled))
388-
.ContainerId(localContainerId)
399+
.ContainerId(_containerId)
389400
.Build());
390401
TaskCompletionSource<bool> twoRecoveryEventsSeenTcs = CreateTaskCompletionSource<bool>();
391402
int recoveryEvents = 0;
@@ -398,14 +409,14 @@ public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
398409
};
399410
IManagement management = connection.Management();
400411
ITopologyListener topologyListener = ((IManagementTopology)management).TopologyListener();
401-
var exSpec = management.Exchange().Name("exchange-should-recover-binding").AutoDelete(true)
412+
IExchangeSpecification exSpec = management.Exchange().Name("exchange-should-recover-binding").AutoDelete(true)
402413
.Type(ExchangeType.DIRECT);
403414
await exSpec.DeclareAsync();
404415
Assert.Equal(1, topologyListener.ExchangeCount());
405-
var queueSpec = management.Queue().Name("queue-should-recover-binding").AutoDelete(true).Exclusive(true);
416+
IQueueSpecification queueSpec = management.Queue().Name("queue-should-recover-binding").AutoDelete(true).Exclusive(true);
406417
await queueSpec.DeclareAsync();
407418
Assert.Equal(1, topologyListener.QueueCount());
408-
var bindingSpec =
419+
IBindingSpecification bindingSpec =
409420
management.Binding().SourceExchange(exSpec).DestinationQueue(queueSpec).Key("key");
410421
await bindingSpec.BindAsync();
411422
Assert.Equal(1, topologyListener.BindingCount());
@@ -415,7 +426,7 @@ public async Task RecoveryTopologyShouldRecoverBindings(bool topologyEnabled)
415426
await SystemUtils.DeleteExchangeAsync("exchange-should-recover-binding");
416427

417428
// The queue will be deleted due of the auto-delete flag
418-
await SystemUtils.WaitUntilConnectionIsKilled(localContainerId);
429+
await SystemUtils.WaitUntilConnectionIsKilled(_containerId);
419430
await twoRecoveryEventsSeenTcs.Task.WaitAsync(TimeSpan.FromSeconds(10));
420431

421432
if (topologyEnabled)
@@ -458,28 +469,29 @@ await SystemUtils.WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync("exchan
458469
[Fact]
459470
public async Task RemoveAQueueShouldRemoveTheBindings()
460471
{
461-
string localContainerId = $"{_containerId}_remove-queue-should-remove-binding-connection-name";
472+
Assert.Null(_connection);
473+
Assert.Null(_management);
462474

463475
IConnection connection = await AmqpConnection.CreateAsync(
464476
ConnectionSettingBuilder.Create()
465477
.RecoveryConfiguration(RecoveryConfiguration.Create()
466478
.BackOffDelayPolicy(new FakeFastBackOffDelay())
467479
.Topology(true))
468-
.ContainerId(localContainerId)
480+
.ContainerId(_containerId)
469481
.Build());
470482

471483
IManagement management = connection.Management();
472484
ITopologyListener topologyListener = ((IManagementTopology)management).TopologyListener();
473-
var exSpec = management.Exchange().Name("e-remove-a-should-remove-binding")
485+
IExchangeSpecification exSpec = management.Exchange().Name("e-remove-a-should-remove-binding")
474486
.Type(ExchangeType.DIRECT);
475487

476488
await exSpec.DeclareAsync();
477489

478-
var queueSpec = management.Queue().Name("q-remove-a-should-remove-binding")
490+
IQueueSpecification queueSpec = management.Queue().Name("q-remove-a-should-remove-binding")
479491
.AutoDelete(true).Exclusive(true);
480492
await queueSpec.DeclareAsync();
481493

482-
var queueSpecWontDeleted = management.Queue().Name("q-remove-a-should-remove-binding-wont-delete")
494+
IQueueSpecification queueSpecWontDeleted = management.Queue().Name("q-remove-a-should-remove-binding-wont-delete")
483495
.AutoDelete(true).Exclusive(true);
484496

485497
await queueSpecWontDeleted.DeclareAsync();
@@ -519,28 +531,30 @@ await SystemUtils.WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync("e-remo
519531
[Fact]
520532
public async Task RemoveAnExchangeShouldRemoveTheBindings()
521533
{
522-
string localContainerId = $"{_containerId}_remove-exchange-should-remove-binding-connection-name";
523-
var connection = await AmqpConnection.CreateAsync(
534+
Assert.Null(_connection);
535+
Assert.Null(_management);
536+
537+
IConnection connection = await AmqpConnection.CreateAsync(
524538
ConnectionSettingBuilder.Create()
525539
.RecoveryConfiguration(RecoveryConfiguration.Create()
526540
.BackOffDelayPolicy(new FakeFastBackOffDelay())
527541
.Topology(true))
528-
.ContainerId(localContainerId)
542+
.ContainerId(_containerId)
529543
.Build());
530544

531545
IManagement management = connection.Management();
532546
ITopologyListener topologyListener = ((IManagementTopology)management).TopologyListener();
533-
var exSpec = management.Exchange().Name("e-remove-exchange-should-remove-binding")
547+
IExchangeSpecification exSpec = management.Exchange().Name("e-remove-exchange-should-remove-binding")
534548
.Type(ExchangeType.DIRECT);
535549

536550
await exSpec.DeclareAsync();
537551

538-
var exSpecWontDeleted = management.Exchange().Name("e-remove-exchange-should-remove-binding-wont-delete")
552+
IExchangeSpecification exSpecWontDeleted = management.Exchange().Name("e-remove-exchange-should-remove-binding-wont-delete")
539553
.Type(ExchangeType.DIRECT);
540554

541555
await exSpecWontDeleted.DeclareAsync();
542556

543-
var queueSpec = management.Queue().Name("q-remove-exchange-should-remove-binding")
557+
IQueueSpecification queueSpec = management.Queue().Name("q-remove-exchange-should-remove-binding")
544558
.AutoDelete(true).Exclusive(true);
545559
await queueSpec.DeclareAsync();
546560

@@ -584,24 +598,26 @@ await SystemUtils.WaitUntilBindingsBetweenExchangeAndQueueDontExistAsync(
584598
[Fact]
585599
public async Task RemoveAnExchangeBoundToAnotherExchangeShouldRemoveTheBindings()
586600
{
587-
string localContainerId = $"{_containerId}_remove-exchange-bound-to-another-exchange-should-remove-binding-connection-name";
588-
var connection = await AmqpConnection.CreateAsync(
601+
Assert.Null(_connection);
602+
Assert.Null(_management);
603+
604+
IConnection connection = await AmqpConnection.CreateAsync(
589605
ConnectionSettingBuilder.Create()
590606
.RecoveryConfiguration(RecoveryConfiguration.Create()
591607
.BackOffDelayPolicy(new FakeFastBackOffDelay())
592608
.Topology(true))
593-
.ContainerId(localContainerId)
609+
.ContainerId(_containerId)
594610
.Build());
595611

596612
IManagement management = connection.Management();
597613
ITopologyListener topologyListener = ((IManagementTopology)management).TopologyListener();
598614

599-
var exSpec = management.Exchange().Name("e-remove-exchange-bound-to-another-exchange-should-remove-binding")
615+
IExchangeSpecification exSpec = management.Exchange().Name("e-remove-exchange-bound-to-another-exchange-should-remove-binding")
600616
.Type(ExchangeType.DIRECT);
601617

602618
await exSpec.DeclareAsync();
603619

604-
var exSpecDestination = management.Exchange()
620+
IExchangeSpecification exSpecDestination = management.Exchange()
605621
.Name("e-remove-exchange-bound-to-another-exchange-should-remove-binding-destination")
606622
.Type(ExchangeType.DIRECT);
607623

Tests/IntegrationTest.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public IntegrationTest(ITestOutputHelper testOutputHelper,
4444
{
4545
_testOutputHelper = testOutputHelper;
4646
_setupConnectionAndManagement = setupConnectionAndManagement;
47-
_queueName = $"{_testDisplayName}-queue-{Now}";
48-
_exchangeName = $"{_testDisplayName}-exchange-{Now}";
4947

5048
_testDisplayName = InitTestDisplayName();
49+
50+
_queueName = $"{_testDisplayName}-queue-{Now}";
51+
_exchangeName = $"{_testDisplayName}-exchange-{Now}";
5152
_containerId = $"{_testDisplayName}:{Now}";
5253

5354
if (SystemUtils.IsVerbose)
@@ -85,7 +86,7 @@ public virtual async Task DisposeAsync()
8586
{
8687
if (SystemUtils.IsVerbose)
8788
{
88-
_testOutputHelper.WriteLine("{0} [DEBUG] [END] {1}", DateTime.Now, _testDisplayName);
89+
_testOutputHelper.WriteLine("{0} [DEBUG] [START DISPOSE] {1}", DateTime.Now, _testDisplayName);
8990
}
9091

9192
if (_management is not null && _management.State == State.Open)
@@ -120,6 +121,11 @@ public virtual async Task DisposeAsync()
120121
Assert.Equal(State.Closed, _connection.State);
121122
_connection.Dispose();
122123
}
124+
125+
if (SystemUtils.IsVerbose)
126+
{
127+
_testOutputHelper.WriteLine("{0} [DEBUG] [END DISPOSE] {1}", DateTime.Now, _testDisplayName);
128+
}
123129
}
124130

125131
protected static Random S_Random

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if ($RunTests -or $RunTestsUntilFailure)
3232
Write-Host "Running tests: Build.csproj traversal (all frameworks)" -ForegroundColor "Magenta"
3333
if ($verbose)
3434
{
35-
dotnet test $build_csproj_file --environment=RABBITMQ_CLIENT_TESTS_VERBOSE=true --no-build --logger 'console;verbosity=detailed'
35+
dotnet test $build_csproj_file --diag test-diag.log --environment=RABBITMQ_CLIENT_TESTS_VERBOSE=true --no-build --logger 'console;verbosity=detailed'
3636
}
3737
else
3838
{

0 commit comments

Comments
 (0)