* Remove Linux only Docker build for E2E tests * Fix cmsVersion variable * Remove custom build number step (already done by Nerdbank.GitVersioning) * Add and use global.json to configure .NET SDK version * Only publish tests build output * Only include unit tests and integration build output (without reference assemblies) * Added "pr: none" to nightly trigger (#15044) * Only run SQL Server Acceptance Tests on release builds or when parameter is set * Use SQLite in-memory database and configure database optimizations (#15461) * Disable content version cleanup and server election * Reference Umbraco.Tests.AcceptanceTest.UmbracoProject instead of copying files * Suspend/disable scheduled publishing * Ensure all Playwright results are copied to the artifact staging directory * Update E2E SQL Server job and also run on Linux * Fix building acceptance test project * Fix building acceptance test project (suing PrivateAssets) * Explicitly disable building project references in E2E tests and use pre-built output * Include obj folder of acceptance test project in build artifacts * Download build artifacts * Re-add PrivateAssets * Revert to copying C# files to E2E application * Disable Integrated Security for SQL Server on Linux * Update SQL Server on Linux connection string * Disable encryption on SQL Server for Linux * Update SQL Server on Linux steps * Add Database to SQL Server connection string on Linux * Update Integration Tests and use SQL Server 2022 Docker image --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
using Microsoft.Data.Sqlite;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Composing;
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace UmbracoProject;
|
|
|
|
/// <summary>
|
|
/// Ensures a SQLite in-memory database is persisted for the whole application duration.
|
|
/// </summary>
|
|
public sealed class SQLiteMemoryComposer : IComposer
|
|
{
|
|
public void Compose(IUmbracoBuilder builder)
|
|
{
|
|
var connectionString = builder.Config.GetUmbracoConnectionString(out var providerName);
|
|
if (!string.IsNullOrEmpty(connectionString) &&
|
|
Constants.ProviderNames.SQLLite.InvariantEquals(providerName) &&
|
|
connectionString.InvariantContains("Mode=Memory"))
|
|
{
|
|
// Open new SQLite connection to ensure in-memory database is persisted for the whole application duration
|
|
var connection = new SqliteConnection(connectionString);
|
|
connection.Open();
|
|
|
|
// And ensure connection is kept open (by keeping a reference) and gets gracefully closed/disposed when application stops
|
|
builder.Services.AddHostedService(_ => new SQLiteMemoryHostedService(connection));
|
|
}
|
|
}
|
|
|
|
private sealed class SQLiteMemoryHostedService : IHostedService, IAsyncDisposable
|
|
{
|
|
private readonly SqliteConnection _connection;
|
|
|
|
public SQLiteMemoryHostedService(SqliteConnection connection) => _connection = connection;
|
|
|
|
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
|
|
public async Task StopAsync(CancellationToken cancellationToken) => await _connection.CloseAsync();
|
|
|
|
public async ValueTask DisposeAsync() => await _connection.DisposeAsync();
|
|
}
|
|
}
|