Skip to content

Commit 010a1f2

Browse files
committed
Clean up resources correctly in connection recovery tests, fingers crossed...
1 parent 5e77460 commit 010a1f2

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

projects/Unit/Fixtures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
namespace RabbitMQ.Client.Unit
4545
{
46-
46+
[Collection("IntegrationFixture")]
4747
public class IntegrationFixture : IDisposable
4848
{
4949
internal IConnectionFactory _connFactory;

projects/Unit/RabbitMQCtl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public static void RestartRabbitMQ()
217217
StopRabbitMQ();
218218
Thread.Sleep(500);
219219
StartRabbitMQ();
220+
AwaitRabbitMQ();
220221
}
221222

222223
public static void StopRabbitMQ()

projects/Unit/TestBlockingCell.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
namespace RabbitMQ.Client.Unit
4040
{
41-
4241
public class TestBlockingCell : TimingFixture
4342
{
4443
internal class DelayedSetter<T>

projects/Unit/TestConnectionRecovery.cs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,6 @@
4545

4646
namespace RabbitMQ.Client.Unit
4747
{
48-
[CollectionDefinition("NoParallelization", DisableParallelization = true)]
49-
public class NoParallelizationCollection { }
50-
class DisposableConnection : IDisposable
51-
{
52-
public DisposableConnection(AutorecoveringConnection c)
53-
{
54-
Connection = c;
55-
}
56-
57-
public AutorecoveringConnection Connection { get; }
58-
59-
public void Dispose()
60-
{
61-
Connection.Close();
62-
}
63-
}
64-
65-
[Collection("NoParallelization")]
6648
public class TestConnectionRecovery : IntegrationFixture
6749
{
6850
private readonly byte[] _messageBody;
@@ -85,10 +67,20 @@ protected override void SetUp()
8567
_model.QueueDelete(_queueName);
8668
}
8769

88-
public override void Dispose()
70+
protected override void ReleaseResources()
8971
{
90-
_conn.Close();
72+
// TODO LRB not really necessary
73+
if (_model.IsOpen)
74+
{
75+
_model.Close();
76+
}
77+
78+
if (_conn.IsOpen)
79+
{
80+
_conn.Close();
81+
}
9182

83+
Unblock();
9284
}
9385

9486
[Fact]
@@ -704,7 +696,7 @@ public void TestRecoveryEventHandlersOnModel()
704696
Assert.True(counter >= 3);
705697
}
706698

707-
[Fact(Skip="FLAKY")]
699+
[Fact]
708700
public void TestRecoveryWithTopologyDisabled()
709701
{
710702
AutorecoveringConnection conn = CreateAutorecoveringConnectionWithTopologyRecoveryDisabled();
@@ -1097,11 +1089,6 @@ internal static ManualResetEventSlim PrepareForShutdown(IConnection conn)
10971089
return latch;
10981090
}
10991091

1100-
protected override void ReleaseResources()
1101-
{
1102-
Unblock();
1103-
}
1104-
11051092
internal void RestartServerAndWaitForRecovery()
11061093
{
11071094
RestartServerAndWaitForRecovery((AutorecoveringConnection)_conn);

0 commit comments

Comments
 (0)