Skip to content

Commit 0e1ca76

Browse files
ronaldbarendsebergmania
andauthoredFeb 2, 2024
Remove Linux only Docker build for E2E tests (#14042)
* 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 <[email protected]>
1 parent 836d45e commit 0e1ca76

11 files changed

+432
-237
lines changed
 

‎.artifactignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
**/*
2-
!**/bin/**
3-
!**/obj/**
2+
!tests/Umbraco.Tests.Integration/bin/**
3+
!tests/Umbraco.Tests.UnitTests/bin/**

‎build/azure-pipelines.yml

+308-165
Large diffs are not rendered by default.

‎global.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.0",
4-
"rollForward": "latestFeature",
5-
"allowPrerelease": false
3+
"version": "8.0.100",
4+
"rollForward": "latestFeature"
65
}
76
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.Data.Sqlite;
2+
using Umbraco.Cms.Core;
3+
using Umbraco.Cms.Core.Composing;
4+
using Umbraco.Cms.Core.DependencyInjection;
5+
using Umbraco.Extensions;
6+
7+
namespace UmbracoProject;
8+
9+
/// <summary>
10+
/// Ensures a SQLite in-memory database is persisted for the whole application duration.
11+
/// </summary>
12+
public sealed class SQLiteMemoryComposer : IComposer
13+
{
14+
public void Compose(IUmbracoBuilder builder)
15+
{
16+
var connectionString = builder.Config.GetUmbracoConnectionString(out var providerName);
17+
if (!string.IsNullOrEmpty(connectionString) &&
18+
Constants.ProviderNames.SQLLite.InvariantEquals(providerName) &&
19+
connectionString.InvariantContains("Mode=Memory"))
20+
{
21+
// Open new SQLite connection to ensure in-memory database is persisted for the whole application duration
22+
var connection = new SqliteConnection(connectionString);
23+
connection.Open();
24+
25+
// And ensure connection is kept open (by keeping a reference) and gets gracefully closed/disposed when application stops
26+
builder.Services.AddHostedService(_ => new SQLiteMemoryHostedService(connection));
27+
}
28+
}
29+
30+
private sealed class SQLiteMemoryHostedService : IHostedService, IAsyncDisposable
31+
{
32+
private readonly SqliteConnection _connection;
33+
34+
public SQLiteMemoryHostedService(SqliteConnection connection) => _connection = connection;
35+
36+
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
37+
38+
public async Task StopAsync(CancellationToken cancellationToken) => await _connection.CloseAsync();
39+
40+
public async ValueTask DisposeAsync() => await _connection.DisposeAsync();
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Microsoft.Data.SqlClient;
2+
using Microsoft.Extensions.Options;
3+
using Umbraco.Cms.Core;
4+
using Umbraco.Cms.Core.Composing;
5+
using Umbraco.Cms.Core.Configuration.Models;
6+
using Umbraco.Cms.Core.DependencyInjection;
7+
using Umbraco.Cms.Core.Events;
8+
using Umbraco.Cms.Core.Notifications;
9+
using Umbraco.Extensions;
10+
11+
namespace UmbracoProject;
12+
13+
/// <summary>
14+
/// Disable waiting on log IO to finish when commiting a transaction (we can tolerate some data loss) on SQL Server.
15+
/// </summary>
16+
public sealed class SqlServerDelayedDurabilityComposer : IComposer
17+
{
18+
public void Compose(IUmbracoBuilder builder)
19+
{
20+
var connectionString = builder.Config.GetUmbracoConnectionString(out var providerName);
21+
if (!string.IsNullOrEmpty(connectionString) &&
22+
Constants.ProviderNames.SQLServer.InvariantEquals(providerName))
23+
{
24+
builder.AddNotificationAsyncHandler<UnattendedInstallNotification, SqlServerDelayedDurabilityInstallNotification>();
25+
}
26+
}
27+
28+
private sealed class SqlServerDelayedDurabilityInstallNotification : INotificationAsyncHandler<UnattendedInstallNotification>
29+
{
30+
private readonly IOptions<ConnectionStrings> _connectionStrings;
31+
32+
public SqlServerDelayedDurabilityInstallNotification(IOptions<ConnectionStrings> connectionStrings) => _connectionStrings = connectionStrings;
33+
34+
public async Task HandleAsync(UnattendedInstallNotification notification, CancellationToken cancellationToken)
35+
{
36+
using var connection = new SqlConnection(_connectionStrings.Value.ConnectionString);
37+
await connection.OpenAsync(cancellationToken);
38+
39+
// Disable waiting on log IO to finish when commiting a transaction (we can tolerate some data loss)
40+
var command = new SqlCommand("ALTER DATABASE CURRENT SET DELAYED_DURABILITY = FORCED;", connection);
41+
await command.ExecuteNonQueryAsync(cancellationToken);
42+
}
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Umbraco.Cms.Core.Composing;
2+
using Umbraco.Cms.Core.DependencyInjection;
3+
using Umbraco.Cms.Infrastructure;
4+
5+
namespace UmbracoProject;
6+
7+
/// <summary>
8+
/// Suspends/disables scheduled publishing, because that takes an eager write lock every minute, resulting in flaky test runs on SQLite.
9+
/// </summary>
10+
public sealed class SuspendScheduledPublishingComposer : IComposer
11+
{
12+
public void Compose(IUmbracoBuilder builder) => Suspendable.ScheduledPublishing.Suspend();
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<!-- All C# files in the root of this project will be copied to the E2E/Acceptance Test application during build -->
4+
<OutputType>Library</OutputType>
5+
<RootNamespace>UmbracoProject</RootNamespace>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="..\..\src\Umbraco.Cms\Umbraco.Cms.csproj" />
9+
</ItemGroup>
10+
</Project>

‎tests/Umbraco.Tests.AcceptanceTest/misc/Directory.Build.props

-7
This file was deleted.

‎tests/Umbraco.Tests.AcceptanceTest/misc/nuget.config

-8
This file was deleted.

‎tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker

-51
This file was deleted.

‎umbraco.sln

+11-1
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
133133
global.json = global.json
134134
icon.png = icon.png
135135
LICENSE.md = LICENSE.md
136-
umbraco.sln.DotSettings = umbraco.sln.DotSettings
137136
nuget.config = nuget.config
137+
umbraco.sln.DotSettings = umbraco.sln.DotSettings
138138
version.json = version.json
139139
EndProjectSection
140140
EndProject
141141
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{20CE9C97-9314-4A19-BCF1-D12CF49B7205}"
142142
ProjectSection(SolutionItems) = preProject
143143
build\azure-pipelines.yml = build\azure-pipelines.yml
144+
build\nightly-build-trigger.yml = build\nightly-build-trigger.yml
144145
EndProjectSection
145146
EndProject
146147
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "csharp-docs", "csharp-docs", "{F2BF84D9-0A14-40AF-A0F3-B9BBBBC16A44}"
@@ -184,6 +185,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Persistence.EFC
184185
EndProject
185186
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Cms.Persistence.EFCore.SqlServer", "src\Umbraco.Cms.Persistence.EFCore.SqlServer\Umbraco.Cms.Persistence.EFCore.SqlServer.csproj", "{9276C3F0-0DC9-46C9-BF32-9EE79D92AE02}"
186187
EndProject
188+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Tests.AcceptanceTest.UmbracoProject", "tests\Umbraco.Tests.AcceptanceTest.UmbracoProject\Umbraco.Tests.AcceptanceTest.UmbracoProject.csproj", "{A13FF0A0-69FA-468A-9F79-565401D5C341}"
189+
EndProject
187190
Global
188191
GlobalSection(SolutionConfigurationPlatforms) = preSolution
189192
Debug|Any CPU = Debug|Any CPU
@@ -357,6 +360,12 @@ Global
357360
{9276C3F0-0DC9-46C9-BF32-9EE79D92AE02}.Release|Any CPU.Build.0 = Release|Any CPU
358361
{9276C3F0-0DC9-46C9-BF32-9EE79D92AE02}.SkipTests|Any CPU.ActiveCfg = Debug|Any CPU
359362
{9276C3F0-0DC9-46C9-BF32-9EE79D92AE02}.SkipTests|Any CPU.Build.0 = Debug|Any CPU
363+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
364+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.Debug|Any CPU.Build.0 = Debug|Any CPU
365+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.Release|Any CPU.ActiveCfg = Release|Any CPU
366+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.Release|Any CPU.Build.0 = Release|Any CPU
367+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.SkipTests|Any CPU.ActiveCfg = Debug|Any CPU
368+
{A13FF0A0-69FA-468A-9F79-565401D5C341}.SkipTests|Any CPU.Build.0 = Debug|Any CPU
360369
EndGlobalSection
361370
GlobalSection(SolutionProperties) = preSolution
362371
HideSolutionNode = FALSE
@@ -375,6 +384,7 @@ Global
375384
{2B47AD9F-FFF1-448A-88F1-D4F568811738} = {F2BF84D9-0A14-40AF-A0F3-B9BBBBC16A44}
376385
{25AECCB5-B187-4406-844B-91B8FF0FCB37} = {2B47AD9F-FFF1-448A-88F1-D4F568811738}
377386
{EA628ABD-624E-4AF3-B548-6710D4D66531} = {2B47AD9F-FFF1-448A-88F1-D4F568811738}
387+
{A13FF0A0-69FA-468A-9F79-565401D5C341} = {B5BD12C1-A454-435E-8A46-FF4A364C0382}
378388
EndGlobalSection
379389
GlobalSection(ExtensibilityGlobals) = postSolution
380390
SolutionGuid = {7A0F2E34-D2AF-4DAB-86A0-7D7764B3D0EC}

0 commit comments

Comments
 (0)
Please sign in to comment.