Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.
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
4 changes: 4 additions & 0 deletions Analytics/Flush/AsyncIntervalFlushHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ private async Task PerformFlush()
{
await FlushImpl();
}
catch
{
Logger.Error("Flush couldn't be completed");
}
finally
{
_semaphore.Release();
Expand Down
12 changes: 12 additions & 0 deletions Test.Net35/Flush/AsyncIntervalFlushHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ public void IntervalFlushTriggerTwoConcurrentProcesses()
_mockRequestHandler.Verify(r => r.MakeRequest(It.IsAny<Batch>()), times: Times.Exactly(2));
}

[Test]
public void FlushCatchExceptions()
{
_mockRequestHandler.Setup(r => r.MakeRequest(It.IsAny<Batch>())).Throws<System.Exception>();

_ = _handler.Process(new Track(null, null, null, null));

_handler.Flush();

_mockRequestHandler.Verify(r => r.MakeRequest(It.IsAny<Batch>()), times: Times.Exactly(1));
}

[Test]
public void IntervalFlushSendsBatchesThatAreSmallerThan512Kb()
{
Expand Down
2 changes: 1 addition & 1 deletion Test.Net35/Stats/StatisticsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NUnit.Framework;
using Segment.Stats;

namespace Segment.Net35.Stats
namespace Segment.Test.Stats
{
[TestFixture]
public class StatisticsTests
Expand Down
12 changes: 12 additions & 0 deletions Test.Net45/Flush/AsyncIntervalFlushHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ public async Task IntervalFlushSendsBatchesThatAreSmallerThan512Kb()

}

[Test]
public void FlushCatchExceptions()
{
_mockRequestHandler.Setup(r => r.MakeRequest(It.IsAny<Batch>())).Throws<System.Exception>();

_ = _handler.Process(new Track(null, null, null, null));

_handler.Flush();

_mockRequestHandler.Verify(r => r.MakeRequest(It.IsAny<Batch>()), times: Times.Exactly(1));
}

[Test]
public async Task BatchMeetTheMaxNumberOfActions()
{
Expand Down
12 changes: 12 additions & 0 deletions Test.NetStandard20/Flush/AsyncIntervalFlushHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ public async Task IntervalFlushSendsBatchesThatAreSmallerThan512Kb()

}

[Test]
public void FlushCatchExceptions()
{
_mockRequestHandler.Setup(r => r.MakeRequest(It.IsAny<Batch>())).Throws<System.Exception>();

_ = _handler.Process(new Track(null, null, null, null));

_handler.Flush();

_mockRequestHandler.Verify(r => r.MakeRequest(It.IsAny<Batch>()), times: Times.Exactly(1));
}

[Test]
public async Task BatchMeetTheMaxNumberOfActions()
{
Expand Down
12 changes: 12 additions & 0 deletions Test/Flush/AsyncIntervalFlushHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ public async Task BatchMeetTheMaxNumberOfActions()
_mockRequestHandler.Verify(r => r.MakeRequest(It.Is<Batch>(b => b.batch.Count == 5)), Times.Exactly(1));
}

[Test]
public void FlushCatchExceptions()
{
_mockRequestHandler.Setup(r => r.MakeRequest(It.IsAny<Batch>())).Throws<System.Exception>();

_ = _handler.Process(new Track(null, null, null, null));

_handler.Flush();

_mockRequestHandler.Verify(r => r.MakeRequest(It.IsAny<Batch>()), times: Times.Exactly(1));
}

private string GetEventName(int size)
{
return string.Join("", Enumerable.Range(0, size).Select(_ => "a"));
Expand Down