You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2023/11/27 11:36:54 UTC
(ignite-3) branch main updated: IGNITE-20967 .NET: Fix TestMicrosoftConsoleLogger flakiness (#2881)
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 4d32d57470 IGNITE-20967 .NET: Fix TestMicrosoftConsoleLogger flakiness (#2881)
4d32d57470 is described below
commit 4d32d57470aaaccc8857717a99a0ac3620f00c7a
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 27 13:36:49 2023 +0200
IGNITE-20967 .NET: Fix TestMicrosoftConsoleLogger flakiness (#2881)
* Use `TextWriter.Synchronized` to handle multithreaded writes
* Close the client and the writer before accessing the log
---
.../platforms/dotnet/Apache.Ignite.Tests/LoggingTests.cs | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/LoggingTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/LoggingTests.cs
index 1b52c32645..284269c55f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/LoggingTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/LoggingTests.cs
@@ -69,7 +69,7 @@ public class LoggingTests
{
var oldWriter = Console.Out;
var writer = new StringWriter();
- Console.SetOut(writer);
+ Console.SetOut(TextWriter.Synchronized(writer));
try
{
@@ -83,15 +83,18 @@ public class LoggingTests
using var server = new FakeServer();
using var client = await server.ConnectClientAsync(cfg);
await client.Tables.GetTablesAsync();
-
- var log = writer.ToString();
- StringAssert.Contains("dbug: Apache.Ignite.Internal.ClientSocket", log);
- StringAssert.Contains("Connection established", log);
- StringAssert.Contains("Handshake succeeded [remoteAddress=[", log);
}
finally
{
Console.SetOut(oldWriter);
}
+
+ // Prevent further writes before accessing the inner StringBuilder.
+ writer.Close();
+ var log = writer.ToString();
+
+ StringAssert.Contains("dbug: Apache.Ignite.Internal.ClientSocket", log);
+ StringAssert.Contains("Connection established", log);
+ StringAssert.Contains("Handshake succeeded [remoteAddress=[", log);
}
}