Skip to content

Commit 620563c

Browse files
authored
Exclude unused Kafka libraries and update .NET to 10.0.13 (#6004)
* Exclude native Kafka dependencies from the RavenDB installer package * Pin the patched PKCS dependency to unblock NuGet audit * Align the runtime and Microsoft packages at 10.0.13
1 parent 011c6f4 commit 620563c

6 files changed

Lines changed: 189 additions & 3 deletions

File tree

‎docs/packaging.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ The zip files minimize duplication to control the overall file size of each inst
88
- `ServiceControl.Audit.zip`
99
- `ServiceControl.Monitoring.zip`
1010
- `InstanceShared.zip` - Contains the transport assemblies that are shared by each instance, as well as any other assemblies that are shared across all 3 instance zip files, such as `NServiceBus.Core.dll`.
11-
- `RavenDBServer.zip` - Contains the RavenDB server assemblies used by ServiceControl and Monitoring instances
11+
- `RavenDBServer.zip` - Contains the RavenDB server assemblies used by ServiceControl and Audit instances
12+
13+
`RavenDBServer.zip` excludes the native Kafka dependencies `librdkafka.dll`, `librdkafkacpp.dll`, and `libcurl.dll`. ServiceControl does not configure RavenDB's Kafka ETL or sink tasks. The Windows installation engine tests extract this archive and verify document persistence and indexing across a server restart without these libraries.
1214

1315
## The mechanics
1416

‎docs/testing.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Installation engine tests run partial installations and check:
2020
- That the generated configuration is correct.
2121
- That transport and persistence are correctly extracted.
2222

23+
On Windows, [PackagedRavenDBTests](../src/ServiceControlInstaller.Engine.UnitTests/Validation/PackagedRavenDBTests.cs) starts the server extracted from the installer's embedded `RavenDBServer.zip`. It verifies the native Kafka dependencies are absent and checks document persistence and indexing before and after a restart. These tests run in the `Windows-DefaultCore` CI job; the `Windows-Raven` tests use the separate server files supplied by `RavenDB.Embedded`.
24+
2325
## Persistence tests
2426

2527
Persistence tests check assumptions at the persistence seam level by exercising each persister.

‎src/Custom.Build.props‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<PropertyGroup>
15-
<RuntimeFrameworkVersion>10.0.11</RuntimeFrameworkVersion>
15+
<RuntimeFrameworkVersion>10.0.13</RuntimeFrameworkVersion>
1616
<RollForward>Disable</RollForward>
1717
</PropertyGroup>
1818

‎src/Directory.Packages.props‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<PackageVersion Include="Azure.Core" Version="1.62.0" />
104104
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.2" />
105105
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(RuntimeFrameworkVersion)" />
106+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(RuntimeFrameworkVersion)" />
106107
<PackageVersion Include="Microsoft.IdentityModel.Abstractions" Version="8.22.0" />
107108
<PackageVersion Include="System.Formats.Cbor" Version="$(RuntimeFrameworkVersion)" />
108109
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="$(RuntimeFrameworkVersion)" />
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
namespace ServiceControlInstaller.Engine.UnitTests.Validation
2+
{
3+
using System;
4+
using System.Diagnostics;
5+
using System.IO;
6+
using System.Net.Http;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
using FileSystem;
10+
using NUnit.Framework;
11+
using Raven.Client.Documents;
12+
using Raven.Client.Documents.Indexes;
13+
using Raven.Client.Documents.Operations.Indexes;
14+
using Raven.Client.ServerWide;
15+
using Raven.Client.ServerWide.Operations;
16+
using TestHelper;
17+
18+
[TestFixture]
19+
[Platform("Win")]
20+
[NonParallelizable]
21+
class PackagedRavenDBTests
22+
{
23+
[Test]
24+
public async Task CanPersistAndIndexDocumentsWithoutNativeKafkaDependencies()
25+
{
26+
var root = Path.Combine(Path.GetTempPath(), "PackagedRavenDB", Guid.NewGuid().ToString("N"));
27+
var serverDirectory = Path.Combine(root, "Server");
28+
var dataDirectory = Path.Combine(root, "Data");
29+
var serverUrl = $"http://127.0.0.1:{PortUtility.FindAvailablePort(33400)}";
30+
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CurrentContext.CancellationToken);
31+
timeout.CancelAfter(TimeSpan.FromMinutes(3));
32+
var cancellationToken = timeout.Token;
33+
Process server = null;
34+
Task<string> standardOutput = null;
35+
Task<string> standardError = null;
36+
37+
try
38+
{
39+
FileUtils.UnzipToSubdirectory("RavenDBServer.zip", serverDirectory);
40+
41+
using (Assert.EnterMultipleScope())
42+
{
43+
Assert.That(Path.Combine(serverDirectory, "libcurl.dll"), Does.Not.Exist);
44+
Assert.That(Path.Combine(serverDirectory, "librdkafka.dll"), Does.Not.Exist);
45+
Assert.That(Path.Combine(serverDirectory, "librdkafkacpp.dll"), Does.Not.Exist);
46+
Assert.That(Path.Combine(serverDirectory, "Raven.Server.exe"), Does.Exist);
47+
}
48+
49+
await StartServer();
50+
51+
const string databaseName = "PackagingSmokeTest";
52+
using var store = new DocumentStore
53+
{
54+
Urls = [serverUrl],
55+
Database = databaseName,
56+
Conventions = { DisableTopologyUpdates = true }
57+
}.Initialize();
58+
59+
await store.Maintenance.Server.SendAsync(new CreateDatabaseOperation(new DatabaseRecord(databaseName)), cancellationToken);
60+
await store.Maintenance.SendAsync(new PutIndexesOperation(new IndexDefinition
61+
{
62+
Name = indexName,
63+
Maps = ["from document in docs select new { document.Name }"]
64+
}), cancellationToken);
65+
66+
using (var session = store.OpenAsyncSession())
67+
{
68+
await session.StoreAsync(new PackagedDocument { Name = documentName }, documentId, cancellationToken);
69+
await session.SaveChangesAsync(cancellationToken);
70+
}
71+
72+
await AssertDocumentAndIndex(store, cancellationToken);
73+
await StopServer();
74+
await StartServer();
75+
await AssertDocumentAndIndex(store, cancellationToken);
76+
}
77+
finally
78+
{
79+
await StopServer();
80+
if (Directory.Exists(root))
81+
{
82+
FileUtils.DeleteDirectory(root, recursive: true, contentsOnly: false);
83+
}
84+
}
85+
86+
async Task StartServer()
87+
{
88+
var startInfo = new ProcessStartInfo(Path.Combine(serverDirectory, "Raven.Server.exe"))
89+
{
90+
WorkingDirectory = serverDirectory,
91+
UseShellExecute = false,
92+
RedirectStandardOutput = true,
93+
RedirectStandardError = true,
94+
CreateNoWindow = true
95+
};
96+
startInfo.ArgumentList.Add("--non-interactive");
97+
startInfo.ArgumentList.Add("--log-to-console");
98+
startInfo.ArgumentList.Add($"--ServerUrl={serverUrl}");
99+
startInfo.ArgumentList.Add($"--DataDir={dataDirectory}");
100+
startInfo.ArgumentList.Add($"--Logs.Path={Path.Combine(root, "Logs")}");
101+
startInfo.ArgumentList.Add("--Setup.Mode=None");
102+
startInfo.ArgumentList.Add("--Security.UnsecuredAccessAllowed=Local");
103+
startInfo.ArgumentList.Add("--License.Eula.Accepted=true");
104+
startInfo.ArgumentList.Add($"--License.Path={Path.Combine(TestContext.CurrentContext.TestDirectory, "RavenLicense.json")}");
105+
startInfo.ArgumentList.Add("--License.DisableAutoUpdate=true");
106+
startInfo.ArgumentList.Add("--License.DisableLicenseSupportCheck=true");
107+
108+
server = Process.Start(startInfo);
109+
standardOutput = server.StandardOutput.ReadToEndAsync(CancellationToken.None);
110+
standardError = server.StandardError.ReadToEndAsync(CancellationToken.None);
111+
112+
using var client = new HttpClient { Timeout = Timeout.InfiniteTimeSpan };
113+
while (true)
114+
{
115+
cancellationToken.ThrowIfCancellationRequested();
116+
Assert.That(server.HasExited, Is.False, "The packaged RavenDB server exited before accepting requests.");
117+
try
118+
{
119+
using var response = await client.GetAsync($"{serverUrl}/build/version", cancellationToken);
120+
if (response.IsSuccessStatusCode)
121+
{
122+
return;
123+
}
124+
}
125+
catch (HttpRequestException)
126+
{
127+
}
128+
await Task.Delay(TimeSpan.FromMilliseconds(100), cancellationToken);
129+
}
130+
}
131+
132+
async Task StopServer()
133+
{
134+
if (server == null)
135+
{
136+
return;
137+
}
138+
139+
try
140+
{
141+
if (!server.HasExited)
142+
{
143+
server.Kill(entireProcessTree: true);
144+
}
145+
146+
await server.WaitForExitAsync(CancellationToken.None).WaitAsync(TimeSpan.FromSeconds(15));
147+
TestContext.Out.WriteLine(await standardOutput.WaitAsync(TimeSpan.FromSeconds(15)));
148+
TestContext.Out.WriteLine(await standardError.WaitAsync(TimeSpan.FromSeconds(15)));
149+
}
150+
finally
151+
{
152+
server.Dispose();
153+
server = null;
154+
}
155+
}
156+
}
157+
158+
static async Task AssertDocumentAndIndex(IDocumentStore store, CancellationToken cancellationToken)
159+
{
160+
using var session = store.OpenAsyncSession();
161+
var document = await session.LoadAsync<PackagedDocument>(documentId, cancellationToken);
162+
Assert.That(document?.Name, Is.EqualTo(documentName));
163+
164+
var indexedDocument = await session.Advanced.AsyncDocumentQuery<PackagedDocument>(indexName)
165+
.WaitForNonStaleResults(TimeSpan.FromSeconds(30))
166+
.WhereEquals(nameof(PackagedDocument.Name), documentName)
167+
.SingleAsync(cancellationToken);
168+
Assert.That(indexedDocument.Name, Is.EqualTo(documentName));
169+
}
170+
171+
class PackagedDocument
172+
{
173+
public string Name { get; set; }
174+
}
175+
176+
const string documentId = "documents/1";
177+
const string documentName = "Packaged RavenDB";
178+
const string indexName = "Packaging/ByName";
179+
}
180+
}

‎src/ServiceControlInstaller.Packaging/ServiceControlInstaller.Packaging.csproj‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
<AuditFilesToZip Include="$(ArtifactsPath)$(Audit)\**\*" />
4646
<MonitoringFilesToZip Include="$(ArtifactsPath)$(Monitoring)\**\*" />
4747
<InstanceSharedFilesToZip Include="@(DuplicateInstanceFiles->'$(ArtifactsPath)$(Primary)\%(Identity)')" />
48-
<RavenDBServerFilesToZip Include="$(ArtifactsPath)$(RavenDBServer)\**\*" />
48+
<RavenDBServerFilesToZip Include="$(ArtifactsPath)$(RavenDBServer)\**\*"
49+
Exclude="$(ArtifactsPath)$(RavenDBServer)\libcurl.dll;$(ArtifactsPath)$(RavenDBServer)\librdkafka.dll;$(ArtifactsPath)$(RavenDBServer)\librdkafkacpp.dll" />
4950
</ItemGroup>
5051
</Target>
5152

0 commit comments

Comments
 (0)