Skip to content

Commit

Permalink
IGNITE-18184 .NET: Fix flaky pooled buffer leak check (apache#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptupitsyn authored and lowka committed Apr 19, 2023
1 parent 1ba56a7 commit b39abc2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions modules/platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,13 @@ public void OneTimeTearDown()

Assert.Greater(_eventListener.BuffersRented, 0);

// Use WaitForCondition to check rented/returned buffers equality:
// Buffer pools are used by everything, including testing framework, internal .NET needs, etc.
var listener = _eventListener;
TestUtils.WaitForCondition(
condition: () => listener.BuffersReturned == listener.BuffersRented,
timeoutMs: 1000,
messageFactory: () => $"rented = {listener.BuffersRented}, returned = {listener.BuffersReturned}");
CheckPooledBufferLeak();

_eventListener.Dispose();
}

[TearDown]
public void TearDown()
{
Assert.AreEqual(_eventListener.BuffersReturned, _eventListener.BuffersRented);
}
public void TearDown() => CheckPooledBufferLeak();

protected static IIgniteTuple GetTuple(long id) => new IgniteTuple { [KeyCol] = id };

Expand All @@ -130,5 +121,16 @@ protected static IgniteClientConfiguration GetConfig() => new()
Endpoints = { "127.0.0.1:" + ServerNode.Port },
Logger = new ConsoleLogger { MinLevel = LogLevel.Trace }
};

private void CheckPooledBufferLeak()
{
// Use WaitForCondition to check rented/returned buffers equality:
// Buffer pools are used by everything, including testing framework, internal .NET needs, etc.
var listener = _eventListener;
TestUtils.WaitForCondition(
condition: () => listener.BuffersReturned == listener.BuffersRented,
timeoutMs: 1000,
messageFactory: () => $"rented = {listener.BuffersRented}, returned = {listener.BuffersReturned}");
}
}
}

0 comments on commit b39abc2

Please sign in to comment.