-
Notifications
You must be signed in to change notification settings - Fork 51
Enable parallelism in test projects #5697
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
rbev
wants to merge
16
commits into
master
Choose a base branch
from
rhys/test-parallel
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
16 commits
Select commit
Hold shift + click to select a range
f747755
Enable parallelism in test projects
rbev 12047cd
Run at least one test serially before parallelising, enable paralleli…
rbev 08d055c
Disable parallelism on SQS, SQL, Rabbit, ASB
rbev dc8f7b1
Attempt to fix race on windows eventlog setup
rbev 8bb2c17
Remove parallel on MSMQ, make flaky test serialised
rbev edea56c
Create eventlog as part of setup in tests
rbev f72a395
Bump test timeout to 30
rbev 20f562d
elimitate timing from startup code
rbev 52e14c4
Make sure event log source exists before continuing
rbev 4fcd528
give setup loop an exit condition on failure
rbev 21e545c
remove parallel from flaky test
rbev 944c6d6
Mark some tests as NonParallelizable
rbev 4990511
Parallelise audit raven acceptance tests
rbev d6d2d61
Remove exclusion and duplciate local file
rbev 4389589
Consolidate lifecycle locking code, apply it to multiinstance tests c…
rbev 5ac4c58
Reinstate explicit parallelism
rbev 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| using NUnit.Framework; | ||
|
|
||
| [assembly: FixtureLifeCycle(LifeCycle.InstancePerTestCase)] | ||
| [assembly: Parallelizable(ParallelScope.All)] | ||
| [assembly: LevelOfParallelism(4)] | ||
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
70 changes: 42 additions & 28 deletions
70
src/ServiceControl.AcceptanceTests.RavenDB/AcceptanceTestStorageConfiguration.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,38 +1,52 @@ | ||
| namespace ServiceControl.AcceptanceTests | ||
| namespace ServiceControl.AcceptanceTests.RavenDB; | ||
|
|
||
| using System; | ||
| using System.Reactive.Disposables; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using ServiceBus.Management.Infrastructure.Settings; | ||
| using ServiceControl.Persistence.Tests; | ||
| using ServiceControl.RavenDB; | ||
|
|
||
| public class AcceptanceTestStorageConfiguration | ||
| { | ||
| using System; | ||
| using System.Threading.Tasks; | ||
| using Persistence.Tests; | ||
| using ServiceBus.Management.Infrastructure.Settings; | ||
| using ServiceControl.RavenDB; | ||
| public string PersistenceType { get; } = "RavenDB"; | ||
|
|
||
|
|
||
| public class AcceptanceTestStorageConfiguration | ||
| public async Task CustomizeSettings(Settings settings) | ||
| { | ||
| public string PersistenceType { get; } = "RavenDB"; | ||
| databaseName = Guid.NewGuid().ToString("n"); | ||
| databaseInstance = await SharedEmbeddedServer.GetInstance(); | ||
|
|
||
| public async Task CustomizeSettings(Settings settings) | ||
| settings.PersisterSpecificSettings = new RavenPersisterSettings | ||
| { | ||
| databaseName = Guid.NewGuid().ToString("n"); | ||
| databaseInstance = await SharedEmbeddedServer.GetInstance(); | ||
|
|
||
| settings.PersisterSpecificSettings = new RavenPersisterSettings | ||
| { | ||
| ErrorRetentionPeriod = TimeSpan.FromDays(10), | ||
| ConnectionString = databaseInstance.ServerUrl, | ||
| DatabaseName = databaseName | ||
| }; | ||
| } | ||
| ErrorRetentionPeriod = TimeSpan.FromDays(10), | ||
| ConnectionString = databaseInstance.ServerUrl, | ||
| DatabaseName = databaseName | ||
| }; | ||
| } | ||
|
|
||
| public async Task Cleanup() | ||
| public async Task Cleanup() | ||
| { | ||
| if (databaseInstance == null) | ||
| { | ||
| if (databaseInstance == null) | ||
| { | ||
| return; | ||
| } | ||
| await databaseInstance.DeleteDatabase(databaseName); | ||
| return; | ||
| } | ||
| using var _ = await UseDatabaseLifecycleLock(); | ||
| await databaseInstance.DeleteDatabase(databaseName); | ||
| } | ||
|
|
||
| EmbeddedDatabase databaseInstance; | ||
| string databaseName; | ||
| /// <summary> | ||
| /// The shared server cannot perform database lifecycle operations in parallel, take this lock when you | ||
| /// need to do one of these operations in a test. | ||
| /// </summary> | ||
| public static async Task<IDisposable> UseDatabaseLifecycleLock(CancellationToken cancellationToken = default) | ||
| { | ||
| await databaseLifecycleLock.WaitAsync(cancellationToken); | ||
| return Disposable.Create(() => databaseLifecycleLock.Release()); | ||
| } | ||
| } | ||
|
|
||
| static readonly SemaphoreSlim databaseLifecycleLock = new SemaphoreSlim(1, 1); | ||
| EmbeddedDatabase databaseInstance; | ||
| string databaseName; | ||
| } |
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,5 @@ | ||
| using NUnit.Framework; | ||
|
|
||
| [assembly: FixtureLifeCycle(LifeCycle.InstancePerTestCase)] | ||
| [assembly: Parallelizable(ParallelScope.All)] | ||
| [assembly: LevelOfParallelism(4)] |
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
29 changes: 29 additions & 0 deletions
29
src/ServiceControl.AcceptanceTests.RavenDB/SetupFixture.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,29 @@ | ||
| namespace ServiceControl.AcceptanceTests.RavenDB; | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
|
|
||
| [SetUpFixture] | ||
| public class SetupFixture | ||
| { | ||
| [OneTimeSetUp] | ||
| public async Task Setup() | ||
| { | ||
| if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
| { | ||
| ServiceBus.Management.Infrastructure.Installers.EventSourceCreator.Create(); | ||
|
|
||
| //There is a delay for this becoming true, tests will fall over if they interleave in the wrong way. | ||
| var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60)); | ||
| while (!EventLog.SourceExists(ServiceBus.Management.Infrastructure.Installers.EventSourceCreator.SourceName)) | ||
| { | ||
| cts.Token.ThrowIfCancellationRequested(); | ||
| await Task.Delay(500, CancellationToken.None); | ||
| } | ||
| } | ||
| } | ||
| } |
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
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
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.
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.
Is it worth adding a common nunit settings that we compile include?