Skip to content

Commit

Permalink
More improvements to chaos testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy D. Miller authored and Jeremy D. Miller committed Apr 18, 2023
1 parent 463c6c4 commit 8c14775
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/Testing/ChaosTesting/ChaosDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void SendMessagesContinuously(string name, int batchSize, TimeSpan durati
while (DateTimeOffset.UtcNow < endingDate)
{
await bus.PublishAsync(new SendMessages(batchSize));
await Task.Delay(100.Milliseconds());
}
});
}
Expand Down
28 changes: 16 additions & 12 deletions src/Testing/ChaosTesting/ChaosSpecifications.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ChaosTesting.Scripts;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using Shouldly;
using Wolverine.RabbitMQ;
Expand Down Expand Up @@ -65,6 +66,9 @@ public ChaosSpecifications(ITestOutputHelper output)
var completed = await driver.WaitForAllMessagingToComplete(script.TimeOut);

completed.ShouldBeTrue();

// COOLDOWN!!!!
await Task.Delay(5.Seconds());
}

[Fact]
Expand Down Expand Up @@ -108,28 +112,28 @@ public ChaosSpecifications(ITestOutputHelper output)

[Fact]
public Task RabbitMqOneInlineListener_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqOneInlineListener);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqOneInlineListener);

[Fact]
public Task RabbitMqFiveParallelInlineListeners_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveParallelInlineListeners);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqFiveParallelInlineListeners);

[Fact]
public Task RabbitMqBufferedListener_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqBufferedListener);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqBufferedListener);

[Fact]
public Task RabbitMqFiveBufferedListeners_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveBufferedListeners);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqFiveBufferedListeners);


[Fact]
public Task RabbitMqDurableListener_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqDurableListener);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqDurableListener);

[Fact]
public Task RabbitMqFiveDurableListeners_Marten_ReceiverStartsLater() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveDurableListeners);
execute<MartenStorageStrategy, ReceiverStartsLater>(RabbitMqFiveDurableListeners);



Expand All @@ -138,28 +142,28 @@ public ChaosSpecifications(ITestOutputHelper output)

[Fact]
public Task RabbitMqOneInlineListener_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqOneInlineListener);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqOneInlineListener);

[Fact]
public Task RabbitMqFiveParallelInlineListeners_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveParallelInlineListeners);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqFiveParallelInlineListeners);

[Fact]
public Task RabbitMqBufferedListener_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqBufferedListener);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqBufferedListener);

[Fact]
public Task RabbitMqFiveBufferedListeners_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveBufferedListeners);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqFiveBufferedListeners);


[Fact]
public Task RabbitMqDurableListener_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqDurableListener);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqDurableListener);

[Fact]
public Task RabbitMqFiveDurableListeners_Marten_ReceiverGoesUpAndDown() =>
execute<MartenStorageStrategy, Simplistic>(RabbitMqFiveDurableListeners);
execute<MartenStorageStrategy, ReceiverGoesUpAndDown>(RabbitMqFiveDurableListeners);



Expand Down
3 changes: 3 additions & 0 deletions src/Testing/ChaosTesting/NoParallelization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Xunit;

[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
4 changes: 2 additions & 2 deletions src/Testing/ChaosTesting/Scripts/ReceiverGoesUpAndDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class ReceiverGoesUpAndDown : ChaosScript
{
public ReceiverGoesUpAndDown()
{
TimeOut = 1.Minutes();
TimeOut = 3.Minutes();
}

public override async Task Drive(ChaosDriver driver)
Expand All @@ -15,7 +15,7 @@ public override async Task Drive(ChaosDriver driver)
await driver.SendMessages("one", 1000);

await driver.StartSender("two");
driver.SendMessagesContinuously("two", 100, 10.Seconds());
driver.SendMessagesContinuously("two", 10, 10.Seconds());
await Task.Delay(1.Seconds());
await driver.StartReceiver("one");
await Task.Delay(3.Seconds());
Expand Down
12 changes: 7 additions & 5 deletions src/Wolverine/Configuration/IDelayedEndpointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ void IDelayedEndpointConfiguration.Apply()
lock (_locker)
{
var endpoint = _endpoint ?? _source!();

foreach (var action in _configurations) action(endpoint);

if (_endpoint != null)
if (endpoint.DelayedConfiguration.ToArray().Contains(this))
{
_endpoint.DelayedConfiguration.Remove(this);
foreach (var action in _configurations) action(endpoint);

if (endpoint.DelayedConfiguration.ToArray().Contains(this))
{
endpoint.DelayedConfiguration.Remove(this);
}
}
}
}
Expand Down

0 comments on commit 8c14775

Please sign in to comment.