-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into Add_option_to_use_BIGINT_IDENTITY_for_journal…
…_ordering_column
- Loading branch information
Showing
2 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/Akka.Persistence.PostgreSql.Tests/PostgreSqlSnapshotStoreSequentialAccessSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="PostgreSqlSnapshotStoreSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using Akka.Configuration; | ||
using Akka.Persistence.TCK.Snapshot; | ||
using Akka.TestKit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.PostgreSql.Tests | ||
{ | ||
[Collection("PostgreSqlSpec")] | ||
public class PostgreSqlSnapshotStoreSequentialAccessSpec : SnapshotStoreSpec | ||
{ | ||
private static Config Initialize(PostgresFixture fixture) | ||
{ | ||
//need to make sure db is created before the tests start | ||
DbUtils.Initialize(fixture); | ||
|
||
var config = @" | ||
akka.persistence { | ||
publish-plugin-commands = on | ||
snapshot-store { | ||
plugin = ""akka.persistence.snapshot-store.postgresql"" | ||
postgresql { | ||
class = ""Akka.Persistence.PostgreSql.Snapshot.PostgreSqlSnapshotStore, Akka.Persistence.PostgreSql"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
table-name = snapshot_store | ||
schema-name = public | ||
auto-initialize = on | ||
connection-string = """ + DbUtils.ConnectionString + @""" | ||
sequential-access = on | ||
} | ||
} | ||
} | ||
akka.test.single-expect-default = 10s"; | ||
|
||
return ConfigurationFactory.ParseString(config); | ||
} | ||
|
||
public PostgreSqlSnapshotStoreSequentialAccessSpec(ITestOutputHelper output, PostgresFixture fixture) | ||
: base(Initialize(fixture), "PostgreSqlSnapshotStoreSpec", output: output) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
DbUtils.Clean(); | ||
} | ||
|
||
[Fact] | ||
public void SnapshotStore_should_save_and_overwrite_snapshot_with_same_sequence_number_unskipped() | ||
{ | ||
TestProbe _senderProbe = CreateTestProbe(); | ||
var md = Metadata[4]; | ||
SnapshotStore.Tell(new SaveSnapshot(md, "s-5-modified"), _senderProbe.Ref); | ||
var md2 = _senderProbe.ExpectMsg<SaveSnapshotSuccess>().Metadata; | ||
Assert.Equal(md.SequenceNr, md2.SequenceNr); | ||
SnapshotStore.Tell(new LoadSnapshot(Pid, new SnapshotSelectionCriteria(md.SequenceNr), long.MaxValue), _senderProbe.Ref); | ||
var result = _senderProbe.ExpectMsg<LoadSnapshotResult>(); | ||
Assert.Equal("s-5-modified", result.Snapshot.Snapshot.ToString()); | ||
Assert.Equal(md.SequenceNr, result.Snapshot.Metadata.SequenceNr); | ||
// metadata timestamp may have been changed | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters