Skip to content

Commit

Permalink
Run strategy unit tests serially. Decrease load a bit on integration …
Browse files Browse the repository at this point in the history
…tests.
  • Loading branch information
James Blair committed Aug 8, 2024
1 parent 83798d0 commit 42bf303
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 23 deletions.
46 changes: 23 additions & 23 deletions Rucksack.Tests/BasicIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BasicIntegrationTests(ITestOutputHelper testOutputHelper)
public async Task BasicOneShotIntegrationTest()
{
int executionCount = 0;
const int count = 1000;
const int count = 250;

await LoadTestRunner.Run(() =>
{
Expand All @@ -34,7 +34,7 @@ await LoadTestRunner.Run(() =>
public async Task BasicRepeatIntegrationTest()
{
int executionCount = 0;
const int count = 10;
const int count = 5;
const int intervalSeconds = 1;
const int durationSeconds = 10;

Expand All @@ -61,10 +61,10 @@ await LoadTestRunner.Run(() =>
public async Task BasicSteppedBurstIntegrationTest()
{
int executionCount = 0;
const int step = 10;
const int from = 10;
const int to = 50;
const int expected = 150; // 10 + 20 + 30 + 40 + 50
const int step = 5;
const int from = 5;
const int to = 25;
const int expected = 75; // 5 + 10 + 15 + 20 + 25

await LoadTestRunner.Run(() =>
{
Expand All @@ -89,8 +89,8 @@ public async Task BasicConstantUserLoadIntegrationTest()
// so we can expect this strategy to spawn 10 each second

int executionCount = 0;
const int count = 10;
const int expected = 50;
const int count = 5;
const int expected = 25;

await LoadTestRunner.Run(() =>
{
Expand All @@ -112,11 +112,11 @@ await LoadTestRunner.Run(() =>
public async Task BasicConstantUserLoadIntegrationTest_WithLongRunningTask()
{
// Only the first task will take a while to run, so we would
// expect it to launch in a pattern of [10, 9, 9, 9, 9] for a total of 46
// expect it to launch in a pattern of [5, 4, 4, 4, 4] for a total of 21

int executionCount = 0;
const int count = 10;
const int expected = 46;
const int count = 5;
const int expected = 21;

await LoadTestRunner.Run(async () =>
{
Expand Down Expand Up @@ -145,10 +145,10 @@ public async Task BasicSteppedUserLoadIntegrationTest()
// so we can expect this strategy to spawn 10-50 each second

int executionCount = 0;
const int step = 10;
const int from = 10;
const int to = 50;
const int expected = 150;
const int step = 5;
const int from = 5;
const int to = 25;
const int expected = 75;

await LoadTestRunner.Run(() =>
{
Expand All @@ -170,13 +170,13 @@ await LoadTestRunner.Run(() =>
public async Task BasicSteppedUserLoadIntegrationTest_WithLongRunningTask()
{
// Only the first task will take a while to run, so we would
// expect it to launch in a pattern of [10, 19, 29, 39, 49] for a total of 146
// expect it to launch in a pattern of [5, 9, 14, 19, 24] for a total of 71

int executionCount = 0;
const int step = 10;
const int from = 10;
const int to = 50;
const int expected = 146;
const int step = 5;
const int from = 5;
const int to = 25;
const int expected = 71;

await LoadTestRunner.Run(async () =>
{
Expand All @@ -202,8 +202,8 @@ await LoadTestRunner.Run(async () =>
public async Task BasicSequentialUserLoadIntegrationTest_OneShot()
{
int executionCount = 0;
const int count = 10;
const int expected = 50;
const int count = 5;
const int expected = 25;

await LoadTestRunner.Run(() =>
{
Expand Down Expand Up @@ -232,7 +232,7 @@ await LoadTestRunner.Run(() =>
public async Task RandomDelayRepeatIntegrationTest()
{
int executionCount = 0;
const int count = 10;
const int count = 5;
const int intervalSeconds = 1;
const int durationSeconds = 5;

Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/ConstantUserLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class ConstantUserLoadStrategyTests
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/OneShotLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class OneShotLoadStrategyTests
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/RepeatBurstLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class RepeatBurstLoadStrategyTests
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/SequentialLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class SequentialLoadStrategyTests
{
[Fact]
Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/SteppedBurstLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class SteppedBurstLoadStrategyTests
{
[InlineData(1, 1, 2, 3)] // generated load = [1, 2] for a total of 3
Expand Down
1 change: 1 addition & 0 deletions Rucksack.Tests/Strategies/SteppedUserLoadStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Rucksack.Tests.Strategies;

[Collection(TestCollections.StrategyTests)]
public class SteppedUserLoadStrategyTests
{
[Fact]
Expand Down
4 changes: 4 additions & 0 deletions Rucksack.Tests/Strategies/StrategyTestCollectionDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Rucksack.Tests.Strategies;

[CollectionDefinition(TestCollections.StrategyTests, DisableParallelization = true)]
public class StrategyTestCollectionDefinition;
6 changes: 6 additions & 0 deletions Rucksack.Tests/TestCollections.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Rucksack.Tests;

public static class TestCollections
{
public const string StrategyTests = "StrategyTests";
}

0 comments on commit 42bf303

Please sign in to comment.