diff --git a/src/Akka.Persistence.Sql.Tests.Common/Containers/MySqlContainer.cs b/src/Akka.Persistence.Sql.Tests.Common/Containers/MySqlContainer.cs
index 0348b158..0ab4e4fc 100644
--- a/src/Akka.Persistence.Sql.Tests.Common/Containers/MySqlContainer.cs
+++ b/src/Akka.Persistence.Sql.Tests.Common/Containers/MySqlContainer.cs
@@ -26,20 +26,22 @@ public sealed class MySqlContainer : DockerContainer
private readonly DbConnectionStringBuilder _connectionStringBuilder;
- public MySqlContainer() : base("mysql", "latest", $"mysql-{Guid.NewGuid():N}")
+ public MySqlContainer() : base("mysql", "8", $"mysql-{Guid.NewGuid():N}")
{
_connectionStringBuilder = new DbConnectionStringBuilder
{
["Server"] = "localhost",
["Port"] = Port.ToString(),
["User Id"] = User,
- ["Password"] = Password
+ ["Password"] = Password,
+ ["allowPublicKeyRetrieval"] = "true",
+ ["Allow User Variables"] = "true"
};
}
public override string ConnectionString => _connectionStringBuilder.ToString();
- public override string ProviderName => LinqToDB.ProviderName.MySql;
+ public override string ProviderName => LinqToDB.ProviderName.MySqlOfficial;
private int Port { get; } = ThreadLocalRandom.Current.Next(9000, 10000);
@@ -70,23 +72,56 @@ protected override void ConfigureContainer(CreateContainerParameters parameters)
parameters.Env = new[]
{
$"MYSQL_ROOT_PASSWORD={Password}",
- $"MYSQL_DATABASE={DatabaseName}"
};
}
+ protected override async Task AfterContainerStartedAsync()
+ {
+ await using var connection = new MySqlConnection(ConnectionString);
+ await connection.OpenAsync();
+
+ await using var command = new MySqlCommand
+ {
+ CommandText = "SET GLOBAL max_connections = 999;",
+ Connection = connection
+ };
+ await command.ExecuteNonQueryAsync();
+ await connection.CloseAsync();
+
+ await base.AfterContainerStartedAsync();
+ }
+
public override async Task InitializeDbAsync()
{
- GenerateDatabaseName();
+ _connectionStringBuilder["Database"] = "sys";
await using var connection = new MySqlConnection(ConnectionString);
await connection.OpenAsync();
+ if (!string.IsNullOrWhiteSpace(DatabaseName))
+ {
+ try
+ {
+ await using var dropCommand = new MySqlCommand
+ {
+ CommandText = @$"DROP DATABASE IF EXISTS `{DatabaseName}`;",
+ Connection = connection
+ };
+ await dropCommand.ExecuteNonQueryAsync();
+ }
+ catch
+ {
+ // no-op
+ }
+ }
+
+ GenerateDatabaseName();
+
await using var command = new MySqlCommand
{
- CommandText = $"CREATE DATABASE {DatabaseName}",
+ CommandText = $"CREATE DATABASE `{DatabaseName}`;",
Connection = connection
};
-
await command.ExecuteNonQueryAsync();
await connection.CloseAsync();
}
diff --git a/src/Akka.Persistence.Sql.Tests/Akka.Persistence.Sql.Tests.csproj b/src/Akka.Persistence.Sql.Tests/Akka.Persistence.Sql.Tests.csproj
index 59d4ebf8..64f0a81e 100644
--- a/src/Akka.Persistence.Sql.Tests/Akka.Persistence.Sql.Tests.csproj
+++ b/src/Akka.Persistence.Sql.Tests/Akka.Persistence.Sql.Tests.csproj
@@ -13,6 +13,7 @@
+
@@ -22,6 +23,8 @@
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonJournalCompatibilitySpec.cs b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonJournalCompatibilitySpec.cs
new file mode 100644
index 00000000..79ceefc8
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonJournalCompatibilitySpec.cs
@@ -0,0 +1,35 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using System;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.MySql.Compatibility
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCommonJournalCompatibilitySpec : SqlCommonJournalCompatibilitySpec
+ {
+ public MySqlCommonJournalCompatibilitySpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(fixture, output)
+ {
+ }
+
+ protected override Func Config => fixture
+ => MySqlCompatibilitySpecConfig.InitJournalConfig(fixture, "event_journal", "metadata");
+
+ protected override string OldJournal => "akka.persistence.journal.mysql";
+
+ protected override string NewJournal => "akka.persistence.journal.sql";
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonSnapshotCompatibilitySpec.cs b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonSnapshotCompatibilitySpec.cs
new file mode 100644
index 00000000..dbcd60bc
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCommonSnapshotCompatibilitySpec.cs
@@ -0,0 +1,35 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using System;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.MySql.Compatibility
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCommonSnapshotCompatibilitySpec : SqlCommonSnapshotCompatibilitySpec
+ {
+ public MySqlCommonSnapshotCompatibilitySpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(fixture, output)
+ {
+ }
+
+ protected override string OldSnapshot => "akka.persistence.snapshot-store.mysql";
+
+ protected override string NewSnapshot => "akka.persistence.snapshot-store.sql";
+
+ protected override Func Config => fixture
+ => MySqlCompatibilitySpecConfig.InitSnapshotConfig(fixture, "snapshot_store");
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCompatibilitySpecConfig.cs b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCompatibilitySpecConfig.cs
new file mode 100644
index 00000000..de36a6d5
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/Compatibility/MySqlCompatibilitySpecConfig.cs
@@ -0,0 +1,90 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.MySql.Journal;
+using Akka.Persistence.MySql.Snapshot;
+using Akka.Persistence.Sql.Journal;
+using Akka.Persistence.Sql.Snapshot;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+
+namespace Akka.Persistence.Sql.Tests.MySql.Compatibility
+{
+ public static class MySqlCompatibilitySpecConfig
+ {
+ public static Configuration.Config InitSnapshotConfig(
+ MySqlContainer fixture,
+ string tableName)
+ => $@"
+ akka.persistence {{
+ publish-plugin-commands = on
+ snapshot-store {{
+ mysql {{
+ class = ""{typeof(MySqlSnapshotStore).AssemblyQualifiedName}""
+ plugin-dispatcher = ""akka.actor.default-dispatcher""
+ connection-string = ""{fixture.ConnectionString}""
+ connection-timeout = 30s
+ table-name = {tableName}
+ auto-initialize = on
+ sequential-access = on
+ }}
+
+ sql {{
+ class = ""{typeof(SqlSnapshotStore).AssemblyQualifiedName}""
+ plugin-dispatcher = ""akka.actor.default-dispatcher""
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = {fixture.ProviderName}
+ table-mapping = mysql
+ auto-initialize = true
+ postgresql {{
+ snapshot {{
+ table-name = ""{tableName}""
+ }}
+ }}
+ }}
+ }}
+ }}";
+
+ public static Configuration.Config InitJournalConfig(
+ MySqlContainer fixture,
+ string tableName,
+ string metadataTableName)
+ => $@"
+ akka.persistence {{
+ publish-plugin-commands = on
+ journal {{
+ mysql {{
+ class = ""{typeof(MySqlJournal).AssemblyQualifiedName}""
+ plugin-dispatcher = ""akka.actor.default-dispatcher""
+ connection-string = ""{fixture.ConnectionString}""
+ connection-timeout = 30s
+ table-name = ""{tableName}""
+ metadata-table-name = ""{metadataTableName}""
+ auto-initialize = on
+ }}
+
+ sql {{
+ class = ""{typeof(SqlWriteJournal).AssemblyQualifiedName}""
+ plugin-dispatcher = ""akka.persistence.dispatchers.default-plugin-dispatcher""
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = ""{fixture.ProviderName}""
+ parallelism = 3
+ table-mapping = mysql
+ auto-initialize = true
+ tag-write-mode = Csv
+ delete-compatibility-mode = true
+ postgresql {{
+ journal {{
+ table-name = ""{tableName}""
+ }}
+ metadata {{
+ table-name = ""{metadataTableName}""
+ }}
+ }}
+ }}
+ }}
+ }}";
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/MySqlJournalSpec.cs b/src/Akka.Persistence.Sql.Tests/MySql/MySqlJournalSpec.cs
new file mode 100644
index 00000000..6184f024
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/MySqlJournalSpec.cs
@@ -0,0 +1,60 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using System;
+using Akka.Configuration;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.TCK.Journal;
+using FluentAssertions.Extensions;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.MySql
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlJournalSpec : JournalSpec
+ {
+ public MySqlJournalSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(Configuration(fixture), nameof(MySqlJournalSpec), output)
+ {
+ Initialize();
+ }
+
+ protected override bool SupportsSerialization => false;
+
+ public 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.sql""
+ sql {{
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = ""{fixture.ProviderName}""
+ }}
+ }}
+ snapshot-store {{
+ plugin = ""akka.persistence.snapshot-store.sql""
+ sql {{
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = ""{fixture.ProviderName}""
+ }}
+ }}
+}}")
+ .WithFallback(SqlPersistence.DefaultConfiguration);
+ }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/MySqlPersistenceSpec.cs b/src/Akka.Persistence.Sql.Tests/MySql/MySqlPersistenceSpec.cs
new file mode 100644
index 00000000..182d6b43
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/MySqlPersistenceSpec.cs
@@ -0,0 +1,14 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Xunit;
+
+namespace Akka.Persistence.Sql.Tests.MySql
+{
+ [CollectionDefinition(nameof(MySqlPersistenceSpec), DisableParallelization = true)]
+ public sealed class MySqlPersistenceSpec : ICollectionFixture { }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/MySql/MySqlSnapshotSpec.cs b/src/Akka.Persistence.Sql.Tests/MySql/MySqlSnapshotSpec.cs
new file mode 100644
index 00000000..fbf6b1a3
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/MySql/MySqlSnapshotSpec.cs
@@ -0,0 +1,58 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using System;
+using Akka.Configuration;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.TCK.Snapshot;
+using FluentAssertions.Extensions;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.MySql
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlSnapshotSpec : SnapshotStoreSpec
+ {
+ public MySqlSnapshotSpec(ITestOutputHelper output, MySqlContainer fixture) :
+ base(Configuration(fixture), nameof(MySqlSnapshotSpec), output)
+ {
+ Initialize();
+ }
+
+ 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.sql""
+ sql {{
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = ""{fixture.ProviderName}""
+ }}
+ }}
+ snapshot-store {{
+ plugin = ""akka.persistence.snapshot-store.sql""
+ sql {{
+ connection-string = ""{fixture.ConnectionString}""
+ provider-name = ""{fixture.ProviderName}""
+ }}
+ }}
+}}")
+ .WithFallback(SqlPersistence.DefaultConfiguration);
+ }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlAllEventsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlAllEventsSpec.cs
new file mode 100644
index 00000000..b6c6de46
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlAllEventsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlAllEventsSpec : BaseAllEventsSpec
+ {
+ public MySqlAllEventsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentAllEventsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentAllEventsSpec.cs
new file mode 100644
index 00000000..e2f6315e
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentAllEventsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentAllEventsSpec : BaseCurrentAllEventsSpec
+ {
+ public MySqlCurrentAllEventsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByPersistenceIdSpec.cs
new file mode 100644
index 00000000..7fdb110f
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByPersistenceIdSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentEventsByPersistenceIdSpec : BaseCurrentEventsByPersistenceIdSpec
+ {
+ public MySqlCurrentEventsByPersistenceIdSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByTagSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByTagSpec.cs
new file mode 100644
index 00000000..c0a3c5b1
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentEventsByTagSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentEventsByTagSpec : BaseCurrentEventsByTagSpec
+ {
+ public MySqlCurrentEventsByTagSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentPersistenceIdsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentPersistenceIdsSpec.cs
new file mode 100644
index 00000000..073118e2
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlCurrentPersistenceIdsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentPersistenceIdsSpec : BaseCurrentPersistenceIdsSpec
+ {
+ public MySqlCurrentPersistenceIdsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByPersistenceIdSpec.cs
new file mode 100644
index 00000000..69907fc5
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByPersistenceIdSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlEventsByPersistenceIdSpec : BaseEventsByPersistenceIdSpec
+ {
+ public MySqlEventsByPersistenceIdSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByTagSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByTagSpec.cs
new file mode 100644
index 00000000..efb2c928
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlEventsByTagSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlEventsByTagSpec : BaseEventsByTagSpec
+ {
+ public MySqlEventsByTagSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlPersistenceIdsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlPersistenceIdsSpec.cs
new file mode 100644
index 00000000..e4656d95
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/Csv/MySqlPersistenceIdsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.Csv
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlPersistenceIdsSpec : BasePersistenceIdsSpec
+ {
+ public MySqlPersistenceIdsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.Csv, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlAllEventsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlAllEventsSpec.cs
new file mode 100644
index 00000000..8aaae3b4
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlAllEventsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlAllEventsSpec : BaseAllEventsSpec
+ {
+ public MySqlAllEventsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentAllEventsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentAllEventsSpec.cs
new file mode 100644
index 00000000..40fa6f6d
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentAllEventsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentAllEventsSpec : BaseCurrentAllEventsSpec
+ {
+ public MySqlCurrentAllEventsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlCurrentAllEventsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByPersistenceIdSpec.cs
new file mode 100644
index 00000000..723e4d31
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByPersistenceIdSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentEventsByPersistenceIdSpec : BaseCurrentEventsByPersistenceIdSpec
+ {
+ public MySqlCurrentEventsByPersistenceIdSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlCurrentEventsByPersistenceIdSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByTagSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByTagSpec.cs
new file mode 100644
index 00000000..fe5b707b
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentEventsByTagSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentEventsByTagSpec : BaseCurrentEventsByTagSpec
+ {
+ public MySqlCurrentEventsByTagSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlCurrentEventsByTagSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentPersistenceIdsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentPersistenceIdsSpec.cs
new file mode 100644
index 00000000..fda9646a
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlCurrentPersistenceIdsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlCurrentPersistenceIdsSpec : BaseCurrentPersistenceIdsSpec
+ {
+ public MySqlCurrentPersistenceIdsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlCurrentPersistenceIdsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByPersistenceIdSpec.cs
new file mode 100644
index 00000000..237b52c9
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByPersistenceIdSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlEventsByPersistenceIdSpec : BaseEventsByPersistenceIdSpec
+ {
+ public MySqlEventsByPersistenceIdSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlEventsByPersistenceIdSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByTagSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByTagSpec.cs
new file mode 100644
index 00000000..454b6c33
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlEventsByTagSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlEventsByTagSpec : BaseEventsByTagSpec
+ {
+ public MySqlEventsByTagSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlEventsByTagSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlPersistenceIdsSpec.cs b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlPersistenceIdsSpec.cs
new file mode 100644
index 00000000..3d15b120
--- /dev/null
+++ b/src/Akka.Persistence.Sql.Tests/Query/MySql/TagTable/MySqlPersistenceIdsSpec.cs
@@ -0,0 +1,28 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (C) 2013-2023 .NET Foundation
+//
+// -----------------------------------------------------------------------
+
+using Akka.Persistence.Sql.Config;
+using Akka.Persistence.Sql.Tests.Common.Containers;
+using Akka.Persistence.Sql.Tests.Common.Query;
+using Akka.Persistence.Sql.Tests.MySql;
+using Xunit;
+using Xunit.Abstractions;
+#if !DEBUG
+using Akka.Persistence.Sql.Tests.Common.Internal.Xunit;
+#endif
+
+namespace Akka.Persistence.Sql.Tests.Query.MySql.TagTable
+{
+#if !DEBUG
+ [SkipWindows]
+#endif
+ [Collection(nameof(MySqlPersistenceSpec))]
+ public class MySqlPersistenceIdsSpec : BasePersistenceIdsSpec
+ {
+ public MySqlPersistenceIdsSpec(ITestOutputHelper output, MySqlContainer fixture)
+ : base(TagMode.TagTable, output, nameof(MySqlPersistenceIdsSpec), fixture) { }
+ }
+}
diff --git a/src/Akka.Persistence.Sql/Db/AkkaDataConnection.cs b/src/Akka.Persistence.Sql/Db/AkkaDataConnection.cs
index 13507a81..fe62d703 100644
--- a/src/Akka.Persistence.Sql/Db/AkkaDataConnection.cs
+++ b/src/Akka.Persistence.Sql/Db/AkkaDataConnection.cs
@@ -30,9 +30,7 @@ public AkkaDataConnection(
_providerName = providerName.ToLower();
_connection = connection;
- UseDateTime =
- !_providerName.ToLowerInvariant().Contains("sqlite") &&
- !_providerName.ToLowerInvariant().Contains("postgresql");
+ UseDateTime = _providerName.ToLowerInvariant().Contains("sqlserver");
}
public bool UseDateTime { get; }
diff --git a/src/Akka.Persistence.Sql/Db/AkkaPersistenceDataConnectionFactory.cs b/src/Akka.Persistence.Sql/Db/AkkaPersistenceDataConnectionFactory.cs
index cec30306..8e7199b7 100644
--- a/src/Akka.Persistence.Sql/Db/AkkaPersistenceDataConnectionFactory.cs
+++ b/src/Akka.Persistence.Sql/Db/AkkaPersistenceDataConnectionFactory.cs
@@ -69,14 +69,13 @@ public AkkaPersistenceDataConnectionFactory(IProviderConfig r.TagArr)
.IsNotColumn();
+ if (config.ProviderName.StartsWith(ProviderName.MySql))
+ {
+ journalRowBuilder
+ .Member(r => r.Message)
+ .HasDbType("LONGBLOB");
+ }
+
if (config.ProviderName.ToLower().Contains("sqlite"))
{
journalRowBuilder
@@ -308,6 +314,13 @@ private static void MapDateTimeSnapshotRow(
.Member(r => r.SerializerId)
.HasColumnName(snapshotConfig.ColumnNames.SerializerId);
+ if (config.ProviderName.StartsWith(ProviderName.MySql))
+ {
+ builder
+ .Member(r => r.Payload)
+ .HasDbType("LONGBLOB");
+ }
+
if (config.IDaoConfig.SqlCommonCompatibilityMode)
{
//builder.Member(r => r.Created)
@@ -352,6 +365,13 @@ private static void MapLongSnapshotRow(
.Member(r => r.SerializerId)
.HasColumnName(snapshotConfig.ColumnNames.SerializerId);
+ if (config.ProviderName.StartsWith(ProviderName.MySql))
+ {
+ builder
+ .Member(r => r.Payload)
+ .HasDbType("LONGBLOB");
+ }
+
if (config.IDaoConfig.SqlCommonCompatibilityMode)
{
//builder.Member(r => r.Created)