Skip to content

Commit e179b8f

Browse files
Open RavenDB.Client version range for broader compatibility (#726)
* Have a latest project with renovate configured * Try latest action * Deliberately use something lower for now * Correct format * Try this * Move * Cluster wide latest * Cap upper bound * Indent * Stable action * Upgrade to latest for now --------- Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
1 parent 5a3bfd4 commit e179b8f

File tree

9 files changed

+335
-2
lines changed

9 files changed

+335
-2
lines changed

.github/renovate.json5

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
packageRules: [
3+
{
4+
description: "Keep non-Latest projects on RavenDB.Client v6.x",
5+
matchFiles: ["**/*.csproj"],
6+
excludeFiles: ["**/*.Latest.*.csproj"],
7+
matchPackageNames: ["RavenDB.Client"],
8+
allowedVersions: ">=6.0.0 <7.0.0"
9+
},
10+
{
11+
description: "Allow .Latest. projects to use RavenDB.Client v7.x and above",
12+
matchFiles: ["**/*.Latest.*.csproj"],
13+
matchPackageNames: ["RavenDB.Client"],
14+
allowedVersions: ">=7.0.0"
15+
}
16+
]
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*.cs]
2+
3+
# Justification: Test project
4+
dotnet_diagnostic.CA2007.severity = none
5+
6+
# may be enabled in future
7+
dotnet_diagnostic.PS0018.severity = suggestion # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext
8+
9+
# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
10+
dotnet_diagnostic.NSB0002.severity = suggestion
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
namespace NServiceBus.Gateway.AcceptanceTests
2+
{
3+
using NServiceBus.AcceptanceTesting.Support;
4+
using NServiceBus.Configuration.AdvancedExtensibility;
5+
using Raven.Client.Documents;
6+
using Raven.Client.ServerWide;
7+
using Raven.Client.ServerWide.Operations;
8+
using System;
9+
using System.Threading.Tasks;
10+
using System.Collections.Generic;
11+
using System.Threading;
12+
13+
public partial class GatewayTestSuiteConstraints
14+
{
15+
public Task<GatewayDeduplicationConfiguration> ConfigureDeduplicationStorage(string endpointName, EndpointConfiguration configuration, RunSettings settings)
16+
{
17+
var ravenGatewayDeduplicationConfiguration = new RavenGatewayDeduplicationConfiguration((builder, _) =>
18+
{
19+
var databaseName = Guid.NewGuid().ToString();
20+
var documentStore = GetInitializedDocumentStore(databaseName);
21+
22+
documentStore.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(databaseName)));
23+
24+
try
25+
{
26+
semaphoreSlim.Wait();
27+
databases.Add(databaseName);
28+
}
29+
finally
30+
{
31+
semaphoreSlim.Release();
32+
}
33+
34+
return documentStore;
35+
})
36+
{
37+
EnableClusterWideTransactions = true
38+
};
39+
40+
var gatewaySettings = configuration.Gateway(ravenGatewayDeduplicationConfiguration);
41+
configuration.GetSettings().Set(gatewaySettings);
42+
43+
return Task.FromResult<GatewayDeduplicationConfiguration>(ravenGatewayDeduplicationConfiguration);
44+
}
45+
46+
public async Task Cleanup()
47+
{
48+
await semaphoreSlim.WaitAsync();
49+
try
50+
{
51+
foreach (var databaseName in databases)
52+
{
53+
// Periodically the delete will throw an exception because Raven has the database locked
54+
// To solve this we have a retry loop with a delay
55+
var triesLeft = 3;
56+
57+
while (triesLeft-- > 0)
58+
{
59+
try
60+
{
61+
// We are using a new store because the global one is disposed of before cleanup
62+
using (var storeForDeletion = GetInitializedDocumentStore(databaseName))
63+
{
64+
storeForDeletion.Maintenance.Server.Send(new DeleteDatabasesOperation(storeForDeletion.Database, hardDelete: true));
65+
break;
66+
}
67+
}
68+
catch
69+
{
70+
if (triesLeft == 0)
71+
{
72+
throw;
73+
}
74+
75+
await Task.Delay(250);
76+
}
77+
}
78+
79+
Console.WriteLine("Deleted '{0}' database", databaseName);
80+
}
81+
82+
databases.Clear();
83+
}
84+
finally
85+
{
86+
semaphoreSlim.Release();
87+
}
88+
}
89+
90+
static DocumentStore GetInitializedDocumentStore(string defaultDatabase)
91+
{
92+
var urls = Environment.GetEnvironmentVariable("CommaSeparatedRavenClusterUrls");
93+
if (urls == null)
94+
{
95+
throw new Exception("RavenDB cluster URLs must be specified in an environment variable named CommaSeparatedRavenClusterUrls.");
96+
}
97+
98+
var documentStore = new DocumentStore
99+
{
100+
Urls = urls.Split(','),
101+
Database = defaultDatabase
102+
};
103+
104+
documentStore.Initialize();
105+
106+
return documentStore;
107+
}
108+
109+
static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
110+
List<string> databases = [];
111+
}
112+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\NServiceBus.Gateway.RavenDB\NServiceBus.Gateway.RavenDB.csproj" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
14+
<PackageReference Include="NUnit" Version="4.4.0" />
15+
<PackageReference Include="NUnit.Analyzers" Version="4.10.0" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<!-- We are pulling in latest here to ensure we are testing against the latest RavenDB.Client -->
21+
<PackageReference Include="RavenDB.Client" Version="7.1.2" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="10.0.0-alpha.4" />
26+
<PackageReference Include="NServiceBus.Gateway.AcceptanceTests.Sources" Version="6.0.0-alpha.2" />
27+
</ItemGroup>
28+
29+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*.cs]
2+
3+
# Justification: Test project
4+
dotnet_diagnostic.CA2007.severity = none
5+
6+
# may be enabled in future
7+
dotnet_diagnostic.PS0018.severity = suggestion # A task-returning method should have a CancellationToken parameter unless it has a parameter implementing ICancellableContext
8+
9+
# Justification: Tests don't support cancellation and don't need to forward IMessageHandlerContext.CancellationToken
10+
dotnet_diagnostic.NSB0002.severity = suggestion
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
namespace NServiceBus.Gateway.AcceptanceTests
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using NServiceBus.AcceptanceTesting.Support;
8+
using NServiceBus.Configuration.AdvancedExtensibility;
9+
using Raven.Client.Documents;
10+
using Raven.Client.ServerWide;
11+
using Raven.Client.ServerWide.Operations;
12+
13+
public partial class GatewayTestSuiteConstraints
14+
{
15+
public Task<GatewayDeduplicationConfiguration> ConfigureDeduplicationStorage(string endpointName, EndpointConfiguration configuration, RunSettings settings)
16+
{
17+
var ravenGatewayDeduplicationConfiguration = new RavenGatewayDeduplicationConfiguration((builder, _) =>
18+
{
19+
var databaseName = Guid.NewGuid().ToString();
20+
var documentStore = GetInitializedDocumentStore(databaseName);
21+
22+
for (var i = 0; i < 3; i++)
23+
{
24+
try
25+
{
26+
documentStore.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(databaseName)));
27+
break;
28+
}
29+
catch (AggregateException)
30+
{
31+
// Usually, Failed to retrieve cluster topology from all known nodes
32+
}
33+
}
34+
35+
try
36+
{
37+
semaphoreSlim.Wait();
38+
databases.Add(databaseName);
39+
}
40+
finally
41+
{
42+
semaphoreSlim.Release();
43+
}
44+
45+
return documentStore;
46+
});
47+
48+
var gatewaySettings = configuration.Gateway(ravenGatewayDeduplicationConfiguration);
49+
configuration.GetSettings().Set(gatewaySettings);
50+
51+
return Task.FromResult<GatewayDeduplicationConfiguration>(ravenGatewayDeduplicationConfiguration);
52+
}
53+
54+
public async Task Cleanup()
55+
{
56+
await semaphoreSlim.WaitAsync();
57+
try
58+
{
59+
foreach (var databaseName in databases)
60+
{
61+
// Periodically the delete will throw an exception because Raven has the database locked
62+
// To solve this we have a retry loop with a delay
63+
var triesLeft = 3;
64+
65+
while (triesLeft-- > 0)
66+
{
67+
try
68+
{
69+
// We are using a new store because the global one is disposed of before cleanup
70+
using (var storeForDeletion = GetInitializedDocumentStore(databaseName))
71+
{
72+
storeForDeletion.Maintenance.Server.Send(new DeleteDatabasesOperation(storeForDeletion.Database, hardDelete: true));
73+
break;
74+
}
75+
}
76+
catch
77+
{
78+
if (triesLeft == 0)
79+
{
80+
throw;
81+
}
82+
83+
await Task.Delay(250);
84+
}
85+
}
86+
87+
Console.WriteLine("Deleted '{0}' database", databaseName);
88+
}
89+
90+
databases.Clear();
91+
}
92+
finally
93+
{
94+
semaphoreSlim.Release();
95+
}
96+
}
97+
98+
static DocumentStore GetInitializedDocumentStore(string defaultDatabase)
99+
{
100+
var url = Environment.GetEnvironmentVariable("RavenSingleNodeUrl") ?? throw new Exception("RavenDB URL must be specified in an environment variable named RavenSingleNodeUrl.");
101+
102+
var documentStore = new DocumentStore
103+
{
104+
Urls = new[] { url },
105+
Database = defaultDatabase
106+
};
107+
108+
documentStore.Initialize();
109+
110+
return documentStore;
111+
}
112+
113+
static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
114+
List<string> databases = [];
115+
}
116+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\NServiceBus.Gateway.RavenDB\NServiceBus.Gateway.RavenDB.csproj" />
9+
</ItemGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
14+
<PackageReference Include="NUnit" Version="4.4.0" />
15+
<PackageReference Include="NUnit.Analyzers" Version="4.10.0" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<!-- We are pulling in latest here to ensure we are testing against the latest RavenDB.Client -->
21+
<PackageReference Include="RavenDB.Client" Version="7.1.2" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="10.0.0-alpha.4" />
26+
<PackageReference Include="NServiceBus.Gateway.AcceptanceTests.Sources" Version="6.0.0-alpha.2" />
27+
</ItemGroup>
28+
29+
</Project>

src/NServiceBus.Gateway.RavenDB.slnx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
<Folder Name="/Tests/">
88
<Project Path="NServiceBus.Gateway.RavenDB.AcceptanceTests/NServiceBus.Gateway.RavenDB.AcceptanceTests.csproj" />
99
<Project Path="NServiceBus.Gateway.RavenDB.ClusterWideTx.AcceptanceTests/NServiceBus.Gateway.RavenDB.ClusterWideTx.AcceptanceTests.csproj" />
10+
<Project Path="NServiceBus.Gateway.RavenDB.Latest.AcceptanceTests\NServiceBus.Gateway.RavenDB.Latest.AcceptanceTests.csproj" Type="Classic C#" />
11+
<Project Path="NServiceBus.Gateway.RavenDB.ClusterWideTx.Latest.AcceptanceTests\NServiceBus.Gateway.RavenDB.ClusterWideTx.Latest.AcceptanceTests.csproj" Type="Classic C#" />
1012
<Project Path="NServiceBus.Gateway.RavenDB.Tests/NServiceBus.Gateway.RavenDB.Tests.csproj" />
1113
</Folder>
1214
<Project Path="NServiceBus.Gateway.RavenDB/NServiceBus.Gateway.RavenDB.csproj" />
13-
</Solution>
15+
</Solution>

src/NServiceBus.Gateway.RavenDB/NServiceBus.Gateway.RavenDB.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
<ItemGroup>
1010
<PackageReference Include="NServiceBus" Version="10.0.0-alpha.4" />
1111
<PackageReference Include="NServiceBus.Gateway" Version="6.0.0-alpha.2" />
12-
<PackageReference Include="RavenDB.Client" Version="6.2.9" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<!-- We are keeping this deliberately open to the currently supported versions (LTS and STS) according to the
16+
guidance we received from RavenDB they should rarely ever introduce breaking changes. Should it ever
17+
happend we can always lock it down to a specific version and release another minor starting from the
18+
version that introduced the breaking change.
19+
-->
20+
<PackageReference Include="RavenDB.Client" Version="[6.2.9,8.0.0)" AutomaticVersionRange="false" />
1321
</ItemGroup>
1422

1523
<ItemGroup>

0 commit comments

Comments
 (0)