Skip to content

Commit

Permalink
* Check to ensure no connection shutdown in `TestBasicConsumeCancella…
Browse files Browse the repository at this point in the history
…tion_GH1750`
  • Loading branch information
lukebakken committed Jan 3, 2025
1 parent 1d4d179 commit f8d2955
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions projects/Test/Integration/GH/TestGitHubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public async Task TestBasicConsumeCancellation_GH1750()
Assert.Null(_channel);

_connFactory = CreateConnectionFactory();
_connFactory.AutomaticRecoveryEnabled = false;
_connFactory.TopologyRecoveryEnabled = false;
_connFactory.NetworkRecoveryInterval = TimeSpan.FromMilliseconds(250);
_connFactory.AutomaticRecoveryEnabled = true;
_connFactory.TopologyRecoveryEnabled = true;

_conn = await _connFactory.CreateConnectionAsync();
_channel = await _conn.CreateChannelAsync();
Expand All @@ -87,11 +88,20 @@ public async Task TestBasicConsumeCancellation_GH1750()
return Task.CompletedTask;
};

bool sawConnectionShutdown = false;
_conn.ConnectionShutdownAsync += (o, ea) =>
{
sawConnectionShutdown = true;
return Task.CompletedTask;
};

try
{
// Note: use this to test timeout via the passed-in RPC token
// using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(5));
// await _channel.BasicConsumeAsync(q.QueueName, true, consumer, cts.Token);
/*
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(5));
await _channel.BasicConsumeAsync(q.QueueName, true, consumer, cts.Token);
*/

// Note: use these to test timeout of the continuation RPC operation
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
Expand All @@ -102,6 +112,10 @@ public async Task TestBasicConsumeCancellation_GH1750()
{
_output.WriteLine("ex: {0}", ex);
}

await Task.Delay(500);

Assert.False(sawConnectionShutdown);
}
}
}

0 comments on commit f8d2955

Please sign in to comment.