Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bf5bbd0
Use alpha
danielmarbach May 8, 2026
71f19ec
Remove no longer needed extension methods
danielmarbach May 8, 2026
19eb5b2
Acceptance testing alpha
danielmarbach May 8, 2026
033c1f8
RegisterComponent
danielmarbach May 8, 2026
49d6c73
Replace `errorContext.Message` with direct `errorContext` usage.
danielmarbach May 10, 2026
86ba618
LogManager.Use suppressions
danielmarbach May 10, 2026
e5058a1
RegisterScenarioContext method added
danielmarbach May 10, 2026
34198d4
Get the scenario context from settings for now and update registratio…
danielmarbach May 10, 2026
9282abf
Adjust to local build and update service resolve
danielmarbach May 10, 2026
9a639d5
Add ScenarioContext to host builder for dependency resolution
danielmarbach May 11, 2026
4ddecf6
Refactor message handler constructors to use parameterized constructo…
danielmarbach May 11, 2026
54a6a78
Refactor InternalCustomChecks to use collection initialization syntax
danielmarbach May 11, 2026
7daea2b
Remove assembly exclusion logic from endpoint configuration
danielmarbach May 11, 2026
51c3526
Register handlers
danielmarbach May 11, 2026
d1a27b5
Disable assembly scanner in monitoring too
danielmarbach May 11, 2026
3b46217
Customization extensions also need to disable assembly scanner
danielmarbach May 11, 2026
67f3e06
Get rid off NServiceBus.Extensions.Hosting dependency
danielmarbach May 11, 2026
526286d
Get rid of the custom context appender since Core acceptance tests do…
danielmarbach May 11, 2026
c7e63e5
Update NServiceBus packages to version 10.2.0-alpha.10
danielmarbach May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
<PackageVersion Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
<PackageVersion Include="Mindscape.Raygun4Net.NetCore" Version="11.2.5" />
<PackageVersion Include="NLog.Extensions.Logging" Version="6.1.3" />
<PackageVersion Include="NServiceBus" Version="10.1.4" />
<PackageVersion Include="NServiceBus.AcceptanceTesting" Version="10.1.4" />
<PackageVersion Include="NServiceBus" Version="10.2.0-alpha.10" />
<PackageVersion Include="NServiceBus.AcceptanceTesting" Version="10.2.0-alpha.10" />
<PackageVersion Include="NServiceBus.AmazonSQS" Version="9.0.1" />
<PackageVersion Include="NServiceBus.CustomChecks" Version="6.0.1" />
<PackageVersion Include="NServiceBus.Extensions.Hosting" Version="4.0.1" />
<PackageVersion Include="NServiceBus.Extensions.Logging" Version="4.0.1" />
<PackageVersion Include="NServiceBus.Heartbeat" Version="6.0.0" />
<PackageVersion Include="NServiceBus.Metrics" Version="6.0.1" />
Expand All @@ -52,7 +51,7 @@
<PackageVersion Include="NServiceBus.Transport.Msmq.Sources" Version="4.0.1" />
<PackageVersion Include="NServiceBus.Transport.PostgreSql" Version="9.0.1" />
<PackageVersion Include="NServiceBus.Transport.SqlServer" Version="9.0.1" />
<PackageVersion Include="NServiceBus.Transport.IBMMQ" Version="1.0.1"/>
<PackageVersion Include="NServiceBus.Transport.IBMMQ" Version="1.0.1" />
<PackageVersion Include="NuGet.Versioning" Version="7.3.1" />
<PackageVersion Include="NUnit" Version="4.6.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.13.0" />
Expand Down Expand Up @@ -94,4 +93,4 @@
<GlobalPackageReference Include="Microsoft.Build.CopyOnWrite" Version="1.0.334" />
<GlobalPackageReference Include="Particular.Packaging" Version="4.5.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Reflection;
using System.Threading.Tasks;
using InfrastructureConfig;
using Microsoft.Extensions.DependencyInjection;
using NServiceBus;
using NServiceBus.AcceptanceTesting.Customization;
using NServiceBus.AcceptanceTesting.Support;
Expand Down Expand Up @@ -62,19 +61,6 @@ public static async Task DefinePersistence(this EndpointConfiguration config, Ru
runDescriptor.OnTestCompleted(_ => persistenceConfiguration.Cleanup());
}

public static void RegisterComponentsAndInheritanceHierarchy(this EndpointConfiguration builder, RunDescriptor runDescriptor) => builder.RegisterComponents(services => { RegisterInheritanceHierarchyOfContextOnContainer(runDescriptor, services); });

static void RegisterInheritanceHierarchyOfContextOnContainer(RunDescriptor runDescriptor,
IServiceCollection services)
{
var type = runDescriptor.ScenarioContext.GetType();
while (type != typeof(object))
{
services.AddSingleton(type, runDescriptor.ScenarioContext);
type = type.BaseType;
}
}

public static void NoImmediateRetries(this EndpointConfiguration configuration)
=> configuration.Recoverability().Immediate(x => x.NumberOfRetries(0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor
await endpointTestExecutionConfiguration.Configure(endpointCustomizations.EndpointName, endpointConfiguration, runDescriptor.Settings, endpointCustomizations.PublisherMetadata);
runDescriptor.OnTestCompleted(_ => endpointTestExecutionConfiguration.Cleanup());

endpointConfiguration.RegisterComponentsAndInheritanceHierarchy(runDescriptor);
await endpointConfiguration.DefinePersistence(runDescriptor, endpointCustomizations);

endpointConfiguration.UseSerialization<SystemJsonSerializer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
public abstract partial class NServiceBusAcceptanceTest
{
[SetUp]
public void SetUp()
{
LogManager.Use<DefaultFactory>(); // Ensures that every test the log manager is 'reset' as log manager can otherwise point to disposed resources. For example, when a test uses NServiceBus hosting

public void SetUp() =>
Conventions.EndpointNamingConvention = t =>
{
var classAndEndpoint = t.FullName.Split('.').Last();
Expand All @@ -37,7 +34,6 @@ public void SetUp()

return testName + "." + endpointBuilder;
};
}

[TearDown]
public void TearDown()
Expand Down
20 changes: 3 additions & 17 deletions src/ServiceControl.AcceptanceTesting/TraceIncomingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ namespace ServiceControl.AcceptanceTesting
using NServiceBus.Pipeline;
using NServiceBus.Settings;

public class TraceIncomingBehavior : IBehavior<IIncomingLogicalMessageContext, IIncomingLogicalMessageContext>
public class TraceIncomingBehavior(IReadOnlySettings settings) : IBehavior<IIncomingLogicalMessageContext, IIncomingLogicalMessageContext>
{
public TraceIncomingBehavior(ScenarioContext scenarioContext, IReadOnlySettings settings)
{
this.scenarioContext = scenarioContext;
this.settings = settings;
}

public Task Invoke(IIncomingLogicalMessageContext context, Func<IIncomingLogicalMessageContext, Task> next)
{
var scenarioContext = settings.Get<ScenarioContext>();
scenarioContext.Logs.Enqueue(new ScenarioContext.LogItem
{
Endpoint = settings.EndpointName(),
Expand All @@ -28,15 +23,6 @@ public Task Invoke(IIncomingLogicalMessageContext context, Func<IIncomingLogical
return next(context);
}

ScenarioContext scenarioContext;
IReadOnlySettings settings;

public class Registration : RegisterStep
{
public Registration()
: base("TraceIncomingBehavior", typeof(TraceIncomingBehavior), "Adds incoming messages to the acceptance test trace")
{
}
}
public class Registration() : RegisterStep("TraceIncomingBehavior", typeof(TraceIncomingBehavior), "Adds incoming messages to the acceptance test trace");
}
}
20 changes: 3 additions & 17 deletions src/ServiceControl.AcceptanceTesting/TraceOutgoingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ namespace ServiceControl.AcceptanceTesting
using NServiceBus.Pipeline;
using NServiceBus.Settings;

public class TraceOutgoingBehavior : IBehavior<IOutgoingLogicalMessageContext, IOutgoingLogicalMessageContext>
public class TraceOutgoingBehavior(IReadOnlySettings settings) : IBehavior<IOutgoingLogicalMessageContext, IOutgoingLogicalMessageContext>
{
public TraceOutgoingBehavior(ScenarioContext scenarioContext, IReadOnlySettings settings)
{
this.scenarioContext = scenarioContext;
this.settings = settings;
}

public Task Invoke(IOutgoingLogicalMessageContext context, Func<IOutgoingLogicalMessageContext, Task> next)
{
var scenarioContext = settings.Get<ScenarioContext>();
scenarioContext.Logs.Enqueue(new ScenarioContext.LogItem
{
Endpoint = settings.EndpointName(),
Expand All @@ -28,15 +23,6 @@ public Task Invoke(IOutgoingLogicalMessageContext context, Func<IOutgoingLogical
return next(context);
}

ScenarioContext scenarioContext;
IReadOnlySettings settings;

public class Registration : RegisterStep
{
public Registration()
: base("TraceOutgoingBehavior", typeof(TraceOutgoingBehavior), "Adds outgoing messages to the acceptance test trace")
{
}
}
public class Registration() : RegisterStep("TraceOutgoingBehavior", typeof(TraceOutgoingBehavior), "Adds outgoing messages to the acceptance test trace");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public async Task Should_restart_dispatch_thread()
{
var externalProcessorSubscribed = false;

CustomizeHostBuilder = builder => builder.Services.AddSingleton<IEventPublisher, FaultyPublisher>();

CustomConfiguration = config =>
{
config.OnEndpointSubscribed<MyContext>((s, ctx) =>
Expand All @@ -37,8 +39,6 @@ public async Task Should_restart_dispatch_thread()
externalProcessorSubscribed = true;
}
});

config.RegisterComponents(services => services.AddSingleton<IEventPublisher, FaultyPublisher>());
};

ExecuteWhen(() => externalProcessorSubscribed, domainEvents => domainEvents.Raise(new EndpointFailedToHeartbeat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public async Task The_import_should_deduplicate_on_TimeOfFailure()
{
var criticalErrorExecuted = false;

SetSettings = settings => { settings.MaximumConcurrencyLevel = 10; };
SetSettings = settings => settings.MaximumConcurrencyLevel = 10;
CustomizeHostBuilder = builder => builder.Services.AddSingleton<CounterEnricher>();
CustomConfiguration = config =>
{
config.DefineCriticalErrorAction((_, __) =>
config.DefineCriticalErrorAction((_, _) =>
{
criticalErrorExecuted = true;
return Task.CompletedTask;
});
config.RegisterComponents(services => services.AddSingleton<CounterEnricher>());
};

FailedMessage failure = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Receiver() =>
EndpointSetup<DefaultServerWithoutAudit>(c =>
{
c.NoRetries();
c.RegisterComponents(services => services.AddSingleton<CorrelationIdRemover>());
c.RegisterMessageMutator(new CorrelationIdRemover());
});

public class MyMessageHandler(MyContext testContext, IReadOnlySettings settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ class When_single_message_fails_in_batch : AcceptanceTest
public async Task Should_import_all_messages()
{
//Make sure the error import attempt fails
CustomConfiguration = config => { config.RegisterComponents(services => services.AddSingleton<FailOnceEnricher>()); };
CustomizeHostBuilder = builder => builder.Services.AddSingleton<FailOnceEnricher>();

var maximumConcurrencyLevel = 5;

SetSettings = settings =>
{
settings.MaximumConcurrencyLevel = maximumConcurrencyLevel;
};
SetSettings = settings => settings.MaximumConcurrencyLevel = maximumConcurrencyLevel;

await Define<MyContext>(ctx =>
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace ServiceControl.AcceptanceTests.TestSupport
{
using System.IO;
using AcceptanceTesting;
using Microsoft.Extensions.DependencyInjection;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Customization;
using NServiceBus.Configuration.AdvancedExtensibility;

public static class EndpointConfigurationExtensions
Expand All @@ -17,21 +16,14 @@ public static void ReportSuccessfulRetriesToServiceControl(this EndpointConfigur
public static void CustomizeServiceControlEndpointTesting(this EndpointConfiguration configuration, ScenarioContext context)
{
configuration.GetSettings().Set("SC.ScenarioContext", context);
configuration.GetSettings().Set(context);

configuration.RegisterComponents(r =>
{
r.AddSingleton(context.GetType(), context);
r.AddSingleton(typeof(ScenarioContext), context);
});
configuration.RegisterScenarioContext(context);

configuration.Pipeline.Register<TraceIncomingBehavior.Registration>();
configuration.Pipeline.Register<TraceOutgoingBehavior.Registration>();
configuration.Pipeline.Register(new StampDispatchBehavior(context), "Stamps outgoing messages with session ID");
configuration.Pipeline.Register(new DiscardMessagesBehavior(context), "Discards messages based on session ID");

var assemblyScanner = configuration.AssemblyScanner();
assemblyScanner.ExcludeAssemblies(Path.GetFileName(typeof(ServiceControlComponentRunner).Assembly.Location));
configuration.AssemblyScanner().Disable = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Microsoft.Extensions.Logging;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Customization;
using NServiceBus.AcceptanceTesting.Support;
using Particular.ServiceControl;
using Particular.ServiceControl.Hosting;
Expand Down Expand Up @@ -122,6 +123,8 @@ async Task InitializeServiceControl(ScenarioContext context)
// Force the DI container to run the dependency resolution check to verify all dependencies can be resolved
EnvironmentName = Environments.Development
});

hostBuilder.Services.AddScenarioContext(context);
hostBuilder.AddServiceControlAuthentication(settings.OpenIdConnectSettings);
hostBuilder.AddServiceControl(settings, configuration);
hostBuilder.AddServiceControlHttps(settings.HttpsSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static void AddServiceControlTesting(this WebApplicationBuilder hostBuild
{
// Do not register additional test controllers or hosted services here. Instead, in the test that needs them, use (for example):
// CustomizeHostBuilder = builder => builder.ConfigureServices((hostContext, services) => services.AddHostedService<SetupNotificationSettings>());
hostBuilder.Logging.AddScenarioContextLogging();

hostBuilder.WebHost.UseTestServer(options => options.BaseAddress = new Uri(settings.RootUrl));

Expand Down
Loading
Loading