Skip to content

Commit

Permalink
use configuration settings for AQStreamingTests
Browse files Browse the repository at this point in the history
  • Loading branch information
tskimmett committed Jun 23, 2024
1 parent f391a62 commit dcafdc5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@
using Orleans.Providers;

[assembly: RegisterProvider("AzureQueueStorage", "Streaming", "Silo", typeof(AzureQueueStreamProviderBuilder))]
[assembly: RegisterProvider("AzureQueueStorage", "Streaming", "Client", typeof(AzureQueueStreamProviderBuilder))]

namespace Orleans.Hosting;

public sealed class AzureQueueStreamProviderBuilder : IProviderBuilder<ISiloBuilder>
public sealed class AzureQueueStreamProviderBuilder : IProviderBuilder<ISiloBuilder>, IProviderBuilder<IClientBuilder>
{
public void Configure(ISiloBuilder builder, string name, IConfigurationSection configurationSection)
{
builder.AddAzureQueueStreams(name, (OptionsBuilder<AzureQueueOptions> optionsBuilder) =>
builder.AddAzureQueueStreams(name, GetQueueOptionBuilder(configurationSection));
}

public void Configure(IClientBuilder builder, string name, IConfigurationSection configurationSection)
{
builder.AddAzureQueueStreams(name, GetQueueOptionBuilder(configurationSection));
}

private static Action<OptionsBuilder<AzureQueueOptions>> GetQueueOptionBuilder(IConfigurationSection configurationSection)
{
return (OptionsBuilder<AzureQueueOptions> optionsBuilder) =>
{
optionsBuilder.Configure<IServiceProvider>((options, services) =>
{
var queueNames = configurationSection.GetSection("QueueNames")?.Get<List<string>>();
Expand Down Expand Up @@ -55,6 +67,7 @@ public void Configure(ISiloBuilder builder, string name, IConfigurationSection c
}
}
}
}));
});
};
}
}
50 changes: 25 additions & 25 deletions test/Extensions/TesterAzureUtils/Streaming/AQStreamingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@ public class AQStreamingTests : TestClusterPerTest
protected override void ConfigureTestCluster(TestClusterBuilder builder)
{
TestUtils.CheckForAzureStorage();
builder.AddSiloBuilderConfigurator<SiloBuilderConfigurator>();
builder.AddClientBuilderConfigurator<MyClientBuilderConfigurator>();
}

private class MyClientBuilderConfigurator : IClientBuilderConfigurator
{
public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
builder.ConfigureHostConfiguration(cb =>
{
clientBuilder
.AddAzureQueueStreams(AzureQueueStreamProviderName, b=>
b.ConfigureAzureQueue(ob=>ob.Configure<IOptions<ClusterOptions>>(
(options, dep) =>
{
options.ConfigureTestDefaults();
options.QueueNames = AzureQueueUtilities.GenerateQueueNames(dep.Value.ClusterId, queueCount);
})));
}
Dictionary<string, string> queueConfig = [];
void ConfigureStreaming(string option, string value)
{
var prefix = $"Orleans:Streaming:{AzureQueueStreamProviderName}:";
queueConfig[$"{prefix}{option}"] = value;
}

ConfigureStreaming("ProviderType", "AzureQueueStorage");
ConfigureStreaming("ConnectionString", TestDefaultConfiguration.UseAadAuthentication
? TestDefaultConfiguration.DataBlobUri.AbsoluteUri
: TestDefaultConfiguration.DataConnectionString);

var names = AzureQueueUtilities.GenerateQueueNames(builder.Options.ClusterId, queueCount);
for (var i = 0; i < names.Count; i++)
{
ConfigureStreaming($"QueueNames:{i}", names[i]);
}

cb.AddInMemoryCollection(queueConfig);
});

builder.AddSiloBuilderConfigurator<SiloBuilderConfigurator>();
}

private class SiloBuilderConfigurator : ISiloConfigurator
Expand All @@ -56,14 +63,7 @@ public void Configure(ISiloBuilder hostBuilder)
options.ConfigureTestDefaults();
options.DeleteStateOnClear = true;
}))
.AddMemoryGrainStorage("MemoryStore")
.AddAzureQueueStreams(AzureQueueStreamProviderName, c=>
c.ConfigureAzureQueue(ob => ob.Configure<IOptions<ClusterOptions>>(
(options, dep) =>
{
options.ConfigureTestDefaults();
options.QueueNames = AzureQueueUtilities.GenerateQueueNames(dep.Value.ClusterId, queueCount);
})));
.AddMemoryGrainStorage("MemoryStore");
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public async Task AQ_06_ManyDifferent_ManyProducerGrainManyConsumerClients()
await runner.StreamTest_06_ManyDifferent_ManyProducerGrainManyConsumerClients();
}

[SkippableFact(Skip="https://github.com/dotnet/orleans/issues/5648"), TestCategory("Functional")]
[SkippableFact(Skip = "https://github.com/dotnet/orleans/issues/5648"), TestCategory("Functional")]
public async Task AQ_07_ManyDifferent_ManyProducerClientsManyConsumerGrains()
{
await runner.StreamTest_07_ManyDifferent_ManyProducerClientsManyConsumerGrains();
Expand Down

0 comments on commit dcafdc5

Please sign in to comment.