mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 00:13:08 +00:00
Disables assert on contract config values check
This commit is contained in:
parent
365e78f050
commit
c16397ae47
@ -6,6 +6,7 @@ namespace CodexClient
|
|||||||
{
|
{
|
||||||
BytesPerSecond? GetUploadSpeed();
|
BytesPerSecond? GetUploadSpeed();
|
||||||
BytesPerSecond? GetDownloadSpeed();
|
BytesPerSecond? GetDownloadSpeed();
|
||||||
|
ITransferSpeeds Combine(ITransferSpeeds? other);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TransferSpeeds : ITransferSpeeds
|
public class TransferSpeeds : ITransferSpeeds
|
||||||
@ -35,6 +36,18 @@ namespace CodexClient
|
|||||||
return downloads.Average();
|
return downloads.Average();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ITransferSpeeds Combine(ITransferSpeeds? other)
|
||||||
|
{
|
||||||
|
if (other == null) return this;
|
||||||
|
var o = (TransferSpeeds)other;
|
||||||
|
var result = new TransferSpeeds();
|
||||||
|
result.uploads.AddRange(uploads);
|
||||||
|
result.uploads.AddRange(o.uploads);
|
||||||
|
result.downloads.AddRange(downloads);
|
||||||
|
result.downloads.AddRange(o.downloads);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private static BytesPerSecond Convert(ByteSize size, TimeSpan duration)
|
private static BytesPerSecond Convert(ByteSize size, TimeSpan duration)
|
||||||
{
|
{
|
||||||
double bytes = size.SizeInBytes;
|
double bytes = size.SizeInBytes;
|
||||||
|
|||||||
@ -105,7 +105,15 @@ namespace CodexContractsPlugin
|
|||||||
{
|
{
|
||||||
if (Convert.ToInt32(value) != expected)
|
if (Convert.ToInt32(value) != expected)
|
||||||
{
|
{
|
||||||
throw new Exception($"Config value '{name}' should be deployed as '{expected}' but was '{value}'");
|
// Merge todo: https://github.com/codex-storage/nim-codex/pull/1303
|
||||||
|
// Once this is merged, the contract config values are settable via env-vars.
|
||||||
|
// This plugin is already updated to set the config vars to values compatible with a
|
||||||
|
// 1-second block frequency. AND it will read back the config and assert it is deployed correctly.
|
||||||
|
// This is waiting for that merge.
|
||||||
|
|
||||||
|
// Replace log with assert WHEN MERGED:
|
||||||
|
// throw new Exception($"Config value '{name}' should be deployed as '{expected}' but was '{value}'");
|
||||||
|
Log($"MERGE TODO. Config value '{name}' should be deployed as '{expected}' but was '{value}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ using Utils;
|
|||||||
|
|
||||||
namespace CodexReleaseTests.DataTests
|
namespace CodexReleaseTests.DataTests
|
||||||
{
|
{
|
||||||
|
namespace SwarmTests
|
||||||
|
{
|
||||||
[TestFixture(2, 10)]
|
[TestFixture(2, 10)]
|
||||||
[TestFixture(5, 20)]
|
[TestFixture(5, 20)]
|
||||||
[TestFixture(10, 20)]
|
[TestFixture(10, 20)]
|
||||||
@ -14,6 +16,7 @@ namespace CodexReleaseTests.DataTests
|
|||||||
{
|
{
|
||||||
private readonly int numberOfNodes;
|
private readonly int numberOfNodes;
|
||||||
private readonly int filesizeMb;
|
private readonly int filesizeMb;
|
||||||
|
private ICodexNodeGroup nodes = null!;
|
||||||
|
|
||||||
public SwarmTests(int numberOfNodes, int filesizeMb)
|
public SwarmTests(int numberOfNodes, int filesizeMb)
|
||||||
{
|
{
|
||||||
@ -21,30 +24,42 @@ namespace CodexReleaseTests.DataTests
|
|||||||
this.filesizeMb = filesizeMb;
|
this.filesizeMb = filesizeMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
ITransferSpeeds speeds = new TransferSpeeds();
|
||||||
|
foreach (var n in nodes)
|
||||||
|
{
|
||||||
|
speeds = speeds.Combine(n.TransferSpeeds);
|
||||||
|
}
|
||||||
|
Log($"Average upload speed: {speeds.GetUploadSpeed()}");
|
||||||
|
Log($"Average download speed: {speeds.GetDownloadSpeed()}");
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Swarm()
|
public void Stream()
|
||||||
{
|
{
|
||||||
var filesize = filesizeMb.MB();
|
var filesize = filesizeMb.MB();
|
||||||
var nodes = StartCodex(numberOfNodes);
|
nodes = StartCodex(numberOfNodes);
|
||||||
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
||||||
|
|
||||||
var tasks = ParallelDownloadEachFile(nodes, files);
|
var tasks = ParallelDownloadEachFile(files);
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
|
|
||||||
AssertAllFilesDownloadedCorrectly(files);
|
AssertAllFilesDownloadedCorrectly(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void StreamlessSwarm()
|
public void Streamless()
|
||||||
{
|
{
|
||||||
var filesize = filesizeMb.MB();
|
var filesize = filesizeMb.MB();
|
||||||
var nodes = StartCodex(numberOfNodes);
|
nodes = StartCodex(numberOfNodes);
|
||||||
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
var files = nodes.Select(n => UploadUniqueFilePerNode(n, filesize)).ToArray();
|
||||||
|
|
||||||
var tasks = ParallelStreamlessDownloadEachFile(nodes, files);
|
var tasks = ParallelStreamlessDownloadEachFile(files);
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
|
|
||||||
AssertAllFilesStreamlesslyDownloadedCorrectly(nodes, files);
|
AssertAllFilesStreamlesslyDownloadedCorrectly(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SwarmTestNetworkFile UploadUniqueFilePerNode(ICodexNode node, ByteSize fileSize)
|
private SwarmTestNetworkFile UploadUniqueFilePerNode(ICodexNode node, ByteSize fileSize)
|
||||||
@ -54,7 +69,7 @@ namespace CodexReleaseTests.DataTests
|
|||||||
return new SwarmTestNetworkFile(node, fileSize, file, cid);
|
return new SwarmTestNetworkFile(node, fileSize, file, cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task[] ParallelDownloadEachFile(ICodexNodeGroup nodes, SwarmTestNetworkFile[] files)
|
private Task[] ParallelDownloadEachFile(SwarmTestNetworkFile[] files)
|
||||||
{
|
{
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
|
|
||||||
@ -66,7 +81,7 @@ namespace CodexReleaseTests.DataTests
|
|||||||
return tasks.ToArray();
|
return tasks.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task[] ParallelStreamlessDownloadEachFile(ICodexNodeGroup nodes, SwarmTestNetworkFile[] files)
|
private Task[] ParallelStreamlessDownloadEachFile(SwarmTestNetworkFile[] files)
|
||||||
{
|
{
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
|
|
||||||
@ -143,7 +158,7 @@ namespace CodexReleaseTests.DataTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AssertAllFilesStreamlesslyDownloadedCorrectly(ICodexNodeGroup nodes, SwarmTestNetworkFile[] files)
|
private void AssertAllFilesStreamlesslyDownloadedCorrectly(SwarmTestNetworkFile[] files)
|
||||||
{
|
{
|
||||||
var totalFilesSpace = 0.Bytes();
|
var totalFilesSpace = 0.Bytes();
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
@ -178,4 +193,5 @@ namespace CodexReleaseTests.DataTests
|
|||||||
public Exception? Error { get; set; } = null;
|
public Exception? Error { get; set; } = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user