Skip to content

Commit b128c2b

Browse files
Merge pull request #56 from AkkaNetContrib/dev
v1.3.12 Release
2 parents d9572c3 + ece60c1 commit b128c2b

29 files changed

+2115
-22
lines changed

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#### 1.3.12 April 05 2019 ####
2+
Support for Akka.Persistence 1.3.12.
3+
Added support for Akka.Persistence.Query.
4+
Upgraded to MongoDb v2.7.0 driver (2.8.0 doesn't support .NET 4.5)
5+
Added support for configurable, binary serialization via Akka.NET.
6+
17

28
#### 1.3.5 March 23 2018 ####
39
Support for Akka.Persistence 1.3.5.

src/Akka.Persistence.MongoDb.Tests/Akka.Persistence.MongoDb.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
1212
<PackageReference Include="xunit" Version="$(XunitVersion)" />
1313
<DotNetCliToolReference Include="dotnet-xunit" Version="$(XunitVersion)" />
14-
<PackageReference Include="Akka.Persistence.TCK" Version="1.3.4-beta" />
14+
<PackageReference Include="Akka.Persistence.TCK" Version="$(AkkaVersion)" />
1515
<PackageReference Include="FluentAssertions" Version="4.19.4" />
16-
<PackageReference Include="Mongo2Go" Version="2.2.1" />
16+
<PackageReference Include="Mongo2Go" Version="2.2.8" />
1717
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
1818
</ItemGroup>
1919

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Akka.Actor;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Akka.Persistence.MongoDb.Tests
7+
{
8+
public class JournalTestActor : UntypedPersistentActor
9+
{
10+
public static Props Props(string persistenceId) => Actor.Props.Create(() => new JournalTestActor(persistenceId));
11+
12+
public sealed class DeleteCommand
13+
{
14+
public DeleteCommand(long toSequenceNr)
15+
{
16+
ToSequenceNr = toSequenceNr;
17+
}
18+
19+
public long ToSequenceNr { get; }
20+
}
21+
22+
public JournalTestActor(string persistenceId)
23+
{
24+
PersistenceId = persistenceId;
25+
}
26+
27+
public override string PersistenceId { get; }
28+
29+
protected override void OnRecover(object message)
30+
{
31+
}
32+
33+
protected override void OnCommand(object message)
34+
{
35+
switch (message) {
36+
case DeleteCommand delete:
37+
DeleteMessages(delete.ToSequenceNr);
38+
Sender.Tell($"{delete.ToSequenceNr}-deleted");
39+
break;
40+
case string cmd:
41+
var sender = Sender;
42+
Persist(cmd, e => sender.Tell($"{e}-done"));
43+
break;
44+
}
45+
}
46+
}
47+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="MongoDbJournalSpec.cs" company="Akka.NET Project">
3+
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
4+
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
5+
// </copyright>
6+
//-----------------------------------------------------------------------
7+
8+
using Akka.Persistence.TCK.Journal;
9+
using Xunit;
10+
using Akka.Configuration;
11+
using Akka.Persistence.MongoDb.Query;
12+
using Akka.Persistence.Query;
13+
using Xunit.Abstractions;
14+
using Akka.Util.Internal;
15+
using System;
16+
using Akka.Actor;
17+
using Akka.Streams.TestKit;
18+
using System.Linq;
19+
using System.Diagnostics;
20+
using Akka.Streams.Dsl;
21+
22+
namespace Akka.Persistence.MongoDb.Tests
23+
{
24+
[Collection("MongoDbSpec")]
25+
public class MongoDbCurrentEventsByPersistenceIdsSpec : Akka.Persistence.TCK.Query.CurrentEventsByPersistenceIdSpec, IClassFixture<DatabaseFixture>
26+
{
27+
public static readonly AtomicCounter Counter = new AtomicCounter(0);
28+
private readonly ITestOutputHelper _output;
29+
30+
public MongoDbCurrentEventsByPersistenceIdsSpec(ITestOutputHelper output, DatabaseFixture databaseFixture)
31+
: base(CreateSpecConfig(databaseFixture, Counter.GetAndIncrement()), "MongoDbCurrentEventsByPersistenceIdsSpec", output)
32+
{
33+
_output = output;
34+
output.WriteLine(databaseFixture.ConnectionString + Counter.Current);
35+
ReadJournal = Sys.ReadJournalFor<MongoDbReadJournal>(MongoDbReadJournal.Identifier);
36+
}
37+
38+
private static Config CreateSpecConfig(DatabaseFixture databaseFixture, int id)
39+
{
40+
var specString = @"
41+
akka.test.single-expect-default = 10s
42+
akka.persistence {
43+
publish-plugin-commands = on
44+
journal {
45+
plugin = ""akka.persistence.journal.mongodb""
46+
mongodb {
47+
class = ""Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb""
48+
connection-string = """ + databaseFixture.ConnectionString + id + @"""
49+
auto-initialize = on
50+
collection = ""EventJournal""
51+
}
52+
}
53+
query {
54+
mongodb {
55+
class = ""Akka.Persistence.MongoDb.Query.MongoDbReadJournalProvider, Akka.Persistence.MongoDb""
56+
refresh-interval = 1s
57+
}
58+
}
59+
}";
60+
61+
return ConfigurationFactory.ParseString(specString);
62+
}
63+
64+
}
65+
66+
67+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="MongoDbJournalSpec.cs" company="Akka.NET Project">
3+
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
4+
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
5+
// </copyright>
6+
//-----------------------------------------------------------------------
7+
8+
using Akka.Persistence.TCK.Journal;
9+
using Xunit;
10+
using Akka.Configuration;
11+
using Akka.Persistence.MongoDb.Query;
12+
using Akka.Persistence.Query;
13+
using Xunit.Abstractions;
14+
using Akka.Util.Internal;
15+
using System;
16+
using Akka.Actor;
17+
using Akka.Streams.TestKit;
18+
using System.Linq;
19+
using System.Diagnostics;
20+
21+
namespace Akka.Persistence.MongoDb.Tests
22+
{
23+
[Collection("MongoDbSpec")]
24+
public class MongoDbCurrentEventsByTagSpec : Akka.Persistence.TCK.Query.CurrentEventsByTagSpec, IClassFixture<DatabaseFixture>
25+
{
26+
public static readonly AtomicCounter Counter = new AtomicCounter(0);
27+
private readonly ITestOutputHelper _output;
28+
29+
public MongoDbCurrentEventsByTagSpec(ITestOutputHelper output, DatabaseFixture databaseFixture)
30+
: base(CreateSpecConfig(databaseFixture, Counter.GetAndIncrement()), "MongoDbCurrentEventsByTagSpec", output)
31+
{
32+
_output = output;
33+
output.WriteLine(databaseFixture.ConnectionString + Counter.Current);
34+
ReadJournal = Sys.ReadJournalFor<MongoDbReadJournal>(MongoDbReadJournal.Identifier);
35+
36+
var x = Sys.ActorOf(TestActor.Props("x"));
37+
x.Tell("warm-up");
38+
ExpectMsg("warm-up-done", TimeSpan.FromSeconds(10));
39+
}
40+
41+
private static Config CreateSpecConfig(DatabaseFixture databaseFixture, int id)
42+
{
43+
var specString = @"
44+
akka.test.single-expect-default = 3s
45+
akka.persistence {
46+
publish-plugin-commands = on
47+
journal {
48+
plugin = ""akka.persistence.journal.mongodb""
49+
mongodb {
50+
class = ""Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb""
51+
connection-string = """ + databaseFixture.ConnectionString + id + @"""
52+
auto-initialize = on
53+
collection = ""EventJournal""
54+
event-adapters {
55+
color-tagger = ""Akka.Persistence.TCK.Query.ColorFruitTagger, Akka.Persistence.TCK""
56+
}
57+
event-adapter-bindings = {
58+
""System.String"" = color-tagger
59+
}
60+
}
61+
}
62+
query {
63+
mongodb {
64+
class = ""Akka.Persistence.MongoDb.Query.MongoDbReadJournalProvider, Akka.Persistence.MongoDb""
65+
refresh-interval = 1s
66+
}
67+
}
68+
}";
69+
70+
return ConfigurationFactory.ParseString(specString);
71+
}
72+
73+
74+
//public override void ReadJournal_query_CurrentEventsByTag_should_find_existing_events()
75+
//{
76+
// var a = Sys.ActorOf(TestActor.Props("a"));
77+
// a.Tell("warm-up");
78+
// ExpectMsg("warm-up-done", TimeSpan.FromSeconds(10));
79+
//}
80+
81+
82+
internal class TestActor : UntypedPersistentActor
83+
{
84+
public static Props Props(string persistenceId) => Actor.Props.Create(() => new TestActor(persistenceId));
85+
86+
public sealed class DeleteCommand
87+
{
88+
public DeleteCommand(long toSequenceNr)
89+
{
90+
ToSequenceNr = toSequenceNr;
91+
}
92+
93+
public long ToSequenceNr { get; }
94+
}
95+
96+
public TestActor(string persistenceId)
97+
{
98+
PersistenceId = persistenceId;
99+
}
100+
101+
public override string PersistenceId { get; }
102+
103+
protected override void OnRecover(object message)
104+
{
105+
}
106+
107+
protected override void OnCommand(object message)
108+
{
109+
switch (message) {
110+
case DeleteCommand delete:
111+
DeleteMessages(delete.ToSequenceNr);
112+
Sender.Tell($"{delete.ToSequenceNr}-deleted");
113+
break;
114+
case string cmd:
115+
var sender = Sender;
116+
Persist(cmd, e => sender.Tell($"{e}-done"));
117+
break;
118+
}
119+
}
120+
}
121+
}
122+
123+
124+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="MongoDbJournalSpec.cs" company="Akka.NET Project">
3+
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
4+
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net>
5+
// </copyright>
6+
//-----------------------------------------------------------------------
7+
8+
using Akka.Persistence.TCK.Journal;
9+
using Xunit;
10+
using Akka.Configuration;
11+
using Akka.Persistence.MongoDb.Query;
12+
using Akka.Persistence.Query;
13+
using Xunit.Abstractions;
14+
using Akka.Util.Internal;
15+
using System;
16+
using Akka.Actor;
17+
using Akka.Streams.TestKit;
18+
using System.Linq;
19+
using System.Diagnostics;
20+
21+
namespace Akka.Persistence.MongoDb.Tests
22+
{
23+
[Collection("MongoDbSpec")]
24+
public class MongoDbCurrentPersistenceIdsSpec : Akka.Persistence.TCK.Query.CurrentPersistenceIdsSpec, IClassFixture<DatabaseFixture>
25+
{
26+
public static readonly AtomicCounter Counter = new AtomicCounter(0);
27+
private readonly ITestOutputHelper _output;
28+
29+
public MongoDbCurrentPersistenceIdsSpec(ITestOutputHelper output, DatabaseFixture databaseFixture)
30+
: base(CreateSpecConfig(databaseFixture, Counter.GetAndIncrement()), "MongoDbCurrentPersistenceIdsSpec", output)
31+
{
32+
_output = output;
33+
output.WriteLine(databaseFixture.ConnectionString + Counter.Current);
34+
ReadJournal = Sys.ReadJournalFor<MongoDbReadJournal>(MongoDbReadJournal.Identifier);
35+
}
36+
37+
private static Config CreateSpecConfig(DatabaseFixture databaseFixture, int id)
38+
{
39+
var specString = @"
40+
akka.test.single-expect-default = 3s
41+
akka.persistence {
42+
publish-plugin-commands = on
43+
journal {
44+
plugin = ""akka.persistence.journal.mongodb""
45+
mongodb {
46+
class = ""Akka.Persistence.MongoDb.Journal.MongoDbJournal, Akka.Persistence.MongoDb""
47+
connection-string = """ + databaseFixture.ConnectionString + id + @"""
48+
auto-initialize = on
49+
collection = ""EventJournal""
50+
}
51+
}
52+
query {
53+
mongodb {
54+
class = ""Akka.Persistence.MongoDb.Query.MongoDbReadJournalProvider, Akka.Persistence.MongoDb""
55+
refresh-interval = 1s
56+
}
57+
}
58+
}";
59+
60+
return ConfigurationFactory.ParseString(specString);
61+
}
62+
63+
public override void ReadJournal_query_CurrentPersistenceIds_should_not_see_new_events_after_complete()
64+
{
65+
var queries = ReadJournal.AsInstanceOf<ICurrentPersistenceIdsQuery>();
66+
67+
Setup("a", 1);
68+
Setup("b", 1);
69+
Setup("c", 1);
70+
71+
var greenSrc = queries.CurrentPersistenceIds();
72+
var probe = greenSrc.RunWith(this.SinkProbe<string>(), Materializer);
73+
var firstTwo = probe.Request(2).ExpectNextN(2);
74+
Assert.Empty(firstTwo.Except(new[] { "a", "b", "c" }).ToArray());
75+
76+
var last = new[] { "a", "b", "c" }.Except(firstTwo).First();
77+
Setup("d", 1);
78+
79+
probe.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
80+
probe.Request(5)
81+
.ExpectNext(last)
82+
.ExpectComplete();
83+
}
84+
85+
private IActorRef Setup(string persistenceId, int n)
86+
{
87+
var sw = Stopwatch.StartNew();
88+
var pref = Sys.ActorOf(JournalTestActor.Props(persistenceId));
89+
for (int i = 1; i <= n; i++) {
90+
pref.Tell($"{persistenceId}-{i}");
91+
ExpectMsg($"{persistenceId}-{i}-done", TimeSpan.FromSeconds(10), $"{persistenceId}-{i}-done");
92+
}
93+
_output.WriteLine(sw.ElapsedMilliseconds.ToString());
94+
return pref;
95+
}
96+
97+
}
98+
99+
100+
}

0 commit comments

Comments
 (0)