Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/actions/dotnet-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
framework:
description: Target framework.
required: true
max-parallel-test-modules:
description: Maximum number of test modules to execute concurrently.
required: false
default: '1'
result-id:
description: Unique test result identifier.
required: true
Expand Down Expand Up @@ -66,7 +70,7 @@ runs:
'--report-trx-filename'
'test_results_${{ inputs.result-id }}_{asm}_{tfm}_{arch}.trx'
'--max-parallel-test-modules'
'1'
'${{ inputs.max-parallel-test-modules }}'
)
./.github/scripts/invoke-test.ps1 -ResultFilePattern 'test_results_${{ inputs.result-id }}_*.trx' -Command $command
- name: Test with coverage
Expand Down Expand Up @@ -97,7 +101,7 @@ runs:
'--report-trx-filename'
'test_results_${{ inputs.result-id }}_{asm}_{tfm}_{arch}.trx'
'--max-parallel-test-modules'
'1'
'${{ inputs.max-parallel-test-modules }}'
)
./.github/scripts/invoke-coverage.ps1 -Settings ./.github/coverage.config.xml -Output "TestResults/${{ inputs.coverage-id }}.cobertura.xml" -RetryLogFile "logs/${{ inputs.coverage-id }}.retry.log" -Command $command
- name: Validate coverage report
Expand Down
6 changes: 6 additions & 0 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
framework:
description: Target framework.
required: true
max-parallel-test-modules:
description: Maximum number of test modules to execute concurrently.
required: false
default: '1'
provider:
description: Provider trait selected by the standard CI filter.
required: false
Expand All @@ -39,6 +43,7 @@ runs:
coverage-id: ${{ inputs.artifact-name }}
filter-query: ${{ inputs.filter-query || format('/[(Provider={0})&((Suite=BVT)|(Suite=SlowBVT)|(Suite=Functional))&(Category!=Performance)&(Category!=Stress)]', inputs.provider) }}
framework: ${{ inputs.framework }}
max-parallel-test-modules: ${{ inputs.max-parallel-test-modules }}
result-id: ${{ inputs.retry == 'true' && format('{0}-attempt1', inputs.artifact-name) || inputs.artifact-name }}
coverage: ${{ runner.os == 'Linux' && inputs.framework == 'net10.0' }}
env:
Expand All @@ -53,6 +58,7 @@ runs:
coverage-id: ${{ inputs.artifact-name }}
filter-query: ${{ inputs.filter-query || format('/[(Provider={0})&((Suite=BVT)|(Suite=SlowBVT)|(Suite=Functional))&(Category!=Performance)&(Category!=Stress)]', inputs.provider) }}
framework: ${{ inputs.framework }}
max-parallel-test-modules: ${{ inputs.max-parallel-test-modules }}
result-id: ${{ format('{0}-attempt2', inputs.artifact-name) }}
coverage: ${{ runner.os == 'Linux' && inputs.framework == 'net10.0' }}
env:
Expand Down
8 changes: 8 additions & 0 deletions .github/actions/run-tests/test-fixture/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: Test filter forwarded by run-tests.
framework:
description: Target framework forwarded by run-tests.
max-parallel-test-modules:
description: Maximum concurrent test modules forwarded by run-tests.
required: false
default: '1'
result-id:
description: Test result identifier for this attempt.
name:
Expand All @@ -27,13 +31,17 @@ runs:
'setup-test-environment' {
'TEST_RETRY_ATTEMPTS=0' >> $env:GITHUB_ENV
'TEST_RETRY_RESULT_IDS=' >> $env:GITHUB_ENV
'TEST_RETRY_MAX_PARALLEL_TEST_MODULES=' >> $env:GITHUB_ENV
}
'dotnet-test' {
$attempt = [int] $env:TEST_RETRY_ATTEMPTS + 1
"TEST_RETRY_ATTEMPTS=$attempt" >> $env:GITHUB_ENV
$resultIds = @($env:TEST_RETRY_RESULT_IDS, '${{ inputs.result-id }}') |
Where-Object { $_ }
"TEST_RETRY_RESULT_IDS=$($resultIds -join ',')" >> $env:GITHUB_ENV
$parallelModules = @($env:TEST_RETRY_MAX_PARALLEL_TEST_MODULES, '${{ inputs.max-parallel-test-modules }}') |
Where-Object { $_ }
"TEST_RETRY_MAX_PARALLEL_TEST_MODULES=$($parallelModules -join ',')" >> $env:GITHUB_ENV
Write-Output "Test attempt $attempt (${{ inputs.result-id }})"
if ($env:TEST_RETRY_FAILURE_MODE -eq 'always' -or
($env:TEST_RETRY_FAILURE_MODE -eq 'first' -and $attempt -eq 1)) {
Expand Down
29 changes: 4 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,37 +327,16 @@ jobs:
framework: ["net8.0", "net10.0"]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Start Azurite
run: |
set -euo pipefail

bash .github/scripts/docker-pull-with-retry.sh "$AZURITE_IMAGE"

docker run -d --pull=never --name azurite \
-p 10000:10000 \
-p 10001:10001 \
-p 10002:10002 \
"$AZURITE_IMAGE" \
azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --skipApiVersionCheck
- name: Wait for Azurite
run: |
echo "Waiting for Azurite to be ready..."
timeout 60 bash -c 'until nc -z localhost 10000 && nc -z localhost 10001 && nc -z localhost 10002; do sleep 1; done'
echo "Azurite is ready"
- name: Verify Linux Docker
run: test "$(docker info --format '{{.OSType}}')" = "linux"
# Each test module starts an isolated Azurite Testcontainer on dynamic ports.
- name: Test
uses: ./.github/actions/run-tests
with:
artifact-name: test_output_${{ github.job }}_${{ matrix.framework }}
framework: ${{ matrix.framework }}
max-parallel-test-modules: 2
provider: AzureStorage
env:
# [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Not a secret")]
# [SuppressMessage("Microsoft.Security", "CSCAN0090:ConfigFile", Justification="Not a secret")]
# [SuppressMessage("Microsoft.Security", "CSCAN0220:DefaultPasswordContexts", Justification="Not a secret")]
ORLEANSDATACONNECTIONSTRING: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
- name: Clean up Azurite
if: always()
run: docker rm -f azurite || true
test-azure-eventhubs:
name: Azure Event Hubs provider tests
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-action-retry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ jobs:
retention: 1
- scenario: second attempt succeeds
retry: 'true'
max-parallel-test-modules: '2'
failure-mode: first
outcome: success
attempts: 2
result-ids: retry-contract-attempt1,retry-contract-attempt2
retention: 1
- scenario: both attempts fail
retry: 'true'
max-parallel-test-modules: '2'
failure-mode: always
outcome: failure
attempts: 2
Expand Down Expand Up @@ -78,6 +80,7 @@ jobs:
with:
artifact-name: retry-contract
framework: net10.0
max-parallel-test-modules: ${{ matrix.max-parallel-test-modules || '1' }}
provider: Cosmos
retry: ${{ matrix.retry }}
env:
Expand All @@ -91,12 +94,14 @@ jobs:
Attempts = '${{ matrix.attempts }}'
ResultIds = '${{ matrix.result-ids }}'
Retention = '${{ matrix.retention }}'
ParallelModules = (@('${{ matrix.max-parallel-test-modules || '1' }}') * [int]'${{ matrix.attempts }}') -join ','
}
$actual = @{
Outcome = '${{ steps.partition.outcome }}'
Attempts = $env:TEST_RETRY_ATTEMPTS
ResultIds = $env:TEST_RETRY_RESULT_IDS
Retention = $env:TEST_RETRY_RETENTION
ParallelModules = $env:TEST_RETRY_MAX_PARALLEL_TEST_MODULES
}
foreach ($key in $expected.Keys) {
if ($actual[$key] -cne $expected[$key]) {
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ dotnet test --solution Orleans.slnx --framework net10.0 --filter-trait "Category
dotnet test --project test/Orleans.Core.Tests/Orleans.Core.Tests.csproj --framework net10.0 --filter-class "*MyTestClass*" --filter-method "*MyTestMethod*" --minimum-expected-tests 1
```

Azure Storage provider tests start a pinned Azurite Testcontainer when neither an Azure Storage connection string nor AAD configuration is supplied. Keep a Docker-compatible runtime running in Linux-container mode; Testcontainers allocates ports and cleans up the container. Local tests skip when the initial Docker availability check fails. CI (`CI`, `GITHUB_ACTIONS`, or `TF_BUILD` set to `true`) requires Linux Docker and reports availability failures as test failures. Container startup receives a five-minute cancellation deadline; startup errors and cancellation fail tests in every environment. To run against an existing emulator or Azure Storage account, set the corresponding `OrleansDataConnectionString` or AAD settings before starting the test process.

Azure grain storage and transaction benchmarks require an explicit `OrleansDataConnectionString` for the storage account or emulator being measured. Azure Blob streaming benchmarks also support the AAD settings. Configure the intended backend before launching the benchmark; missing connection settings produce a benchmark-specific configuration error.

### Work on an application with local source

For an application which needs to exercise an unreleased change, reference the relevant project under `src` instead of the published NuGet package. For example, reference `src/Orleans.Core/Orleans.Core.csproj` from the application project and build the application together with the Orleans solution. This lets the debugger step into the local Orleans source.
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<PackageVersion Include="System.Reactive" Version="6.1.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Testcontainers" Version="4.10.0" />
<PackageVersion Include="Testcontainers.Azurite" Version="4.10.0" />
<PackageVersion Include="Testcontainers.Consul" Version="4.10.0" />
<PackageVersion Include="Utf8Json" Version="1.3.7" />
<PackageVersion Include="Verify.XunitV3" Version="29.5.0" />
Expand Down
12 changes: 11 additions & 1 deletion test/Benchmarks/GrainStorage/GrainStorageBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public class SiloAzureTableStorageConfigurator : ISiloConfigurator
{
public void Configure(ISiloBuilder hostBuilder)
{
if (string.IsNullOrWhiteSpace(TestDefaultConfiguration.DataConnectionString))
{
throw new InvalidOperationException("OrleansDataConnectionString must be set for Azure Table grain storage benchmarks.");
}

hostBuilder.AddAzureTableGrainStorageAsDefault(options =>
{
options.TableServiceClient = new(TestDefaultConfiguration.DataConnectionString);
Expand All @@ -77,6 +82,11 @@ public class SiloAzureBlobStorageConfigurator : ISiloConfigurator
{
public void Configure(ISiloBuilder hostBuilder)
{
if (string.IsNullOrWhiteSpace(TestDefaultConfiguration.DataConnectionString))
{
throw new InvalidOperationException("OrleansDataConnectionString must be set for Azure Blob grain storage benchmarks.");
}

hostBuilder.AddAzureBlobGrainStorageAsDefault(options =>
{
options.BlobServiceClient = new(TestDefaultConfiguration.DataConnectionString);
Expand All @@ -90,7 +100,7 @@ public void Configure(ISiloBuilder hostBuilder)
{
hostBuilder.AddAdoNetGrainStorageAsDefault(options =>
{
options.ConnectionString = TestDefaultConfiguration.DataConnectionString!; // The benchmark requires the configured ADO.NET test connection.
options.ConnectionString = TestDefaultConfiguration.MsSqlConnectionString!;
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/Benchmarks/Transactions/TransactionBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public class SiloAzureStorageConfigurator : ISiloConfigurator
{
public void Configure(ISiloBuilder hostBuilder)
{
if (string.IsNullOrWhiteSpace(TestDefaultConfiguration.DataConnectionString))
{
throw new InvalidOperationException("OrleansDataConnectionString must be set for Azure Table transaction benchmarks.");
}

hostBuilder.AddAzureTableTransactionalStateStorageAsDefault(options =>
{
options.TableServiceClient = new(TestDefaultConfiguration.DataConnectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static TableServiceClient GetTableServiceClient()
var clientOptions = GetTableClientOptions();
return TestDefaultConfiguration.UseAadAuthentication
? new(TestDefaultConfiguration.TableEndpoint, TestDefaultConfiguration.TokenCredential, clientOptions)
: new(TestDefaultConfiguration.DataConnectionString, clientOptions);
: new(TestDefaultConfiguration.AzureStorageConnectionString, clientOptions);
}

internal static TableClientOptions GetTableClientOptions()
Expand Down Expand Up @@ -60,42 +60,27 @@ public static Orleans.Reminders.AzureStorage.AzureStorageOperationOptions Config

public static Orleans.Configuration.AzureBlobStorageOptions ConfigureTestDefaults(this Orleans.Configuration.AzureBlobStorageOptions options)
{
if (TestDefaultConfiguration.UseAadAuthentication)
{
options.BlobServiceClient = new(TestDefaultConfiguration.DataBlobUri, TestDefaultConfiguration.TokenCredential);
}
else
{
options.BlobServiceClient = new(TestDefaultConfiguration.DataConnectionString);
}
options.BlobServiceClient = TestDefaultConfiguration.UseAadAuthentication
? new(TestDefaultConfiguration.DataBlobUri, TestDefaultConfiguration.TokenCredential)
: new(TestDefaultConfiguration.AzureStorageConnectionString);

return options;
}

public static Orleans.Configuration.AzureQueueOptions ConfigureTestDefaults(this Orleans.Configuration.AzureQueueOptions options)
{
if (TestDefaultConfiguration.UseAadAuthentication)
{
options.QueueServiceClient = new(TestDefaultConfiguration.DataQueueUri, TestDefaultConfiguration.TokenCredential);
}
else
{
options.QueueServiceClient = new(TestDefaultConfiguration.DataConnectionString);
}
options.QueueServiceClient = TestDefaultConfiguration.UseAadAuthentication
? new(TestDefaultConfiguration.DataQueueUri, TestDefaultConfiguration.TokenCredential)
: new(TestDefaultConfiguration.AzureStorageConnectionString);

return options;
}

public static Orleans.Configuration.AzureBlobLeaseProviderOptions ConfigureTestDefaults(this Orleans.Configuration.AzureBlobLeaseProviderOptions options)
{
if (TestDefaultConfiguration.UseAadAuthentication)
{
options.BlobServiceClient = new(TestDefaultConfiguration.DataBlobUri, TestDefaultConfiguration.TokenCredential);
}
else
{
options.BlobServiceClient = new(TestDefaultConfiguration.DataConnectionString);
}
options.BlobServiceClient = TestDefaultConfiguration.UseAadAuthentication
? new(TestDefaultConfiguration.DataBlobUri, TestDefaultConfiguration.TokenCredential)
: new(TestDefaultConfiguration.AzureStorageConnectionString);

return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Xunit;
using Microsoft.Extensions.Logging;
using Orleans.Testing.Reminders;
using TestExtensions;
using UnitTests.TimerTests;
using Orleans.Internal;

Expand Down Expand Up @@ -101,7 +102,8 @@ public override async ValueTask DisposeAsync()
}
}

public ReminderTests_AzureTable(Fixture fixture) : base(fixture.ReminderClock, fixture.HostedCluster)
public ReminderTests_AzureTable(Fixture fixture)
: base(fixture.ReminderClock, fixture.HostedCluster, TestDefaultConfiguration.UseAzurite ? 2 : 1)
{
_fixture = fixture;
fixture.EnsurePreconditionsMet();
Expand Down
32 changes: 28 additions & 4 deletions test/Extensions/Orleans.Azure.Tests/StorageEmulatorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,36 @@ public static class StorageEmulatorUtilities
{
public static void EnsureEmulatorIsNotUsed()
{
if (TestDefaultConfiguration.DataConnectionString is { Length: > 0 } connectionString
&& (connectionString.Contains("UseDevelopmentStorage", StringComparison.OrdinalIgnoreCase)
|| connectionString.Contains("devstoreaccount", StringComparison.OrdinalIgnoreCase)))
var skipReason = GetUnsupportedEmulatorSkipReason(
TestDefaultConfiguration.UseAadAuthentication,
TestDefaultConfiguration.UseAzurite,
TestDefaultConfiguration.DataConnectionString);
if (skipReason is not null)
{
throw Xunit.Sdk.SkipException.ForSkip(skipReason);
}
}

internal static string? GetUnsupportedEmulatorSkipReason(
bool useAadAuthentication,
bool useAzurite,
string? dataConnectionString)
{
if (useAadAuthentication)
{
throw Xunit.Sdk.SkipException.ForSkip("This test does not support the storage emulator.");
return null;
}

if (useAzurite)
{
return "This test does not support Azurite.";
}

return dataConnectionString is { Length: > 0 } connectionString
&& (connectionString.Contains("UseDevelopmentStorage", StringComparison.OrdinalIgnoreCase)
|| connectionString.Contains("devstoreaccount", StringComparison.OrdinalIgnoreCase))
? "This test does not support the storage emulator."
: null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Xunit;

namespace Tester.AzureUtils;

[TestCategory("BVT")]
[TestSuite("BVT")]
[TestProvider("None")]
[TestArea("Persistence")]
public class StorageEmulatorUtilitiesTests
{
[Fact]
public void DefaultAzuriteIsRejectedWithoutResolvingConnectionString()
{
var reason = StorageEmulatorUtilities.GetUnsupportedEmulatorSkipReason(
useAadAuthentication: false,
useAzurite: true,
dataConnectionString: null);

Assert.Equal("This test does not support Azurite.", reason);
}

[Fact]
public void ExplicitCloudStorageIsAccepted()
{
var reason = StorageEmulatorUtilities.GetUnsupportedEmulatorSkipReason(
useAadAuthentication: false,
useAzurite: false,
dataConnectionString: "DefaultEndpointsProtocol=https;AccountName=account");

Assert.Null(reason);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void ConfigureStreaming(string option, string? value)
}
else
{
ConfigureStreaming("ConnectionString", TestDefaultConfiguration.DataConnectionString);
ConfigureStreaming("ConnectionString", TestDefaultConfiguration.AzureStorageConnectionString);
}

var names = AzureQueueUtilities.GenerateQueueNames(builder.Options.ClusterId, queueCount);
Expand Down
Loading
Loading