Skip to content

Commit 7bfdf43

Browse files
authored
Merge pull request #5620 from Particular/rhys/in-memory-raven
Add option to run tests against an in-memory raven instance
2 parents a803013 + 6b52aaf commit 7bfdf43

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/ServiceControl.Persistence.Tests.RavenDB/SharedEmbeddedServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static async Task<EmbeddedDatabase> GetInstance(CancellationToken cancell
3838
};
3939

4040
// TODO: See if more refactoring can be done between this and the RavenPersisterSettings above
41-
var embeddedConfig = new EmbeddedDatabaseConfiguration(settings.ServerUrl, RavenPersisterSettings.DatabaseNameDefault, dbPath, logPath, logsMode);
41+
var embeddedConfig = new EmbeddedDatabaseConfiguration(settings.ServerUrl, RavenPersisterSettings.DatabaseNameDefault, dbPath, logPath, logsMode) { RunInMemory = true };
4242

4343
embeddedDatabase = EmbeddedDatabase.Start(embeddedConfig, new ApplicationLifetime(new NullLogger<ApplicationLifetime>()));
4444

src/ServiceControl.RavenDB/EmbeddedDatabase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,22 @@ public static EmbeddedDatabase Start(EmbeddedDatabaseConfiguration databaseConfi
6969
}
7070

7171
logger.LogInformation("Loading RavenDB license from {LicenseFileName}", licenseFileNameAndServerDirectory.LicenseFileName);
72+
73+
List<string> optionalArgs = [];
74+
if (databaseConfiguration.RunInMemory)
75+
{
76+
optionalArgs.Add("--RunInMemory=true");
77+
}
78+
7279
var serverOptions = new ServerOptions
7380
{
7481
CommandLineArgs =
7582
[
7683
$"--Logs.Mode={databaseConfiguration.LogsMode}",
7784
// HINT: If this is not set, then Raven will pick a default location relative to the server binaries
7885
// See https://github.com/ravendb/ravendb/issues/15694
79-
$"--Indexing.NuGetPackagesPath=\"{nugetPackagesPath}\""
86+
$"--Indexing.NuGetPackagesPath=\"{nugetPackagesPath}\"",
87+
..optionalArgs
8088
],
8189
DataDirectory = databaseConfiguration.DbPath,
8290
ServerUrl = databaseConfiguration.ServerUrl,

src/ServiceControl.RavenDB/EmbeddedDatabaseConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class EmbeddedDatabaseConfiguration(string serverUrl, string dbName, stri
1010
public string LogPath { get; } = logPath;
1111
public string LogsMode { get; } = logsMode;
1212

13+
public bool RunInMemory { get; set; }
14+
1315
public Func<string, BlittableJsonReaderObject, string> FindClrType { get; init; }
1416
}
1517
}

0 commit comments

Comments
 (0)