Skip to content

Commit

Permalink
Merge pull request #1288 from rabbitmq/lukebakken/flaky-test
Browse files Browse the repository at this point in the history
Address some test flakes
  • Loading branch information
michaelklishin authored Feb 6, 2023
2 parents f3ae7f8 + cb5d735 commit 99768db
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .ci/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"erlang": "25.2",
"rabbitmq": "3.11.5"
"rabbitmq": "3.11.6"
}
24 changes: 22 additions & 2 deletions projects/Unit/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class IntegrationFixture : IDisposable
internal Encoding _encoding = new UTF8Encoding();

public static TimeSpan RECOVERY_INTERVAL = TimeSpan.FromSeconds(2);

protected readonly TimeSpan _waitSpan;
protected readonly ITestOutputHelper _output;
protected readonly string _testDisplayName;

Expand All @@ -64,6 +64,15 @@ public IntegrationFixture(ITestOutputHelper output)
_testDisplayName = test.DisplayName;

SetUp();

if (IsRunningInCI())
{
_waitSpan = TimeSpan.FromSeconds(30);
}
else
{
_waitSpan = TimeSpan.FromSeconds(10);
}
}

protected virtual void SetUp()
Expand Down Expand Up @@ -400,7 +409,7 @@ internal void StartRabbitMQ()

internal void Wait(ManualResetEventSlim latch)
{
Assert.True(latch.Wait(TimeSpan.FromSeconds(10)), "waiting on a latch timed out");
Assert.True(latch.Wait(_waitSpan), "waiting on a latch timed out");
}

internal void Wait(ManualResetEventSlim latch, TimeSpan timeSpan)
Expand All @@ -416,6 +425,17 @@ public static string CertificatesDirectory()
{
return Environment.GetEnvironmentVariable("SSL_CERTS_DIR");
}

private static bool IsRunningInCI()
{
string concourse = Environment.GetEnvironmentVariable("CONCOURSE_CI_BUILD");
string gha = Environment.GetEnvironmentVariable("GITHUB_ACTIONS");
if (String.IsNullOrWhiteSpace(concourse) && String.IsNullOrWhiteSpace(gha))
{
return false;
}
return true;
}
}

public class TimingFixture
Expand Down
4 changes: 2 additions & 2 deletions projects/Unit/TestAsyncConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public async Task TestBasicRoundtripConcurrent()

var publish1SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var publish2SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var maximumWaitTime = TimeSpan.FromSeconds(5);
var maximumWaitTime = TimeSpan.FromSeconds(10);
var tokenSource = new CancellationTokenSource(maximumWaitTime);
tokenSource.Token.Register(() =>
{
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task TestBasicRoundtripConcurrentManyMessages()
{
var publish1SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var publish2SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var maximumWaitTime = TimeSpan.FromSeconds(10);
var maximumWaitTime = TimeSpan.FromSeconds(30);
var tokenSource = new CancellationTokenSource(maximumWaitTime);
tokenSource.Token.Register(() =>
{
Expand Down
2 changes: 1 addition & 1 deletion projects/Unit/TestConnectionRecovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace RabbitMQ.Client.Unit
public class TestConnectionRecovery : IntegrationFixture
{
private readonly byte[] _messageBody;
private readonly ushort _totalMessageCount = 1024;
private readonly ushort _totalMessageCount = 8192;
private readonly ushort _closeAtCount = 16;
private string _queueName;

Expand Down
2 changes: 1 addition & 1 deletion projects/Unit/TestConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task TestBasicRoundtripConcurrent()

var publish1SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var publish2SyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var maximumWaitTime = TimeSpan.FromSeconds(5);
var maximumWaitTime = TimeSpan.FromSeconds(10);
var tokenSource = new CancellationTokenSource(maximumWaitTime);
tokenSource.Token.Register(() =>
{
Expand Down
2 changes: 1 addition & 1 deletion projects/Unit/TestPublisherConfirms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public async Task TestWaitForConfirmsWithEvents()
// to be equal to N because acks can be batched,
// so we primarily care about event handlers being invoked
// in this test
Assert.True(c > 5);
Assert.True(c >= 1);
}
finally
{
Expand Down

0 comments on commit 99768db

Please sign in to comment.