mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-09 10:45:07 +00:00
Allows downloading only log-tails.
This commit is contained in:
parent
30364abf21
commit
c8cb04d859
@ -55,7 +55,7 @@ namespace ContinuousTests
|
|||||||
|
|
||||||
var appender = new LogAppender(filepath);
|
var appender = new LogAppender(filepath);
|
||||||
|
|
||||||
lifecycle.CodexStarter.DownloadLog(container, appender);
|
lifecycle.CodexStarter.DownloadLog(container, appender, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLogName(RunningContainer container)
|
private static string GetLogName(RunningContainer container)
|
||||||
|
@ -64,10 +64,10 @@ namespace DistTestCore
|
|||||||
RunningGroups.Clear();
|
RunningGroups.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadLog(RunningContainer container, ILogHandler logHandler)
|
public void DownloadLog(RunningContainer container, ILogHandler logHandler, int? tailLines)
|
||||||
{
|
{
|
||||||
var workflow = CreateWorkflow();
|
var workflow = CreateWorkflow();
|
||||||
workflow.DownloadContainerLog(container, logHandler);
|
workflow.DownloadContainerLog(container, logHandler, tailLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers)
|
private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers)
|
||||||
|
@ -25,7 +25,7 @@ namespace DistTestCore.Marketplace
|
|||||||
WaitUntil(() =>
|
WaitUntil(() =>
|
||||||
{
|
{
|
||||||
var logHandler = new ContractsReadyLogHandler(Debug);
|
var logHandler = new ContractsReadyLogHandler(Debug);
|
||||||
workflow.DownloadContainerLog(container, logHandler);
|
workflow.DownloadContainerLog(container, logHandler, null);
|
||||||
return logHandler.Found;
|
return logHandler.Found;
|
||||||
});
|
});
|
||||||
Log("Contracts deployed. Extracting addresses...");
|
Log("Contracts deployed. Extracting addresses...");
|
||||||
|
@ -80,7 +80,7 @@ namespace DistTestCore.Marketplace
|
|||||||
private string FetchPubKey()
|
private string FetchPubKey()
|
||||||
{
|
{
|
||||||
var enodeFinder = new PubKeyFinder(s => log.Debug(s));
|
var enodeFinder = new PubKeyFinder(s => log.Debug(s));
|
||||||
workflow.DownloadContainerLog(container, enodeFinder);
|
workflow.DownloadContainerLog(container, enodeFinder, null);
|
||||||
return enodeFinder.GetPubKey();
|
return enodeFinder.GetPubKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace DistTestCore
|
|||||||
ContentId UploadFile(TestFile file);
|
ContentId UploadFile(TestFile file);
|
||||||
TestFile? DownloadContent(ContentId contentId, string fileLabel = "");
|
TestFile? DownloadContent(ContentId contentId, string fileLabel = "");
|
||||||
void ConnectToPeer(IOnlineCodexNode node);
|
void ConnectToPeer(IOnlineCodexNode node);
|
||||||
IDownloadedLog DownloadLog();
|
IDownloadedLog DownloadLog(int? tailLines = null);
|
||||||
IMetricsAccess Metrics { get; }
|
IMetricsAccess Metrics { get; }
|
||||||
IMarketplaceAccess Marketplace { get; }
|
IMarketplaceAccess Marketplace { get; }
|
||||||
CodexDebugVersionResponse Version { get; }
|
CodexDebugVersionResponse Version { get; }
|
||||||
@ -103,9 +103,9 @@ namespace DistTestCore
|
|||||||
Log($"Successfully connected to peer {peer.GetName()}.");
|
Log($"Successfully connected to peer {peer.GetName()}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDownloadedLog DownloadLog()
|
public IDownloadedLog DownloadLog(int? tailLines = null)
|
||||||
{
|
{
|
||||||
return lifecycle.DownloadLog(CodexAccess.Container);
|
return lifecycle.DownloadLog(CodexAccess.Container, tailLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICodexSetup BringOffline()
|
public ICodexSetup BringOffline()
|
||||||
|
@ -29,7 +29,7 @@ namespace DistTestCore
|
|||||||
{
|
{
|
||||||
var config = "";
|
var config = "";
|
||||||
config += "global:\n";
|
config += "global:\n";
|
||||||
config += " scrape_interval: 30s\n";
|
config += " scrape_interval: 10s\n";
|
||||||
config += " scrape_timeout: 10s\n";
|
config += " scrape_timeout: 10s\n";
|
||||||
config += "\n";
|
config += "\n";
|
||||||
config += "scrape_configs:\n";
|
config += "scrape_configs:\n";
|
||||||
|
@ -49,14 +49,14 @@ namespace DistTestCore
|
|||||||
FileManager.DeleteAllTestFiles();
|
FileManager.DeleteAllTestFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDownloadedLog DownloadLog(RunningContainer container)
|
public IDownloadedLog DownloadLog(RunningContainer container, int? tailLines = null)
|
||||||
{
|
{
|
||||||
var subFile = Log.CreateSubfile();
|
var subFile = Log.CreateSubfile();
|
||||||
var description = container.Name;
|
var description = container.Name;
|
||||||
var handler = new LogDownloadHandler(container, description, subFile);
|
var handler = new LogDownloadHandler(container, description, subFile);
|
||||||
|
|
||||||
Log.Log($"Downloading logs for {description} to file '{subFile.FullFilename}'");
|
Log.Log($"Downloading logs for {description} to file '{subFile.FullFilename}'");
|
||||||
CodexStarter.DownloadLog(container, handler);
|
CodexStarter.DownloadLog(container, handler, tailLines);
|
||||||
|
|
||||||
return new DownloadedLog(subFile, description);
|
return new DownloadedLog(subFile, description);
|
||||||
}
|
}
|
||||||
|
@ -53,10 +53,10 @@ namespace KubernetesWorkflow
|
|||||||
WaitUntilPodOffline(pod.PodInfo.Name);
|
WaitUntilPodOffline(pod.PodInfo.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadPodLog(RunningPod pod, ContainerRecipe recipe, ILogHandler logHandler)
|
public void DownloadPodLog(RunningPod pod, ContainerRecipe recipe, ILogHandler logHandler, int? tailLines)
|
||||||
{
|
{
|
||||||
log.Debug();
|
log.Debug();
|
||||||
using var stream = client.Run(c => c.ReadNamespacedPodLog(pod.PodInfo.Name, K8sTestNamespace, recipe.Name));
|
using var stream = client.Run(c => c.ReadNamespacedPodLog(pod.PodInfo.Name, K8sTestNamespace, recipe.Name, tailLines: tailLines));
|
||||||
logHandler.Log(stream);
|
logHandler.Log(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ namespace KubernetesWorkflow
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DownloadContainerLog(RunningContainer container, ILogHandler logHandler)
|
public void DownloadContainerLog(RunningContainer container, ILogHandler logHandler, int? tailLines)
|
||||||
{
|
{
|
||||||
K8s(controller =>
|
K8s(controller =>
|
||||||
{
|
{
|
||||||
controller.DownloadPodLog(container.Pod, container.Recipe, logHandler);
|
controller.DownloadPodLog(container.Pod, container.Recipe, logHandler, tailLines);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using DistTestCore;
|
using DistTestCore;
|
||||||
|
using Logging;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
@ -61,12 +62,13 @@ namespace Tests.BasicTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void HoldMyBeerTest()
|
public void HoldMyBeerTest()
|
||||||
{
|
{
|
||||||
var group = SetupCodexNodes(5, o => o
|
var blockExpirationTime = TimeSpan.FromMinutes(3);
|
||||||
|
var group = SetupCodexNodes(1, o => o
|
||||||
.EnableMetrics()
|
.EnableMetrics()
|
||||||
.WithBlockTTL(TimeSpan.FromMinutes(2))
|
.WithBlockTTL(blockExpirationTime)
|
||||||
.WithBlockMaintenanceInterval(TimeSpan.FromMinutes(5))
|
.WithBlockMaintenanceInterval(TimeSpan.FromMinutes(1))
|
||||||
.WithBlockMaintenanceNumber(10000)
|
.WithBlockMaintenanceNumber(10000)
|
||||||
.WithStorageQuota(1000.MB()));
|
.WithStorageQuota(2000.MB()));
|
||||||
|
|
||||||
var nodes = group.Cast<OnlineCodexNode>().ToArray();
|
var nodes = group.Cast<OnlineCodexNode>().ToArray();
|
||||||
|
|
||||||
@ -78,43 +80,63 @@ namespace Tests.BasicTests
|
|||||||
var sizeInBytes = filesize.SizeInBytes;
|
var sizeInBytes = filesize.SizeInBytes;
|
||||||
Assert.That(numberOfBlocks, Is.EqualTo(1282));
|
Assert.That(numberOfBlocks, Is.EqualTo(1282));
|
||||||
|
|
||||||
|
var successfulUploads = 0;
|
||||||
|
var successfulDownloads = 0;
|
||||||
|
|
||||||
while (DateTime.UtcNow < endTime)
|
while (DateTime.UtcNow < endTime)
|
||||||
{
|
{
|
||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var uploadStartTime = DateTime.UtcNow;
|
||||||
var file = GenerateTestFile(filesize);
|
var file = GenerateTestFile(filesize);
|
||||||
var cid = node.UploadFile(file);
|
var cid = node.UploadFile(file);
|
||||||
|
|
||||||
var cidTag = cid.Id.Substring(cid.Id.Length - 6);
|
var cidTag = cid.Id.Substring(cid.Id.Length - 6);
|
||||||
var uploadLog = node.DownloadLog();
|
Stopwatch.Measure(Get().Log, "upload-log-asserts", () =>
|
||||||
|
{
|
||||||
|
var uploadLog = node.DownloadLog(tailLines: 50000);
|
||||||
|
|
||||||
var storeLines = uploadLog.FindLinesThatContain("Stored data", "topics=\"codex node\"");
|
var storeLines = uploadLog.FindLinesThatContain("Stored data", "topics=\"codex node\"");
|
||||||
uploadLog.DeleteFile();
|
uploadLog.DeleteFile();
|
||||||
|
|
||||||
var storeLine = GetLineForCidTag(storeLines, cidTag);
|
var storeLine = GetLineForCidTag(storeLines, cidTag);
|
||||||
AssertStoreLineContains(storeLine, numberOfBlocks, sizeInBytes);
|
AssertStoreLineContains(storeLine, numberOfBlocks, sizeInBytes);
|
||||||
|
});
|
||||||
|
successfulUploads++;
|
||||||
|
|
||||||
|
var uploadTimeTaken = DateTime.UtcNow - uploadStartTime;
|
||||||
|
if (uploadTimeTaken >= blockExpirationTime.Subtract(TimeSpan.FromSeconds(10)))
|
||||||
|
{
|
||||||
|
Assert.Fail("Upload took too long. Blocks already expired.");
|
||||||
|
}
|
||||||
|
|
||||||
var dl = node.DownloadContent(cid);
|
var dl = node.DownloadContent(cid);
|
||||||
file.AssertIsEqual(dl);
|
file.AssertIsEqual(dl);
|
||||||
var downloadLog = node.DownloadLog();
|
|
||||||
|
|
||||||
var sentLines = downloadLog.FindLinesThatContain("Sent bytes", "topics=\"codex restapi\"");
|
Stopwatch.Measure(Get().Log, "download-log-asserts", () =>
|
||||||
downloadLog.DeleteFile();
|
{
|
||||||
|
var downloadLog = node.DownloadLog(tailLines: 50000);
|
||||||
|
|
||||||
var sentLine = GetLineForCidTag(sentLines, cidTag);
|
var sentLines = downloadLog.FindLinesThatContain("Sent bytes", "topics=\"codex restapi\"");
|
||||||
AssertSentLineContains(sentLine, sizeInBytes);
|
downloadLog.DeleteFile();
|
||||||
|
|
||||||
|
var sentLine = GetLineForCidTag(sentLines, cidTag);
|
||||||
|
AssertSentLineContains(sentLine, sizeInBytes);
|
||||||
|
});
|
||||||
|
successfulDownloads++;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Log("Test failed. Delaying shut-down by 30 seconds to collect metrics.");
|
Log("Test failed. Delaying shut-down by 30 seconds to collect metrics.");
|
||||||
|
Log($"Test failed after {successfulUploads} successful uploads and {successfulDownloads} successful downloads");
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(30));
|
Thread.Sleep(TimeSpan.FromSeconds(30));
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(TimeSpan.FromSeconds(3));
|
Thread.Sleep(TimeSpan.FromSeconds(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user