-
Notifications
You must be signed in to change notification settings - Fork 51
Standardise the use of TimeProvider across the error instance #5843
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
+764
−135
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4eca4f6
Shifts the registration of TimeProvider.Default to AddServiceControl …
warwickschroeder b79084a
Use TimeProvider in FailedMessageLifecycleDataStore. This allows for …
warwickschroeder 16db3ad
pass MessageArchiver's TimeProvider to the archiving and unarchiving …
warwickschroeder daad9a7
Standardise the use of TimeProvider to ravenDB, allowing for testing …
warwickschroeder cb4cfba
clean: remove dead code on persistence test base
warwickschroeder cdb2a02
use TimeProvider in retries
warwickschroeder a7bd034
cleanup
warwickschroeder 00e796a
Specify maintenance mode support for persistence and update related t…
warwickschroeder 0e40f67
Apply suggestion from @warwickschroeder
warwickschroeder 4ae496d
Standardise the use of test clocks in tests.
warwickschroeder 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
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
55 changes: 55 additions & 0 deletions
55
src/ServiceControl.AcceptanceTests/ClockRegistrationTests.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,55 @@ | ||
| namespace ServiceControl.AcceptanceTests | ||
| { | ||
| using System; | ||
| using System.Runtime.Loader; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Hosting; | ||
| using NServiceBus; | ||
| using NUnit.Framework; | ||
| using Particular.ServiceControl; | ||
| using ServiceBus.Management.Infrastructure.Settings; | ||
|
|
||
| class ClockRegistrationTests : AcceptanceTest | ||
| { | ||
| Settings settings; | ||
|
|
||
| [SetUp] | ||
| public async Task InitializeSettings() | ||
| { | ||
| settings = new Settings( | ||
| transportType: TransportIntegration.TypeName, | ||
| persisterType: StorageConfiguration.PersistenceType, | ||
| forwardErrorMessages: false, | ||
| errorRetentionPeriod: TimeSpan.FromDays(1)) | ||
| { | ||
| TransportConnectionString = TransportIntegration.ConnectionString, | ||
| IngestErrorMessages = false, | ||
| RunRetryProcessor = false, | ||
| DisableHealthChecks = true, | ||
| AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default | ||
| }; | ||
|
|
||
| await StorageConfiguration.CustomizeSettings(settings); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Should_keep_the_clock_the_host_registered() | ||
| { | ||
| TimeProvider hostClock = new StubTimeProvider(); | ||
|
|
||
| var endpointConfiguration = new EndpointConfiguration(settings.InstanceName); | ||
| endpointConfiguration.AssemblyScanner().Disable = true; | ||
|
|
||
| var hostBuilder = Host.CreateApplicationBuilder(); | ||
| hostBuilder.Services.AddSingleton(hostClock); | ||
| hostBuilder.AddServiceControl(settings, endpointConfiguration); | ||
|
|
||
| using var host = hostBuilder.Build(); | ||
|
|
||
| Assert.That(host.Services.GetRequiredService<TimeProvider>(), Is.SameAs(hostClock)); | ||
| } | ||
|
|
||
| sealed class StubTimeProvider : TimeProvider; | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/ServiceControl.AcceptanceTests/MaintenanceModeTests.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,31 @@ | ||
| namespace ServiceControl.AcceptanceTests | ||
| { | ||
| using System; | ||
| using System.Runtime.Loader; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using NUnit.Framework; | ||
| using Persistence; | ||
| using ServiceBus.Management.Infrastructure.Settings; | ||
|
|
||
| class MaintenanceModeTests : AcceptanceTest | ||
| { | ||
| // The refusal happens before any database is touched, so this needs no storage set up. | ||
| [Test] | ||
| public void Should_refuse_maintenance_mode() | ||
| { | ||
| var settings = new Settings( | ||
| transportType: TransportIntegration.TypeName, | ||
| persisterType: StorageConfiguration.PersistenceType, | ||
| forwardErrorMessages: false, | ||
| errorRetentionPeriod: TimeSpan.FromDays(1)) | ||
| { | ||
| TransportConnectionString = TransportIntegration.ConnectionString, | ||
| AssemblyLoadContextResolver = static _ => AssemblyLoadContext.Default | ||
| }; | ||
|
|
||
| var exception = Assert.Throws<Exception>(() => new ServiceCollection().AddPersistence(settings, maintenanceMode: true)); | ||
|
|
||
| Assert.That(exception.Message, Does.Contain("Maintenance mode is not supported").And.Contain(StorageConfiguration.PersistenceType)); | ||
| } | ||
| } | ||
| } |
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
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
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.