Skip to content

Commit 19e834f

Browse files
committed
Modify Tests.csproj to use net462 since (supposedly) Microsoft.Extensions.Diagnostics supports it.
2 parents 0b4b623 + bcdee01 commit 19e834f

22 files changed

+253
-150
lines changed

.github/workflows/wf_build-and-test.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ jobs:
3535
run: ${{ github.workspace }}\.ci\windows\gha-setup.ps1
3636
- name: Test
3737
timeout-minutes: 25
38+
# --diag ${{ github.workspace}}\diag
3839
run: dotnet test ${{ github.workspace }}\Build.csproj --no-restore --no-build --logger 'console;verbosity=detailed'
3940
- name: Check for errors in RabbitMQ logs
4041
run: ${{ github.workspace }}\.ci\windows\gha-log-check.ps1
42+
# - name: Upload dotnet test diag logs (on failure)
43+
# if: failure()
44+
# uses: actions/upload-artifact@v4
45+
# with:
46+
# name: dotnet-test-diag-win32
47+
# path: ${{ github.workspace }}/diag/
4148
- name: Maybe upload RabbitMQ logs
4249
if: failure()
4350
uses: actions/upload-artifact@v4
@@ -48,12 +55,6 @@ jobs:
4855
runs-on: ubuntu-latest
4956
steps:
5057
- uses: actions/checkout@v4
51-
- name: Setup dotnet
52-
uses: actions/setup-dotnet@v4
53-
with:
54-
dotnet-version: |
55-
6.0.x
56-
8.0.x
5758
- name: Build (Debug)
5859
run: dotnet build ${{ github.workspace }}/Build.csproj
5960
- name: Verify
@@ -63,12 +64,19 @@ jobs:
6364
run: ${{ github.workspace }}/.ci/ubuntu/cluster/gha-setup.sh
6465
- name: Test
6566
timeout-minutes: 25
67+
# --diag ${{ github.workspace}}/diag
6668
run: dotnet test ${{ github.workspace }}/Build.csproj --no-restore --no-build --logger "console;verbosity=detailed"
6769
- name: Check for errors in RabbitMQ logs
6870
run: ${{ github.workspace}}/.ci/ubuntu/cluster/gha-logs.sh check
6971
- name: Collect RabbitMQ logs (on failure)
7072
if: failure()
7173
run: ${{ github.workspace}}/.ci/ubuntu/cluster/gha-logs.sh
74+
# - name: Upload dotnet test diag logs (on failure)
75+
# if: failure()
76+
# uses: actions/upload-artifact@v4
77+
# with:
78+
# name: dotnet-test-diag-ubuntu
79+
# path: ${{ github.workspace }}/diag/
7280
- name: Upload RabbitMQ logs (on failure)
7381
if: failure()
7482
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ InternalTrace*
1111
*.lock.json
1212
nunit-agent*
1313
*.pyc
14+
test-diag.log
1415
test-output.log
1516
TestResults.xml
1617
TestResult.xml
@@ -24,6 +25,7 @@ gensrc/
2425
.ionide/
2526
NuGet/
2627
tmp/
28+
diag/
2729
.vscode/
2830

2931
#################

Directory.Packages.props

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
<!-- HAClient -->
99
<PackageVersion Include="DotNext.Threading" Version="5.15.0" />
1010
<!-- Tests -->
11+
<PackageVersion Include="Microsoft.Extensions.Diagnostics" Version="8.0.1" />
1112
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0" />
12-
<PackageVersion Include="xunit" Version="2.9.0" />
13+
<PackageVersion Include="xunit" Version="2.9.2" />
1314
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
1415
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
1516
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
16-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
17+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
1718
<PackageVersion Include="EasyNetQ.Management.Client" Version="3.0.0" />
1819
</ItemGroup>
1920
<ItemGroup Condition="$(TargetFramework)=='netstandard2.0'">
@@ -26,19 +27,15 @@
2627
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
2728
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
2829
</ItemGroup>
29-
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
30-
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
31-
</ItemGroup>
3230
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
3331
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
34-
<PackageVersion Include="Microsoft.Extensions.Diagnostics" Version="8.0.1" />
3532
</ItemGroup>
3633
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
3734
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
3835
</ItemGroup>
3936
<ItemGroup Condition="'$(IsPackable)'=='true'">
4037
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
4138
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
42-
<GlobalPackageReference Include="MinVer" Version="5.0.0" />
39+
<GlobalPackageReference Include="MinVer" Version="6.0.0" />
4340
</ItemGroup>
44-
</Project>
41+
</Project>

RabbitMQ.AMQP.Client/IEntitiesInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface IQueueInfo : IEntityInfo
3232
string Leader();
3333

3434
// TODO IEnumerable? ICollection?
35-
List<string> Replicas();
35+
List<string> Members();
3636

3737
ulong MessageCount();
3838

RabbitMQ.AMQP.Client/Impl/AbstractLifeCycle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected void ThrowIfClosed()
4747
case State.Closing:
4848
throw new AmqpNotOpenException("Resource is closing");
4949
case State.Reconnecting:
50-
throw new AmqpNotOpenException("Resource is Reconnecting");
50+
throw new AmqpNotOpenException("Resource is reconnecting");
5151
case State.Open:
5252
break;
5353
default:

RabbitMQ.AMQP.Client/Impl/AmqpConsumer.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public override async Task OpenAsync()
6363
Attach attach = Utils.CreateAttach(_configuration.Address, DeliveryMode.AtLeastOnce, _id,
6464
_configuration.Filters);
6565

66-
void onAttached(ILink argLink, Attach argAttach)
66+
void OnAttached(ILink argLink, Attach argAttach)
6767
{
6868
if (argLink is ReceiverLink link)
6969
{
@@ -73,30 +73,25 @@ void onAttached(ILink argLink, Attach argAttach)
7373
{
7474
// TODO create "internal bug" exception type?
7575
var ex = new InvalidOperationException(
76-
"invalid link in onAttached, report via https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client/issues");
76+
"invalid link in OnAttached, report via https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client/issues");
7777
attachCompletedTcs.SetException(ex);
7878
}
7979
}
8080

81-
ReceiverLink? tmpReceiverLink = null;
82-
Task receiverLinkTask = Task.Run(async () =>
83-
{
84-
Session session = await _amqpConnection._nativePubSubSessions.GetOrCreateSessionAsync()
85-
.ConfigureAwait(false);
86-
tmpReceiverLink = new ReceiverLink(session, _id.ToString(), attach, onAttached);
87-
});
81+
Session session = await _amqpConnection._nativePubSubSessions.GetOrCreateSessionAsync()
82+
.ConfigureAwait(false);
8883

89-
// TODO configurable timeout
90-
TimeSpan waitSpan = TimeSpan.FromSeconds(5);
84+
var tmpReceiverLink = new ReceiverLink(session, _id.ToString(), attach, OnAttached);
9185

86+
// TODO configurable timeout
87+
var waitSpan = TimeSpan.FromSeconds(5);
9288
_receiverLink = await attachCompletedTcs.Task.WaitAsync(waitSpan)
9389
.ConfigureAwait(false);
9490

95-
await receiverLinkTask.WaitAsync(waitSpan)
96-
.ConfigureAwait(false);
97-
98-
System.Diagnostics.Debug.Assert(tmpReceiverLink != null);
99-
System.Diagnostics.Debug.Assert(object.ReferenceEquals(_receiverLink, tmpReceiverLink));
91+
if (false == Object.ReferenceEquals(_receiverLink, tmpReceiverLink))
92+
{
93+
// TODO log this case?
94+
}
10095

10196
if (_receiverLink is null)
10297
{

RabbitMQ.AMQP.Client/Impl/AmqpEnvironment.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ public async Task<IConnection> CreateConnectionAsync(IConnectionSettings connect
5050
return c;
5151
}
5252

53-
public async Task<IConnection> CreateConnectionAsync()
53+
public Task<IConnection> CreateConnectionAsync()
5454
{
55-
if (ConnectionSettings != null)
55+
if (ConnectionSettings is null)
5656
{
57-
return await CreateConnectionAsync(ConnectionSettings).ConfigureAwait(false);
57+
throw new ConnectionException("Connection settings are not set");
5858
}
5959

60-
throw new ConnectionException("Connection settings are not set");
60+
return CreateConnectionAsync(ConnectionSettings);
6161
}
6262

6363
public ReadOnlyCollection<IConnection> GetConnections() =>

RabbitMQ.AMQP.Client/Impl/AmqpManagement.cs

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Collections.Concurrent;
7-
using System.Diagnostics;
87
using System.Linq;
98
using System.Threading;
109
using System.Threading.Tasks;
@@ -270,24 +269,38 @@ private async Task EnsureReceiverLinkAsync()
270269
new Target() { Address = ManagementNodeAddress, ExpiryPolicy = new Symbol("SESSION_END"), },
271270
};
272271

273-
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
274-
_receiverLink = new ReceiverLink(
272+
var tcs = new TaskCompletionSource<ReceiverLink>(TaskCreationOptions.RunContinuationsAsynchronously);
273+
var tmpReceiverLink = new ReceiverLink(
275274
_managementSession, LinkPairName, receiveAttach, (ILink link, Attach attach) =>
276275
{
277-
Debug.Assert(Object.ReferenceEquals(_receiverLink, link));
278-
tcs.SetResult(true);
276+
if (link is ReceiverLink receiverLink)
277+
{
278+
tcs.SetResult(receiverLink);
279+
}
280+
else
281+
{
282+
// TODO create "internal bug" exception type?
283+
var ex = new InvalidOperationException(
284+
"invalid link in OnAttached, report via https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client/issues");
285+
tcs.SetException(ex);
286+
}
279287
});
280288

281-
await tcs.Task
289+
_receiverLink = await tcs.Task
282290
.ConfigureAwait(false);
283291

292+
if (false == Object.ReferenceEquals(_receiverLink, tmpReceiverLink))
293+
{
294+
// TODO log this case?
295+
}
296+
284297
// TODO
285298
// using a credit of 1 can result in AmqpExceptions in ProcessResponses
286299
_receiverLink.SetCredit(100);
287300
}
288301
}
289302

290-
private Task EnsureSenderLinkAsync()
303+
private async Task EnsureSenderLinkAsync()
291304
{
292305
if (_senderLink == null || _senderLink.IsClosed)
293306
{
@@ -315,18 +328,30 @@ private Task EnsureSenderLinkAsync()
315328
},
316329
};
317330

318-
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
319-
_senderLink = new SenderLink(
331+
var tcs = new TaskCompletionSource<SenderLink>(TaskCreationOptions.RunContinuationsAsynchronously);
332+
var tmpSenderLink = new SenderLink(
320333
_managementSession, LinkPairName, senderAttach, (ILink link, Attach attach) =>
321334
{
322-
Debug.Assert(Object.ReferenceEquals(_senderLink, link));
323-
tcs.SetResult(true);
335+
if (link is SenderLink senderLink)
336+
{
337+
tcs.SetResult(senderLink);
338+
}
339+
else
340+
{
341+
// TODO create "internal bug" exception type?
342+
var ex = new InvalidOperationException(
343+
"invalid link in OnAttached, report via https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client/issues");
344+
tcs.SetException(ex);
345+
}
324346
});
325-
return tcs.Task;
326-
}
327-
else
328-
{
329-
return Task.CompletedTask;
347+
348+
_senderLink = await tcs.Task
349+
.ConfigureAwait(false);
350+
351+
if (false == Object.ReferenceEquals(_senderLink, tmpSenderLink))
352+
{
353+
// TODO log this case?
354+
}
330355
}
331356
}
332357

RabbitMQ.AMQP.Client/Impl/AmqpPublisher.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override async Task OpenAsync()
4242

4343
Attach attach = Utils.CreateAttach(_address, DeliveryMode.AtLeastOnce, _id);
4444

45-
void onAttached(ILink argLink, Attach argAttach)
45+
void OnAttached(ILink argLink, Attach argAttach)
4646
{
4747
if (argLink is SenderLink link)
4848
{
@@ -57,25 +57,19 @@ void onAttached(ILink argLink, Attach argAttach)
5757
}
5858
}
5959

60-
SenderLink? tmpSenderLink = null;
61-
Task senderLinkTask = Task.Run(async () =>
62-
{
63-
Session session = await _connection._nativePubSubSessions.GetOrCreateSessionAsync()
64-
.ConfigureAwait(false);
65-
tmpSenderLink = new SenderLink(session, _id.ToString(), attach, onAttached);
66-
});
60+
Session session = await _connection._nativePubSubSessions.GetOrCreateSessionAsync()
61+
.ConfigureAwait(false);
62+
var tmpSenderLink = new SenderLink(session, _id.ToString(), attach, OnAttached);
6763

6864
// TODO configurable timeout
69-
TimeSpan waitSpan = TimeSpan.FromSeconds(5);
70-
65+
var waitSpan = TimeSpan.FromSeconds(5);
7166
_senderLink = await attachCompletedTcs.Task.WaitAsync(waitSpan)
7267
.ConfigureAwait(false);
7368

74-
await senderLinkTask.WaitAsync(waitSpan)
75-
.ConfigureAwait(false);
76-
77-
System.Diagnostics.Debug.Assert(tmpSenderLink != null);
78-
System.Diagnostics.Debug.Assert(Object.ReferenceEquals(_senderLink, tmpSenderLink));
69+
if (false == Object.ReferenceEquals(_senderLink, tmpSenderLink))
70+
{
71+
// TODO log this case?
72+
}
7973

8074
if (_senderLink is null)
8175
{
@@ -133,10 +127,13 @@ public async Task<PublishResult> PublishAsync(IMessage message, CancellationToke
133127

134128
void OutcomeCallback(ILink sender, Message inMessage, Outcome outcome, object state)
135129
{
136-
System.Diagnostics.Debug.Assert(object.ReferenceEquals(this, state));
137-
System.Diagnostics.Debug.Assert(object.ReferenceEquals(_senderLink, sender));
138130
// Note: sometimes `message` is null 🤔
139-
// System.Diagnostics.Debug.Assert(Object.ReferenceEquals(nativeMessage, message));
131+
System.Diagnostics.Debug.Assert(Object.ReferenceEquals(this, state));
132+
133+
if (false == Object.ReferenceEquals(_senderLink, sender))
134+
{
135+
// TODO log this case?
136+
}
140137

141138
PublishOutcome publishOutcome;
142139
switch (outcome)

RabbitMQ.AMQP.Client/Impl/AmqpQueueSpecification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public string Leader()
9393
return _leader;
9494
}
9595

96-
public List<string> Replicas()
96+
public List<string> Members()
9797
{
9898
return _replicas;
9999
}

0 commit comments

Comments
 (0)