From 705f6244a323bf7262a07f58a993b10bfb915df8 Mon Sep 17 00:00:00 2001 From: Marty T <120425148+tippmar-nr@users.noreply.github.com> Date: Thu, 23 May 2024 15:48:03 -0500 Subject: [PATCH] test: Update NServiceBus tests to include v8 and v9 (#2502) --- .../MultiFunctionApplicationHelpers.csproj | 5 ++--- .../NServiceBus/Handlers/AsyncCommandHandler.cs | 4 +++- .../NServiceBus/Handlers/AsyncEventHandler.cs | 4 +++- .../NetStandardLibraries/NServiceBus/NServiceBusDriver.cs | 6 +++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj index 47aa88a9c1..c16e2a5176 100644 --- a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj @@ -211,9 +211,8 @@ - - - + + diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncCommandHandler.cs b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncCommandHandler.cs index b216ef3a48..1852133c43 100644 --- a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncCommandHandler.cs +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncCommandHandler.cs @@ -1,4 +1,4 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. +// Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 using System.Threading.Tasks; @@ -15,7 +15,9 @@ public class AsyncCommandHandler : public async Task Handle(Command command, IMessageHandlerContext context) { ConsoleMFLogger.Info($"Async Command handler received message with Id {command.Id}."); +#pragma warning disable NSB0002 // Forward the 'CancellationToken' property of the context parameter to methods await Task.Delay(500); +#pragma warning restore NSB0002 // Forward the 'CancellationToken' property of the context parameter to methods ConsoleMFLogger.Info($"Async Command handler done delaying message with Id {command.Id}."); // Make sure segment/transaction ends } diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncEventHandler.cs b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncEventHandler.cs index 0bdba415bc..5e150f2040 100644 --- a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncEventHandler.cs +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/Handlers/AsyncEventHandler.cs @@ -1,4 +1,4 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. +// Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 using System.Threading.Tasks; @@ -15,7 +15,9 @@ public class AsyncEventHandler : public async Task Handle(Event message, IMessageHandlerContext context) { ConsoleMFLogger.Info($"Async Event handler received message with Id {message.Id}."); +#pragma warning disable NSB0002 // Forward the 'CancellationToken' property of the context parameter to methods await Task.Delay(500); +#pragma warning restore NSB0002 // Forward the 'CancellationToken' property of the context parameter to methods ConsoleMFLogger.Info($"Async Event handler done delaying message with Id {message.Id}."); // Make sure segment/transaction ends } diff --git a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/NServiceBusDriver.cs b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/NServiceBusDriver.cs index eb1e26db6d..387dacb383 100644 --- a/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/NServiceBusDriver.cs +++ b/tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/NetStandardLibraries/NServiceBus/NServiceBusDriver.cs @@ -1,4 +1,4 @@ -// Copyright 2020 New Relic, Inc. All rights reserved. +// Copyright 2020 New Relic, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 using MultiFunctionApplicationHelpers; @@ -35,6 +35,10 @@ private void StartNServiceBusInternal(Type handlerToAllow = null) endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.EnableInstallers(); +#if NET8_0_OR_GREATER // serializer must be specified starting with NServiceBus 9.0.0 + endpointConfiguration.UseSerialization(); +#endif + // We want to control which handlers are loaded for different test cases endpointConfiguration.AssemblyScanner().ScanAppDomainAssemblies = false; var typesToIgnore = new List