mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-06-01 05:59:26 +00:00
Make release tests use json log sink for structured logs
This commit is contained in:
parent
23ee029f3c
commit
d95318f2aa
10
ProjectPlugins/LogosStorageClient/LogosStorageLogFormat.cs
Normal file
10
ProjectPlugins/LogosStorageClient/LogosStorageLogFormat.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace LogosStorageClient
|
||||
{
|
||||
public enum LogosStorageLogFormat
|
||||
{
|
||||
Auto,
|
||||
Colors,
|
||||
NoColors,
|
||||
Json
|
||||
}
|
||||
}
|
||||
@ -60,6 +60,7 @@ namespace StoragePlugin
|
||||
|
||||
AddArg("--disc-port", pc.DiscPort);
|
||||
AddArg("--log-level", config.LogLevelWithTopics());
|
||||
AddArg("--log-format", config.LogFormat.ToString().ToLowerInvariant());
|
||||
|
||||
// This makes the node announce itself to its local IP address.
|
||||
AddArg("--nat", $"extip:{pc.LocalIpAddrs}");
|
||||
|
||||
@ -11,6 +11,7 @@ namespace StoragePlugin
|
||||
ILogosStorageSetup WithBootstrapNode(IStorageNode node);
|
||||
ILogosStorageSetup WithLogLevel(LogosStorageLogLevel level);
|
||||
ILogosStorageSetup WithLogLevel(LogosStorageLogLevel level, LogosStorageLogCustomTopics customTopics);
|
||||
ILogosStorageSetup WithLogFormat(LogosStorageLogFormat format);
|
||||
ILogosStorageSetup WithStorageQuota(ByteSize storageQuota);
|
||||
ILogosStorageSetup WithBlockTTL(TimeSpan duration);
|
||||
ILogosStorageSetup WithBlockMaintenanceInterval(TimeSpan duration);
|
||||
@ -82,6 +83,12 @@ namespace StoragePlugin
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogosStorageSetup WithLogFormat(LogosStorageLogFormat format)
|
||||
{
|
||||
LogFormat = format;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogosStorageSetup WithStorageQuota(ByteSize storageQuota)
|
||||
{
|
||||
StorageQuota = storageQuota;
|
||||
|
||||
@ -9,6 +9,7 @@ namespace StoragePlugin
|
||||
public string? NameOverride { get; set; }
|
||||
public ILocation Location { get; set; } = KnownLocations.UnspecifiedLocation;
|
||||
public LogosStorageLogLevel LogLevel { get; set; }
|
||||
public LogosStorageLogFormat LogFormat { get; set; }
|
||||
public LogosStorageLogCustomTopics? CustomTopics { get; set; } = new LogosStorageLogCustomTopics(LogosStorageLogLevel.Info, LogosStorageLogLevel.Warn);
|
||||
public ByteSize? StorageQuota { get; set; }
|
||||
public bool MetricsEnabled { get; set; }
|
||||
|
||||
@ -2,6 +2,7 @@ using StoragePlugin;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
using LogosStorageClient;
|
||||
|
||||
namespace LogosStorageReleaseTests.DataTests
|
||||
{
|
||||
@ -24,7 +25,9 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
public void DeletesExpiredData()
|
||||
{
|
||||
var fileSize = 3.MB();
|
||||
var node = StartLogosStorage(s => WithFastBlockExpiry(s));
|
||||
var node = StartLogosStorage(s =>
|
||||
WithFastBlockExpiry(s).WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
var startSpace = node.Space();
|
||||
Assert.That(startSpace.QuotaUsedBytes, Is.EqualTo(0));
|
||||
|
||||
@ -31,7 +31,10 @@ namespace LogosStorageReleaseTests.DataTests.DHT
|
||||
public void PressureTest()
|
||||
{
|
||||
var cids = new List<ContentId>();
|
||||
var nodes = StartLogosStorage(numNodes);
|
||||
var nodes = StartLogosStorage(
|
||||
numNodes,
|
||||
s => s.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
for (var i = 0; i < numFilesPerNode; i++)
|
||||
{
|
||||
@ -45,7 +48,7 @@ namespace LogosStorageReleaseTests.DataTests.DHT
|
||||
var estimate = numNodes * numFilesPerNode * 2;
|
||||
Log($"Estimate of DHT records: {estimate}");
|
||||
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
for (var i = 0; i < numToFetch; i++)
|
||||
{
|
||||
var timing = Stopwatch.Measure(GetTestLog(), nameof(PressureTest) + i, () =>
|
||||
|
||||
@ -12,7 +12,7 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void UploadInterruptTest()
|
||||
{
|
||||
var nodes = StartLogosStorage(10);
|
||||
var nodes = StartLogosStorage(10, s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var tasks = nodes.Select(n => Task<bool>.Run(() => RunInterruptUploadTest(n)));
|
||||
Task.WaitAll(tasks.ToArray());
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LogosStorageTests;
|
||||
using LogosStorageClient;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -15,7 +16,7 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void ShouldShowLocalFiles()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var size1 = 123.KB();
|
||||
var size2 = 23.MB();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LogosStorageTests;
|
||||
using LogosStorageClient;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
@ -10,8 +11,10 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void ManifestOnlyTest()
|
||||
{
|
||||
var uploader = StartLogosStorage();
|
||||
var downloader = StartLogosStorage(s => s.WithBootstrapNode(uploader));
|
||||
var uploader = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
var downloader = StartLogosStorage(s =>
|
||||
s.WithBootstrapNode(uploader).WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
var file = GenerateTestFile(2.GB());
|
||||
var size = file.GetFilesize().SizeInBytes;
|
||||
|
||||
@ -11,7 +11,7 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void OneClient()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
PerformOneClientTest(node);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LogosStorageTests;
|
||||
using LogosStorageClient;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
@ -10,8 +11,10 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void StreamlessTest()
|
||||
{
|
||||
var uploader = StartLogosStorage();
|
||||
var downloader = StartLogosStorage(s => s.WithBootstrapNode(uploader));
|
||||
var uploader = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
var downloader = StartLogosStorage(s =>
|
||||
s.WithBootstrapNode(uploader).WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
var size = 10.MB();
|
||||
var file = GenerateTestFile(size);
|
||||
|
||||
@ -40,7 +40,10 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
public void Stream()
|
||||
{
|
||||
var filesize = filesizeMb.MB();
|
||||
nodes = StartLogosStorage(numberOfNodes);
|
||||
nodes = StartLogosStorage(
|
||||
numberOfNodes,
|
||||
s => s.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
||||
|
||||
var tasks = ParallelDownloadEachFile(files);
|
||||
@ -53,7 +56,10 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
public void Streamless()
|
||||
{
|
||||
var filesize = filesizeMb.MB();
|
||||
nodes = StartLogosStorage(numberOfNodes);
|
||||
nodes = StartLogosStorage(
|
||||
numberOfNodes,
|
||||
s => s.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
||||
|
||||
var tasks = ParallelStreamlessDownloadEachFile(files);
|
||||
|
||||
@ -29,7 +29,13 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
Assert.That(remainingNodes, Is.GreaterThan(0));
|
||||
Assert.That(steps, Is.GreaterThan(remainingNodes + 1));
|
||||
|
||||
nodes.AddRange(StartLogosStorage(remainingNodes + 1));
|
||||
nodes.AddRange(
|
||||
StartLogosStorage(
|
||||
remainingNodes + 1,
|
||||
s => s.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
)
|
||||
);
|
||||
|
||||
cid = nodes.First().UploadFile(file);
|
||||
|
||||
AllNodesHaveFile();
|
||||
@ -40,7 +46,7 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
nodes[0].Stop(waitTillStopped: true);
|
||||
nodes.RemoveAt(0);
|
||||
|
||||
nodes.Add(StartLogosStorage());
|
||||
nodes.Add(StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json)));
|
||||
|
||||
AllNodesHaveFile();
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LogosStorageTests;
|
||||
using LogosStorageClient;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
@ -9,8 +10,8 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void ThreeClient()
|
||||
{
|
||||
var primary = StartLogosStorage();
|
||||
var secondary = StartLogosStorage();
|
||||
var primary = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
var secondary = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var testFile = GenerateTestFile(10.MB());
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using LogosStorageClient;
|
||||
using StoragePlugin;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using StoragePlugin;
|
||||
using Utils;
|
||||
|
||||
namespace LogosStorageReleaseTests.DataTests
|
||||
@ -12,8 +12,14 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void TwoClientTest()
|
||||
{
|
||||
var uploader = StartLogosStorage(s => s.WithName("Uploader"));
|
||||
var downloader = StartLogosStorage(s => s.WithName("Downloader").WithBootstrapNode(uploader));
|
||||
var uploader = StartLogosStorage(s =>
|
||||
s.WithName("Uploader").WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
var downloader = StartLogosStorage(s =>
|
||||
s.WithName("Downloader")
|
||||
.WithBootstrapNode(uploader)
|
||||
.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
PerformTwoClientTest(uploader, downloader);
|
||||
}
|
||||
@ -29,8 +35,17 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
return;
|
||||
}
|
||||
|
||||
var uploader = Ci.StartStorageNode(s => s.WithName("Uploader").At(locations.Get(0)));
|
||||
var downloader = Ci.StartStorageNode(s => s.WithName("Downloader").WithBootstrapNode(uploader).At(locations.Get(1)));
|
||||
var uploader = Ci.StartStorageNode(s =>
|
||||
s.WithName("Uploader")
|
||||
.At(locations.Get(0))
|
||||
.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
var downloader = Ci.StartStorageNode(s =>
|
||||
s.WithName("Downloader")
|
||||
.WithBootstrapNode(uploader)
|
||||
.At(locations.Get(1))
|
||||
.WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
|
||||
PerformTwoClientTest(uploader, downloader);
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ namespace LogosStorageReleaseTests.DataTests
|
||||
[Test]
|
||||
public void DownloadingUnknownCidDoesNotCauseCrash()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var unknownCid = new ContentId("zDvZRwzkzHsok3Z8yMoiXE9EDBFwgr8WygB8s4ddcLzzSwwXAxLZ");
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LogosStorageTests;
|
||||
using LogosStorageClient;
|
||||
using LogosStorageTests;
|
||||
using NUnit.Framework;
|
||||
using Utils;
|
||||
|
||||
@ -11,7 +12,9 @@ namespace LogosStorageReleaseTests.NodeTests
|
||||
public void QuotaTest()
|
||||
{
|
||||
var size = 3.GB();
|
||||
var node = StartLogosStorage(s => s.WithStorageQuota(size));
|
||||
var node = StartLogosStorage(s =>
|
||||
s.WithStorageQuota(size).WithLogFormat(LogosStorageLogFormat.Json)
|
||||
);
|
||||
var space = node.Space();
|
||||
|
||||
Assert.That(space.QuotaMaxBytes, Is.EqualTo(size.SizeInBytes));
|
||||
@ -20,8 +23,8 @@ namespace LogosStorageReleaseTests.NodeTests
|
||||
[Test]
|
||||
public void Spr()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
Assert.That(!string.IsNullOrEmpty(info.Spr));
|
||||
|
||||
@ -34,7 +37,7 @@ namespace LogosStorageReleaseTests.NodeTests
|
||||
[Test]
|
||||
public void VersionInfo()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
Assert.That(!string.IsNullOrEmpty(info.Version.Version));
|
||||
@ -44,7 +47,7 @@ namespace LogosStorageReleaseTests.NodeTests
|
||||
[Test]
|
||||
public void AnnounceAddress()
|
||||
{
|
||||
var node = StartLogosStorage();
|
||||
var node = StartLogosStorage(s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
var addr = node.GetListenEndpoint();
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
|
||||
@ -11,7 +11,7 @@ namespace LogosStorageReleaseTests.NodeTests
|
||||
[Test]
|
||||
public void PeerTableCompleteness()
|
||||
{
|
||||
var nodes = StartLogosStorage(10);
|
||||
var nodes = StartLogosStorage(10, s => s.WithLogFormat(LogosStorageLogFormat.Json));
|
||||
|
||||
AssertAllNodesSeeEachOther(nodes.Concat([BootstrapNode!]));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user