Skip to content

Commit c32ac3a

Browse files
committed
Fix flaky test and ensure RabbitMQ is fully started after stopping in a test.
1 parent 38bd629 commit c32ac3a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

_site

Submodule _site updated 166 files

projects/Unit/Fixtures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ internal void StopRabbitMQ()
382382
internal void StartRabbitMQ()
383383
{
384384
RabbitMQCtl.StartRabbitMQ();
385+
RabbitMQCtl.AwaitRabbitMQ();
385386
}
386387

387388
//

projects/Unit/RabbitMQCtl.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,10 @@ public static void StartRabbitMQ()
228228
{
229229
ExecRabbitMQCtl("start_app");
230230
}
231+
232+
public static void AwaitRabbitMQ()
233+
{
234+
ExecRabbitMQCtl("await_startup");
235+
}
231236
}
232237
}

projects/Unit/TestConnectionRecovery.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -851,22 +851,22 @@ public void TestPublishRpcRightAfterReconnect()
851851
var properties = new BasicProperties();
852852
properties.ReplyTo = "amq.rabbitmq.reply-to";
853853

854-
bool done = false;
854+
TimeSpan doneSpan = TimeSpan.FromMilliseconds(100);
855+
var done = new ManualResetEventSlim(false);
855856
Task.Run(() =>
856857
{
857858
try
858859
{
859860

860861
CloseAndWaitForRecovery();
861-
Thread.Sleep(500);
862862
}
863863
finally
864864
{
865-
done = true;
865+
done.Set();
866866
}
867867
});
868868

869-
while (!done)
869+
while (!done.IsSet)
870870
{
871871
try
872872
{
@@ -880,7 +880,7 @@ public void TestPublishRpcRightAfterReconnect()
880880
Assert.NotEqual(406, a.ShutdownReason.ReplyCode);
881881
}
882882
}
883-
Thread.Sleep(1);
883+
done.Wait(doneSpan);
884884
}
885885
}
886886

0 commit comments

Comments
 (0)