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
17 changes: 17 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
packageRules: [
{
description: "Keep non-Latest projects on RavenDB.Client v6.x",
matchFiles: ["**/*.csproj"],
excludeFiles: ["**/*.Latest.*.csproj"],
matchPackageNames: ["RavenDB.Client"],
allowedVersions: ">=6.0.0 <7.0.0"
},
{
description: "Allow .Latest. projects to use RavenDB.Client v7.x and above",
matchFiles: ["**/*.Latest.*.csproj"],
matchPackageNames: ["RavenDB.Client"],
allowedVersions: ">=7.0.0"
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
creds: ${{ secrets.AZURE_ACI_CREDENTIALS }}
- name: Setup RavenDB
id: setup-ravendb
uses: Particular/setup-ravendb-action@v1.10.0
uses: Particular/setup-ravendb-action@v1.11.0
with:
single-connection-string-name: RavenSingleNodeUrl
cluster-connection-string-name: CommaSeparatedRavenClusterUrls
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.cs]

# Justification: Test project
dotnet_diagnostic.CA2007.severity = none

# may be enabled in future
dotnet_diagnostic.PS0018.severity = suggestion # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext

# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
dotnet_diagnostic.NSB0002.severity = suggestion
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
namespace NServiceBus.Gateway.AcceptanceTests
{
using NServiceBus.AcceptanceTesting.Support;
using NServiceBus.Configuration.AdvancedExtensibility;
using Raven.Client.Documents;
using Raven.Client.ServerWide;
using Raven.Client.ServerWide.Operations;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;

public partial class GatewayTestSuiteConstraints
{
public Task<GatewayDeduplicationConfiguration> ConfigureDeduplicationStorage(string endpointName, EndpointConfiguration configuration, RunSettings settings)
{
var ravenGatewayDeduplicationConfiguration = new RavenGatewayDeduplicationConfiguration((builder, _) =>
{
var databaseName = Guid.NewGuid().ToString();
var documentStore = GetInitializedDocumentStore(databaseName);

documentStore.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(databaseName)));

try
{
semaphoreSlim.Wait();
databases.Add(databaseName);
}
finally
{
semaphoreSlim.Release();
}

return documentStore;
})
{
EnableClusterWideTransactions = true
};

var gatewaySettings = configuration.Gateway(ravenGatewayDeduplicationConfiguration);
configuration.GetSettings().Set(gatewaySettings);

return Task.FromResult<GatewayDeduplicationConfiguration>(ravenGatewayDeduplicationConfiguration);
}

public async Task Cleanup()
{
await semaphoreSlim.WaitAsync();
try
{
foreach (var databaseName in databases)
{
// Periodically the delete will throw an exception because Raven has the database locked
// To solve this we have a retry loop with a delay
var triesLeft = 3;

while (triesLeft-- > 0)
{
try
{
// We are using a new store because the global one is disposed of before cleanup
using (var storeForDeletion = GetInitializedDocumentStore(databaseName))
{
storeForDeletion.Maintenance.Server.Send(new DeleteDatabasesOperation(storeForDeletion.Database, hardDelete: true));
break;
}
}
catch
{
if (triesLeft == 0)
{
throw;
}

await Task.Delay(250);
}
}

Console.WriteLine("Deleted '{0}' database", databaseName);
}

databases.Clear();
}
finally
{
semaphoreSlim.Release();
}
}

static DocumentStore GetInitializedDocumentStore(string defaultDatabase)
{
var urls = Environment.GetEnvironmentVariable("CommaSeparatedRavenClusterUrls");
if (urls == null)
{
throw new Exception("RavenDB cluster URLs must be specified in an environment variable named CommaSeparatedRavenClusterUrls.");
}

var documentStore = new DocumentStore
{
Urls = urls.Split(','),
Database = defaultDatabase
};

documentStore.Initialize();

return documentStore;
}

static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
List<string> databases = [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.Gateway.RavenDB\NServiceBus.Gateway.RavenDB.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
<!-- We are pulling in latest here to ensure we are testing against the latest RavenDB.Client -->
<PackageReference Include="RavenDB.Client" Version="7.1.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="10.0.0-alpha.4" />
<PackageReference Include="NServiceBus.Gateway.AcceptanceTests.Sources" Version="6.0.0-alpha.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*.cs]

# Justification: Test project
dotnet_diagnostic.CA2007.severity = none

# may be enabled in future
dotnet_diagnostic.PS0018.severity = suggestion # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext

# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
dotnet_diagnostic.NSB0002.severity = suggestion
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
namespace NServiceBus.Gateway.AcceptanceTests
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using NServiceBus.AcceptanceTesting.Support;
using NServiceBus.Configuration.AdvancedExtensibility;
using Raven.Client.Documents;
using Raven.Client.ServerWide;
using Raven.Client.ServerWide.Operations;

public partial class GatewayTestSuiteConstraints
{
public Task<GatewayDeduplicationConfiguration> ConfigureDeduplicationStorage(string endpointName, EndpointConfiguration configuration, RunSettings settings)
{
var ravenGatewayDeduplicationConfiguration = new RavenGatewayDeduplicationConfiguration((builder, _) =>
{
var databaseName = Guid.NewGuid().ToString();
var documentStore = GetInitializedDocumentStore(databaseName);

for (var i = 0; i < 3; i++)
{
try
{
documentStore.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(databaseName)));
break;
}
catch (AggregateException)
{
// Usually, Failed to retrieve cluster topology from all known nodes
}
}

try
{
semaphoreSlim.Wait();
databases.Add(databaseName);
}
finally
{
semaphoreSlim.Release();
}

return documentStore;
});

var gatewaySettings = configuration.Gateway(ravenGatewayDeduplicationConfiguration);
configuration.GetSettings().Set(gatewaySettings);

return Task.FromResult<GatewayDeduplicationConfiguration>(ravenGatewayDeduplicationConfiguration);
}

public async Task Cleanup()
{
await semaphoreSlim.WaitAsync();
try
{
foreach (var databaseName in databases)
{
// Periodically the delete will throw an exception because Raven has the database locked
// To solve this we have a retry loop with a delay
var triesLeft = 3;

while (triesLeft-- > 0)
{
try
{
// We are using a new store because the global one is disposed of before cleanup
using (var storeForDeletion = GetInitializedDocumentStore(databaseName))
{
storeForDeletion.Maintenance.Server.Send(new DeleteDatabasesOperation(storeForDeletion.Database, hardDelete: true));
break;
}
}
catch
{
if (triesLeft == 0)
{
throw;
}

await Task.Delay(250);
}
}

Console.WriteLine("Deleted '{0}' database", databaseName);
}

databases.Clear();
}
finally
{
semaphoreSlim.Release();
}
}

static DocumentStore GetInitializedDocumentStore(string defaultDatabase)
{
var url = Environment.GetEnvironmentVariable("RavenSingleNodeUrl") ?? throw new Exception("RavenDB URL must be specified in an environment variable named RavenSingleNodeUrl.");

var documentStore = new DocumentStore
{
Urls = new[] { url },
Database = defaultDatabase
};

documentStore.Initialize();

return documentStore;
}

static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
List<string> databases = [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NServiceBus.Gateway.RavenDB\NServiceBus.Gateway.RavenDB.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
<!-- We are pulling in latest here to ensure we are testing against the latest RavenDB.Client -->
<PackageReference Include="RavenDB.Client" Version="7.1.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="10.0.0-alpha.4" />
<PackageReference Include="NServiceBus.Gateway.AcceptanceTests.Sources" Version="6.0.0-alpha.2" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/NServiceBus.Gateway.RavenDB.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<Folder Name="/Tests/">
<Project Path="NServiceBus.Gateway.RavenDB.AcceptanceTests/NServiceBus.Gateway.RavenDB.AcceptanceTests.csproj" />
<Project Path="NServiceBus.Gateway.RavenDB.ClusterWideTx.AcceptanceTests/NServiceBus.Gateway.RavenDB.ClusterWideTx.AcceptanceTests.csproj" />
<Project Path="NServiceBus.Gateway.RavenDB.Latest.AcceptanceTests\NServiceBus.Gateway.RavenDB.Latest.AcceptanceTests.csproj" Type="Classic C#" />
<Project Path="NServiceBus.Gateway.RavenDB.ClusterWideTx.Latest.AcceptanceTests\NServiceBus.Gateway.RavenDB.ClusterWideTx.Latest.AcceptanceTests.csproj" Type="Classic C#" />
<Project Path="NServiceBus.Gateway.RavenDB.Tests/NServiceBus.Gateway.RavenDB.Tests.csproj" />
</Folder>
<Project Path="NServiceBus.Gateway.RavenDB/NServiceBus.Gateway.RavenDB.csproj" />
</Solution>
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
<ItemGroup>
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.4" />
<PackageReference Include="NServiceBus.Gateway" Version="6.0.0-alpha.2" />
<PackageReference Include="RavenDB.Client" Version="6.2.9" />
</ItemGroup>

<ItemGroup>
<!-- We are keeping this deliberately open to the currently supported versions (LTS and STS) according to the
guidance we received from RavenDB they should rarely ever introduce breaking changes. Should it ever
happend we can always lock it down to a specific version and release another minor starting from the
version that introduced the breaking change.
-->
<PackageReference Include="RavenDB.Client" Version="[6.2.9,8.0.0)" AutomaticVersionRange="false" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading