-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed foreign key constraints from all tables (#46)
Also: * Minor documentation updates * Incremented version to v0.10.1-beta * Added sub-orchestration stress test (exclude from CI)
- Loading branch information
Showing
7 changed files
with
111 additions
and
13 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
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
76 changes: 76 additions & 0 deletions
76
test/DurableTask.SqlServer.Tests/Integration/StressTests.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,76 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
namespace DurableTask.SqlServer.Tests.Integration | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using DurableTask.SqlServer.Tests.Utils; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
/// <summary> | ||
/// Integration tests that are intended to reveal issues related to load or concurrency. | ||
/// These tests are expected to take longer to complete compared to functional integration | ||
/// tests and therefore may not be appropriate for all CI or rapid testing scenarios. | ||
/// </summary> | ||
[Trait("Category", "Stress")] | ||
public class StressTests : IAsyncLifetime | ||
{ | ||
readonly TestService testService; | ||
|
||
public StressTests(ITestOutputHelper output) | ||
{ | ||
this.testService = new TestService(output); | ||
} | ||
|
||
Task IAsyncLifetime.InitializeAsync() => this.testService.InitializeAsync(); | ||
|
||
Task IAsyncLifetime.DisposeAsync() => this.testService.DisposeAsync(); | ||
|
||
// This test has previously been used to uncover various deadlock issues by stressing the code paths | ||
// related to foreign keys that point to the Instances and Payloads tables. | ||
// Example: https://github.com/microsoft/durabletask-mssql/issues/45 | ||
[Theory] | ||
[InlineData(10)] | ||
[InlineData(2000)] | ||
public async Task ParallelSubOrchestrations(int subOrchestrationCount) | ||
{ | ||
const string SubOrchestrationName = "SubOrchestration"; | ||
|
||
this.testService.RegisterInlineOrchestration<DateTime, string>( | ||
orchestrationName: SubOrchestrationName, | ||
version: "", | ||
implementation: async (ctx, input) => | ||
{ | ||
await ctx.CreateTimer(DateTime.MinValue, input); | ||
return ctx.CurrentUtcDateTime; | ||
}); | ||
|
||
TestInstance<int> testInstance = await this.testService.RunOrchestration( | ||
input: 1, | ||
orchestrationName: nameof(ParallelSubOrchestrations), | ||
implementation: async (ctx, input) => | ||
{ | ||
var listInstances = new List<Task<DateTime>>(); | ||
for (int i = 0; i < subOrchestrationCount; i++) | ||
{ | ||
Task<DateTime> instance = ctx.CreateSubOrchestrationInstance<DateTime>( | ||
name: SubOrchestrationName, | ||
version: "", | ||
instanceId: $"suborchestration[{i}]", | ||
input: $"{i}"); | ||
listInstances.Add(instance); | ||
} | ||
DateTime[] results = await Task.WhenAll(listInstances); | ||
return new List<DateTime>(results); | ||
}); | ||
|
||
// On a fast Windows desktop machine, a 2000 sub-orchestration test should complete in 30-40 seconds. | ||
// On slower CI machines, this test could take several minutes to complete. | ||
await testInstance.WaitForCompletion(TimeSpan.FromMinutes(5)); | ||
} | ||
} | ||
} |