forked from umbraco/Umbraco-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v13/dev' into v14/dev
# Conflicts: # .artifactignore # build/azure-pipelines.yml # tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker
- Loading branch information
Showing
13 changed files
with
437 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
**/* | ||
!**/bin/** | ||
!**/obj/** | ||
!tests/Umbraco.Tests.Integration/bin/** | ||
!tests/Umbraco.Tests.UnitTests/bin/** | ||
**/node_modules |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.0", | ||
"rollForward": "latestFeature", | ||
"allowPrerelease": false | ||
"version": "8.0.100", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/Umbraco.Tests.AcceptanceTest.UmbracoProject/SQLiteMemoryComposer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/Umbraco.Tests.AcceptanceTest.UmbracoProject/SqlServerDelayedDurabilityComposer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Microsoft.Data.SqlClient; | ||
using Microsoft.Extensions.Options; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Core.Configuration.Models; | ||
using Umbraco.Cms.Core.DependencyInjection; | ||
using Umbraco.Cms.Core.Events; | ||
using Umbraco.Cms.Core.Notifications; | ||
using Umbraco.Extensions; | ||
|
||
namespace UmbracoProject; | ||
|
||
/// <summary> | ||
/// Disable waiting on log IO to finish when commiting a transaction (we can tolerate some data loss) on SQL Server. | ||
/// </summary> | ||
public sealed class SqlServerDelayedDurabilityComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
var connectionString = builder.Config.GetUmbracoConnectionString(out var providerName); | ||
if (!string.IsNullOrEmpty(connectionString) && | ||
Constants.ProviderNames.SQLServer.InvariantEquals(providerName)) | ||
{ | ||
builder.AddNotificationAsyncHandler<UnattendedInstallNotification, SqlServerDelayedDurabilityInstallNotification>(); | ||
} | ||
} | ||
|
||
private sealed class SqlServerDelayedDurabilityInstallNotification : INotificationAsyncHandler<UnattendedInstallNotification> | ||
{ | ||
private readonly IOptions<ConnectionStrings> _connectionStrings; | ||
|
||
public SqlServerDelayedDurabilityInstallNotification(IOptions<ConnectionStrings> connectionStrings) => _connectionStrings = connectionStrings; | ||
|
||
public async Task HandleAsync(UnattendedInstallNotification notification, CancellationToken cancellationToken) | ||
{ | ||
using var connection = new SqlConnection(_connectionStrings.Value.ConnectionString); | ||
await connection.OpenAsync(cancellationToken); | ||
|
||
// Disable waiting on log IO to finish when commiting a transaction (we can tolerate some data loss) | ||
var command = new SqlCommand("ALTER DATABASE CURRENT SET DELAYED_DURABILITY = FORCED;", connection); | ||
await command.ExecuteNonQueryAsync(cancellationToken); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Umbraco.Tests.AcceptanceTest.UmbracoProject/SuspendScheduledPublishingComposer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Core.DependencyInjection; | ||
using Umbraco.Cms.Infrastructure; | ||
|
||
namespace UmbracoProject; | ||
|
||
/// <summary> | ||
/// Suspends/disables scheduled publishing, because that takes an eager write lock every minute, resulting in flaky test runs on SQLite. | ||
/// </summary> | ||
public sealed class SuspendScheduledPublishingComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) => Suspendable.ScheduledPublishing.Suspend(); | ||
} |
10 changes: 10 additions & 0 deletions
10
...co.Tests.AcceptanceTest.UmbracoProject/Umbraco.Tests.AcceptanceTest.UmbracoProject.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<!-- All C# files in the root of this project will be copied to the E2E/Acceptance Test application during build --> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>UmbracoProject</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Umbraco.Cms\Umbraco.Cms.csproj" /> | ||
</ItemGroup> | ||
</Project> |
7 changes: 0 additions & 7 deletions
7
tests/Umbraco.Tests.AcceptanceTest/misc/Directory.Build.props
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
tests/Umbraco.Tests.AcceptanceTest/misc/umbraco-linux.docker
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters