-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #986 from neoeinstein/supervisor-strategy-bad-time…
…outs Supervisor strategy bad timeouts
- Loading branch information
Showing
3 changed files
with
108 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using Akka.Actor; | ||
using Xunit; | ||
|
||
namespace Akka.Tests.Actor | ||
{ | ||
public class SupervisorStrategySpecs | ||
{ | ||
public static readonly object[][] RetriesTestData = new[] | ||
{ | ||
new object[] { new int?(), -1 }, | ||
new object[] { new int?(-1), -1 }, | ||
new object[] { new int?(0), 0 }, | ||
new object[] { new int?(5), 5 }, | ||
}; | ||
|
||
public static readonly object[][] TimeoutTestData = new[] | ||
{ | ||
new object[] { new TimeSpan?(), -1 }, | ||
new object[] { new TimeSpan?(System.Threading.Timeout.InfiniteTimeSpan), -1 }, | ||
new object[] { new TimeSpan?(TimeSpan.FromMilliseconds(0)), 0 }, | ||
new object[] { new TimeSpan?(TimeSpan.FromMilliseconds(100)), 100 }, | ||
new object[] { new TimeSpan?(TimeSpan.FromMilliseconds(100).Add(TimeSpan.FromTicks(75))), 100 }, | ||
new object[] { new TimeSpan?(TimeSpan.FromMilliseconds(10000)), 10000 }, | ||
}; | ||
|
||
[Theory] | ||
[MemberData("RetriesTestData")] | ||
public void A_constructed_OneForOne_supervisor_strategy_with_nullable_retries_has_the_expected_properties(int? retries, int expectedRetries) | ||
{ | ||
var uut = new OneForOneStrategy(retries, null, exn => Directive.Restart); | ||
|
||
Assert.Equal(uut.MaxNumberOfRetries, expectedRetries); | ||
} | ||
|
||
[Theory] | ||
[MemberData("TimeoutTestData")] | ||
public void A_constructed_OneForOne_supervisor_strategy_with_nullable_timeouts_has_the_expected_properties(TimeSpan? timeout, int expectedTimeoutMilliseconds) | ||
{ | ||
var uut = new OneForOneStrategy(-1, timeout, exn => Directive.Restart); | ||
|
||
Assert.Equal(uut.WithinTimeRangeMilliseconds, expectedTimeoutMilliseconds); | ||
} | ||
|
||
[Theory] | ||
[MemberData("RetriesTestData")] | ||
public void A_constructed_OneForOne_supervisor_strategy_with_nullable_retries_and_a_decider_has_the_expected_properties(int? retries, int expectedRetries) | ||
{ | ||
var uut = new OneForOneStrategy(retries, null, Decider.From(Directive.Restart)); | ||
|
||
Assert.Equal(uut.MaxNumberOfRetries, expectedRetries); | ||
} | ||
|
||
[Theory] | ||
[MemberData("TimeoutTestData")] | ||
public void A_constructed_OneForOne_supervisor_strategy_with_nullable_timeouts_and_a_decider_has_the_expected_properties(TimeSpan? timeout, int expectedTimeoutMilliseconds) | ||
{ | ||
var uut = new OneForOneStrategy(-1, timeout, Decider.From(Directive.Restart)); | ||
|
||
Assert.Equal(uut.WithinTimeRangeMilliseconds, expectedTimeoutMilliseconds); | ||
} | ||
|
||
[Theory] | ||
[MemberData("RetriesTestData")] | ||
public void A_constructed_AllForOne_supervisor_strategy_with_nullable_retries_has_the_expected_properties(int? retries, int expectedRetries) | ||
{ | ||
var uut = new AllForOneStrategy(retries, null, exn => Directive.Restart); | ||
|
||
Assert.Equal(uut.MaxNumberOfRetries, expectedRetries); | ||
} | ||
|
||
[Theory] | ||
[MemberData("TimeoutTestData")] | ||
public void A_constructed_AllForOne_supervisor_strategy_with_nullable_timeouts_has_the_expected_properties(TimeSpan? timeout, int expectedTimeoutMilliseconds) | ||
{ | ||
var uut = new AllForOneStrategy(-1, timeout, exn => Directive.Restart); | ||
|
||
Assert.Equal(uut.WithinTimeRangeMilliseconds, expectedTimeoutMilliseconds); | ||
} | ||
|
||
[Theory] | ||
[MemberData("RetriesTestData")] | ||
public void A_constructed_AllForOne_supervisor_strategy_with_nullable_retries_and_a_decider_has_the_expected_properties(int? retries, int expectedRetries) | ||
{ | ||
var uut = new OneForOneStrategy(retries, null, Decider.From(Directive.Restart)); | ||
|
||
Assert.Equal(uut.MaxNumberOfRetries, expectedRetries); | ||
} | ||
|
||
[Theory] | ||
[MemberData("TimeoutTestData")] | ||
public void A_constructed_AllForOne_supervisor_strategy_with_nullable_timeouts_and_a_decider_has_the_expected_properties(TimeSpan? timeout, int expectedTimeoutMilliseconds) | ||
{ | ||
var uut = new OneForOneStrategy(-1, timeout, Decider.From(Directive.Restart)); | ||
|
||
Assert.Equal(uut.WithinTimeRangeMilliseconds, expectedTimeoutMilliseconds); | ||
} | ||
} | ||
} |
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