From e7e464b4fa445a9a7a69c3f33e8272ff522af187 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 30 Jun 2023 08:39:18 +0200 Subject: [PATCH] Adds container alias to log. Useful for transient nodes --- ContinuousTests/NodeRunner.cs | 9 +++++---- ContinuousTests/SingleTestRun.cs | 2 +- DistTestCore/Codex/CodexAccess.cs | 2 +- DistTestCore/Http.cs | 13 +++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ContinuousTests/NodeRunner.cs b/ContinuousTests/NodeRunner.cs index 9551cc0..b970a08 100644 --- a/ContinuousTests/NodeRunner.cs +++ b/ContinuousTests/NodeRunner.cs @@ -28,17 +28,17 @@ namespace ContinuousTests this.ethereumAccountIndex = ethereumAccountIndex; } - public void RunNode(Action operation) + public void RunNode(Action operation) { RunNode(nodes.ToList().PickOneRandom(), operation, 0.TestTokens()); } - public void RunNode(CodexAccess bootstrapNode, Action operation) + public void RunNode(CodexAccess bootstrapNode, Action operation) { RunNode(bootstrapNode, operation, 0.TestTokens()); } - public void RunNode(CodexAccess bootstrapNode, Action operation, TestToken mintTestTokens) + public void RunNode(CodexAccess bootstrapNode, Action operation, TestToken mintTestTokens) { var (workflowCreator, lifecycle) = CreateFacilities(); var flow = workflowCreator.CreateWorkflow(); @@ -49,6 +49,7 @@ namespace ContinuousTests Assert.That(!string.IsNullOrEmpty(debugInfo.spr)); var startupConfig = new StartupConfig(); + startupConfig.NameOverride = "TransientNode"; var codexStartConfig = new CodexStartupConfig(CodexLogLevel.Trace); codexStartConfig.MarketplaceConfig = new MarketplaceInitialConfig(0.Eth(), 0.TestTokens(), false); codexStartConfig.MarketplaceConfig.AccountIndexOverride = ethereumAccountIndex; @@ -74,7 +75,7 @@ namespace ContinuousTests try { - operation(codexAccess, marketAccess); + operation(codexAccess, marketAccess, lifecycle); } catch { diff --git a/ContinuousTests/SingleTestRun.cs b/ContinuousTests/SingleTestRun.cs index 17752d2..b67a0f7 100644 --- a/ContinuousTests/SingleTestRun.cs +++ b/ContinuousTests/SingleTestRun.cs @@ -168,7 +168,7 @@ namespace ContinuousTests { Log(msg); var containerNames = $"({string.Join(",", nodes.Select(n => n.Container.Name))})"; - overviewLog.Log( testName + ": " + msg); + overviewLog.Log($"{containerNames} {testName}: {msg}"); } private CodexAccess[] CreateRandomNodes(int number) diff --git a/DistTestCore/Codex/CodexAccess.cs b/DistTestCore/Codex/CodexAccess.cs index d0cb1fc..2aea3b6 100644 --- a/DistTestCore/Codex/CodexAccess.cs +++ b/DistTestCore/Codex/CodexAccess.cs @@ -80,7 +80,7 @@ namespace DistTestCore.Codex private Http Http(TimeSpan? timeoutOverride = null) { - return new Http(log, timeSet, Address, baseUrl: "/api/codex/v1", timeoutOverride); + return new Http(log, timeSet, Address, baseUrl: "/api/codex/v1", Container.Name, timeoutOverride); } } } diff --git a/DistTestCore/Http.cs b/DistTestCore/Http.cs index 2aa5085..d4b716a 100644 --- a/DistTestCore/Http.cs +++ b/DistTestCore/Http.cs @@ -12,14 +12,16 @@ namespace DistTestCore private readonly ITimeSet timeSet; private readonly Address address; private readonly string baseUrl; + private readonly string? logAlias; private readonly TimeSpan? timeoutOverride; - public Http(BaseLog log, ITimeSet timeSet, Address address, string baseUrl, TimeSpan? timeoutOverride = null) + public Http(BaseLog log, ITimeSet timeSet, Address address, string baseUrl, string? logAlias = null, TimeSpan? timeoutOverride = null) { this.log = log; this.timeSet = timeSet; this.address = address; this.baseUrl = baseUrl; + this.logAlias = logAlias; this.timeoutOverride = timeoutOverride; if (!this.baseUrl.StartsWith("/")) this.baseUrl = "/" + this.baseUrl; if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/"; @@ -113,7 +115,14 @@ namespace DistTestCore private void Log(string url, string message) { - log.Debug($"({url}) = '{message}'", 3); + if (logAlias != null) + { + log.Debug($"({logAlias})({url}) = '{message}'", 3); + } + else + { + log.Debug($"({url}) = '{message}'", 3); + } } private T Retry(Func operation, string description)