Skip to content

Commit

Permalink
Add xUnit 2.5.1 compatibility (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Sep 25, 2023
1 parent 47bec0f commit fd67772
Show file tree
Hide file tree
Showing 12 changed files with 336 additions and 196 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// -----------------------------------------------------------------------
// <copyright file="SqlServerJournalPerfSpec.cs" company="Akka.NET Project">
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

using System;
using Akka.Configuration;
using Akka.Persistence.MySql;
using Akka.Persistence.Sql.Tests.Common.Containers;
using Akka.Persistence.SqlServer;
using FluentAssertions.Extensions;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Sql.Benchmark.Tests.MySql
{
[Collection(nameof(MySqlPersistenceBenchmark))]
public class MySqlJournalPerfSpec : SqlJournalPerfSpec<MySqlContainer>
{
public MySqlJournalPerfSpec(ITestOutputHelper output, MySqlContainer fixture)
: base(
Configuration(fixture),
nameof(MySqlJournalPerfSpec),
output,
40,
eventsCount: TestConstants.DockerNumMessages) { }

private static Configuration.Config Configuration(MySqlContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(
$$"""
akka.persistence {
publish-plugin-commands = on
journal {
plugin = "akka.persistence.journal.mysql"
mysql {
auto-initialize = on
connection-string = "{{fixture.ConnectionString}}"
}
}
}
""")
.WithFallback(Persistence.DefaultConfig())
.WithFallback(MySqlPersistence.DefaultConfiguration());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// -----------------------------------------------------------------------
// <copyright file="SqlServerLinq2DbJournalPerfSpec.cs" company="Akka.NET Project">
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Configuration;
using Akka.Persistence.Sql.Tests.Common.Containers;
using FluentAssertions.Extensions;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Sql.Benchmark.Tests.MySql
{
[Collection(nameof(MySqlPersistenceBenchmark))]
public class MySqlLinq2DbJournalPerfSpec : SqlJournalPerfSpec<MySqlContainer>
{
public MySqlLinq2DbJournalPerfSpec(ITestOutputHelper output, MySqlContainer fixture)
: base(
Configure(fixture),
nameof(MySqlLinq2DbJournalPerfSpec),
output,
40,
eventsCount: TestConstants.DockerNumMessages) { }

private static Configuration.Config Configure(MySqlContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
plugin = ""akka.persistence.journal.sql""
sql {{
connection-string = ""{fixture.ConnectionString}""
provider-name = ""{fixture.ProviderName}""
use-clone-connection = true
auto-initialize = true
default {{
journal {{
table-name = testPerfTable
}}
}}
}}
}}
}}")
.WithFallback(Persistence.DefaultConfig())
.WithFallback(SqlPersistence.DefaultConfiguration);
}

[Fact]
public async Task PersistenceActor_Must_measure_PersistGroup1000()
=> await RunGroupBenchmarkAsync(1000, 10);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// -----------------------------------------------------------------------
// <copyright file="SqlServerPersistenceBenchmark.cs" company="Akka.NET Project">
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

using Akka.Persistence.Sql.Benchmark.Tests.SqlServer;
using Akka.Persistence.Sql.Tests.Common.Containers;
using Xunit;

namespace Akka.Persistence.Sql.Benchmark.Tests.MySql
{
[CollectionDefinition(nameof(MySqlPersistenceBenchmark), DisableParallelization = true)]
public sealed class MySqlPersistenceBenchmark : ICollectionFixture<MySqlContainer> { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// -----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Configuration;
using Akka.Persistence.PostgreSql;
using Akka.Persistence.Sql.Tests.Common.Containers;
Expand Down Expand Up @@ -44,11 +45,12 @@ public static Configuration.Config InitConfig(PostgreSqlContainer fixture)
}}
}}
}}")
.WithFallback(Persistence.DefaultConfig())
.WithFallback(PostgreSqlPersistence.DefaultConfiguration());
}

[Fact]
public void PersistenceActor_Must_measure_PersistGroup1000()
=> RunGroupBenchmark(1000, 10);
public async Task PersistenceActor_Must_measure_PersistGroup1000()
=> await RunGroupBenchmarkAsync(1000, 10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// -----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Configuration;
using Akka.Persistence.Sql.Tests.Common.Containers;
using FluentAssertions.Extensions;
Expand Down Expand Up @@ -42,19 +43,14 @@ private static Configuration.Config Configuration(PostgreSqlContainer fixture)
provider-name = ""{fixture.ProviderName}""
use-clone-connection = true
auto-initialize = true
default {{
journal {{
table-name = testPerfTable
}}
}}
}}
}}
}}")
.WithFallback(SqlPersistence.DefaultConfiguration);
}

[Fact]
public void PersistenceActor_Must_measure_PersistGroup1000()
=> RunGroupBenchmark(1000, 10);
public async Task PersistenceActor_Must_measure_PersistGroup1000()
=> await RunGroupBenchmarkAsync(1000, 10);
}
}
Loading

0 comments on commit fd67772

Please sign in to comment.