-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed blob storage tests Implemented HighestSequenceNrEntry to keep track of the highest sequence number separate from the journal entries themselves Updated replay query to consider the highest sequence number entry * This was the first pass at a completed implementation with the exception of the two tests that will not pass when the entire spec is run but will pass if run individually * Cleaned up table entities
- Loading branch information
1 parent
7ca87ea
commit d8c3a7f
Showing
38 changed files
with
2,733 additions
and
289 deletions.
There are no files selected for viewing
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
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
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
29 changes: 0 additions & 29 deletions
29
src/Akka.Persistence.Azure.Tests/AzureStorageConfigHelper.cs
This file was deleted.
Oops, something went wrong.
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
66 changes: 66 additions & 0 deletions
66
src/Akka.Persistence.Azure.Tests/Helper/AzureStorageConfigHelper.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,66 @@ | ||
using System; | ||
using Akka.Configuration; | ||
|
||
namespace Akka.Persistence.Azure.Tests.Helper | ||
{ | ||
public static class AzureStorageConfigHelper | ||
{ | ||
public static Config AzureConfig(string connectionString) | ||
{ | ||
var tableName = "t" + Guid.NewGuid().ToString().Replace("-", ""); | ||
var containerName = "testcontainer" + Guid.NewGuid(); | ||
|
||
return ConfigurationFactory.ParseString( | ||
@" | ||
akka { | ||
loglevel = DEBUG | ||
log-config-on-start = off | ||
test.single-expect-default = 30s | ||
persistence { | ||
publish-plugin-commands = on | ||
journal { | ||
plugin = ""akka.persistence.journal.azure-table"" | ||
azure-table { | ||
connection-string=""" + connectionString + @""" | ||
connect-timeout = 3s | ||
request-timeout = 3s | ||
verbose-logging = on | ||
event-adapters { | ||
color-tagger = ""Akka.Persistence.TCK.Query.ColorFruitTagger, Akka.Persistence.TCK"" | ||
} | ||
event-adapter-bindings = { | ||
""System.String"" = color-tagger | ||
} | ||
} | ||
} | ||
query { | ||
journal { | ||
azure-table { | ||
write-plugin = ""akka.persistence.journal.azure-table"" | ||
refresh-interval = 1s | ||
max-buffer-size = 150 | ||
} | ||
} | ||
} | ||
snapshot-store { | ||
plugin = ""akka.persistence.snapshot-store.azure-blob-store"" | ||
azure-blob-store { | ||
connection-string=""" + connectionString + @""" | ||
request-timeout = 3s | ||
} | ||
} | ||
} | ||
}") | ||
.WithFallback("akka.persistence.journal.azure-table.table-name=" + tableName) | ||
.WithFallback("akka.persistence.snapshot-store.azure-blob-store.container-name=" + containerName); | ||
} | ||
|
||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Akka.Persistence.Azure.Tests/Helper/JournalTestActor.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,45 @@ | ||
using Akka.Actor; | ||
|
||
namespace Akka.Persistence.Azure.Tests.Helper | ||
{ | ||
public class JournalTestActor : UntypedPersistentActor | ||
{ | ||
public static Props Props(string persistenceId) => Actor.Props.Create(() => new JournalTestActor(persistenceId)); | ||
|
||
public sealed class DeleteCommand | ||
{ | ||
public DeleteCommand(long toSequenceNr) | ||
{ | ||
ToSequenceNr = toSequenceNr; | ||
} | ||
|
||
public long ToSequenceNr { get; } | ||
} | ||
|
||
public JournalTestActor(string persistenceId) | ||
{ | ||
PersistenceId = persistenceId; | ||
} | ||
|
||
public override string PersistenceId { get; } | ||
|
||
protected override void OnRecover(object message) | ||
{ | ||
} | ||
|
||
protected override void OnCommand(object message) | ||
{ | ||
switch (message) | ||
{ | ||
case DeleteCommand delete: | ||
DeleteMessages(delete.ToSequenceNr); | ||
Sender.Tell($"{delete.ToSequenceNr}-deleted"); | ||
break; | ||
case string cmd: | ||
var sender = Sender; | ||
Persist(cmd, e => sender.Tell($"{e}-done")); | ||
break; | ||
} | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Akka.Persistence.Azure.Tests/Query/AzureTableCurrentEventsByPersistenceIdSpec.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,43 @@ | ||
using Akka.Configuration; | ||
using Akka.Persistence.Azure.Query; | ||
using Akka.Persistence.Azure.TestHelpers; | ||
using Akka.Persistence.Azure.Tests.Helper; | ||
using Akka.Persistence.Query; | ||
using Akka.Persistence.TCK.Query; | ||
using System; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Azure.Tests.Query | ||
{ | ||
[Collection("AzureQuery")] | ||
public sealed class AzureTableCurrentEventsByPersistenceIdSpec | ||
: CurrentEventsByPersistenceIdSpec | ||
{ | ||
public AzureTableCurrentEventsByPersistenceIdSpec(ITestOutputHelper output) | ||
: base(Config(), nameof(AzureTablePersistenceIdsSpec), output) | ||
{ | ||
AzurePersistence.Get(Sys); | ||
|
||
ReadJournal = | ||
Sys.ReadJournalFor<AzureTableStorageReadJournal>( | ||
AzureTableStorageReadJournal.Identifier); | ||
|
||
output.WriteLine("Current table: {0}", TableName); | ||
} | ||
|
||
public static string TableName { get; private set; } | ||
|
||
public static Config Config() | ||
{ | ||
var azureConfig = | ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_CONNECTION_STR")) | ||
? AzureStorageConfigHelper.AzureConfig(Environment.GetEnvironmentVariable("AZURE_CONNECTION_STR")) | ||
: AzureStorageConfigHelper.AzureConfig(WindowsAzureStorageEmulatorFixture.GenerateConnStr()); | ||
|
||
TableName = azureConfig.GetString("akka.persistence.journal.azure-table.table-name"); | ||
|
||
return azureConfig; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Akka.Persistence.Azure.Tests/Query/AzureTableCurrentEventsByTagSpec.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,49 @@ | ||
using System; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Persistence.Azure.Query; | ||
using Akka.Persistence.Azure.TestHelpers; | ||
using Akka.Persistence.Azure.Tests.Helper; | ||
using Akka.Persistence.Query; | ||
using Akka.Persistence.TCK.Query; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Azure.Tests.Query | ||
{ | ||
[Collection("AzureQuery")] | ||
public sealed class AzureTableCurrentEventsByTagSpec | ||
: CurrentEventsByTagSpec | ||
{ | ||
public AzureTableCurrentEventsByTagSpec(ITestOutputHelper output) | ||
: base(Config(), nameof(AzureTablePersistenceIdsSpec), output) | ||
{ | ||
AzurePersistence.Get(Sys); | ||
|
||
ReadJournal = | ||
Sys.ReadJournalFor<AzureTableStorageReadJournal>( | ||
AzureTableStorageReadJournal.Identifier); | ||
|
||
output.WriteLine("Current table: {0}", TableName); | ||
|
||
var x = Sys.ActorOf(JournalTestActor.Props("x")); | ||
x.Tell("warm-up"); | ||
ExpectMsg("warm-up-done", TimeSpan.FromSeconds(10)); | ||
|
||
} | ||
|
||
public static string TableName { get; private set; } | ||
|
||
public static Config Config() | ||
{ | ||
var azureConfig = | ||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_CONNECTION_STR")) | ||
? AzureStorageConfigHelper.AzureConfig(Environment.GetEnvironmentVariable("AZURE_CONNECTION_STR")) | ||
: AzureStorageConfigHelper.AzureConfig(WindowsAzureStorageEmulatorFixture.GenerateConnStr()); | ||
|
||
TableName = azureConfig.GetString("akka.persistence.journal.azure-table.table-name"); | ||
|
||
return azureConfig; | ||
} | ||
} | ||
} |
Oops, something went wrong.