Skip to content
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

TestJournal and TestSnaphostStore #3881

Merged
merged 24 commits into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
46c77c4
TestJournal with Write intreception and varios failure strategies
valdisz Aug 9, 2019
10ac5b2
unit tests for message interceptors
valdisz Aug 10, 2019
42d7f8c
TestJournal OnRecovery behavior
valdisz Aug 10, 2019
9dbb8ed
Recovery unit tests
valdisz Aug 10, 2019
eaa701c
PersistenceTestKit base for easier test setup
valdisz Aug 11, 2019
4fb4ea9
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 12, 2019
8e0f81e
added example of built-in TestKit method
Aaronontheweb Aug 12, 2019
e32dfff
use Async api whenver possible
valdisz Aug 13, 2019
17ac3b3
Merge branch 'dev' into feature/persistence-testkit
valdisz Aug 13, 2019
aceb9aa
(wip) TestSnapshotStore
valdisz Aug 14, 2019
55b9f92
TestSnapshotStore interceptors
valdisz Aug 14, 2019
610999f
unit tests for TestSnapshotStore
valdisz Aug 16, 2019
c97481a
separate package with Xunit2 integration
valdisz Aug 16, 2019
a85d950
XML doc
valdisz Aug 17, 2019
a14b2c9
Journal Write and Recovery behavior documentation
valdisz Aug 18, 2019
c05ec27
removed unneeded statements from csproj files
valdisz Aug 22, 2019
c4cebe0
PersistenceTestKitBase is removed to correctly add ITestOutputHelper …
valdisz Aug 22, 2019
1147968
added mor xml docs
valdisz Aug 23, 2019
fa4c150
Merge branch 'dev' into feature/persistence-testkit
valdisz Aug 23, 2019
7d50ddd
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 26, 2019
bd299f2
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 30, 2019
0218d9a
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 30, 2019
b823a45
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 30, 2019
bc6962c
Merge branch 'dev' into feature/persistence-testkit
Aaronontheweb Aug 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/Akka.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2010
# Visual Studio Version 16
Aaronontheweb marked this conversation as resolved.
Show resolved Hide resolved
VisualStudioVersion = 16.0.29201.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmark", "Benchmark", "{73108242-625A-4D7B-AA09-63375DBAE464}"
EndProject
Expand Down Expand Up @@ -197,6 +197,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpawnBenchmark", "benchmark
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Akka.Persistence.FSharp", "core\Akka.Persistence.FSharp\Akka.Persistence.FSharp.fsproj", "{539C3EB6-FCC8-41FA-9373-364605877EE1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Persistence.TestKit", "core\Akka.Persistence.TestKit\Akka.Persistence.TestKit.csproj", "{212A2D35-E8D1-46A7-A1D1-418CF9509D77}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Persistence.TestKit.Tests", "core\Akka.Persistence.TestKit.Tests\Akka.Persistence.TestKit.Tests.csproj", "{22F6EA86-0079-41A0-9BD3-82D2D6C34638}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Akka.Persistence.TestKit.Xunit2", "core\Akka.Persistence.TestKit.Xunit2\Akka.Persistence.TestKit.Xunit2.csproj", "{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -844,6 +850,42 @@ Global
{539C3EB6-FCC8-41FA-9373-364605877EE1}.Release|x64.Build.0 = Release|Any CPU
{539C3EB6-FCC8-41FA-9373-364605877EE1}.Release|x86.ActiveCfg = Release|Any CPU
{539C3EB6-FCC8-41FA-9373-364605877EE1}.Release|x86.Build.0 = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|x64.ActiveCfg = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|x64.Build.0 = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|x86.ActiveCfg = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Debug|x86.Build.0 = Debug|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|Any CPU.Build.0 = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|x64.ActiveCfg = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|x64.Build.0 = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|x86.ActiveCfg = Release|Any CPU
{212A2D35-E8D1-46A7-A1D1-418CF9509D77}.Release|x86.Build.0 = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|x64.ActiveCfg = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|x64.Build.0 = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|x86.ActiveCfg = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Debug|x86.Build.0 = Debug|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|Any CPU.Build.0 = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|x64.ActiveCfg = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|x64.Build.0 = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|x86.ActiveCfg = Release|Any CPU
{22F6EA86-0079-41A0-9BD3-82D2D6C34638}.Release|x86.Build.0 = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|x64.ActiveCfg = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|x64.Build.0 = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|x86.ActiveCfg = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Debug|x86.Build.0 = Debug|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|Any CPU.Build.0 = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|x64.ActiveCfg = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|x64.Build.0 = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|x86.ActiveCfg = Release|Any CPU
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -929,6 +971,9 @@ Global
{A1D57384-A933-480A-9DF4-FA5E60AB1A67} = {73108242-625A-4D7B-AA09-63375DBAE464}
{9BEAF609-B406-4CCB-9708-6E8DFF764232} = {73108242-625A-4D7B-AA09-63375DBAE464}
{539C3EB6-FCC8-41FA-9373-364605877EE1} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{212A2D35-E8D1-46A7-A1D1-418CF9509D77} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{22F6EA86-0079-41A0-9BD3-82D2D6C34638} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
{6F8FECD6-6E39-473E-9B9A-9EE22CBF479F} = {01167D3C-49C4-4CDE-9787-C176D139ACDD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03AD8E21-7507-4E68-A4E9-F4A7E7273164}
Expand Down
59 changes: 59 additions & 0 deletions src/core/Akka.Persistence.TestKit.Tests/Actors/PersistActor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// -----------------------------------------------------------------------
// <copyright file="PersistActor.cs" company="Akka.NET Project">
// Copyright (C) 2009-2019 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2019 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

namespace Akka.Persistence.TestKit.Tests
{
using System;
using Actor;

public class PersistActor : UntypedPersistentActor
{
public PersistActor(IActorRef probe)
{
_probe = probe;
}

private readonly IActorRef _probe;

public override string PersistenceId => "foo";

protected override void OnCommand(object message)
{
switch (message as string)
{
case "write":
Persist(message, _ =>
{
_probe.Tell("ack");
});

break;

default:
return;
}
}

protected override void OnRecover(object message)
{
}

protected override void OnPersistFailure(Exception cause, object @event, long sequenceNr)
{
_probe.Tell("failure");

base.OnPersistFailure(cause, @event, sequenceNr);
}

protected override void OnPersistRejected(Exception cause, object @event, long sequenceNr)
{
_probe.Tell("rejected");

base.OnPersistRejected(cause, @event, sequenceNr);
}
}
}
100 changes: 100 additions & 0 deletions src/core/Akka.Persistence.TestKit.Tests/Actors/SnapshotActor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// -----------------------------------------------------------------------
// <copyright file="SnapshotActor.cs" company="Akka.NET Project">
// Copyright (C) 2009-2019 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2019 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

namespace Akka.Persistence.TestKit.Tests
{
using System;
using Actor;

public class SnapshotActor : UntypedPersistentActor
{
public SnapshotActor(IActorRef probe)
{
_probe = probe;
}

private readonly IActorRef _probe;

public override string PersistenceId => "bar";

protected override void OnCommand(object message)
{
switch (message)
{
case "save":
SaveSnapshot(message);
return;

case DeleteOne del:
DeleteSnapshot(del.SequenceNr);
return;

case DeleteMany del:
DeleteSnapshots(del.Criteria);
return;

case SaveSnapshotSuccess _:
case SaveSnapshotFailure _:
case DeleteSnapshotSuccess _:
case DeleteSnapshotFailure _:
case DeleteSnapshotsSuccess _:
case DeleteSnapshotsFailure _:
_probe.Tell(message);
return;

default:
return;
}
}

protected override void OnRecover(object message)
{
if (message is SnapshotOffer snapshot)
{
_probe.Tell(message);
}
}

protected override void OnRecoveryFailure(Exception reason, object message = null)
{
_probe.Tell(new RecoveryFailure(reason, message));
base.OnRecoveryFailure(reason, message);
}

public class DeleteOne
{
public DeleteOne(long sequenceNr)
{
SequenceNr = sequenceNr;
}

public long SequenceNr { get; }
}

public class DeleteMany
{
public DeleteMany(SnapshotSelectionCriteria criteria)
{
Criteria = criteria;
}

public SnapshotSelectionCriteria Criteria { get; }
}

public class RecoveryFailure
{
public RecoveryFailure(Exception reason, object message)
{
Reason = reason;
Message = message;
}

public Exception Reason { get; }
public object Message { get; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />

<PropertyGroup>
<AssemblyTitle>Akka.Persistence.TestKit.Tests</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
valdisz marked this conversation as resolved.
Show resolved Hide resolved
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="TeamCity.ServiceMessages" Version="3.0.8" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Akka.Persistence.TestKit\Akka.Persistence.TestKit.csproj" />
<ProjectReference Include="..\Akka.Persistence.TestKit.Xunit2\Akka.Persistence.TestKit.Xunit2.csproj" />
<ProjectReference Include="..\Akka.Tests.Shared.Internals\Akka.Tests.Shared.Internals.csproj" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == '$(NetCoreTestVersion)' ">
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
</Project>
Loading