Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Sep 17, 2024
1 parent fbff9be commit 55ebdc4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/Elastic.Channels.Continuous/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Threading.Channels;
Expand Down
4 changes: 2 additions & 2 deletions src/Elastic.Channels/BufferedChannelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ async Task<bool> AsyncSlowPath(IOutboundBuffer<TEvent> b)
/// <inheritdoc cref="object.ToString"/>>
public override string ToString()
{
if (DiagnosticsListener == null) return base.ToString();
var sb = new StringBuilder();
if (DiagnosticsListener != null)
sb.AppendLine(DiagnosticsListener.ToString());
sb.AppendLine(DiagnosticsListener.ToString());
sb.AppendLine($"{nameof(InflightEvents)}: {InflightEvents:N0}");
sb.AppendLine($"{nameof(BufferOptions.InboundBufferMaxSize)}: {BufferOptions.InboundBufferMaxSize:N0}");
sb.AppendLine($"{nameof(BatchExportOperations)}: {BatchExportOperations:N0}");
Expand Down
6 changes: 3 additions & 3 deletions tests/Elastic.Channels.Tests/BehaviorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ Task StartChannel(int taskNumber)
[Fact] public async Task SlowlyPushEvents()
{
int totalEvents = 50_000_000, maxInFlight = totalEvents / 5, bufferSize = maxInFlight / 10;
var expectedSentBuffers = totalEvents / bufferSize;
var expectedSentBuffers = totalEvents / 10_000;
var bufferOptions = new BufferOptions
{
WaitHandle = new CountdownEvent(expectedSentBuffers),
InboundBufferMaxSize = maxInFlight,
OutboundBufferMaxSize = 10_000,
OutboundBufferMaxLifetime = TimeSpan.FromMilliseconds(100)
OutboundBufferMaxLifetime = TimeSpan.FromMilliseconds(1000)
};
using var channel = new DiagnosticsBufferedChannel(bufferOptions, name: $"Slow push channel");
await Task.Delay(TimeSpan.FromMilliseconds(200));
Expand All @@ -175,7 +175,7 @@ [Fact] public async Task SlowlyPushEvents()
}
}, TaskCreationOptions.LongRunning);
// wait for some work to have progressed
bufferOptions.WaitHandle.Wait(TimeSpan.FromMilliseconds(500));
bufferOptions.WaitHandle.Wait(TimeSpan.FromMilliseconds(2000));
//Ensure we written to the channel but not enough to satisfy OutboundBufferMaxSize
written.Should().BeGreaterThan(0).And.BeLessThan(10_000);
//even though OutboundBufferMaxSize was not hit we should still observe an invocation to Export()
Expand Down

0 comments on commit 55ebdc4

Please sign in to comment.