Skip to content

Commit 8b54bf4

Browse files
committed
Fix some more tests.
1 parent 4d42e3e commit 8b54bf4

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

projects/Test/SequentialIntegration/SequentialIntegrationFixture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public async Task BlockAsync()
4848
await Task.Delay(TimeSpan.FromSeconds(1));
4949
}
5050

51-
public async Task BlockAsync(IChannel channel)
51+
public async Task BlockAndPublishAsync()
5252
{
53+
// TODO fix publisher confirmation tracking to time out so this test succeeds
54+
await using IChannel ch = await _conn.CreateChannelAsync(publisherConfirmationsEnabled: false);
5355
await BlockAsync();
54-
await channel.BasicPublishAsync(exchange: "amq.direct",
56+
await ch.BasicPublishAsync(exchange: "amq.direct",
5557
routingKey: Guid.NewGuid().ToString(), _encoding.GetBytes("message"));
5658
}
5759

projects/Test/SequentialIntegration/TestConnectionBlocked.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public override async Task DisposeAsync()
6060
public async Task TestConnectionBlockedNotification()
6161
{
6262
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
63-
_conn.ConnectionBlockedAsync += async (object sender, ConnectionBlockedEventArgs args) =>
63+
_conn.ConnectionBlockedAsync += (object sender, ConnectionBlockedEventArgs args) =>
6464
{
65-
// TODO should this continue to be doing fire and forget?
66-
await UnblockAsync();
65+
UnblockAsync();
66+
return Task.CompletedTask;
6767
};
6868

6969
_conn.ConnectionUnblockedAsync += (object sender, AsyncEventArgs ea) =>
@@ -72,7 +72,7 @@ public async Task TestConnectionBlockedNotification()
7272
return Task.CompletedTask;
7373
};
7474

75-
await BlockAsync(_channel);
75+
await BlockAndPublishAsync();
7676
await tcs.Task.WaitAsync(TimeSpan.FromSeconds(15));
7777
Assert.True(await tcs.Task, "Unblock notification not received.");
7878
}
@@ -82,7 +82,7 @@ public async Task TestDisposeOnBlockedConnectionDoesNotHang()
8282
{
8383
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
8484

85-
await BlockAsync(_channel);
85+
await BlockAndPublishAsync();
8686

8787
Task disposeTask = Task.Run(async () =>
8888
{

projects/Test/SequentialIntegration/TestConnectionRecovery.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,16 @@ Task _channel_ChannelShutdownAsync(object sender, ShutdownEventArgs e)
145145
[Fact]
146146
public async Task TestBlockedListenersRecovery()
147147
{
148-
try
149-
{
150-
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
151-
_conn.ConnectionBlockedAsync += (c, reason) =>
152-
{
153-
tcs.SetResult(true);
154-
return Task.CompletedTask;
155-
};
156-
await CloseAndWaitForRecoveryAsync();
157-
await CloseAndWaitForRecoveryAsync();
158-
await BlockAsync(_channel);
159-
await WaitAsync(tcs, "connection blocked");
160-
}
161-
finally
148+
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
149+
_conn.ConnectionBlockedAsync += (c, reason) =>
162150
{
163-
await UnblockAsync();
164-
}
151+
tcs.SetResult(true);
152+
return Task.CompletedTask;
153+
};
154+
await CloseAndWaitForRecoveryAsync();
155+
await CloseAndWaitForRecoveryAsync();
156+
await BlockAndPublishAsync();
157+
await WaitAsync(tcs, "connection blocked");
165158
}
166159

167160
[Fact]
@@ -340,7 +333,7 @@ public async Task TestUnblockedListenersRecovery()
340333
};
341334
await CloseAndWaitForRecoveryAsync();
342335
await CloseAndWaitForRecoveryAsync();
343-
await BlockAsync(_channel);
336+
await BlockAndPublishAsync();
344337
await UnblockAsync();
345338
await WaitAsync(tcs, "connection unblocked");
346339
}

0 commit comments

Comments
 (0)