2
0
mirror of synced 2025-01-11 17:14:25 +00:00

Allows parsing longs only from a certain timestamp

This commit is contained in:
Ben 2024-04-25 10:57:19 +02:00
parent e1c710a093
commit 15d7e6483e
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1

View File

@ -5,25 +5,32 @@ using Utils;
namespace CodexTests.BasicTests
{
[TestFixture]
public class LogHelperTests : CodexDistTest
public class LogHelperTests : AutoBootstrapDistTest
{
[Test]
public void FindMostCommonLogMessages()
{
var node = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace));
var uploader = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace));
var downloader = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace));
node.UploadFile(GenerateTestFile(1.GB()));
var cid = uploader.UploadFile(GenerateTestFile(1.MB()));
Thread.Sleep(1000);
var logStartUtc = DateTime.UtcNow;
Thread.Sleep(1000);
downloader.DownloadContent(cid);
var map = GetLogMap(node).OrderByDescending(p => p.Value);
var map = GetLogMap(uploader, logStartUtc).OrderByDescending(p => p.Value);
foreach (var entry in map)
{
Log($"'{entry.Key}' = {entry.Value}");
}
}
private Dictionary<string, int> GetLogMap(ICodexNode node)
private Dictionary<string, int> GetLogMap(ICodexNode node, DateTime? startUtc = null)
{
var log = Ci.DownloadLog(node);
var map = new Dictionary<string, int>();
@ -36,6 +43,13 @@ namespace CodexTests.BasicTests
line[33] != ' '
) return;
if (startUtc.HasValue)
{
var timestampLine = line.Substring(4, 23);
var timestamp = DateTime.Parse(timestampLine);
if (timestamp < startUtc) return;
}
// "INF 2024-04-14 10:40:50.042+00:00 Creating a private key and saving it tid=1 count=2"
var start = 34;
var msg = line.Substring(start);