Skip to content

Commit f8a3028

Browse files
committed
Tweak test so that it times out earlier in the error case observed here:
https://github.com/rabbitmq/rabbitmq-dotnet-client/actions/runs/7450578332/attempts/1
1 parent 2ef965b commit f8a3028

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

projects/Test/AsyncIntegration/TestAsyncConsumer.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ public async Task TestBasicRejectAsync()
235235
{
236236
var publishSyncSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
237237

238+
using var cancellationTokenSource = new CancellationTokenSource(TestTimeout);
239+
240+
cancellationTokenSource.Token.Register(() =>
241+
{
242+
publishSyncSource.SetCanceled();
243+
});
244+
238245
_conn.ConnectionShutdown += (o, ea) =>
239246
{
240247
HandleConnectionShutdown(_conn, ea, (args) =>
@@ -261,8 +268,19 @@ public async Task TestBasicRejectAsync()
261268
consumer.Received += async (object sender, BasicDeliverEventArgs args) =>
262269
{
263270
var c = sender as AsyncEventingBasicConsumer;
264-
Assert.NotNull(c);
271+
Assert.Same(c, consumer);
265272
await _channel.BasicCancelAsync(c.ConsumerTags[0]);
273+
/*
274+
* https://github.com/rabbitmq/rabbitmq-dotnet-client/actions/runs/7450578332/attempts/1
275+
* That job failed with a bizarre error where the delivery tag ack timed out:
276+
*
277+
* AI.TestAsyncConsumer.TestBasicRejectAsync channel 1 shut down:
278+
* AMQP close-reason, initiated by Peer, code=406, text=
279+
* 'PRECONDITION_FAILED - delivery acknowledgement on channel 1 timed out. Timeout value used: 1800000 ms ...', classId=0, methodId=0
280+
*
281+
* Added Task.Yield() to see if it ever happens again.
282+
*/
283+
await Task.Yield();
266284
await _channel.BasicRejectAsync(args.DeliveryTag, true);
267285
publishSyncSource.TrySetResult(true);
268286
};

0 commit comments

Comments
 (0)