From 1a277ef1b5895d6853710d96701bed5cbb13a77e Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 10 Oct 2023 17:54:19 +0200 Subject: [PATCH] Logging repostore content on twoclient test failure --- ProjectPlugins/CodexPlugin/CodexAccess.cs | 5 +++++ ProjectPlugins/CodexPlugin/CodexApiTypes.cs | 5 +++++ ProjectPlugins/CodexPlugin/CodexNode.cs | 6 ++++++ .../Tests/TwoClientTest.cs | 19 +++++++++++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index f9d7772..eb2cf6b 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -49,6 +49,11 @@ namespace CodexPlugin return Http().HttpGetJson("debug/blockexchange"); } + public CodexDebugRepoStoreResponse[] GetDebugRepoStore() + { + return Http().HttpGetJson("debug/repostore"); + } + public CodexDebugThresholdBreaches GetDebugThresholdBreaches() { return Http().HttpGetJson("debug/loop"); diff --git a/ProjectPlugins/CodexPlugin/CodexApiTypes.cs b/ProjectPlugins/CodexPlugin/CodexApiTypes.cs index b347508..49b0d2d 100644 --- a/ProjectPlugins/CodexPlugin/CodexApiTypes.cs +++ b/ProjectPlugins/CodexPlugin/CodexApiTypes.cs @@ -165,4 +165,9 @@ namespace CodexPlugin public string wantType { get; set; } = string.Empty; public bool sendDontHave { get; set; } } + + public class CodexDebugRepoStoreResponse + { + public string cid { get; set; } = string.Empty; + } } diff --git a/ProjectPlugins/CodexPlugin/CodexNode.cs b/ProjectPlugins/CodexPlugin/CodexNode.cs index 4a5940d..d2438dd 100644 --- a/ProjectPlugins/CodexPlugin/CodexNode.cs +++ b/ProjectPlugins/CodexPlugin/CodexNode.cs @@ -14,6 +14,7 @@ namespace CodexPlugin CodexDebugResponse GetDebugInfo(); CodexDebugPeerResponse GetDebugPeer(string peerId); CodexDebugBlockExchangeResponse GetDebugBlockExchange(); + CodexDebugRepoStoreResponse[] GetDebugRepoStore(); ContentId UploadFile(TrackedFile file); TrackedFile? DownloadContent(ContentId contentId, string fileLabel = ""); void ConnectToPeer(ICodexNode node); @@ -87,6 +88,11 @@ namespace CodexPlugin return CodexAccess.GetDebugBlockExchange(); } + public CodexDebugRepoStoreResponse[] GetDebugRepoStore() + { + return CodexAccess.GetDebugRepoStore(); + } + public ContentId UploadFile(TrackedFile file) { using var fileStream = File.OpenRead(file.Filename); diff --git a/Tests/CodexContinuousTests/Tests/TwoClientTest.cs b/Tests/CodexContinuousTests/Tests/TwoClientTest.cs index 0035d01..4275202 100644 --- a/Tests/CodexContinuousTests/Tests/TwoClientTest.cs +++ b/Tests/CodexContinuousTests/Tests/TwoClientTest.cs @@ -38,14 +38,29 @@ namespace ContinuousTests.Tests { TrackedFile? dl = null; - LogBytesPerMillisecond(() => dl = Nodes[1].DownloadContent(cid!)); + try + { + LogBytesPerMillisecond(() => dl = Nodes[1].DownloadContent(cid!)); - file.AssertIsEqual(dl); + file.AssertIsEqual(dl); + } + catch + { + LogRepoStore(Nodes[0]); + LogRepoStore(Nodes[1]); + throw; + } LogBlockExchangeStatus(Nodes[0], "After download"); LogBlockExchangeStatus(Nodes[1], "After download"); } + private void LogRepoStore(ICodexNode codexNode) + { + var response = codexNode.GetDebugRepoStore(); + Log.Log($"{codexNode.GetName()} has {string.Join(",", response.Select(r => r.cid))}"); + } + private void LogStoredBytes(ICodexNode node) { var metrics = CreateMetricsAccess(node);