diff --git a/Tests/CodexTests/BasicTests/LogHelperTests.cs b/Tests/CodexTests/BasicTests/LogHelperTests.cs new file mode 100644 index 00000000..d0b623a2 --- /dev/null +++ b/Tests/CodexTests/BasicTests/LogHelperTests.cs @@ -0,0 +1,61 @@ +using CodexPlugin; +using NUnit.Framework; +using Utils; + +namespace CodexTests.BasicTests +{ + [TestFixture] + public class LogHelperTests : CodexDistTest + { + [Test] + public void FindMostCommonLogMessages() + { + var node = AddCodex(s => s.WithLogLevel(CodexLogLevel.Trace)); + + + node.UploadFile(GenerateTestFile(1.GB())); + + + var map = GetLogMap(node).OrderByDescending(p => p.Value); + foreach (var entry in map) + { + Log($"'{entry.Key}' = {entry.Value}"); + } + } + + private Dictionary GetLogMap(ICodexNode node) + { + var log = Ci.DownloadLog(node); + var map = new Dictionary(); + log.IterateLines(line => + { + if (string.IsNullOrEmpty(line) || + !line.Contains(" ") || + !line.Contains("=") || + line.Length < 34 || + line[33] != ' ' + ) 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); + + // "Creating a private key and saving it tid=1 count=2" + var firstEqualSign = msg.IndexOf("="); + msg = msg.Substring(0, firstEqualSign); + + // "Creating a private key and saving it tid" + var lastSpace = msg.LastIndexOf(" "); + msg = msg.Substring(0, lastSpace); + + // "Creating a private key and saving it " + msg = msg.Trim(); + + // "Creating a private key and saving it" + if (map.ContainsKey(msg)) map[msg] += 1; + else map.Add(msg, 1); + }); + return map; + } + } +} diff --git a/Tests/CodexTests/BasicTests/OneClientTests.cs b/Tests/CodexTests/BasicTests/OneClientTests.cs index d8045862..9d4f5a58 100644 --- a/Tests/CodexTests/BasicTests/OneClientTests.cs +++ b/Tests/CodexTests/BasicTests/OneClientTests.cs @@ -1,5 +1,4 @@ using CodexPlugin; -using DistTestCore; using NUnit.Framework; using Utils; @@ -11,7 +10,7 @@ namespace CodexTests.BasicTests [Test] public void OneClientTest() { - var primary = Ci.StartCodexNode(); + var primary = AddCodex(); PerformOneClientTest(primary); } @@ -19,11 +18,11 @@ namespace CodexTests.BasicTests [Test] public void RestartTest() { - var primary = Ci.StartCodexNode(); + var primary = AddCodex(); primary.Stop(waitTillStopped: true); - primary = Ci.StartCodexNode(); + primary = AddCodex(); PerformOneClientTest(primary); }