Skip to content

Commit f950aff

Browse files
committed
test(streaming): persist Aspire SQS subscriptions
1 parent 8c4438e commit f950aff

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

test/Extensions/Orleans.AWS.Tests/Orleans.AWS.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<ProjectReference Include="$(SourceRoot)src\AWS\Orleans.Persistence.DynamoDB\Orleans.Persistence.DynamoDB.csproj" />
3333
<ProjectReference Include="$(SourceRoot)src\AWS\Orleans.Reminders.DynamoDB\Orleans.Reminders.DynamoDB.csproj" />
3434
<ProjectReference Include="$(SourceRoot)src\AWS\Orleans.Streaming.SQS\Orleans.Streaming.SQS.csproj" />
35+
<ProjectReference Include="$(SourceRoot)src\File\Orleans.Persistence.FileStorage\Orleans.Persistence.FileStorage.csproj" />
3536
<ProjectReference Include="$(SourceRoot)src\Orleans.Persistence.TestKit\Orleans.Persistence.TestKit.csproj" PrivateAssets="all" />
3637
<ProjectReference Include="$(SourceRoot)src\Orleans.Reminders.TestKit\Orleans.Reminders.TestKit.csproj" PrivateAssets="all" />
3738
<ProjectReference Include="$(SourceRoot)test\Orleans.Runtime.Internal.Tests\Orleans.Runtime.Internal.Tests.csproj" />

test/Extensions/Orleans.AWS.Tests/Streaming/SQSAspireLiveStreamTests.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.Logging.Abstractions;
55
using Orleans.Hosting;
6+
using Orleans.Persistence.FileStorage;
67
using Orleans.TestingHost;
78
using OrleansAWSUtils.Streams;
89
using TestExtensions;
@@ -20,8 +21,10 @@ namespace AWSUtils.Tests.Streaming;
2021
public sealed class SQSAspireLiveStreamTests : TestClusterPerTest
2122
{
2223
private const string ProviderName = "AspireSQS";
24+
private const string PubSubStoreRootDirectoryKey = "AspireSQS:PubSubStoreRootDirectory";
2325
private SqsAspireTestApp _app = null!;
2426
private EnvironmentVariableScope _environment = null!;
27+
private string? _ownedDirectory;
2528
private SingleStreamTestRunner _runner = null!;
2629

2730
protected override void CheckPreconditionsOrThrow()
@@ -34,13 +37,24 @@ protected override void CheckPreconditionsOrThrow()
3437

3538
protected override void ConfigureTestCluster(TestClusterBuilder builder)
3639
{
40+
var ownedDirectory = _ownedDirectory
41+
?? throw new InvalidOperationException("The PubSubStore directory has not been initialized.");
42+
builder.Options.InitialSilosCount = 1;
43+
builder.Properties[PubSubStoreRootDirectoryKey] = Path.Combine(
44+
ownedDirectory,
45+
"PubSubStore");
3746
builder.ConfigureHostConfiguration(configuration => configuration.AddEnvironmentVariables());
3847
builder.AddSiloBuilderConfigurator<SiloConfigurator>();
3948
}
4049

4150
public override async ValueTask InitializeAsync()
4251
{
4352
EnsurePreconditionsMet();
53+
_ownedDirectory = Path.Combine(
54+
Path.GetTempPath(),
55+
nameof(SQSAspireLiveStreamTests),
56+
Guid.NewGuid().ToString("N"));
57+
Directory.CreateDirectory(_ownedDirectory);
4458
_app = await SqsAspireTestApp.CreateAsync(
4559
ProviderName,
4660
[
@@ -87,13 +101,23 @@ await SQSStreamProviderUtils.DeleteAllUsedQueues(
87101
{
88102
await _app.DisposeAsync();
89103
}
104+
105+
if (_ownedDirectory is not null && Directory.Exists(_ownedDirectory))
106+
{
107+
Directory.Delete(_ownedDirectory, recursive: true);
108+
}
90109
}
91110
}
92111

93112
private sealed class SiloConfigurator : ISiloConfigurator
94113
{
95114
public void Configure(ISiloBuilder siloBuilder)
96-
=> siloBuilder.AddMemoryGrainStorage("PubSubStore");
115+
=> siloBuilder.AddFileGrainStorage(
116+
"PubSubStore",
117+
options => options.RootDirectory =
118+
siloBuilder.Configuration[PubSubStoreRootDirectoryKey]
119+
?? throw new InvalidOperationException(
120+
$"Missing {PubSubStoreRootDirectoryKey} configuration."));
97121
}
98122
}
99123
#endif

0 commit comments

Comments
 (0)