Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 0 additions & 29 deletions src/ServiceControl.AcceptanceTests.RavenDB/SetupFixture.cs

This file was deleted.

42 changes: 42 additions & 0 deletions src/ServiceControl.AcceptanceTests/SetupFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace ServiceControl.AcceptanceTests;

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using ServiceBus.Management.Infrastructure.Installers;

[SetUpFixture]
public class SetupFixture
{
[OneTimeSetUp]
public async Task Setup()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

// Every test runs the setup command, which creates the event source if it is missing. Tests run in
// parallel, so without creating it up front several of them race and all but one fail with
// "Source ServiceControl already exists".
EventSourceCreator.Create();

await WaitForSource(EventSourceCreator.SourceName);
}

//There is a delay for this becoming true, tests will fall over if they interleave in the wrong way.
[SupportedOSPlatform("windows")]
static async Task WaitForSource(string sourceName)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
while (!EventLog.SourceExists(sourceName))
{
cts.Token.ThrowIfCancellationRequested();
await Task.Delay(500, CancellationToken.None);
}
}
}
29 changes: 0 additions & 29 deletions src/ServiceControl.Audit.AcceptanceTests.RavenDB/SetupFixture.cs

This file was deleted.

42 changes: 42 additions & 0 deletions src/ServiceControl.Audit.AcceptanceTests/SetupFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace ServiceControl.Audit.AcceptanceTests;

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using ServiceControl.Audit.Infrastructure;

[SetUpFixture]
public class SetupFixture
{
[OneTimeSetUp]
public async Task Setup()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

// Every test runs the setup command, which creates the event source if it is missing. Tests run in
// parallel, so without creating it up front several of them race and all but one fail with
// "Source ServiceControl.Audit already exists".
EventSourceCreator.Create();

await WaitForSource(EventSourceCreator.SourceName);
}

//There is a delay for this becoming true, tests will fall over if they interleave in the wrong way.
[SupportedOSPlatform("windows")]
static async Task WaitForSource(string sourceName)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
while (!EventLog.SourceExists(sourceName))
{
cts.Token.ThrowIfCancellationRequested();
await Task.Delay(500, CancellationToken.None);
}
}
}
Loading