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

Conversation

@valdisz
Copy link
Contributor

commented Aug 8, 2019

PR addresses issue #3877

Added 3 new projects:

  • Akka.Persistence.TestKit
  • Akka.Persistence.TestKit.Tests
  • Akka.Persistence.TestKit.Xunit2

It adds a new journal (TestJournal) and a new snapshot store (TestSnaphostStore). It is possible to intercept calls to them and apply user-defined behavior, i.e. to simulate network problems or anything else.

It adds new test base class PersistenceTestKit (Xunit2 based) to simplify usage. API loos like this:

public class PersistentActorSpec : PersistenceTestKit
{
    [Fact]
    public async Task actor_must_fail_when_journal_will_fail_saving_message()
    {
        await WithJournalWrite(write => write.Fail(), () =>
        {
            var actor = ActorOf(() => new PersistActor());
            Watch(actor);

            actor.Tell("write", TestActor);
            ExpectTerminated(actor);
        });
    }
}

@valdisz valdisz changed the title Feedback needed on feature addressing issue #3877 Feedback needed on feature addressing specialised Test Journal Aug 8, 2019

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 8, 2019

Build failed due to TestJournalSpec.cs(28,13): error CS0165: Use of unassigned local variable 'journal' [D:\a\1\s\src\core\Akka.Persistence.TestKit.Tests\Akka.Persistence.TestKit.Tests.csproj]

@Aaronontheweb
Copy link
Member

left a comment

I know this is a very early preview and you have more iterations you're working on, but I wanted to pass along some comments.

@valdisz valdisz force-pushed the valdisz:feature/persistence-testkit branch 2 times, most recently from d0aa37f to f640b69 Aug 8, 2019

@valdisz valdisz force-pushed the valdisz:feature/persistence-testkit branch from f640b69 to 46c77c4 Aug 9, 2019

valdisz added 2 commits Aug 10, 2019
@Aaronontheweb
Copy link
Member

left a comment

Looking good so far - I think we should add a new base class on top of the TestKitBase that makes it more concise to use some of these Journal failure methods when writing a test, The underlying TestJournal itself looks great though.

src/core/Akka.Persistence.TestKit/TestJournal.cs Outdated Show resolved Hide resolved
src/core/Akka.Persistence.TestKit/TestJournal.cs Outdated Show resolved Hide resolved
src/core/Akka.Persistence.TestKit/TestJournal.cs Outdated Show resolved Hide resolved

@valdisz valdisz changed the title Feedback needed on feature addressing specialised Test Journal TestJournal and TestSnaphostStore Aug 11, 2019

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 11, 2019

@Aaronontheweb I have implemented PersistenceTestKit. Is it what you were expecting?

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 12, 2019

One test in a totally different project (which was not modified) is failing. No idea why.

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 12, 2019

@valdisz we have a number of test failures that are due to concurrent tests with hard deadlines blocking threads, We have an open proposal to fix this by moving everything to an async / await model in #3854 - we're going to have to address it in a future release. Don't worry about it for the time being.

@Aaronontheweb
Copy link
Member

left a comment

Have some more comments I want to add, but I need to do some work with this code locally on my machine first.

@Aaronontheweb
Copy link
Member

left a comment

Added some examples of the type of functionality I'd like to see built into the PersistentTestkit class, and some recommendations on moving away from blocking threads and towards async / await implementations

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

@valdisz this is looking good - what are next steps for implementing this? More overloads on the PersistenceTestKit class?

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

@Aaronontheweb more unit tests for existing code (some are still needed), then SnaphsotStore and then XML DOC.

@valdisz valdisz force-pushed the valdisz:feature/persistence-testkit branch from 7ed6cef to aceb9aa Aug 14, 2019

valdisz added 2 commits Aug 17, 2019
@Aaronontheweb
Copy link
Member

left a comment

This looks great - have some minor changes we need to address (left comments for them) but otherwise I think this is ready to go.

We'll work on getting documentation added to the website for this built into a separate pull request and we'll also plan on releasing this as part of the v1.4.0-beta2 launch, so users can start using it and giving us some feedback. We'll probably consume it inside the Akka.Persistence.Extras project as a starting point.

/// This class represents an Akka.NET Persistence TestKit that uses <a href="https://xunit.github.io/">xUnit</a>
/// as its testing framework.
/// </summary>
public abstract class PersistenceTestKit : PersistenceTestKitBase

This comment has been minimized.

Copy link
@Aaronontheweb

Aaronontheweb Aug 21, 2019

Member

Need to add a constructor overload here which takes an ITestOutputHelper for XUnit - that's how we're able to inject the XUnit output capture system into the Akka.NET logging infrastructure. Here's an example of a unit test where a user would do that:

https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka.Remote.Tests/RemotingSpec.cs#L31

This comment has been minimized.

Copy link
@valdisz

valdisz Aug 22, 2019

Author Contributor

To correctly handle ITestOutputHelper in test kit I changed the base class of PersistenceTestKit to TestKit. This means that PersistenceTestKitBase no longer exists other test frameworks will not have Test Kit class with persistence testing API out of the box for now.

@valdisz valdisz marked this pull request as ready for review Aug 23, 2019

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 23, 2019

PR is ready, all work is done. If any issues are found, please comment, otherwise, merge.

@Danthar

This comment has been minimized.

Copy link
Member

commented Aug 25, 2019

We got some errors in Tests, in the MNTK tests related to persistence are failing with casting errors. However as far as i can tell that should not be code this PR changed.

Did we change an IList to an SortedSet somewhere in this PR ?

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 25, 2019

We got some errors in Tests, in the MNTK tests related to persistence are failing with casting errors. However as far as i can tell that should not be code this PR changed.

Did we change an IList to an SortedSet somewhere in this PR ?

This PR does not change anything except adding 3 new projects to the solution.
For me, it is hard to guess why that particular test failed.
I can dig in, but that will take some time.

@Danthar

This comment has been minimized.

Copy link
Member

commented Aug 25, 2019

@Danthar

This comment has been minimized.

Copy link
Member

commented Aug 26, 2019

Think i found the issue. Problem happens during json serialization/deserialization. Im thinking this PR is the culprit #3671 Because i cannot find anything else that might cause this.

@valdisz

This comment has been minimized.

Copy link
Contributor Author

commented Aug 26, 2019

Surprisingly my next PR does not fail any builds. #3889

@Danthar

This comment has been minimized.

Copy link
Member

commented Aug 26, 2019

@Aaronontheweb
Copy link
Member

left a comment

LGTM

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 26, 2019

I'll take a look at that failing spec - I think it's due to the JSON.NET upgrade. CI didn't run because I think the common.props file was the only thing that was upgraded. Incrementalist will need to be upgraded to detect that a shared project property file changed.

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 26, 2019

@Aaronontheweb

This comment has been minimized.

Copy link
Member

commented Aug 27, 2019

Having a persistent failure with MNTR specs on .NET Framework only:

##teamcity[testFailed name='Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs' message='|[NODE2:second|]|[12:33 PM|]: SPEC FAILED: Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs|r FAIL' details='' timestamp='2019-08-27T12:33:42.162+0000' flowId='11']
[INFO][8/27/2019 12:33:42 PM][Thread 0003][[akka://TestRunnerLogging/user/TcpLogger#1268474739]] Node disconnected on [akka://TestRunnerLogging/system/IO-TCP/$a/$o#557351663]

Unknown message: Node\PublishSubscribe\DistributedPubSubMediatorSpec.cs:line 751
   at Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.<DistributedPubSubMediator_must_remove_entries_when_node_is_removed>b__39_0() in D:\a\1\s\src\contrib\cluster\Akka.Cluster.Tools.Tests.MultiNode\PublishSubscribe\DistributedPubSubMediatorSpec.cs:line 752
   at Akka.TestKit.TestKitBase.<>c__DisplayClass141_0.<Within>b__0() in D:\a\1\s\src\core\Akka.TestKit\TestKitBase_Within.cs:line 48
   at Akka.TestKit.T
Unknown message: estKitBase.Within[T](TimeSpan min, TimeSpan max, Func`1 function, String hint, Nullable`1 epsilonValue) in D:\a\1\s\src\core\Akka.TestKit\TestKitBase_Within.cs:line 101
   at Akka.TestKit.TestKitBase.Within(TimeSpan min, TimeSpan max, Action action, String hint, Nullable`1 epsilonValue) in D:\a\1\s\src\core\Akka.TestKit\TestKitBase_Within.cs:line 49
   at Akka.TestKit.TestKitBase.Within(TimeSpan max, Action action, Nullable`1 epsilonValue) in D:\a\1\s\src\core\Akka.TestKit\TestKitBase_Within.cs:line 32
 
Unknown message:   at Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediator_must_remove_entries_when_node_is_removed() in D:\a\1\s\src\contrib\cluster\Akka.Cluster.Tools.Tests.MultiNode\PublishSubscribe\DistributedPubSubMediatorSpec.cs:line 761
   at Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs() in D:\a\1\s\src\contrib\cluster\Akka.Cluster.Tools.Tests.MultiNode\PublishSubscribe\DistributedPubSubMediato
Unknown message: nToken) in D:\a\1\s\src\core\Akka\Actor\Futures.cs:line 128

##teamcity[testFailed name='Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs' message='|[NODE1:first|]|[12:33 PM|]: SPEC FAILED: Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs|r FAIL' details='' timestamp='2019-08-27T12:33:47.471+0000' flowId='11']
##teamcity[testFailed name='Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs' message='|[NODE1:first|]|[12:33 PM|]: SPEC FAILED: Message: Timeout after 00:00:05 seconds|r' details='' timestamp='2019-08-27T12:33:47.471+0000' flowId='11']
##teamcity[testFailed name='Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs' message='|[NODE1:first|]|[12:33 PM|]: SPEC FAILED: StackTrace:    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)|r' details='' timestamp='2019-08-27T12:33:47.471+0000' flowId='11']
##teamcity[testFailed name='Akka.Cluster.Tools.Tests.MultiNode.PublishSubscribe.DistributedPubSubMediatorSpec.DistributedPubSubMediatorSpecs' message='|[NODE1:first|]|[12:33 PM|]: SPEC FAILED: StackTrace:    at Akka.Actor.Futures.Ask(ICanTell self, Func`2 messageFactory, IActorRefProvider provider, Nullable`1 timeout, CancellationToken cancellationToken) in D:\a\1\s\src\core\Akka\Actor\Futures.cs:line 187|r' details='' timestamp='2019-08-27T12:33:47.471+0000' flowId='11']

Going to take a closer look at this - don't think it's related to these changes.

@Aaronontheweb Aaronontheweb merged commit 37be6a5 into akkadotnet:dev Aug 31, 2019

8 checks passed

PR Validation Build #2019.8.30.16 had test failures
Details
PR Validation (.NET Core Multi-Node Tests (Windows)) .NET Core Multi-Node Tests (Windows) succeeded
Details
PR Validation (.NET Core Unit Tests (Linux)) .NET Core Unit Tests (Linux) succeeded
Details
PR Validation (.NET Core Unit Tests (Windows)) .NET Core Unit Tests (Windows) succeeded
Details
PR Validation (.NET Framework Multi-Node Tests (Windows)) .NET Framework Multi-Node Tests (Windows) succeeded
Details
PR Validation (.NET Framework Unit Tests (Windows)) .NET Framework Unit Tests (Windows) succeeded
Details
PR Validation (NuGet Pack) NuGet Pack succeeded
Details
PR Validation (Windows Build) Windows Build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.