Skip to content
Merged
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
3 changes: 0 additions & 3 deletions eng/Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<PropertyGroup>
<TestResultsDirectory>$([MSBuild]::ValueOrDefault('$(TestResultsDirectory)', '$([System.IO.Path]::Combine($(ArtifactsPath), 'tests'))'))</TestResultsDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(TestResultsDirectory)' != '' ">
<_TestingPlatformCommandLineArguments>--results-directory %22$(TestResultsDirectory)%22</_TestingPlatformCommandLineArguments>
</PropertyGroup>
<PropertyGroup>
<_TestingPlatformCommandLineArguments>$(_TestingPlatformCommandLineArguments) --coverage</_TestingPlatformCommandLineArguments>
<_TestingPlatformCommandLineArguments Condition=" '$(CoverageFormat)' != '' ">$(_TestingPlatformCommandLineArguments) --coverage-output-format %22$(CoverageFormat)%22</_TestingPlatformCommandLineArguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,42 @@ public async Task OnActionPreExecute_HalfOpen()
called.ShouldBeTrue();
}

[Fact]
public async Task OnActionPreExecute_HalfOpen_OnHalfOpenedNotCompleted_WaitsForCompletion()
{
// arrange
var context = ResilienceContextPool.Shared.Get(TestCancellation.Token);
var halfOpenedStarted = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
var halfOpenedCanComplete = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);

_options.OnHalfOpened = async _ =>
{
halfOpenedStarted.SetResult(true);
await halfOpenedCanComplete.Task;
};

using var controller = CreateController();

await OpenCircuit(controller, Outcome.FromResult(10));
AdvanceTime(_options.BreakDuration);

// act
var pending = controller.OnActionPreExecuteAsync(context);

// assert
await halfOpenedStarted.Task;

pending.IsCompleted.ShouldBeFalse();
controller.CircuitState.ShouldBe(CircuitState.HalfOpen);

halfOpenedCanComplete.SetResult(true);

var outcome = await pending;

outcome.ShouldBeNull();
controller.CircuitState.ShouldBe(CircuitState.HalfOpen);
}

[InlineData(CircuitState.HalfOpen, CircuitState.Closed)]
[InlineData(CircuitState.Isolated, CircuitState.Isolated)]
[InlineData(CircuitState.Closed, CircuitState.Closed)]
Expand Down
Loading