-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PersistenceId Query and Sqlite unit tests #5715
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ protected override bool Receive(object message) | |
{ | ||
case Request _: | ||
_journalRef.Tell(new SelectCurrentPersistenceIds(0, Self)); | ||
Become(Initializing); | ||
Become(Waiting); | ||
return true; | ||
case Continue _: | ||
return true; | ||
|
@@ -148,7 +148,7 @@ protected override bool Receive(object message) | |
} | ||
} | ||
|
||
private bool Initializing(object message) | ||
private bool Waiting(object message) | ||
{ | ||
switch (message) | ||
{ | ||
|
@@ -175,16 +175,12 @@ private bool Active(object message) | |
{ | ||
switch (message) | ||
{ | ||
case CurrentPersistenceIds added: | ||
_lastOrderingOffset = added.HighestOrderingNumber; | ||
_buffer.AddRange(added.AllPersistenceIds); | ||
_buffer.DeliverBuffer(TotalDemand); | ||
return true; | ||
case Request _: | ||
_buffer.DeliverBuffer(TotalDemand); | ||
return true; | ||
case Continue _: | ||
_journalRef.Tell(new SelectCurrentPersistenceIds(_lastOrderingOffset, Self)); | ||
Become(Waiting); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With short |
||
return true; | ||
case Cancel _: | ||
Context.Stop(Self); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ protected override bool ReceivePluginInternal(object message) | |
return true; | ||
case SelectCurrentPersistenceIds request: | ||
SelectAllPersistenceIdsAsync(request.Offset) | ||
.PipeTo(request.ReplyTo, success: result => new CurrentPersistenceIds(result.Ids, request.Offset)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a major bug, if we kept sending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch |
||
.PipeTo(request.ReplyTo, success: result => new CurrentPersistenceIds(result.Ids, result.LastOrdering)); | ||
return true; | ||
case SubscribeTag subscribe: | ||
AddTagSubscriber(Sender, subscribe.Tag); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,14 @@ public class BatchingSqliteAllEventsSpec : AllEventsSpec | |
public static Config Config => ConfigurationFactory.ParseString($@" | ||
akka.loglevel = INFO | ||
akka.persistence.journal.plugin = ""akka.persistence.journal.sqlite"" | ||
akka.persistence.query.journal.sql.refresh-interval = 1s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have been using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going to need to update documentation anywhere for this? @eaba |
||
akka.persistence.journal.sqlite {{ | ||
class = ""Akka.Persistence.Sqlite.Journal.BatchingSqliteJournal, Akka.Persistence.Sqlite"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
table-name = event_journal | ||
metadata-table-name = journal_metadata | ||
auto-initialize = on | ||
connection-string = ""Filename=file:memdb-journal-eventsbytag-{Guid.NewGuid()}.db;Mode=Memory;Cache=Shared"" | ||
refresh-interval = 1s | ||
}} | ||
akka.test.single-expect-default = 10s") | ||
.WithFallback(SqlReadJournal.DefaultConfiguration()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
|
@@ -16,6 +17,7 @@ | |
using Akka.Streams.TestKit; | ||
using Akka.TestKit; | ||
using Akka.Util.Internal; | ||
using FluentAssertions; | ||
using Reactive.Streams; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
@@ -76,18 +78,23 @@ public virtual void ReadJournal_AllPersistenceIds_should_find_new_events_after_d | |
var source = queries.PersistenceIds(); | ||
var probe = source.RunWith(this.SinkProbe<string>(), Materializer); | ||
|
||
var expected = new List<string> { "h", "i", "j" }; | ||
probe.Within(TimeSpan.FromSeconds(10), () => | ||
{ | ||
probe.Request(1).ExpectNext(); | ||
return probe.ExpectNoMsg(TimeSpan.FromMilliseconds(100)); | ||
expected.Remove(probe.Request(1).ExpectNext()).Should().BeTrue(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is enough to test that the returned value is part of the expected values |
||
return probe.ExpectNoMsg(TimeSpan.FromMilliseconds(500)); | ||
}); | ||
|
||
Setup("j", 1); | ||
probe.Within(TimeSpan.FromSeconds(10), () => | ||
{ | ||
probe.Request(5).ExpectNext(); | ||
return probe.ExpectNext(); | ||
}); | ||
probe.Within(TimeSpan.FromSeconds(10), () => probe.Request(5).ExpectNextUnordered(expected[0], expected[1])); | ||
|
||
Setup("a1", 1); | ||
Thread.Sleep(TimeSpan.FromSeconds(2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is enough to trigger the bug There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer |
||
probe.ExpectNext(TimeSpan.FromSeconds(10)); | ||
|
||
Thread.Sleep(TimeSpan.FromSeconds(2)); | ||
Setup("a2", 1); | ||
probe.ExpectNext(TimeSpan.FromSeconds(10)); | ||
} | ||
|
||
[Fact] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CurrentPersistenceIds message will only be received in the
Waiting
method (previously calledInitializing
)