-
Notifications
You must be signed in to change notification settings - Fork 2
Update dependency NServiceBus to 10.2.0 and obsolete ExtensionsLoggerFactory #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dependencyupdates
wants to merge
7
commits into
master
Choose a base branch
from
renovate/nsb-core
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
688171a
Update dependency NServiceBus to 10.2.0
dependencyupdates[bot] 8b38997
Add obsolescence attributes to ExtensionsLoggerFactory and update pro…
danielmarbach 5368db3
Add NServiceBus acceptance testing dependencies and update logging test
danielmarbach f0bf570
Anoher pragma of course
danielmarbach f5d56ba
Add acceptance test for NLog integration with NServiceBus
danielmarbach c095161
Improve obsolete
danielmarbach a7eb5ee
Better grouping
danielmarbach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/NServiceBus.Extensions.Logging.NLog.AcceptanceTests/TestSuiteConstraints.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| namespace NServiceBus.AcceptanceTests; | ||
|
|
||
| using AcceptanceTesting.Support; | ||
|
|
||
| public partial class TestSuiteConstraints | ||
| { | ||
| public bool SupportsDtc => false; | ||
| public bool SupportsCrossQueueTransactions => true; | ||
| public bool SupportsNativePubSub => false; | ||
| public bool SupportsDelayedDelivery => false; | ||
| public bool SupportsOutbox => true; | ||
| public bool SupportsPurgeOnStartup => true; | ||
|
|
||
| public IConfigureEndpointTestExecution CreateTransportConfiguration() | ||
| => new ConfigureEndpointAcceptanceTestingTransport(SupportsNativePubSub, SupportsDelayedDelivery); | ||
|
|
||
| public IConfigureEndpointTestExecution CreatePersistenceConfiguration() | ||
| => new ConfigureEndpointAcceptanceTestingPersistence(); | ||
| } |
89 changes: 50 additions & 39 deletions
89
src/NServiceBus.Extensions.Logging.NLog.AcceptanceTests/When_using_nlog_extension_logger.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,54 @@ | ||
| namespace NServiceBus.Extensions.DependencyInjection.AcceptanceTests | ||
| namespace NServiceBus.Extensions.Logging.NLog.AcceptanceTests; | ||
|
|
||
| using System.Threading.Tasks; | ||
| using global::NLog.Config; | ||
| using global::NLog.Extensions.Logging; | ||
| using global::NLog.Targets; | ||
| using NUnit.Framework; | ||
| using NServiceBus.AcceptanceTesting; | ||
| using NServiceBus.AcceptanceTests; | ||
| using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
| using NServiceBus.Logging; | ||
| using NLogLogManager = global::NLog.LogManager; | ||
| using NsbLogManager = NServiceBus.Logging.LogManager; | ||
|
|
||
| [NonParallelizable] | ||
| public class When_using_nlog_extension_logger : NServiceBusAcceptanceTest | ||
| { | ||
| using System.Threading.Tasks; | ||
| using Logging; | ||
| using NLog; | ||
| using NLog.Extensions.Logging; | ||
| using NUnit.Framework; | ||
| using NsbLogManager = NServiceBus.Logging.LogManager; | ||
|
|
||
| public class When_using_nlog_extension_logger | ||
| [Test] | ||
| public async Task Should_log_nsb_logs_through_nlog() | ||
| { | ||
| var memoryTarget = new MemoryTarget(); | ||
| var config = new LoggingConfiguration(); | ||
| config.AddRuleForAllLevels(memoryTarget); | ||
| NLogLogManager.Configuration = config; | ||
|
|
||
| await using var nlogLoggerFactory = new NLogLoggerFactory(); | ||
|
|
||
| #pragma warning disable CS0618 // ExtensionsLoggerFactory is deprecated; test exercises legacy behavior intentionally | ||
| NsbLogManager.UseFactory(new ExtensionsLoggerFactory(nlogLoggerFactory)); | ||
| #pragma warning restore CS0618 | ||
|
|
||
| await Scenario.Define<Context>() | ||
| .WithEndpoint<EndpointUsingBridge>() | ||
| .Done(c => c.EndpointsStarted) | ||
| .Run(); | ||
|
|
||
| Assert.That(memoryTarget.Logs, Is.Not.Empty); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void Teardown() | ||
| { | ||
| #pragma warning disable CS0618 | ||
| NsbLogManager.Use<DefaultFactory>(); | ||
| #pragma warning restore CS0618 | ||
| } | ||
|
|
||
| class Context : ScenarioContext; | ||
|
|
||
| class EndpointUsingBridge : EndpointConfigurationBuilder | ||
| { | ||
| [Test] | ||
| public async Task Should_log_nsb_logs() | ||
| { | ||
| var config = new NLog.Config.LoggingConfiguration(); | ||
| var memoryTarget = new NLog.Targets.MemoryTarget(); | ||
| config.AddRuleForAllLevels(memoryTarget); | ||
| LogManager.Configuration = config; | ||
|
|
||
| NsbLogManager.UseFactory(new ExtensionsLoggerFactory(new NLogLoggerFactory())); | ||
|
|
||
| var endpointConfiguration = new EndpointConfiguration("LoggingTests"); | ||
| endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
| endpointConfiguration.EnableInstallers(); | ||
| endpointConfiguration.SendFailedMessagesTo("error"); | ||
| endpointConfiguration.UseTransport(new LearningTransport()); | ||
| endpointConfiguration.UsePersistence<LearningPersistence>(); | ||
|
|
||
| var endpoint = await Endpoint.Start(endpointConfiguration) | ||
| .ConfigureAwait(false); | ||
|
|
||
| try | ||
| { | ||
| Assert.That(memoryTarget.Logs, Is.Not.Empty); | ||
| } | ||
| finally | ||
| { | ||
| await endpoint.Stop() | ||
| .ConfigureAwait(false); | ||
| } | ||
| } | ||
| public EndpointUsingBridge() => EndpointSetup<DefaultServer>(); | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
...ceBus.Extensions.Logging.NLog.AcceptanceTests/When_using_nlog_with_register_components.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #pragma warning disable CS0618 // Type or member is obsolete | ||
| namespace NServiceBus.Extensions.Logging.NLog.AcceptanceTests; | ||
|
|
||
| using System.Collections.Concurrent; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Threading.Tasks; | ||
| using Configuration.AdvancedExtensibility; | ||
| using global::NLog.Config; | ||
| using global::NLog.Extensions.Logging; | ||
| using global::NLog.Targets; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using NUnit.Framework; | ||
| using NServiceBus.AcceptanceTesting; | ||
| using NServiceBus.AcceptanceTests; | ||
| using NServiceBus.AcceptanceTests.EndpointTemplates; | ||
| using Settings; | ||
|
|
||
| [NonParallelizable] | ||
| public class When_using_nlog_with_register_components : NServiceBusAcceptanceTest | ||
| { | ||
| [Test] | ||
| public async Task Should_log_nsb_logs_through_nlog() | ||
| { | ||
| var memoryTarget = new MemoryTarget(); | ||
| var config = new LoggingConfiguration(); | ||
| config.AddRuleForAllLevels(memoryTarget); | ||
|
|
||
| await Scenario.Define<Context>() | ||
| .WithEndpoint<EndpointWithRegisterComponents>(b => | ||
| { | ||
| b.CustomConfig(c => c.RegisterComponents(s => s.AddLogging(builder => builder.AddNLog(config)))); | ||
| b.ToCreateInstance( | ||
| (_, configuration) => | ||
| { | ||
| // The acceptance test infrastructure populates settings with the adapter which then makes RegisterComponent to be rerouted to the adapter | ||
| // in self-hosting scenarios this is never the case as the adapter is only used for multi-endpoint hosting, so we need to remove the adapter | ||
| // from settings to properly test the scenario but it allows us to use the acceptance test infrastructure to create the endpoint instance and | ||
| // start it which is required to properly test the scenario | ||
| RemoveOverride(configuration.GetSettings(), "NServiceBus.KeyedServiceCollectionAdapter"); | ||
| return Endpoint.Create(configuration); | ||
| }, | ||
| async (startableEndpoint, _, ct) => | ||
| { | ||
| var endpoint = await startableEndpoint.Start(ct); | ||
| return endpoint.Stop; | ||
| }); | ||
| }) | ||
| .Done(c => c.EndpointsStarted) | ||
| .Run(); | ||
|
|
||
| Assert.That(memoryTarget.Logs, Is.Not.Empty); | ||
| } | ||
|
|
||
| [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "Overrides")] | ||
| static extern ref ConcurrentDictionary<string, object> GetOverrides(SettingsHolder settingsHolder); | ||
|
|
||
| static void RemoveOverride(SettingsHolder settingsHolder, string key) => GetOverrides(settingsHolder).TryRemove(key, out _); | ||
|
|
||
| class Context : ScenarioContext; | ||
|
|
||
| class EndpointWithRegisterComponents : EndpointConfigurationBuilder | ||
| { | ||
| public EndpointWithRegisterComponents() => EndpointSetup<DefaultServer>(); | ||
| } | ||
| } | ||
| #pragma warning restore CS0618 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ogging.Tests/ApprovalFiles/APIApprovals.Approve_NServiceBusExtensionsLogging.approved.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this one? (core will bring it)