You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by fr...@apache.org on 2025/05/11 19:49:16 UTC
(logging-log4net) branch Feature/696-TelnetTest-Hang created (now 6d1358fa)
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a change to branch Feature/696-TelnetTest-Hang
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
at 6d1358fa https://issues.apache.org/jira/browse/LOG4NET-696 - added timeout and log messages
This branch includes the following new commits:
new 6d1358fa https://issues.apache.org/jira/browse/LOG4NET-696 - added timeout and log messages
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4net) 01/01: https://issues.apache.org/jira/browse/LOG4NET-696 - added timeout and log messages
Posted by fr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a commit to branch Feature/696-TelnetTest-Hang
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
commit 6d1358faaadd14b789230cd9ec95577bd5df94ba
Author: Jan Friedrich <fr...@apache.org>
AuthorDate: Sun May 11 21:48:21 2025 +0200
https://issues.apache.org/jira/browse/LOG4NET-696 - added timeout and log messages
---
src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs | 7 ++++++-
src/log4net.Tests/Appender/TelnetAppenderTest.cs | 14 +++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
index 7d5b822b..72767bf7 100644
--- a/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
+++ b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
@@ -41,11 +41,14 @@ internal sealed class SimpleTelnetClient(
/// <summary>
/// Runs the client (in a task)
/// </summary>
- internal void Run() => Task.Run(() =>
+ internal void Run(Action<string> log) => Task.Run(() =>
{
+ log("client: starting ...");
_client.Connect(new IPEndPoint(IPAddress.Loopback, port));
+ log("client: connected");
// Get a stream object for reading and writing
using NetworkStream stream = _client.GetStream();
+ log("client: has stream");
int i;
byte[] bytes = new byte[256];
@@ -54,9 +57,11 @@ internal sealed class SimpleTelnetClient(
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
string data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
+ log("client: read: " + data);
received(data);
if (_cancellationTokenSource.Token.IsCancellationRequested)
{
+ log("client: canceled");
return;
}
}
diff --git a/src/log4net.Tests/Appender/TelnetAppenderTest.cs b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
index 48bf970b..0e8d5f84 100644
--- a/src/log4net.Tests/Appender/TelnetAppenderTest.cs
+++ b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
@@ -70,11 +70,15 @@ public void TelnetTest()
XmlConfigurator.Configure(repository, log4NetConfig["log4net"]!);
using (SimpleTelnetClient telnetClient = new(Received, port))
{
- telnetClient.Run();
+ TestContext.Out.WriteLine("test: starting client ...");
+ telnetClient.Run(TestContext.Out.WriteLine);
WaitForReceived(1); // wait for welcome message
ILogger logger = repository.GetLogger("Telnet");
+ TestContext.Out.WriteLine("test: logging to client ...");
logger.Log(typeof(TelnetAppenderTest), Level.Info, logId, null);
+ TestContext.Out.WriteLine("test: waiting for message of client ...");
WaitForReceived(2); // wait for log message
+ TestContext.Out.WriteLine("test: canceling client ...");
}
repository.Shutdown();
Assert.That(received, Has.Count.EqualTo(2));
@@ -84,10 +88,18 @@ public void TelnetTest()
void WaitForReceived(int count)
{
+ int retries = 1;
while (received.Count < count)
{
+ retries++;
+ TestContext.Out.WriteLine($"receiver: waiting for message {count} of client - retry {retries} failed");
+ if (retries > 100)
+ {
+ Assert.Fail("Timeout waiting for received messages");
+ }
Thread.Sleep(10);
}
+ TestContext.Out.WriteLine($"receiver: waiting for message {count} of client - retry {retries} succeeded");
}
}
}
\ No newline at end of file