Skip to content

Commit 899521e

Browse files
committed
* Fix test
* Remove more commented-out code
1 parent a7f61e0 commit 899521e

File tree

7 files changed

+6
-47
lines changed

7 files changed

+6
-47
lines changed

projects/RabbitMQ.Client/Impl/ChannelBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ await ModelSendAsync(in method, k.CancellationToken)
17771777

17781778
// NOTE: this method is internal for its use in this test:
17791779
// TestWaitForConfirmsWithTimeoutAsync_MessageNacked_WaitingHasTimedout_ReturnFalse
1780-
internal async Task HandleAckNack(ulong deliveryTag, bool multiple, bool isNack, CancellationToken cancellationToken = default)
1780+
private async Task HandleAckNack(ulong deliveryTag, bool multiple, bool isNack, CancellationToken cancellationToken = default)
17811781
{
17821782
// Only do this if confirms are enabled *and* the library is tracking confirmations
17831783
if (_publisherConfirmationsEnabled && _publisherConfirmationTrackingEnabled)

projects/Test/Common/TestConnectionRecoveryBase.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ await WithTemporaryNonExclusiveQueueAsync(ch, async (_, q) =>
7878
string rk = "routing-key";
7979
await ch.QueueBindAsync(q, x, rk);
8080
await ch.BasicPublishAsync(x, rk, _messageBody);
81-
// Assert.True(await WaitForConfirmsWithCancellationAsync(ch));
8281
await ch.ExchangeDeclarePassiveAsync(x);
8382
});
8483
}
@@ -90,16 +89,13 @@ protected Task AssertExclusiveQueueRecoveryAsync(IChannel m, string q)
9089

9190
protected async Task AssertQueueRecoveryAsync(IChannel ch, string q, bool exclusive, IDictionary<string, object> arguments = null)
9291
{
93-
// Note: no need to enable publisher confirmations as they are
94-
// automatically enabled for channels
95-
await ch.QueueDeclareAsync(queue: q, passive: true, durable: false, exclusive: false, autoDelete: false, arguments: null);
92+
await ch.QueueDeclarePassiveAsync(q);
9693

9794
RabbitMQ.Client.QueueDeclareOk ok1 = await ch.QueueDeclareAsync(queue: q, passive: false,
9895
durable: false, exclusive: exclusive, autoDelete: false, arguments: arguments);
9996
Assert.Equal(0u, ok1.MessageCount);
10097

10198
await ch.BasicPublishAsync("", q, _messageBody);
102-
// Assert.True(await WaitForConfirmsWithCancellationAsync(ch));
10399

104100
RabbitMQ.Client.QueueDeclareOk ok2 = await ch.QueueDeclareAsync(queue: q, passive: false,
105101
durable: false, exclusive: exclusive, autoDelete: false, arguments: arguments);

projects/Test/Integration/ConnectionRecovery/TestConnectionRecovery.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ await _channel.ExchangeDeclareAsync(exchange: exchangeName,
9696
consumer.ReceivedAsync += MessageReceived;
9797
await _channel.BasicConsumeAsync(queueName, true, consumer);
9898

99-
await using (IChannel pubCh = await _conn.CreateChannelAsync())
99+
await using (IChannel pubCh = await _conn.CreateChannelAsync(publisherConfirmationsEnabled: true, publisherConfirmationTrackingEnabled: true))
100100
{
101101
await pubCh.BasicPublishAsync(exchange: exchangeName, routingKey: routingKey, body: body);
102102
await pubCh.CloseAsync();
@@ -106,7 +106,7 @@ await _channel.ExchangeDeclareAsync(exchange: exchangeName,
106106

107107
await CloseAndWaitForRecoveryAsync();
108108

109-
await using (IChannel pubCh = await _conn.CreateChannelAsync())
109+
await using (IChannel pubCh = await _conn.CreateChannelAsync(publisherConfirmationsEnabled: true, publisherConfirmationTrackingEnabled: true))
110110
{
111111
await pubCh.BasicPublishAsync(exchange: exchangeName, routingKey: "unused", body: body);
112112
await pubCh.CloseAsync();

projects/Test/Integration/TestAsyncEventingBasicConsumer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public async Task TestAsyncEventingBasicConsumer_GH1038()
105105
await _channel.BasicConsumeAsync(queueName, false, consumer);
106106

107107
//publisher
108-
await using IChannel publisherChannel = await _conn.CreateChannelAsync();
108+
await using IChannel publisherChannel = await _conn.CreateChannelAsync(publisherConfirmationsEnabled: true, publisherConfirmationTrackingEnabled: true);
109109
byte[] messageBodyBytes = System.Text.Encoding.UTF8.GetBytes("Hello, world!");
110110
var props = new BasicProperties();
111111
await publisherChannel.BasicPublishAsync(exchange: exchangeName, routingKey: string.Empty,

projects/Test/Integration/TestConnectionTopologyRecovery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public async Task TestTopologyRecoveryQueueFilter()
104104
tcs.SetResult(true);
105105
return Task.CompletedTask;
106106
};
107-
IChannel ch = await conn.CreateChannelAsync();
107+
IChannel ch = await conn.CreateChannelAsync(publisherConfirmationsEnabled: true, publisherConfirmationTrackingEnabled: true);
108108

109109
await ch.QueueDeclareAsync(queueToRecover, false, false, false);
110110
await ch.QueueDeclareAsync(queueToIgnore, false, false, false);

projects/Test/Integration/TestExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ public TestExtensions(ITestOutputHelper output) : base(output)
4343
{
4444
}
4545

46-
[Fact]
47-
public async Task TestConfirmBarrier()
48-
{
49-
for (int i = 0; i < 10; i++)
50-
{
51-
await _channel.BasicPublishAsync(string.Empty, string.Empty, Array.Empty<byte>());
52-
}
53-
// Assert.True(await _channel.WaitForConfirmsAsync());
54-
}
55-
5646
[Fact]
5747
public async Task TestExchangeBinding()
5848
{

projects/Test/Integration/TestPublisherConfirms.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
// Copyright (c) 2007-2024 Broadcom. All Rights Reserved.
3030
//---------------------------------------------------------------------------
3131

32-
using System;
3332
using System.Collections.Generic;
3433
using System.Threading;
3534
using System.Threading.Tasks;
@@ -103,31 +102,5 @@ await ch.QueueDeclareAsync(queue: queueName, passive: false, durable: false,
103102
await ch.CloseAsync();
104103
}
105104
}
106-
107-
private async Task TestWaitForConfirmsAsync(int numberOfMessagesToPublish, Func<IChannel, Task> fn)
108-
{
109-
string queueName = GenerateQueueName();
110-
await using IChannel ch = await _conn.CreateChannelAsync(publisherConfirmationsEnabled: true, publisherConfirmationTrackingEnabled: true);
111-
var props = new BasicProperties { Persistent = true };
112-
113-
await ch.QueueDeclareAsync(queue: queueName, passive: false, durable: false,
114-
exclusive: true, autoDelete: false, arguments: null);
115-
116-
for (int i = 0; i < numberOfMessagesToPublish; i++)
117-
{
118-
await ch.BasicPublishAsync(exchange: string.Empty, routingKey: queueName,
119-
body: _messageBody, mandatory: true, basicProperties: props);
120-
}
121-
122-
try
123-
{
124-
await fn(ch);
125-
}
126-
finally
127-
{
128-
await ch.QueueDeleteAsync(queue: queueName, ifUnused: false, ifEmpty: false);
129-
await ch.CloseAsync();
130-
}
131-
}
132105
}
133106
}

0 commit comments

Comments
 (0)