From 0d59f13aeab30caf19867a6861c3781d55a3afad Mon Sep 17 00:00:00 2001 From: Mattias Jakobsson Date: Fri, 7 Jun 2024 12:21:33 +0200 Subject: [PATCH] Added benchmarks (#41) --- .gitignore | 3 + Akka.Persistence.EventStore.sln | 17 ++ Directory.Packages.props | 1 + ...a.Persistence.EventStore.Benchmarks.csproj | 26 +++ .../Const.cs | 15 ++ .../EventStoreBenchmarkFixture.cs | 69 ++++++++ .../EventStoreTagBenchmark.cs | 76 ++++++++ .../EventStoreWriteBenchmark.cs | 97 ++++++++++ .../EventTagger.cs | 24 +++ .../InitializeDbActor.cs | 71 ++++++++ .../MicroBenchmarkConfig.cs | 17 ++ .../Program.cs | 14 ++ .../README.md | 8 + .../benchmark.conf | 17 ++ .../EventStoreEndToEndSpec.cs | 2 +- ...ventStoreHostingTestsDatabaseCollection.cs | 2 +- .../Akka.Persistence.EventStore.Tests.csproj | 3 - .../DatabaseFixture.cs | 167 ------------------ .../EventStoreConfiguration.cs | 6 +- .../EventStoreContainer.cs | 154 ++++++++++++++++ .../EventStoreJournalAltAdapterSpec.cs | 4 +- .../EventStoreJournalSpec.cs | 4 +- .../EventStoreSnapshotStoreSpec.cs | 4 +- .../EventStoreTestsDatabaseCollection.cs | 2 +- .../PersistentSubscriptionSpec.cs | 6 +- .../Query/EventStoreAllEventsSpec.cs | 4 +- .../Query/EventStoreCurrentAllEventsSpec.cs | 4 +- ...ntStoreCurrentEventsByPersistenceIdSpec.cs | 4 +- .../Query/EventStoreCurrentEventsByTagSpec.cs | 4 +- .../EventStoreCurrentPersistenceIdsSpec.cs | 4 +- .../EventStoreEventsByPersistenceIdSpec.cs | 4 +- .../Query/EventStoreEventsByTagSpec.cs | 4 +- .../Query/EventStorePersistenceIdsSpec.cs | 4 +- .../appsettings.json | 3 - 34 files changed, 640 insertions(+), 204 deletions(-) create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/Akka.Persistence.EventStore.Benchmarks.csproj create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/Const.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/EventStoreBenchmarkFixture.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/EventStoreTagBenchmark.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/EventStoreWriteBenchmark.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/EventTagger.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/InitializeDbActor.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/MicroBenchmarkConfig.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/Program.cs create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/README.md create mode 100644 src/Akka.Persistence.EventStore.Benchmarks/benchmark.conf delete mode 100644 src/Akka.Persistence.EventStore.Tests/DatabaseFixture.cs create mode 100644 src/Akka.Persistence.EventStore.Tests/EventStoreContainer.cs delete mode 100644 src/Akka.Persistence.EventStore.Tests/appsettings.json diff --git a/.gitignore b/.gitignore index 83c0980..b3bef1d 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,9 @@ _site/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* +# Benchmark Results +BenchmarkDotNet.Artifacts/ + # NUNIT *.VisualState.xml TestResult.xml diff --git a/Akka.Persistence.EventStore.sln b/Akka.Persistence.EventStore.sln index 5b49f53..41e2bf7 100644 --- a/Akka.Persistence.EventStore.sln +++ b/Akka.Persistence.EventStore.sln @@ -39,6 +39,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.EventStore EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.EventStore.Hosting.Tests", "src\Akka.Persistence.EventStore.Hosting.Tests\Akka.Persistence.EventStore.Hosting.Tests.csproj", "{8D28138D-C51A-491A-B5EA-028D725B6442}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{6DCB3F60-66B1-44BE-AA32-C7CA4B11563D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.EventStore.Benchmarks", "src\Akka.Persistence.EventStore.Benchmarks\Akka.Persistence.EventStore.Benchmarks.csproj", "{EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +101,18 @@ Global {8D28138D-C51A-491A-B5EA-028D725B6442}.Release|x64.Build.0 = Release|Any CPU {8D28138D-C51A-491A-B5EA-028D725B6442}.Release|x86.ActiveCfg = Release|Any CPU {8D28138D-C51A-491A-B5EA-028D725B6442}.Release|x86.Build.0 = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|x64.ActiveCfg = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|x64.Build.0 = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|x86.ActiveCfg = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Debug|x86.Build.0 = Debug|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|Any CPU.Build.0 = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|x64.ActiveCfg = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|x64.Build.0 = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|x86.ActiveCfg = Release|Any CPU + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -108,5 +124,6 @@ Global {96349315-C6BE-4888-B81A-9A46EF7CE685} = {F4AC94E7-D5F3-4B85-9810-A8BF02441883} {DF2C9C02-9F0D-4FC8-8F72-234FD68FC918} = {F4AC94E7-D5F3-4B85-9810-A8BF02441883} {6017AE31-4718-413B-983E-EAF9D4B465C9} = {DF2C9C02-9F0D-4FC8-8F72-234FD68FC918} + {EF1D827E-2B2B-4BA0-8733-D54CACDEE69F} = {6DCB3F60-66B1-44BE-AA32-C7CA4B11563D} EndGlobalSection EndGlobal diff --git a/Directory.Packages.props b/Directory.Packages.props index 106d825..b5ca83f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -32,6 +32,7 @@ + diff --git a/src/Akka.Persistence.EventStore.Benchmarks/Akka.Persistence.EventStore.Benchmarks.csproj b/src/Akka.Persistence.EventStore.Benchmarks/Akka.Persistence.EventStore.Benchmarks.csproj new file mode 100644 index 0000000..3de3db0 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/Akka.Persistence.EventStore.Benchmarks.csproj @@ -0,0 +1,26 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + + Always + + + + diff --git a/src/Akka.Persistence.EventStore.Benchmarks/Const.cs b/src/Akka.Persistence.EventStore.Benchmarks/Const.cs new file mode 100644 index 0000000..3159892 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/Const.cs @@ -0,0 +1,15 @@ +namespace Akka.Persistence.EventStore.Benchmarks; + +internal static class Const +{ + public const int TotalMessages = 3000000; + public const int TagLowerBound = 2 * (TotalMessages / 3); + public const string Tag10 = "Tag1"; + public const string Tag100 = "Tag2"; + public const string Tag1000 = "Tag3"; + public const string Tag10000 = "Tag4"; + public const int Tag10UpperBound = TagLowerBound + 10; + public const int Tag100UpperBound = TagLowerBound + 100; + public const int Tag1000UpperBound = TagLowerBound + 1000; + public const int Tag10000UpperBound = TagLowerBound + 10000; +} diff --git a/src/Akka.Persistence.EventStore.Benchmarks/EventStoreBenchmarkFixture.cs b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreBenchmarkFixture.cs new file mode 100644 index 0000000..b687072 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreBenchmarkFixture.cs @@ -0,0 +1,69 @@ +using Akka.Actor; +using Akka.Configuration; +using Akka.Persistence.EventStore.Tests; +using FluentAssertions.Extensions; + +namespace Akka.Persistence.EventStore.Benchmarks; + +public static class EventStoreBenchmarkFixture +{ + private static EventStoreContainer? _eventStoreContainer; + + public static async Task CreateActorSystem(string name, Config? extraConfig = null) + { + var config = ConfigurationFactory.ParseString(await File.ReadAllTextAsync("benchmark.conf")) + .WithFallback(extraConfig ?? "") + .WithFallback(Persistence.DefaultConfig()) + .WithFallback(EventStorePersistence.DefaultConfiguration); + + return ActorSystem.Create(name, config); + } + + public static async Task Initialize() + { + _eventStoreContainer = new EventStoreContainer(); + await _eventStoreContainer.InitializeAsync(); + + await File.WriteAllTextAsync( + "benchmark.conf", + $$""" + akka.persistence.journal { + plugin = akka.persistence.journal.eventstore + eventstore { + connection-string = "{{_eventStoreContainer.ConnectionString}}" + + event-adapters { + event-tagger = "{{typeof(EventTagger).AssemblyQualifiedName}}" + } + event-adapter-bindings { + "System.Int32" = event-tagger + } + } + } + + akka.persistence.query.journal.eventstore { + write-plugin = akka.persistence.journal.eventstore + } + """); + + var sys = await CreateActorSystem("Initializer", """ + akka.persistence.journal { + eventstore { + auto-initialize = true + } + } + """); + + var initializer = sys.ActorOf(Props.Create(() => new InitializeDbActor()), "INITIALIZER"); + + await initializer.Ask( + InitializeDbActor.Initialize.Instance, + 20.Minutes()); + } + + public static async Task Dispose() + { + if (_eventStoreContainer is not null) + await _eventStoreContainer.DisposeAsync(); + } +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Benchmarks/EventStoreTagBenchmark.cs b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreTagBenchmark.cs new file mode 100644 index 0000000..a718649 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreTagBenchmark.cs @@ -0,0 +1,76 @@ +using Akka.Actor; +using Akka.Persistence.EventStore.Query; +using Akka.Persistence.Query; +using Akka.Streams; +using BenchmarkDotNet.Attributes; +using FluentAssertions; + +namespace Akka.Persistence.EventStore.Benchmarks; + +[Config(typeof(MicroBenchmarkConfig))] +public class EventStoreTagBenchmark +{ + private IMaterializer? _materializer; + private IReadJournal? _readJournal; + + private ActorSystem? _sys; + + [GlobalSetup] + public async Task Setup() + { + _sys = await EventStoreBenchmarkFixture.CreateActorSystem("system"); + _materializer = _sys.Materializer(); + _readJournal = _sys.ReadJournalFor("akka.persistence.query.journal.eventstore"); + } + + [GlobalCleanup] + public async Task Cleanup() + { + if (_sys is not null) + await _sys.Terminate(); + } + + [Benchmark] + public async Task QueryByTag10() + { + var events = new List(); + var source = ((ICurrentEventsByTagQuery)_readJournal!).CurrentEventsByTag(Const.Tag10, NoOffset.Instance); + await source.RunForeach( + msg => { events.Add(msg); }, + _materializer); + events.Select(e => e.SequenceNr).Should().BeEquivalentTo(Enumerable.Range(2000001, 10)); + } + + [Benchmark] + public async Task QueryByTag100() + { + var events = new List(); + var source = ((ICurrentEventsByTagQuery)_readJournal!).CurrentEventsByTag(Const.Tag100, NoOffset.Instance); + await source.RunForeach( + msg => { events.Add(msg); }, + _materializer); + events.Select(e => e.SequenceNr).Should().BeEquivalentTo(Enumerable.Range(2000001, 100)); + } + + [Benchmark] + public async Task QueryByTag1000() + { + var events = new List(); + var source = ((ICurrentEventsByTagQuery)_readJournal!).CurrentEventsByTag(Const.Tag1000, NoOffset.Instance); + await source.RunForeach( + msg => { events.Add(msg); }, + _materializer); + events.Select(e => e.SequenceNr).Should().BeEquivalentTo(Enumerable.Range(2000001, 1000)); + } + + [Benchmark] + public async Task QueryByTag10000() + { + var events = new List(); + var source = ((ICurrentEventsByTagQuery)_readJournal!).CurrentEventsByTag(Const.Tag10000, NoOffset.Instance); + await source.RunForeach( + msg => { events.Add(msg); }, + _materializer); + events.Select(e => e.SequenceNr).Should().BeEquivalentTo(Enumerable.Range(2000001, 10000)); + } +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Benchmarks/EventStoreWriteBenchmark.cs b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreWriteBenchmark.cs new file mode 100644 index 0000000..fc11da4 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/EventStoreWriteBenchmark.cs @@ -0,0 +1,97 @@ +using Akka.Actor; +using BenchmarkDotNet.Attributes; + +namespace Akka.Persistence.EventStore.Benchmarks; + +[Config(typeof(MicroBenchmarkConfig))] +public class EventStoreWriteBenchmark +{ + private ActorSystem? _sys; + + [GlobalSetup] + public async Task Setup() + { + _sys = await EventStoreBenchmarkFixture.CreateActorSystem("system"); + } + + [GlobalCleanup] + public async Task Cleanup() + { + if (_sys is not null) + await _sys.Terminate(); + } + + [Benchmark] + public async Task Write10Events() + { + var writeEventsActor = _sys!.ActorOf(Props.Create(() => new WriteEventsActor(Guid.NewGuid().ToString()))); + + for (var i = 0; i < 10; i++) + { + await writeEventsActor.Ask( + new WriteEventsActor.Commands.WriteEvents(1)); + } + } + + [Benchmark] + public async Task Write100Events() + { + var writeEventsActor = _sys!.ActorOf(Props.Create(() => new WriteEventsActor(Guid.NewGuid().ToString()))); + + for (var i = 0; i < 100; i++) + { + await writeEventsActor.Ask( + new WriteEventsActor.Commands.WriteEvents(1)); + } + } + + [Benchmark] + public async Task Write10EventsBatched() + { + var writeEventsActor = _sys!.ActorOf(Props.Create(() => new WriteEventsActor(Guid.NewGuid().ToString()))); + + await writeEventsActor.Ask( + new WriteEventsActor.Commands.WriteEvents(10)); + } + + [Benchmark] + public async Task Write100EventsBatched() + { + var writeEventsActor = _sys!.ActorOf(Props.Create(() => new WriteEventsActor(Guid.NewGuid().ToString()))); + + await writeEventsActor.Ask( + new WriteEventsActor.Commands.WriteEvents(100)); + } + + private class WriteEventsActor : ReceivePersistentActor + { + public static class Commands + { + public record WriteEvents(int NumberOfEvents); + } + + public static class Responses + { + public record WriteEventsResponse; + } + + public override string PersistenceId { get; } + + public WriteEventsActor(string id) + { + PersistenceId = id; + + Command(cmd => + { + var events = Enumerable.Range(1, cmd.NumberOfEvents).Select(_ => Guid.NewGuid()); + + PersistAll(events, _ => { }); + + DeferAsync("done", _ => + { + Sender.Tell(new Responses.WriteEventsResponse()); + }); + }); + } + } +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Benchmarks/EventTagger.cs b/src/Akka.Persistence.EventStore.Benchmarks/EventTagger.cs new file mode 100644 index 0000000..60baac3 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/EventTagger.cs @@ -0,0 +1,24 @@ +using Akka.Persistence.Journal; + +namespace Akka.Persistence.EventStore.Benchmarks; + +public sealed class EventTagger : IWriteEventAdapter +{ + public string Manifest(object evt) => string.Empty; + + public object ToJournal(object evt) + { + if (evt is not int i) + return evt; + + return i switch + { + <= Const.TagLowerBound => evt, + <= Const.Tag10UpperBound => new Tagged(evt, new[] { Const.Tag10, Const.Tag100, Const.Tag1000, Const.Tag10000 }), + <= Const.Tag100UpperBound => new Tagged(evt, new[] { Const.Tag100, Const.Tag1000, Const.Tag10000 }), + <= Const.Tag1000UpperBound => new Tagged(evt, new[] { Const.Tag1000, Const.Tag10000 }), + <= Const.Tag10000UpperBound => new Tagged(evt, new[] { Const.Tag10000 }), + _ => evt, + }; + } +} diff --git a/src/Akka.Persistence.EventStore.Benchmarks/InitializeDbActor.cs b/src/Akka.Persistence.EventStore.Benchmarks/InitializeDbActor.cs new file mode 100644 index 0000000..ce6ea65 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/InitializeDbActor.cs @@ -0,0 +1,71 @@ +using Akka.Actor; +using Akka.Event; + +namespace Akka.Persistence.EventStore.Benchmarks; + +public class InitializeDbActor : ReceivePersistentActor +{ + private IActorRef? _replyTo; + + public InitializeDbActor() + { + var log = Context.GetLogger(); + int pending; + + var messages = Enumerable.Range(1, Const.TotalMessages) + .Chunk(10000) + .ToList(); + + Command( + _ => + { + _replyTo = Sender; + Self.Tell(new Send(0)); + }); + + Command( + send => + { + if (send.Index == messages.Count) + { + _replyTo!.Tell(Initialized.Instance); + Context.Stop(Self); + return; + } + + var write = messages[send.Index]; + pending = write[^1]; + + log.Info($"Persisting {write[0]} to {pending}"); + + PersistAll( + write, + i => + { + if (i != pending) + return; + + Self.Tell(new Send(send.Index + 1)); + }); + }); + } + + public override string PersistenceId => "PID"; + + public sealed class Initialize + { + public static readonly Initialize Instance = new(); + private Initialize() { } + } + + public sealed class Initialized + { + public static readonly Initialized Instance = new(); + private Initialized() { } + } + + private sealed class Send(int index) + { + public int Index { get; } = index; + } +} diff --git a/src/Akka.Persistence.EventStore.Benchmarks/MicroBenchmarkConfig.cs b/src/Akka.Persistence.EventStore.Benchmarks/MicroBenchmarkConfig.cs new file mode 100644 index 0000000..2ffb1a0 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/MicroBenchmarkConfig.cs @@ -0,0 +1,17 @@ +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Diagnosers; +using BenchmarkDotNet.Loggers; + +namespace Akka.Persistence.EventStore.Benchmarks; + +/// +/// Basic BenchmarkDotNet configuration used for micro benchmarks. +/// +public class MicroBenchmarkConfig : ManualConfig +{ + public MicroBenchmarkConfig() + { + AddDiagnoser(MemoryDiagnoser.Default); + AddLogger(ConsoleLogger.Default); + } +} diff --git a/src/Akka.Persistence.EventStore.Benchmarks/Program.cs b/src/Akka.Persistence.EventStore.Benchmarks/Program.cs new file mode 100644 index 0000000..fd5664a --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/Program.cs @@ -0,0 +1,14 @@ +using System.Reflection; +using Akka.Persistence.EventStore.Benchmarks; +using BenchmarkDotNet.Running; + +try +{ + await EventStoreBenchmarkFixture.Initialize(); + + BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args); +} +finally +{ + await EventStoreBenchmarkFixture.Dispose(); +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Benchmarks/README.md b/src/Akka.Persistence.EventStore.Benchmarks/README.md new file mode 100644 index 0000000..4b423d2 --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/README.md @@ -0,0 +1,8 @@ +# Akka.Persistence.EventStore Benchmarks + +This benchmark uses BenchmarkDotNet to benchmark the performance of `CurrentEventsByTag` query. + +How to run this benchmark: +1. You have to have docker installed on your machine. +2. Go to the project directory. +3. Run the benchmark by running `dotnet run -c Release` \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Benchmarks/benchmark.conf b/src/Akka.Persistence.EventStore.Benchmarks/benchmark.conf new file mode 100644 index 0000000..a12deca --- /dev/null +++ b/src/Akka.Persistence.EventStore.Benchmarks/benchmark.conf @@ -0,0 +1,17 @@ +akka.persistence.journal { + plugin = akka.persistence.journal.eventstore + eventstore { + connection-string = "esdb://admin:changeit@localhost:2300?tls=false&tlsVerifyCert=false" + + event-adapters { + event-tagger = "Akka.Persistence.EventStore.Benchmarks.EventTagger, Akka.Persistence.EventStore.Benchmarks, Version=1.5.20.0, Culture=neutral, PublicKeyToken=null" + } + event-adapter-bindings { + "System.Int32" = event-tagger + } + } +} + +akka.persistence.query.journal.eventstore { + write-plugin = akka.persistence.journal.eventstore +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreEndToEndSpec.cs b/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreEndToEndSpec.cs index 52e0fcd..0d47dbd 100644 --- a/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreEndToEndSpec.cs +++ b/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreEndToEndSpec.cs @@ -13,7 +13,7 @@ namespace Akka.Persistence.EventStore.Hosting.Tests; [Collection("EventStoreDatabaseSpec")] -public class EventStoreEndToEndSpec(ITestOutputHelper output, DatabaseFixture fixture) +public class EventStoreEndToEndSpec(ITestOutputHelper output, EventStoreContainer fixture) : Akka.Hosting.TestKit.TestKit(nameof(EventStoreEndToEndSpec), output) { private const string GetAll = "getAll"; diff --git a/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreHostingTestsDatabaseCollection.cs b/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreHostingTestsDatabaseCollection.cs index 79fbfe2..48c0f38 100644 --- a/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreHostingTestsDatabaseCollection.cs +++ b/src/Akka.Persistence.EventStore.Hosting.Tests/EventStoreHostingTestsDatabaseCollection.cs @@ -4,4 +4,4 @@ namespace Akka.Persistence.EventStore.Hosting.Tests; [CollectionDefinition("EventStoreDatabaseSpec")] -public class EventStoreHostingTestsDatabaseCollection : ICollectionFixture; \ No newline at end of file +public class EventStoreHostingTestsDatabaseCollection : ICollectionFixture; \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Tests/Akka.Persistence.EventStore.Tests.csproj b/src/Akka.Persistence.EventStore.Tests/Akka.Persistence.EventStore.Tests.csproj index c15e609..d5065fc 100644 --- a/src/Akka.Persistence.EventStore.Tests/Akka.Persistence.EventStore.Tests.csproj +++ b/src/Akka.Persistence.EventStore.Tests/Akka.Persistence.EventStore.Tests.csproj @@ -22,9 +22,6 @@ - - Always - Always diff --git a/src/Akka.Persistence.EventStore.Tests/DatabaseFixture.cs b/src/Akka.Persistence.EventStore.Tests/DatabaseFixture.cs deleted file mode 100644 index bebd23c..0000000 --- a/src/Akka.Persistence.EventStore.Tests/DatabaseFixture.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Diagnostics; -using Docker.DotNet; -using Docker.DotNet.Models; -using Microsoft.Extensions.Configuration; -using System.Runtime.InteropServices; -using Xunit; - -namespace Akka.Persistence.EventStore.Tests; - -public class DatabaseFixture : IAsyncLifetime -{ - private DockerClient? _client; - private readonly string _eventStoreContainerName = $"es-{Guid.NewGuid():N}"; - private static readonly Random Random; - private const string ImageName = "eventstore/eventstore"; - private const string Tag = "23.10.0-jammy"; - private const string EventStoreImage = ImageName + ":" + Tag; - private int _httpPort; - - static DatabaseFixture() - { - Random = new Random(); - } - - public string? ConnectionString { get; private set; } - - public async Task InitializeAsync() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json"); - - var configuration = builder.Build(); - - if (configuration["autoProvisionEventStore"] == "true") - { - DockerClientConfiguration config; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || - RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - config = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")); - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - config = new DockerClientConfiguration(new Uri("npipe://./pipe/docker_engine")); - } - else - { - throw new Exception("Unsupported OS"); - } - - _client = config.CreateClient(); - - var images = await _client.Images.ListImagesAsync(new ImagesListParameters - { - Filters = new Dictionary> - { - { - "reference", - new Dictionary - { - { EventStoreImage, true } - } - } - } - }); - - if (images.Count == 0) - { - await _client.Images.CreateImageAsync( - new ImagesCreateParameters { FromImage = ImageName, Tag = Tag }, null, - new Progress(message => - { - Console.WriteLine(!string.IsNullOrEmpty(message.ErrorMessage) - ? message.ErrorMessage - : $"{message.ID} {message.Status} {message.ProgressMessage}"); - })); - } - - _httpPort = Random.Next(2100, 2399); - - await _client.Containers.CreateContainerAsync( - new CreateContainerParameters - { - Image = EventStoreImage, - Name = _eventStoreContainerName, - Tty = true, - ExposedPorts = new Dictionary - { - { "2113/tcp", new EmptyStruct() } - }, - Env = new List - { - "EVENTSTORE_RUN_PROJECTIONS=All", - "EVENTSTORE_MEM_DB=True", - "EVENTSTORE_INSECURE=True" - }, - HostConfig = new HostConfig - { - PortBindings = new Dictionary> - { - { - "2113/tcp", - new List - { - new() - { - HostPort = $"{_httpPort}" - } - } - } - } - } - }); - - // Starting the container ... - await _client.Containers.StartContainerAsync( - _eventStoreContainerName, - new ContainerStartParameters()); - - ConnectionString = $"esdb://admin:changeit@localhost:{_httpPort}?tls=false&tlsVerifyCert=false"; - - await WaitForEventStoreToStart(TimeSpan.FromSeconds(5), _client); - - async Task WaitForEventStoreToStart(TimeSpan timeout, IDockerClient dockerClient) - { - var logStream = await dockerClient.Containers.GetContainerLogsAsync(_eventStoreContainerName, new ContainerLogsParameters - { - Follow = true, - ShowStdout = true, - ShowStderr = true - }); - - using (var reader = new StreamReader(logStream)) - { - var stopwatch = Stopwatch.StartNew(); - - while (stopwatch.Elapsed < timeout && await reader.ReadLineAsync() is { } line) - { - if (line.Contains("IS LEADER... SPARTA!")) break; - } - - stopwatch.Stop(); - } - - await logStream.DisposeAsync(); - } - } - else - { - ConnectionString = "esdb://admin:changeit@localhost:2113?tls=false&tlsVerifyCert=false"; - } - } - - public async Task DisposeAsync() - { - if (_client != null) - { - await _client.Containers.StopContainerAsync(_eventStoreContainerName, - new ContainerStopParameters { WaitBeforeKillSeconds = 0 }); - await _client.Containers.RemoveContainerAsync(_eventStoreContainerName, - new ContainerRemoveParameters { Force = true }); - _client.Dispose(); - } - } -} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreConfiguration.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreConfiguration.cs index aa18808..d0deda4 100644 --- a/src/Akka.Persistence.EventStore.Tests/EventStoreConfiguration.cs +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreConfiguration.cs @@ -5,7 +5,7 @@ namespace Akka.Persistence.EventStore.Tests; public static class EventStoreConfiguration { public static Config Build( - DatabaseFixture databaseFixture, + EventStoreContainer eventStoreContainer, string tenant, Type? overrideSerializer = null) { @@ -14,7 +14,7 @@ public static Config Build( akka.persistence.journal.plugin = ""akka.persistence.journal.eventstore"" akka.persistence.journal.eventstore {{ class = ""Akka.Persistence.EventStore.Journal.EventStoreJournal, Akka.Persistence.EventStore"" - connection-string = ""{databaseFixture.ConnectionString}"" + connection-string = ""{eventStoreContainer.ConnectionString}"" auto-initialize = true tenant = ""{tenant}"" event-adapters {{ @@ -27,7 +27,7 @@ class = ""Akka.Persistence.EventStore.Journal.EventStoreJournal, Akka.Persistenc akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.eventstore"" akka.persistence.snapshot-store.eventstore {{ class = ""Akka.Persistence.EventStore.Snapshot.EventStoreSnapshotStore, Akka.Persistence.EventStore"" - connection-string = ""{databaseFixture.ConnectionString}"" + connection-string = ""{eventStoreContainer.ConnectionString}"" tenant = ""{tenant}"" }} akka.persistence.query.journal.eventstore {{ diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreContainer.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreContainer.cs new file mode 100644 index 0000000..55b88ef --- /dev/null +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreContainer.cs @@ -0,0 +1,154 @@ +using System.Diagnostics; +using Docker.DotNet; +using Docker.DotNet.Models; +using System.Runtime.InteropServices; +using Xunit; + +namespace Akka.Persistence.EventStore.Tests; + +public class EventStoreContainer : IAsyncLifetime +{ + private DockerClient? _client; + private readonly string _eventStoreContainerName = $"es-{Guid.NewGuid():N}"; + private static readonly Random Random; + private const string ImageName = "eventstore/eventstore"; + private const string Tag = "23.10.0-jammy"; + private const string EventStoreImage = ImageName + ":" + Tag; + private int _httpPort; + + static EventStoreContainer() + { + Random = new Random(); + } + + public string? ConnectionString { get; private set; } + + public async Task InitializeAsync() + { + DockerClientConfiguration config; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || + RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + config = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + config = new DockerClientConfiguration(new Uri("npipe://./pipe/docker_engine")); + } + else + { + throw new Exception("Unsupported OS"); + } + + _client = config.CreateClient(); + + var images = await _client.Images.ListImagesAsync(new ImagesListParameters + { + Filters = new Dictionary> + { + { + "reference", + new Dictionary + { + { EventStoreImage, true } + } + } + } + }); + + if (images.Count == 0) + { + await _client.Images.CreateImageAsync( + new ImagesCreateParameters { FromImage = ImageName, Tag = Tag }, null, + new Progress(message => + { + Console.WriteLine(!string.IsNullOrEmpty(message.ErrorMessage) + ? message.ErrorMessage + : $"{message.ID} {message.Status} {message.ProgressMessage}"); + })); + } + + _httpPort = Random.Next(2100, 2399); + + await _client.Containers.CreateContainerAsync( + new CreateContainerParameters + { + Image = EventStoreImage, + Name = _eventStoreContainerName, + Tty = true, + ExposedPorts = new Dictionary + { + { "2113/tcp", new EmptyStruct() } + }, + Env = new List + { + "EVENTSTORE_RUN_PROJECTIONS=All", + "EVENTSTORE_MEM_DB=True", + "EVENTSTORE_INSECURE=True" + }, + HostConfig = new HostConfig + { + PortBindings = new Dictionary> + { + { + "2113/tcp", + new List + { + new() + { + HostPort = $"{_httpPort}" + } + } + } + } + } + }); + + // Starting the container ... + await _client.Containers.StartContainerAsync( + _eventStoreContainerName, + new ContainerStartParameters()); + + ConnectionString = $"esdb://admin:changeit@localhost:{_httpPort}?tls=false&tlsVerifyCert=false"; + + await WaitForEventStoreToStart(TimeSpan.FromSeconds(5), _client); + + async Task WaitForEventStoreToStart(TimeSpan timeout, IDockerClient dockerClient) + { + var logStream = await dockerClient.Containers.GetContainerLogsAsync(_eventStoreContainerName, + new ContainerLogsParameters + { + Follow = true, + ShowStdout = true, + ShowStderr = true + }); + + using (var reader = new StreamReader(logStream)) + { + var stopwatch = Stopwatch.StartNew(); + + while (stopwatch.Elapsed < timeout && await reader.ReadLineAsync() is { } line) + { + if (line.Contains("IS LEADER... SPARTA!")) break; + } + + stopwatch.Stop(); + } + + await logStream.DisposeAsync(); + } + } + + public async Task DisposeAsync() + { + if (_client != null) + { + await _client.Containers.StopContainerAsync(_eventStoreContainerName, + new ContainerStopParameters { WaitBeforeKillSeconds = 0 }); + await _client.Containers.RemoveContainerAsync(_eventStoreContainerName, + new ContainerRemoveParameters { Force = true }); + _client.Dispose(); + } + } +} \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreJournalAltAdapterSpec.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreJournalAltAdapterSpec.cs index 2d538ab..53be7a0 100644 --- a/src/Akka.Persistence.EventStore.Tests/EventStoreJournalAltAdapterSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreJournalAltAdapterSpec.cs @@ -11,9 +11,9 @@ public class EventStoreJournalAltAdapterSpec : JournalSpec // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 protected override bool SupportsSerialization => false; - public EventStoreJournalAltAdapterSpec(DatabaseFixture databaseFixture) + public EventStoreJournalAltAdapterSpec(EventStoreContainer eventStoreContainer) : base(EventStoreConfiguration.Build( - databaseFixture, + eventStoreContainer, "alt-journal-spec", typeof(TestMessageAdapter)), nameof(EventStoreJournalSpec)) { diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreJournalSpec.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreJournalSpec.cs index 980878c..89e4885 100644 --- a/src/Akka.Persistence.EventStore.Tests/EventStoreJournalSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreJournalSpec.cs @@ -11,8 +11,8 @@ public class EventStoreJournalSpec : JournalSpec // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 protected override bool SupportsSerialization => false; - public EventStoreJournalSpec(DatabaseFixture databaseFixture) - : base(EventStoreConfiguration.Build(databaseFixture, "es-journal-spec"), nameof(EventStoreJournalSpec)) + public EventStoreJournalSpec(EventStoreContainer eventStoreContainer) + : base(EventStoreConfiguration.Build(eventStoreContainer, "es-journal-spec"), nameof(EventStoreJournalSpec)) { Initialize(); } diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreSnapshotStoreSpec.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreSnapshotStoreSpec.cs index b057432..5ab9f57 100644 --- a/src/Akka.Persistence.EventStore.Tests/EventStoreSnapshotStoreSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreSnapshotStoreSpec.cs @@ -9,8 +9,8 @@ public sealed class EventStoreSnapshotStoreSpec : SnapshotStoreSpec // TODO: hack. Replace when https://github.com/akkadotnet/akka.net/issues/3811 protected override bool SupportsSerialization => false; - public EventStoreSnapshotStoreSpec(DatabaseFixture databaseFixture) - : base(EventStoreConfiguration.Build(databaseFixture, "es-snapshot-spec"), nameof(EventStoreSnapshotStoreSpec)) + public EventStoreSnapshotStoreSpec(EventStoreContainer eventStoreContainer) + : base(EventStoreConfiguration.Build(eventStoreContainer, "es-snapshot-spec"), nameof(EventStoreSnapshotStoreSpec)) { Initialize(); } diff --git a/src/Akka.Persistence.EventStore.Tests/EventStoreTestsDatabaseCollection.cs b/src/Akka.Persistence.EventStore.Tests/EventStoreTestsDatabaseCollection.cs index 3654a38..08686d1 100644 --- a/src/Akka.Persistence.EventStore.Tests/EventStoreTestsDatabaseCollection.cs +++ b/src/Akka.Persistence.EventStore.Tests/EventStoreTestsDatabaseCollection.cs @@ -3,4 +3,4 @@ namespace Akka.Persistence.EventStore.Tests; [CollectionDefinition("EventStoreDatabaseSpec")] -public class EventStoreTestsDatabaseCollection : ICollectionFixture; \ No newline at end of file +public class EventStoreTestsDatabaseCollection : ICollectionFixture; \ No newline at end of file diff --git a/src/Akka.Persistence.EventStore.Tests/PersistentSubscriptionSpec.cs b/src/Akka.Persistence.EventStore.Tests/PersistentSubscriptionSpec.cs index c3e004f..89e26c1 100644 --- a/src/Akka.Persistence.EventStore.Tests/PersistentSubscriptionSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/PersistentSubscriptionSpec.cs @@ -15,10 +15,10 @@ public class PersistentSubscriptionSpec : Akka.TestKit.Xunit2.TestKit private readonly EventStorePersistentSubscriptionsClient _subscriptionClient; private readonly EventStoreClient _eventStoreClient; - public PersistentSubscriptionSpec(DatabaseFixture databaseFixture) - : base(EventStoreConfiguration.Build(databaseFixture, "persistent-subscription-spec")) + public PersistentSubscriptionSpec(EventStoreContainer eventStoreContainer) + : base(EventStoreConfiguration.Build(eventStoreContainer, "persistent-subscription-spec")) { - var clientSettings = EventStoreClientSettings.Create(databaseFixture.ConnectionString ?? ""); + var clientSettings = EventStoreClientSettings.Create(eventStoreContainer.ConnectionString ?? ""); _subscriptionClient = new EventStorePersistentSubscriptionsClient(clientSettings); _eventStoreClient = new EventStoreClient(clientSettings); diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreAllEventsSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreAllEventsSpec.cs index 5d845bc..bc16187 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreAllEventsSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreAllEventsSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreAllEventsSpec : AllEventsSpec { - public EventStoreAllEventsSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreAllEventsSpec), output) + public EventStoreAllEventsSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreAllEventsSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentAllEventsSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentAllEventsSpec.cs index 56a2930..59e3083 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentAllEventsSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentAllEventsSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreCurrentAllEventsSpec : CurrentAllEventsSpec { - public EventStoreCurrentAllEventsSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreCurrentAllEventsSpec), output) + public EventStoreCurrentAllEventsSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreCurrentAllEventsSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByPersistenceIdSpec.cs index 257b80c..3bcdca8 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByPersistenceIdSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByPersistenceIdSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec { - public EventStoreCurrentEventsByPersistenceIdSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByPersistenceIdSpec), output) + public EventStoreCurrentEventsByPersistenceIdSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByPersistenceIdSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByTagSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByTagSpec.cs index b695334..f95e712 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByTagSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentEventsByTagSpec.cs @@ -15,8 +15,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreCurrentEventsByTagSpec : CurrentEventsByTagSpec { - public EventStoreCurrentEventsByTagSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByTagSpec), output) + public EventStoreCurrentEventsByTagSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByTagSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentPersistenceIdsSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentPersistenceIdsSpec.cs index a7bec97..18020f4 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentPersistenceIdsSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreCurrentPersistenceIdsSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreCurrentPersistenceIdsSpec : CurrentPersistenceIdsSpec { - public EventStoreCurrentPersistenceIdsSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreCurrentPersistenceIdsSpec), output) + public EventStoreCurrentPersistenceIdsSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreCurrentPersistenceIdsSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByPersistenceIdSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByPersistenceIdSpec.cs index e9effc7..6693a78 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByPersistenceIdSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByPersistenceIdSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreEventsByPersistenceIdSpec : EventsByPersistenceIdSpec { - public EventStoreEventsByPersistenceIdSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByPersistenceIdSpec), output) + public EventStoreEventsByPersistenceIdSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreCurrentEventsByPersistenceIdSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByTagSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByTagSpec.cs index 518e934..4df9e43 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByTagSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStoreEventsByTagSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStoreEventsByTagSpec : EventsByTagSpec { - public EventStoreEventsByTagSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStoreEventsByTagSpec), output) + public EventStoreEventsByTagSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStoreEventsByTagSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/Query/EventStorePersistenceIdsSpec.cs b/src/Akka.Persistence.EventStore.Tests/Query/EventStorePersistenceIdsSpec.cs index 464e92e..c987cfc 100644 --- a/src/Akka.Persistence.EventStore.Tests/Query/EventStorePersistenceIdsSpec.cs +++ b/src/Akka.Persistence.EventStore.Tests/Query/EventStorePersistenceIdsSpec.cs @@ -9,8 +9,8 @@ namespace Akka.Persistence.EventStore.Tests.Query; [Collection("EventStoreDatabaseSpec")] public class EventStorePersistenceIdsSpec : PersistenceIdsSpec { - public EventStorePersistenceIdsSpec(DatabaseFixture databaseFixture, ITestOutputHelper output) : - base(EventStoreConfiguration.Build(databaseFixture, Guid.NewGuid().ToString()), nameof(EventStorePersistenceIdsSpec), output) + public EventStorePersistenceIdsSpec(EventStoreContainer eventStoreContainer, ITestOutputHelper output) : + base(EventStoreConfiguration.Build(eventStoreContainer, Guid.NewGuid().ToString()), nameof(EventStorePersistenceIdsSpec), output) { ReadJournal = Sys.ReadJournalFor(EventStorePersistence.QueryConfigPath); } diff --git a/src/Akka.Persistence.EventStore.Tests/appsettings.json b/src/Akka.Persistence.EventStore.Tests/appsettings.json deleted file mode 100644 index 1238786..0000000 --- a/src/Akka.Persistence.EventStore.Tests/appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "autoProvisionEventStore": "true" -} \ No newline at end of file