This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 8d7c589e56 IGNITE-17993 .NET: Fix test flakiness due to pooled buffer 
count check (#1278)
8d7c589e56 is described below

commit 8d7c589e5637cb6cf395c70dc46e6235f095cdba
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon Oct 31 21:06:50 2022 +0300

    IGNITE-17993 .NET: Fix test flakiness due to pooled buffer count check 
(#1278)
---
 .../platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs   | 10 +++++++++-
 modules/platforms/dotnet/Apache.Ignite.Tests/TestUtils.cs     | 11 +++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs
index 37f8cf3f7a..8412ec9e0d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteTestsBase.cs
@@ -79,7 +79,15 @@ namespace Apache.Ignite.Tests
             Client?.Dispose();
 
             Assert.Greater(_eventListener.BuffersRented, 0);
-            Assert.AreEqual(_eventListener.BuffersReturned, 
_eventListener.BuffersRented);
+
+            // 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}");
+
             _eventListener.Dispose();
         }
 
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/TestUtils.cs 
b/modules/platforms/dotnet/Apache.Ignite.Tests/TestUtils.cs
index fa35d387a8..5feb90762d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/TestUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/TestUtils.cs
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Tests
 
         public static bool IsWindows => 
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
 
-        public static void WaitForCondition(Func<bool> condition, int 
timeoutMs = 1000)
+        public static void WaitForCondition(Func<bool> condition, int 
timeoutMs = 1000, Func<string>? messageFactory = null)
         {
             if (condition())
             {
@@ -52,7 +52,14 @@ namespace Apache.Ignite.Tests
                 Thread.Sleep(50);
             }
 
-            Assert.Fail("Condition not reached after " + sw.Elapsed);
+            var message = "Condition not reached after " + sw.Elapsed;
+
+            if (messageFactory != null)
+            {
+                message += $" ({messageFactory()})";
+            }
+
+            Assert.Fail(message);
         }
 
         private static string GetSolutionDir()

Reply via email to