Skip to content

Commit

Permalink
Add EventsByPersistenceId persistence query back (#133)
Browse files Browse the repository at this point in the history
* Refactor namespace from Test to Tests

* Add EventsByPersistenceIdSpec and CurrentEventsByPersistenceIdSpec unit tests back

* Replace Source based EventsByPersistenceIdSource with ActorPublisher based EventsByPersistenceIdPublisher

* Add RedisReadJournalProvider back (accidentally deleted in dev)

* Cleanup RedisJournal class from all the leftover commented query support code.
  • Loading branch information
Arkatufus authored Feb 9, 2021
1 parent 65a81aa commit 44efc18
Show file tree
Hide file tree
Showing 21 changed files with 804 additions and 231 deletions.
3 changes: 1 addition & 2 deletions src/Akka.Persistence.Redis.Cluster.Tests/DbUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
// </copyright>
// -----------------------------------------------------------------------

using System.Linq;
using StackExchange.Redis;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
public static class DbUtils
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Akka.Configuration;
using Akka.Persistence.Query;
using Akka.Persistence.Redis.Query;
using Akka.Persistence.TCK.Query;
using Xunit;
using Xunit.Abstractions; //-----------------------------------------------------------------------
// <copyright file="RedisCurrentEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// Copyright (C) 2017 Akka.NET Contrib <https://github.com/AkkaNetContrib/Akka.Persistence.Redis>
// </copyright>
//-----------------------------------------------------------------------

namespace Akka.Persistence.Redis.Cluster.Tests.Query
{
[Collection("RedisClusterSpec")]
public class RedisCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec
{
public static Config Config(RedisClusterFixture fixture)
{
DbUtils.Initialize(fixture);

return ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.redis""
akka.persistence.journal.redis {{
class = ""Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis""
plugin-dispatcher = ""akka.actor.default-dispatcher""
configuration-string = ""{fixture.ConnectionString}""
}}
akka.test.single-expect-default = 3s")
.WithFallback(RedisPersistence.DefaultConfig());
}

public RedisCurrentEventsByPersistenceIdSpec(ITestOutputHelper output, RedisClusterFixture fixture)
: base(Config(fixture), nameof(RedisCurrentEventsByPersistenceIdSpec), output)
{
ReadJournal = Sys.ReadJournalFor<RedisReadJournal>(RedisReadJournal.Identifier);
}

protected override void Dispose(bool disposing)
{
DbUtils.Clean();
base.Dispose(disposing);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//-----------------------------------------------------------------------
// <copyright file="RedisEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// Copyright (C) 2017 Akka.NET Contrib <https://github.com/AkkaNetContrib/Akka.Persistence.Redis>
// </copyright>
//-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.Query;
using Akka.Persistence.Redis.Query;
using Akka.Persistence.TCK.Query;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Tests.Query
{
[Collection("RedisClusterSpec")]
public class RedisEventsByPersistenceIdSpec : EventsByPersistenceIdSpec
{
public static Config Config(RedisClusterFixture fixture)
{
DbUtils.Initialize(fixture);

return ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.redis""
akka.persistence.journal.redis {{
class = ""Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis""
plugin-dispatcher = ""akka.actor.default-dispatcher""
configuration-string = ""{fixture.ConnectionString}""
}}
akka.test.single-expect-default = 3s")
.WithFallback(RedisPersistence.DefaultConfig());
}

public RedisEventsByPersistenceIdSpec(ITestOutputHelper output, RedisClusterFixture fixture)
: base(Config(fixture), nameof(RedisEventsByPersistenceIdSpec), output)
{
ReadJournal = Sys.ReadJournalFor<RedisReadJournal>(RedisReadJournal.Identifier);
}

protected override void Dispose(bool disposing)
{
DbUtils.Clean();
base.Dispose(disposing);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Docker.DotNet.Models;
using Xunit;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
[CollectionDefinition("RedisClusterSpec")]
public sealed class RedisSpecsFixture : ICollectionFixture<RedisClusterFixture>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
// </copyright>
// -----------------------------------------------------------------------

using System;
using Akka.Configuration;
using Akka.Persistence.TestKit.Performance;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
[Collection("RedisClusterSpec")]
public class RedisJournalPerfSpec : JournalPerfSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
[Collection("RedisClusterSpec")]
public class RedisJournalSpec : JournalSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using FluentAssertions;
using Xunit;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
public class RedisSettingsSpec : Akka.TestKit.Xunit2.TestKit
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Test
namespace Akka.Persistence.Redis.Cluster.Tests
{
[Collection("RedisClusterSpec")]
public class RedisSnapshotStoreSpec : SnapshotStoreSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Test.Serialization
namespace Akka.Persistence.Redis.Cluster.Tests.Serialization
{
[Collection("RedisClusterSpec")]
public class RedisJournalSerializationSpec : JournalSerializationSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Cluster.Test.Serialization
namespace Akka.Persistence.Redis.Cluster.Tests.Serialization
{
[Collection("RedisClusterSpec")]
public class RedisSnapshotStoreSerializationSpec : SnapshotStoreSerializationSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Akka.Persistence.Redis;
using Akka.Persistence.Redis.Tests;

//-----------------------------------------------------------------------
// <copyright file="RedisCurrentEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// Copyright (C) 2017 Akka.NET Contrib <https://github.com/AkkaNetContrib/Akka.Persistence.Redis>
// </copyright>
//-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.Query;
using Akka.Persistence.Redis.Query;
using Akka.Persistence.TCK.Query;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Tests.Query
{
[Collection("RedisSpec")]
public class RedisCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec
{
public const int Database = 1;

public static Config Config(RedisFixture fixture, int id)
{
DbUtils.Initialize(fixture);

return ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.redis""
akka.persistence.journal.redis {{
class = ""Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis""
plugin-dispatcher = ""akka.actor.default-dispatcher""
configuration-string = ""{fixture.ConnectionString}""
database = {id}
}}
akka.test.single-expect-default = 3s")
.WithFallback(RedisPersistence.DefaultConfig());
}

public RedisCurrentEventsByPersistenceIdSpec(ITestOutputHelper output, RedisFixture fixture)
: base(Config(fixture, Database), nameof(RedisCurrentEventsByPersistenceIdSpec), output)
{
ReadJournal = Sys.ReadJournalFor<RedisReadJournal>(RedisReadJournal.Identifier);
}

protected override void Dispose(bool disposing)
{
DbUtils.Clean(Database);
base.Dispose(disposing);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//-----------------------------------------------------------------------
// <copyright file="RedisEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// Copyright (C) 2017 Akka.NET Contrib <https://github.com/AkkaNetContrib/Akka.Persistence.Redis>
// </copyright>
//-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.Query;
using Akka.Persistence.Redis.Query;
using Akka.Persistence.TCK.Query;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Persistence.Redis.Tests.Query
{
[Collection("RedisSpec")]
public class RedisEventsByPersistenceIdSpec : EventsByPersistenceIdSpec
{
public const int Database = 1;

public static Config Config(RedisFixture fixture, int id)
{
DbUtils.Initialize(fixture);

return ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.redis""
akka.persistence.journal.redis {{
class = ""Akka.Persistence.Redis.Journal.RedisJournal, Akka.Persistence.Redis""
plugin-dispatcher = ""akka.actor.default-dispatcher""
configuration-string = ""{fixture.ConnectionString}""
database = {id}
}}
akka.test.single-expect-default = 3s")
.WithFallback(RedisPersistence.DefaultConfig());
}

public RedisEventsByPersistenceIdSpec(ITestOutputHelper output, RedisFixture fixture) : base(Config(fixture, Database), nameof(RedisEventsByPersistenceIdSpec), output)
{
ReadJournal = Sys.ReadJournalFor<RedisReadJournal>(RedisReadJournal.Identifier);
}

protected override void Dispose(bool disposing)
{
DbUtils.Clean(Database);
base.Dispose(disposing);
}
}
}
107 changes: 0 additions & 107 deletions src/Akka.Persistence.Redis.Tests/RedisClusterFixture.cs

This file was deleted.

Loading

0 comments on commit 44efc18

Please sign in to comment.