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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ windows-2022 ]
test-category: [ Default, SqlServer, AzureServiceBus, RabbitMQ, AzureStorageQueues, MSMQ, SQS ]
test-category: [ Default, SqlServer, AzureServiceBus, RabbitMQ, AzureStorageQueues, MSMQ, SQS, Raven35Acceptance ]
include:
- os: windows-2022
os-name: Windows
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ src/scaffolding.config

# Visual Studio Code
.vscode


.transport
6 changes: 6 additions & 0 deletions src/Persisters.Primary.Includes.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<ItemGroup Label="Persisters">
<ProjectReference Include="..\ServiceControl.Persistence.InMemory\ServiceControl.Persistence.InMemory.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Persistence.RavenDb\ServiceControl.Persistence.RavenDb.csproj" ReferenceOutputAssembly="false" Private="false" />
</ItemGroup>
</Project>
7 changes: 3 additions & 4 deletions src/ServiceControl.AcceptanceTesting/DispatchRawMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public DispatchTask(IDispatchMessages dispatcher, Func<TransportOperations> oper

protected override async Task OnStart(IMessageSession session)
{
await before(session).ConfigureAwait(false);
await before(session);
var operations = operationFactory();
foreach (var op in operations.UnicastTransportOperations)
{
Expand All @@ -63,9 +63,8 @@ protected override async Task OnStart(IMessageSession session)
op.Message.Headers["SC.SessionID"] = scenarioContext.TestRunId.ToString();
}

await dispatchMessages.Dispatch(operations, new TransportTransaction(), new ContextBag())
.ConfigureAwait(false);
await after(session).ConfigureAwait(false);
await dispatchMessages.Dispatch(operations, new TransportTransaction(), new ContextBag());
await after(session);
}

protected override Task OnStop(IMessageSession session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescr
runDescriptor.OnTestCompleted(_ => endpointTestExecutionConfiguration.Cleanup());

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

typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic).SetValue(runDescriptor.ScenarioContext, endpointCustomizations.EndpointName);

Expand Down
22 changes: 11 additions & 11 deletions src/ServiceControl.AcceptanceTesting/HttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static async Task<ManyResult<T>> TryGetMany<T>(this IAcceptanceTestInfras
condition = _ => true;
}

var response = await provider.GetInternal<List<T>>(url).ConfigureAwait(false);
var response = await provider.GetInternal<List<T>>(url);

if (response == null || !response.Any(m => condition(m)))
{
Expand All @@ -83,13 +83,13 @@ public static async Task<HttpStatusCode> Patch<T>(this IAcceptanceTestInfrastruc

var json = JsonConvert.SerializeObject(payload, provider.SerializerSettings);
var httpClient = provider.HttpClient;
var response = await httpClient.PatchAsync(url, new StringContent(json, null, "application/json")).ConfigureAwait(false);
var response = await httpClient.PatchAsync(url, new StringContent(json, null, "application/json"));

Console.WriteLine($"PATCH - {url} - {(int)response.StatusCode}");

if (!response.IsSuccessStatusCode)
{
var body = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var body = await response.Content.ReadAsStringAsync();
throw new InvalidOperationException($"Call failed: {(int)response.StatusCode} - {response.ReasonPhrase} - {body}");
}

Expand All @@ -103,7 +103,7 @@ public static async Task<SingleResult<T>> TryGet<T>(this IAcceptanceTestInfrastr
condition = _ => true;
}

var response = await provider.GetInternal<T>(url).ConfigureAwait(false);
var response = await provider.GetInternal<T>(url);

if (response == null || !condition(response))
{
Expand All @@ -115,9 +115,9 @@ public static async Task<SingleResult<T>> TryGet<T>(this IAcceptanceTestInfrastr

public static async Task<SingleResult<T>> TryGet<T>(this IAcceptanceTestInfrastructureProvider provider, string url, Func<T, Task<bool>> condition) where T : class
{
var response = await provider.GetInternal<T>(url).ConfigureAwait(false);
var response = await provider.GetInternal<T>(url);

if (response == null || !await condition(response).ConfigureAwait(false))
if (response == null || !await condition(response))
{
return SingleResult<T>.Empty;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public static async Task<HttpStatusCode> Get(this IAcceptanceTestInfrastructureP
}

var httpClient = provider.HttpClient;
var response = await httpClient.GetAsync(url).ConfigureAwait(false);
var response = await httpClient.GetAsync(url);

Console.WriteLine($"{response.RequestMessage.Method} - {url} - {(int)response.StatusCode}");

Expand All @@ -178,7 +178,7 @@ public static async Task Post<T>(this IAcceptanceTestInfrastructureProvider prov

var json = JsonConvert.SerializeObject(payload, provider.SerializerSettings);
var httpClient = provider.HttpClient;
var response = await httpClient.PostAsync(url, new StringContent(json, null, "application/json")).ConfigureAwait(false);
var response = await httpClient.PostAsync(url, new StringContent(json, null, "application/json"));

Console.WriteLine($"{response.RequestMessage.Method} - {url} - {(int)response.StatusCode}");

Expand All @@ -194,7 +194,7 @@ public static async Task Post<T>(this IAcceptanceTestInfrastructureProvider prov

if (!response.IsSuccessStatusCode)
{
var body = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var body = await response.Content.ReadAsStringAsync();
throw new InvalidOperationException($"Call failed: {(int)response.StatusCode} - {response.ReasonPhrase} - {body}");
}
}
Expand Down Expand Up @@ -238,7 +238,7 @@ public static async Task<byte[]> DownloadData(this IAcceptanceTestInfrastructure

static async Task<T> GetInternal<T>(this IAcceptanceTestInfrastructureProvider provider, string url) where T : class
{
var response = await provider.GetRaw(url).ConfigureAwait(false);
var response = await provider.GetRaw(url);

//for now
if (response.StatusCode == HttpStatusCode.NotFound || response.StatusCode == HttpStatusCode.ServiceUnavailable)
Expand All @@ -254,7 +254,7 @@ static async Task<T> GetInternal<T>(this IAcceptanceTestInfrastructureProvider p
throw new InvalidOperationException($"Call failed: {(int)response.StatusCode} - {response.ReasonPhrase} {Environment.NewLine} {content}");
}

var body = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var body = await response.Content.ReadAsStringAsync();
LogRequest();
return JsonConvert.DeserializeObject<T>(body, provider.SerializerSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

public class ConfigureEndpointLearningTransport : ITransportIntegration
{
public ConfigureEndpointLearningTransport()
{
var relativePath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..", "..", "..", ".transport");
ConnectionString = Path.GetFullPath(relativePath);
}

public string ConnectionString { get; set; }

public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
{
Directory.CreateDirectory(ConnectionString);
Expand All @@ -24,14 +32,19 @@ public Task Cleanup()
{
if (Directory.Exists(ConnectionString))
{
Directory.Delete(ConnectionString, true);
try
{
Directory.Delete(ConnectionString, true);
}
catch (DirectoryNotFoundException)
{
}
}

return Task.FromResult(0);
}

public string Name => "Learning";
public string TypeName => $"{typeof(LearningTransportCustomization).AssemblyQualifiedName}";
public string ConnectionString { get; set; } = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\.transport");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// Base class for all the NSB test that sets up our conventions
/// </summary>
[TestFixture]
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public abstract partial class NServiceBusAcceptanceTest
{
[SetUp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public override Task ComponentsStarted(CancellationToken cancellationToken = def
{
while (!tokenSource.IsCancellationRequested)
{
if (await isDone(scenarioContext).ConfigureAwait(false))
if (await isDone(scenarioContext))
{
setDone();
return;
}

await Task.Delay(100, tokenSource.Token).ConfigureAwait(false);
await Task.Delay(100, tokenSource.Token);
}
}
catch (Exception e)
Expand All @@ -136,7 +136,7 @@ public override async Task Stop()
tokenSource.Cancel();
try
{
await checkTask.ConfigureAwait(false);
await checkTask;
}
catch (OperationCanceledException)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceControl.AcceptanceTesting/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Sequence<TContext> Do(string step, Func<TContext, Task> handler)
{
steps.Add(async context =>
{
await handler(context).ConfigureAwait(false);
await handler(context);
return true;
});
stepNames.Add(step);
Expand All @@ -39,7 +39,7 @@ public async Task<bool> Continue(TContext context)
}

var step = steps[currentStep];
var advance = await step(context).ConfigureAwait(false);
var advance = await step(context);
if (advance)
{
var nextStep = currentStep + 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace ServiceControl.AcceptanceTests
{
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using Persistence.RavenDb;

class AcceptanceTestStorageConfiguration
{
public string PersistenceType { get; protected set; }

public Task<IDictionary<string, string>> CustomizeSettings()
{
return Task.FromResult<IDictionary<string, string>>(new Dictionary<string, string>
{
{ "RavenDB35/RunInMemory", bool.TrueString},
{ "DatabaseMaintenancePort", FindAvailablePort(33334).ToString()},
{ "HostName", "localhost" }
});
}

public Task Configure()
{
PersistenceType = typeof(RavenDbPersistenceConfiguration).AssemblyQualifiedName;

return Task.CompletedTask;
}

static int FindAvailablePort(int startPort)
{
var activeTcpListeners = IPGlobalProperties
.GetIPGlobalProperties()
.GetActiveTcpListeners();

for (var port = startPort; port < startPort + 1024; port++)
{
var portCopy = port;
if (activeTcpListeners.All(endPoint => endPoint.Port != portCopy))
{
return port;
}
}

return startPort;
}

public Task Cleanup() => Task.CompletedTask;
}
}
Loading