2
0
mirror of synced 2025-02-02 19:53:29 +00:00

Sets up tests for symmetric, asymmetric and binary speed checks

This commit is contained in:
Ben 2025-01-13 11:31:56 +01:00
parent 53bc6d8983
commit 6d36d0c048
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
13 changed files with 145 additions and 561 deletions

View File

@ -234,8 +234,15 @@ namespace CodexPlugin
.CreateEndpoint(GetAddress(), "/api/codex/v1/", Container.Name);
}
public static Address? UploaderOverride { get; set; } = null;
public static Address? DownloaderOverride { get; set; } = null;
private Address GetAddress()
{
if (GetName().ToLowerInvariant().Contains("upload") && UploaderOverride != null) return UploaderOverride;
if (GetName().ToLowerInvariant().Contains("download") && DownloaderOverride != null) return DownloaderOverride;
return Container.Containers.Single().GetAddress(CodexContainerRecipe.ApiPortTag);
}

View File

@ -1,9 +0,0 @@
<Application x:Class="SeeTimeline.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SeeTimeline"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -1,14 +0,0 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace SeeTimeline
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -1,10 +0,0 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -1,286 +0,0 @@
using CodexPlugin;
using System.IO;
using System.Windows.Media;
namespace SeeTimeline
{
public class CodexEvent
{
public string Name { get; }
public Color Color { get; }
public DateTime Dt { get; private set; }
public CodexEvent(string name, Color color, DateTime dt)
{
Name = name;
Color = color;
Dt = dt;
}
public void Scale(DateTime from, double factor)
{
var span = Dt - from;
Dt = from + (span * factor);
}
public override string ToString()
{
return Name;
}
}
public class EventSet
{
public const string NoAddress = "-";
public const string MiscAddress = "~";
private readonly Dictionary<string, List<CodexEvent>> events = new Dictionary<string, List<CodexEvent>>();
private readonly LogLineAdder adder = new LogLineAdder();
public void Add(string address, CodexEvent e)
{
if (!events.ContainsKey(address)) events.Add(address, new List<CodexEvent>());
events[address].Add(e);
if (e.Dt > Latest) Latest = e.Dt;
if (e.Dt < Earliest) Earliest = e.Dt;
}
public string[] Addresses => events.Keys.ToArray();
public DateTime Earliest { get; private set; } = DateTime.MaxValue;
public DateTime Latest { get; private set; } = DateTime.MinValue;
public void KeepOnly(string[] addresses)
{
var keys = events.Keys.ToArray();
foreach (var key in keys)
{
if (key != NoAddress && !key.StartsWith(MiscAddress) && !addresses.Contains(key))
{
events.Remove(key);
}
}
}
public void Iterate(Action<string, CodexEvent[]> action)
{
foreach (var pair in events)
{
action(pair.Key, pair.Value.ToArray());
}
}
public void AddLine(string line)
{
var cline = CodexLogLine.Parse(line);
if (cline == null) return;
adder.Add(cline, this);
}
public void AddFile(string path)
{
var lines = File.ReadAllLines(path);
foreach (var line in lines) AddLine(line);
}
public void Scale(DateTime from, double factor)
{
foreach (var pair in events)
{
foreach (var e in pair.Value) e.Scale(from, factor);
}
}
}
public class LogLineAdder
{
public void Add(CodexLogLine line, EventSet set)
{
var context = new SetLineContext(line, set);
context.Parse();
}
public class SetLineContext
{
private readonly CodexLogLine line;
private readonly EventSet set;
public SetLineContext(CodexLogLine line, EventSet set)
{
this.line = line;
this.set = set;
}
public void Parse()
{
var colormap = new Dictionary<string, Color>
{
{ "0", Colors.Black },
{ "1", Colors.Red },
{ "2", Colors.Green },
{ "3", Colors.Blue },
{ "4", Colors.Red },
{ "5", Colors.Green },
{ "6", Colors.Blue },
{ "7", Colors.Red },
{ "8", Colors.Green },
{ "9", Colors.Blue },
{ "10", Colors.Black }
};
//if (!line.Attributes.Any(a => a.Value.ToLowerInvariant().Contains("index: 5"))) return;
//AddJobs(result, "Created", Colors.Red, req.Created);
// trace "BlockRequest created", address
if (line.Message == "BlockRequest created") AddEvent(line.Attributes["address"], "ReqCreated", Colors.Red);
//AddJobs(result, "TaskScheduled", Colors.Purple, req.TaskScheduled);
// trace "Task scheduled", peerId = task.id
else if (line.Message == "Task scheduled") AddEvent(EventSet.NoAddress, "TaskScheduled", Colors.Black);
//trace "Sending wantHave request", toAsk, peer = p.id
//AddJobs(result, "WantHaveSent", Colors.Orange, req.WantHaveSent);
else if (line.Message == "Sending wantHave request") AddMultiple(line.Attributes["toAsk"], "SentWantHave", Colors.Orange);
//trace "Sending wantBlock request to", addresses, peer = blockPeer.id
//AddJobs(result, "WantBlkSent", Colors.Green, req.WantBlkSent);
else if (line.Message == "Sending wantBlock request to") AddMultiple(line.Attributes["addresses"], "SentWantBlk", Colors.Green);
//trace "Handling blockPresences", addrs = blocks.mapIt(it.address), anyCancel = blocks.anyIt(it.isCancel)
//AddJobs(result, "PresenceRecv", Colors.Yellow, req.PresenceRecv);
else if (line.Message == "Handling blockPresences")
{
var anyCancel = line.Attributes["anyCancel"].ToLowerInvariant();
if (anyCancel == "true")
{
AddMultiple(line.Attributes["addrs"], "CancelPresenceRecv", Colors.Red);
}
else
{
AddMultiple(line.Attributes["addrs"], "PresenceRecv", Colors.Yellow);
}
}
//trace "Sending block request cancellations to peers", addrs, peers = b.peers.mapIt($it.id)
//AddJobs(result, "CancelSent", Colors.Purple, req.CancelSent);
else if (line.Message == "Sending block request cancellations to peers") AddMultiple(line.Attributes["addrs"], "CancelSent", Colors.Purple);
//trace "Resolving blocks", addrs = blocksDelivery.mapIt(it.address)
//AddJobs(result, "Resolve", Colors.Pink, req.Resolve);
else if (line.Message == "Resolving blocks") AddMultiple(line.Attributes["addrs"], "Resolve", Colors.Pink);
//trace "Received blocks from peer", peer, blocks = (blocksDelivery.mapIt(it.address))
//AddJobs(result, "BlkRecv", Colors.Blue, req.BlkRecv);
else if (line.Message == "Received blocks from peer") AddMultiple(line.Attributes["blocks"], "BlkRecv", Colors.Blue);
//logScope:
// peer = peerCtx.id
// address = e.address
// wantType = $e.wantType
// isCancel = $e.cancel
//trace "Received wantHave".
//AddJobs(result, "WantHaveRecv", Colors.Red, req.WantHaveRecv);
else if (line.Message == "Received wantHave")
{
var isCancel = line.Attributes["isCancel"];
if (isCancel.ToLowerInvariant() == "true")
{
AddEvent(line.Attributes["address"], "CancelRecv", Colors.Red);
}
else
{
AddEvent(line.Attributes["address"], "WantHaveRecv", Colors.Red);
}
}
//trace "Received wantBlock"
//AddJobs(result, "WantBlkRecv", Colors.Yellow, req.WantBlkRecv);
else if (line.Message == "Received wantBlock") AddEvent(line.Attributes["address"], "WantBlkRecv", Colors.Yellow);
//trace "Sending presence to remote", addrs = presence.mapIt(it.address), anyCancel = presence.anyIt(it.isCancel)
//AddJobs(result, "PresenceSent", Colors.Orange, req.PresenceSent);
else if (line.Message == "Sending presence")
{
var isCancel = line.Attributes["anyCancel"];
if (isCancel.ToLowerInvariant() == "true")
{
AddMultiple(line.Attributes["addrs"], "CancelPresenceSent", Colors.Red);
}
else
{
AddMultiple(line.Attributes["addrs"], "PresenceSent", Colors.Orange);
}
}
//trace "Begin sending blocks", addrs = wantAddresses
//AddJobs(result, "BlkSendStart", Colors.Green, req.BlkSendStart);
else if (line.Message == "Begin sending blocks") AddMultiple(line.Attributes["addrs"], "BlkSendStart", Colors.Green);
//trace "Finished sending blocks", addrs = wantAddresses
//AddJobs(result, "BlkSendEnd", Colors.Blue, req.BlkSendEnd);
else if (line.Message == "Finished sending blocks") AddMultiple(line.Attributes["addrs"], "BlkSendEnd", Colors.Blue);
else if (line.Message == "tick") AddEvent(EventSet.MiscAddress, "tick", Colors.Black);
//// Discovery Started
//else if (line.Message == "Discovery Started") AddEvent(EventSet.NoAddress, "DiscoveryStart", Colors.Black);
//// Setting up peer
//else if (line.Message == "Setting up peer") AddEvent(EventSet.NoAddress, "NewPeer", Colors.Black);
//// Error block handle, disconnecting peer
//else if (line.Message == "Error block handle, disconnecting peer") AddEvent(EventSet.NoAddress, "DisconnectPeer", Colors.Black);
//// Dropping peer
//else if (line.Message == "Dropping peer") AddEvent(EventSet.NoAddress, "DisconnectPeer", Colors.Black);
//// Acquired slot
//else if (line.Message == "Acquired slot") AddEvent(EventSet.MiscAddress, "AcqSlot", Colors.Black);
//// Released slot
//else if (line.Message == "Released slot") AddEvent(EventSet.MiscAddress, "RlsSlot", Colors.Black);
//// Got discv5 lookup query response
//else if (line.Message == "Got discv5 lookup query response") AddEvent(EventSet.MiscAddress, "Discv5", Colors.Black);
//// waiting for data
//else if (line.Message == "waiting for data") AddEvent(EventSet.MiscAddress, "wait", Colors.Black);
// MsgReceived
// MsgSending
// MsgSent
//else if (line.Message == "MsgSending") AddEvent(EventSet.MiscAddress + "snd", line.Attributes["num"], colormap[line.Attributes["num"]]);
//else if (line.Message == "MsgSent") AddEvent(EventSet.MiscAddress + "snt", line.Attributes["num"], colormap[line.Attributes["num"]]);
//else if (line.Message == "MsgReceived") AddEvent(EventSet.MiscAddress + "rcv", line.Attributes["num"], colormap[line.Attributes["num"]]);
//else if (line.Message == "lpc-write-fast") AddEvent(EventSet.MiscAddress + "f", "F", Colors.Black);
//else if (line.Message == "lpc-write-prepare") AddEvent(EventSet.MiscAddress + "p", "P", Colors.Black);
else if (line.Message == "chronoswrite") AddEvent(EventSet.MiscAddress + "chronos-write", line.Attributes["ticks"], Colors.Black);
else if (line.Message == "chronosread") AddEvent(EventSet.MiscAddress + "chronos-read", line.Attributes["ticks"], Colors.Black);
}
private void AddMultiple(string addresses, string name, Color color)
{
var addressToken = addresses
.Replace("@[", "")
.Replace("]", "");
//foreach (var adddress in addressTokens)
//{
// AddEvent(adddress, name, color);
//}
AddEvent(addressToken, name, color);
}
private void AddEvent(string address, string name, Color color)
{
set.Add(address, new CodexEvent(name, color, line.TimestampUtc));
}
}
}
}

View File

@ -1,42 +0,0 @@
<Window x:Class="SeeTimeline.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tl="clr-namespace:TimelinerNet;assembly=TimelinerNet"
xmlns:local="clr-namespace:SeeTimeline"
mc:Ignorable="d"
Title="SeeTimeline" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Content="Load Logs" Click="Button_Click"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.LayoutTransform>
<ScaleTransform
ScaleX="1.0"
ScaleY="1.0"/>
</Grid.LayoutTransform>
<TextBlock Grid.Row="0" Name="Line1Name" HorizontalAlignment="Center"/>
<tl:Timeliner Name="Timeliner1" Grid.Row="1"/>
<TextBlock Grid.Row="2" Name="Line2Name" HorizontalAlignment="Center"/>
<tl:Timeliner Name="Timeliner2" Grid.Row="3"/>
<TextBlock Grid.Row="4" Name="Line3Name" HorizontalAlignment="Center"/>
<tl:Timeliner Name="Timeliner3" Grid.Row="5"/>
<TextBlock Grid.Row="6" Name="Line4Name" HorizontalAlignment="Center"/>
<tl:Timeliner Name="Timeliner4" Grid.Row="7"/>
</Grid>
</Grid>
</Window>

View File

@ -1,161 +0,0 @@
using System.IO;
using System.Windows;
using System.Windows.Media;
using TimelinerNet;
namespace SeeTimeline
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Timeliner1.PropertyChanged += Timeliner1_PropertyChanged;
Timeliner3.PropertyChanged += Timeliner3_PropertyChanged;
}
private void Timeliner3_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Timeliner4.LeftEdge = Timeliner3.LeftEdge;
Timeliner4.RightEdge = Timeliner3.RightEdge;
}
private void Timeliner1_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Timeliner2.LeftEdge = Timeliner1.LeftEdge;
Timeliner2.RightEdge = Timeliner1.RightEdge;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//var path = "d:\\Projects\\cs-codex-dist-tests\\Tests\\CodexReleaseTests\\bin\\Debug\\net8.0\\CodexTestLogs\\2025-01\\08\\13-56-44Z_TwoClientTests\\";
var path = "c:\\Projects\\cs-codex-dist-tests\\Tests\\CodexReleaseTests\\bin\\Debug\\net8.0\\CodexTestLogs\\2025-01\\09\\10-45-20Z_TwoClientTests\\";
var file1 = Path.Combine(path, "TwoClientTest[thatbenbierens_nim-codex_blkex-cancelpresence-25-f]_000001_Downloader1.log");
var file2 = Path.Combine(path, "TwoClientTest[thatbenbierens_nim-codex_blkex-cancelpresence-25-f]_000000_Uploader0.log");
var file3 = Path.Combine(path, "TwoClientTest[thatbenbierens_nim-codex_blkex-cancelpresence-25-s]_000001_Downloader1.log");
var file4 = Path.Combine(path, "TwoClientTest[thatbenbierens_nim-codex_blkex-cancelpresence-25-s]_000000_Uploader0.log");
Line1Name.Text = file1;
Line2Name.Text = file2;
Line3Name.Text = file3;
Line4Name.Text = file4;
var set1 = new EventSet();
set1.AddFile(file1);
var addrs1 = set1.Addresses.Take(5).ToArray();
set1.KeepOnly(addrs1);
var set2 = new EventSet();
set2.AddFile(file2);
set2.KeepOnly(addrs1);
var set3 = new EventSet();
set3.AddFile(file3);
var addrs2 = set3.Addresses.Take(5).ToArray();
set3.KeepOnly(addrs2);
var set4 = new EventSet();
set4.AddFile(file4);
set4.KeepOnly(addrs2);
var factor = 3600.0 * 24.0;
var now1 = set1.Earliest;
set1.Scale(from: now1, factor);
set2.Scale(from: now1, factor);
var now2 = set3.Earliest;
set3.Scale(from: now2, factor);
set4.Scale(from: now2, factor);
DisplaySet(set1, Timeliner1);
DisplaySet(set2, Timeliner2);
DisplaySet(set3, Timeliner3);
DisplaySet(set4, Timeliner4);
//var end1 = set2.Latest;
Timeliner1.Now = now1;
Timeliner2.Now = now1;
Timeliner1.LeftEdge = now1;
//Timeliner1.RightEdge = end1;
Timeliner2.LeftEdge = now1;
//Timeliner2.RightEdge = end1;
//var end2 = set3.Latest;
Timeliner3.Now = now2;
Timeliner4.Now = now2;
Timeliner3.LeftEdge = now2;
//Timeliner3.RightEdge = end2;
Timeliner4.LeftEdge = now2;
//Timeliner4.RightEdge = end2;
}
private void DisplaySet(EventSet set, Timeliner timeliner)
{
timeliner.Data = new TimelinerData()
{
Items = CreateItems(set)
};
}
private List<TimelinerItem> CreateItems(EventSet set)
{
var result = new List<TimelinerItem>();
set.Iterate((addr, events) =>
{
if (addr == EventSet.NoAddress || addr.StartsWith(EventSet.MiscAddress))
{
result.Add(CreateItem(addr, events));
}
else
{
foreach (var e in events)
{
result.Add(new TimelinerItem()
{
Name = addr + " " + e.Name,
Jobs = new List<TimelinerJob>
{
CreateJob(e)
}
});
}
}
});
return result;
}
private TimelinerItem CreateItem(string addr, CodexEvent[] events)
{
return new TimelinerItem
{
Name = addr,
Jobs = CreateJobs(events)
};
}
private List<TimelinerJob> CreateJobs(CodexEvent[] events)
{
return events.Select(CreateJob).ToList();
}
private TimelinerJob CreateJob(CodexEvent e)
{
return new TimelinerJob
{
Name = e.Name,
Color = new SolidColorBrush(e.Color),
Begin = e.Dt,
End = e.Dt
};
}
}
}

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TimelinerNet" Version="0.1.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProjectPlugins\CodexPlugin\CodexPlugin.csproj" />
</ItemGroup>
</Project>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
using NUnit.Framework;
[assembly: LevelOfParallelism(1)]
namespace CodexTests
{
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProjectPlugins\CodexPlugin\CodexPlugin.csproj" />
<ProjectReference Include="..\Tests\DistTestCore\DistTestCore.csproj" />
<ProjectReference Include="..\Tests\ExperimentalTests\ExperimentalTests.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,107 @@
using CodexPlugin;
using CodexTests;
using NUnit.Framework;
using System.Diagnostics;
using System.Drawing;
using Utils;
namespace SpeedCheckTests
{
[TestFixture]
public class SpeedTest : CodexDistTest
{
[Test]
public void Symmetric()
{
// Symmetric: A node always sends a reply to every message it receives.
CodexContainerRecipe.DockerImageOverride = "thatbenbierens/nim-codex:blkex-cancelpresence-27-f";
var uploader = StartCodex(s => s.WithName("SymUploader"));
var downloader = StartCodex(s => s.WithName("SymDownloader").WithBootstrapNode(uploader));
var timeTaken = PerformTest(uploader, downloader);
Console.WriteLine($"Symmetric time: {Time.FormatDuration(timeTaken)}");
Assert.That(timeTaken, Is.LessThan(TimeSpan.FromSeconds(10.0)),
$"Symmetric: Too slow. Expected less than 10 seconds but was: {Time.FormatDuration(timeTaken)}");
}
[Test]
public void Asymmetric()
{
// Asymmetric: A node does not always send a reply when a message is received.
CodexContainerRecipe.DockerImageOverride = "thatbenbierens/nim-codex:blkex-cancelpresence-27-s";
var uploader = StartCodex(s => s.WithName("AsymUploader"));
var downloader = StartCodex(s => s.WithName("AsymDownloader").WithBootstrapNode(uploader));
var timeTaken = PerformTest(uploader, downloader);
Console.WriteLine($"Asymmetric time: {Time.FormatDuration(timeTaken)}");
Assert.That(timeTaken, Is.LessThan(TimeSpan.FromSeconds(10.0)),
$"Asymmetric: Too slow. Expected less than 10 seconds but was: {Time.FormatDuration(timeTaken)}");
}
[Test]
public void Binary()
{
// Docker image not used: Here for api check.
CodexContainerRecipe.DockerImageOverride = "thatbenbierens/nim-codex:blkex-cancelpresence-27-f";
var binary = "C:\\Projects\\nim-codex\\build\\codex.exe";
if (!File.Exists(binary)) throw new Exception("TODO: Update binary path");
var uploadInfo = new ProcessStartInfo
{
FileName = binary,
Arguments = "--data-dir=upload_data " +
"--api-port=8081 " +
"--nat=127.0.0.1 " +
"--disc-ip=127.0.0.1 " +
"--disc-port=8091 " +
"--listen-addrs=/ip4/127.0.0.1/tcp/8071",
UseShellExecute = true,
};
var uploadProcess = Process.Start(uploadInfo);
Thread.Sleep(5000);
if (uploadProcess == null || uploadProcess.HasExited) throw new Exception("Node exited.");
CodexAccess.UploaderOverride = new Address("http://localhost", 8081);
var uploader = StartCodex(s => s.WithName("BinaryUploader"));
var spr = uploader.GetSpr();
var downloadProcess = Process.Start(binary,
"--data-dir=download_data " +
"--api-port=8082 " +
"--nat=127.0.0.1 " +
"--disc-ip=127.0.0.1 " +
"--disc-port=8092 " +
"--listen-addrs=/ip4/127.0.0.1/tcp/8072 " +
"--bootstrap-node=" + spr
);
CodexAccess.DownloaderOverride = new Address("http://localhost", 8082);
var downloader = StartCodex(s => s.WithName("BinaryDownloader"));
var timeTaken = PerformTest(uploader, downloader);
uploadProcess.Kill();
downloadProcess.Kill();
Console.WriteLine($"Binary time: {Time.FormatDuration(timeTaken)}");
Assert.That(timeTaken, Is.LessThan(TimeSpan.FromSeconds(10.0)),
$"Binary: Too slow. Expected less than 10 seconds but was: {Time.FormatDuration(timeTaken)}");
}
private TimeSpan PerformTest(ICodexNode uploader, ICodexNode downloader)
{
var testFile = GenerateTestFile(100.MB());
var contentId = uploader.UploadFile(testFile);
var (downloadedFile, timeTaken) = downloader.DownloadContentT(contentId);
return timeTaken;
}
}
}

View File

@ -82,7 +82,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExperimentalTests", "Tests\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlockchainUtils", "Framework\BlockchainUtils\BlockchainUtils.csproj", "{4648B5AA-A0A7-44BA-89BC-2FD57370943C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeeTimeline", "SeeTimeline\SeeTimeline.csproj", "{24702B12-0448-4770-9AD2-8BDE5B04EF94}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeedCheckTests", "SpeedCheckTests\SpeedCheckTests.csproj", "{5D134D9A-DC61-4472-8F47-92250C8DB5CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -222,10 +222,10 @@ Global
{4648B5AA-A0A7-44BA-89BC-2FD57370943C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4648B5AA-A0A7-44BA-89BC-2FD57370943C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4648B5AA-A0A7-44BA-89BC-2FD57370943C}.Release|Any CPU.Build.0 = Release|Any CPU
{24702B12-0448-4770-9AD2-8BDE5B04EF94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24702B12-0448-4770-9AD2-8BDE5B04EF94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24702B12-0448-4770-9AD2-8BDE5B04EF94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24702B12-0448-4770-9AD2-8BDE5B04EF94}.Release|Any CPU.Build.0 = Release|Any CPU
{5D134D9A-DC61-4472-8F47-92250C8DB5CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D134D9A-DC61-4472-8F47-92250C8DB5CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D134D9A-DC61-4472-8F47-92250C8DB5CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D134D9A-DC61-4472-8F47-92250C8DB5CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -264,7 +264,7 @@ Global
{639A0603-4E80-465B-BB59-AB02F1DEEF5A} = {88C2A621-8A98-4D07-8625-7900FC8EF89E}
{BA7369CD-7C2F-4075-8E35-98BCC19EE203} = {88C2A621-8A98-4D07-8625-7900FC8EF89E}
{4648B5AA-A0A7-44BA-89BC-2FD57370943C} = {81AE04BC-CBFA-4E6F-B039-8208E9AFAAE7}
{24702B12-0448-4770-9AD2-8BDE5B04EF94} = {88C2A621-8A98-4D07-8625-7900FC8EF89E}
{5D134D9A-DC61-4472-8F47-92250C8DB5CC} = {88C2A621-8A98-4D07-8625-7900FC8EF89E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {237BF0AA-9EC4-4659-AD9A-65DEB974250C}