adds block exchange tests. Updates namespaces
This commit is contained in:
parent
7aae48d489
commit
b81d574a4b
|
@ -1,6 +1,7 @@
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
using FileUtils;
|
using FileUtils;
|
||||||
using Logging;
|
using Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
|
@ -21,6 +22,9 @@ namespace ContinuousTests.Tests
|
||||||
[TestMoment(t: Zero)]
|
[TestMoment(t: Zero)]
|
||||||
public void UploadTestFile()
|
public void UploadTestFile()
|
||||||
{
|
{
|
||||||
|
LogBlockExchangeStatus(Nodes[0], "Before upload");
|
||||||
|
LogBlockExchangeStatus(Nodes[1], "Before upload");
|
||||||
|
|
||||||
file = FileManager.GenerateFile(size);
|
file = FileManager.GenerateFile(size);
|
||||||
|
|
||||||
LogStoredBytes(Nodes[0]);
|
LogStoredBytes(Nodes[0]);
|
||||||
|
@ -37,6 +41,9 @@ namespace ContinuousTests.Tests
|
||||||
LogBytesPerMillisecond(() => dl = Nodes[1].DownloadContent(cid!));
|
LogBytesPerMillisecond(() => dl = Nodes[1].DownloadContent(cid!));
|
||||||
|
|
||||||
file.AssertIsEqual(dl);
|
file.AssertIsEqual(dl);
|
||||||
|
|
||||||
|
LogBlockExchangeStatus(Nodes[0], "After download");
|
||||||
|
LogBlockExchangeStatus(Nodes[1], "After download");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogStoredBytes(ICodexNode node)
|
private void LogStoredBytes(ICodexNode node)
|
||||||
|
@ -65,5 +72,11 @@ namespace ContinuousTests.Tests
|
||||||
var bytesPerMs = totalBytes / totalMs;
|
var bytesPerMs = totalBytes / totalMs;
|
||||||
Log.Log($"Bytes per millisecond: {bytesPerMs}");
|
Log.Log($"Bytes per millisecond: {bytesPerMs}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogBlockExchangeStatus(ICodexNode codexNode, string msg)
|
||||||
|
{
|
||||||
|
var response = codexNode.GetDebugBlockExchange();
|
||||||
|
Log.Log($"{codexNode.GetName()} {msg}: {JsonConvert.SerializeObject(response)}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
using CodexTests;
|
||||||
using DistTestCore;
|
using DistTestCore;
|
||||||
using FileUtils;
|
using FileUtils;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Tests;
|
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace CodexLongTests.BasicTests
|
namespace CodexLongTests.BasicTests
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
|
using CodexTests;
|
||||||
using DistTestCore;
|
using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NUnit.Framework.Interfaces;
|
using NUnit.Framework.Interfaces;
|
||||||
using Tests;
|
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace CodexLongTests.BasicTests
|
namespace CodexLongTests.BasicTests
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using DistTestCore;
|
using CodexTests;
|
||||||
|
using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Tests;
|
|
||||||
|
|
||||||
namespace CodexLongTests.BasicTests
|
namespace CodexLongTests.BasicTests
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
|
using CodexTests;
|
||||||
using DistTestCore;
|
using DistTestCore;
|
||||||
using FileUtils;
|
using FileUtils;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Tests;
|
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace CodexLongTests.BasicTests
|
namespace CodexLongTests.BasicTests
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using DistTestCore;
|
using CodexTests;
|
||||||
|
using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Tests;
|
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace CodexLongTests.DownloadConnectivityTests
|
namespace CodexLongTests.DownloadConnectivityTests
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace Tests
|
namespace CodexTests
|
||||||
{
|
{
|
||||||
public class AutoBootstrapDistTest : CodexDistTest
|
public class AutoBootstrapDistTest : CodexDistTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
using CodexPlugin;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Utils;
|
||||||
|
|
||||||
|
namespace CodexTests.BasicTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class BlockExchangeTests : CodexDistTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void EmptyAfterExchange()
|
||||||
|
{
|
||||||
|
var bootstrap = AddCodex(s => s.WithName("bootstrap"));
|
||||||
|
var node = AddCodex(s => s.WithName("node").WithBootstrapNode(bootstrap));
|
||||||
|
|
||||||
|
AssertExchangeIsEmpty(bootstrap, node);
|
||||||
|
|
||||||
|
var file = GenerateTestFile(1.MB());
|
||||||
|
var cid = bootstrap.UploadFile(file);
|
||||||
|
node.DownloadContent(cid);
|
||||||
|
|
||||||
|
AssertExchangeIsEmpty(bootstrap, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmptyAfterExchangeWithBystander()
|
||||||
|
{
|
||||||
|
var bootstrap = AddCodex(s => s.WithName("bootstrap"));
|
||||||
|
var node = AddCodex(s => s.WithName("node").WithBootstrapNode(bootstrap));
|
||||||
|
var bystander = AddCodex(s => s.WithName("bystander").WithBootstrapNode(bootstrap));
|
||||||
|
|
||||||
|
AssertExchangeIsEmpty(bootstrap, node, bystander);
|
||||||
|
|
||||||
|
var file = GenerateTestFile(1.MB());
|
||||||
|
var cid = bootstrap.UploadFile(file);
|
||||||
|
node.DownloadContent(cid);
|
||||||
|
|
||||||
|
AssertExchangeIsEmpty(bootstrap, node, bystander);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssertExchangeIsEmpty(params ICodexNode[] nodes)
|
||||||
|
{
|
||||||
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
Time.Retry(() => AssertBlockExchangeIsEmpty(node), nameof(AssertExchangeIsEmpty));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssertBlockExchangeIsEmpty(ICodexNode node)
|
||||||
|
{
|
||||||
|
var msg = $"BlockExchange for {node.GetName()}: ";
|
||||||
|
var response = node.GetDebugBlockExchange();
|
||||||
|
foreach (var peer in response.peers)
|
||||||
|
{
|
||||||
|
var activeWants = peer.wants.Where(w => !w.cancel).ToArray();
|
||||||
|
Assert.That(activeWants.Length, Is.EqualTo(0), msg + "thinks a peer has active wants.");
|
||||||
|
}
|
||||||
|
Assert.That(response.taskQueue, Is.EqualTo(0), msg + "has tasks in queue.");
|
||||||
|
Assert.That(response.pendingBlocks, Is.EqualTo(0), msg + "has pending blocks.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ using MetricsPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
[Ignore("Used for debugging continuous tests")]
|
[Ignore("Used for debugging continuous tests")]
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
|
@ -87,7 +87,7 @@ namespace Tests.BasicTests
|
||||||
//CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
|
//CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
|
||||||
//CheckRoutingTables(GetAllOnlineCodexNodes());
|
//CheckRoutingTables(GetAllOnlineCodexNodes());
|
||||||
|
|
||||||
var node = RandomUtils.PickOneRandom(nodes.ToList());
|
var node = nodes.ToList().PickOneRandom();
|
||||||
var file = GenerateTestFile(50.MB());
|
var file = GenerateTestFile(50.MB());
|
||||||
node.UploadFile(file);
|
node.UploadFile(file);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ using MetricsPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ExampleTests : CodexDistTest
|
public class ExampleTests : CodexDistTest
|
||||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
// Warning!
|
// Warning!
|
||||||
// This is a test to check network-isolation in the test-infrastructure.
|
// This is a test to check network-isolation in the test-infrastructure.
|
||||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class OneClientTests : DistTest
|
public class OneClientTests : DistTest
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
using DistTestCore;
|
using NUnit.Framework;
|
||||||
using NUnit.Framework;
|
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ThreeClientTest : AutoBootstrapDistTest
|
public class ThreeClientTest : AutoBootstrapDistTest
|
||||||
|
|
|
@ -3,7 +3,7 @@ using DistTestCore;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Tests.BasicTests
|
namespace CodexTests.BasicTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TwoClientTests : DistTest
|
public class TwoClientTests : DistTest
|
||||||
|
|
|
@ -9,7 +9,7 @@ using GethPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NUnit.Framework.Constraints;
|
using NUnit.Framework.Constraints;
|
||||||
|
|
||||||
namespace Tests
|
namespace CodexTests
|
||||||
{
|
{
|
||||||
public class CodexDistTest : DistTest
|
public class CodexDistTest : DistTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using CodexContractsPlugin;
|
using CodexContractsPlugin;
|
||||||
|
using CodexTests;
|
||||||
using GethPlugin;
|
using GethPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
|
@ -3,7 +3,7 @@ using Logging;
|
||||||
using MetricsPlugin;
|
using MetricsPlugin;
|
||||||
using NUnit.Framework.Constraints;
|
using NUnit.Framework.Constraints;
|
||||||
|
|
||||||
namespace Tests
|
namespace CodexTests
|
||||||
{
|
{
|
||||||
public static class MetricsAccessExtensions
|
public static class MetricsAccessExtensions
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
[assembly: LevelOfParallelism(1)]
|
[assembly: LevelOfParallelism(1)]
|
||||||
namespace Tests
|
namespace CodexTests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using CodexPlugin;
|
using CodexPlugin;
|
||||||
|
using CodexTests;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace Tests.PeerDiscoveryTests
|
namespace Tests.PeerDiscoveryTests
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using CodexContractsPlugin;
|
using CodexContractsPlugin;
|
||||||
|
using CodexTests;
|
||||||
using GethPlugin;
|
using GethPlugin;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue