twoclient test passed.

This commit is contained in:
benbierens 2023-09-12 11:43:46 +02:00
parent 4cbd9ac828
commit 32ad778a91
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 35 additions and 27 deletions

View File

@ -1,4 +1,5 @@

using DistTestCore;
namespace CodexPlugin
{
public interface ICodexNodeFactory
@ -8,6 +9,13 @@ namespace CodexPlugin
public class CodexNodeFactory : ICodexNodeFactory
{
private readonly IPluginTools tools;
public CodexNodeFactory(IPluginTools tools)
{
this.tools = tools;
}
//private readonly TestLifecycle lifecycle;
//private readonly IMetricsAccessFactory metricsAccessFactory;
//private readonly IMarketplaceAccessFactory marketplaceAccessFactory;
@ -23,7 +31,7 @@ namespace CodexPlugin
{
//var metricsAccess = metricsAccessFactory.CreateMetricsAccess(access.Container);
//var marketplaceAccess = marketplaceAccessFactory.CreateMarketplaceAccess(access);
return new OnlineCodexNode(/*lifecycle,*/ access, group/*, metricsAccess, marketplaceAccess*/);
return new OnlineCodexNode(tools, access, group/*, metricsAccess, marketplaceAccess*/);
}
}
}

View File

@ -50,7 +50,7 @@ namespace CodexPlugin
{
//var metricAccessFactory = CollectMetrics(codexSetup, containers);
var codexNodeFactory = new CodexNodeFactory();// (lifecycle, metricAccessFactory, gethStartResult.MarketplaceAccessFactory);
var codexNodeFactory = new CodexNodeFactory(pluginTools);// (lifecycle, metricAccessFactory, gethStartResult.MarketplaceAccessFactory);
return CreateCodexGroup(/*codexSetup,*/ containers, codexNodeFactory);
//lifecycle.SetCodexVersion(group.Version);

View File

@ -1,5 +1,7 @@
using DistTestCore.Logs;
using DistTestCore;
using DistTestCore.Logs;
using FileUtils;
using Logging;
using NUnit.Framework;
using Utils;
@ -24,11 +26,11 @@ namespace CodexPlugin
{
private const string SuccessfullyConnectedMessage = "Successfully connected to peer";
private const string UploadFailedMessage = "Unable to store block";
//private readonly TestLifecycle lifecycle;
private readonly IPluginTools tools;
public OnlineCodexNode(/*TestLifecycle lifecycle, */CodexAccess codexAccess, CodexNodeGroup group/*, IMetricsAccess metricsAccess, IMarketplaceAccess marketplaceAccess*/)
public OnlineCodexNode(IPluginTools tools, CodexAccess codexAccess, CodexNodeGroup group/*, IMetricsAccess metricsAccess, IMarketplaceAccess marketplaceAccess*/)
{
//this.lifecycle = lifecycle;
this.tools = tools;
CodexAccess = codexAccess;
Group = group;
//Metrics = metricsAccess;
@ -62,32 +64,30 @@ namespace CodexPlugin
public ContentId UploadFile(TestFile file)
{
//using var fileStream = File.OpenRead(file.Filename);
using var fileStream = File.OpenRead(file.Filename);
//var logMessage = $"Uploading file {file.Describe()}...";
//Log(logMessage);
//var response = Stopwatch.Measure(lifecycle.Log, logMessage, () =>
//{
// return CodexAccess.UploadFile(fileStream);
//});
var logMessage = $"Uploading file {file.Describe()}...";
Log(logMessage);
var response = Stopwatch.Measure(tools.GetLog(), logMessage, () =>
{
return CodexAccess.UploadFile(fileStream);
});
//if (string.IsNullOrEmpty(response)) Assert.Fail("Received empty response.");
//if (response.StartsWith(UploadFailedMessage)) Assert.Fail("Node failed to store block.");
if (string.IsNullOrEmpty(response)) Assert.Fail("Received empty response.");
if (response.StartsWith(UploadFailedMessage)) Assert.Fail("Node failed to store block.");
//Log($"Uploaded file. Received contentId: '{response}'.");
//return new ContentId(response);
return null!;
Log($"Uploaded file. Received contentId: '{response}'.");
return new ContentId(response);
}
public TestFile? DownloadContent(ContentId contentId, string fileLabel = "")
{
//var logMessage = $"Downloading for contentId: '{contentId.Id}'...";
//Log(logMessage);
//var file = lifecycle.FileManager.CreateEmptyTestFile(fileLabel);
//Stopwatch.Measure(lifecycle.Log, logMessage, () => DownloadToFile(contentId.Id, file));
//Log($"Downloaded file {file.Describe()} to '{file.Filename}'.");
//return file;
return null!;
var logMessage = $"Downloading for contentId: '{contentId.Id}'...";
Log(logMessage);
var file = tools.GetFileManager().CreateEmptyTestFile(fileLabel);
Stopwatch.Measure(tools.GetLog(), logMessage, () => DownloadToFile(contentId.Id, file));
Log($"Downloaded file {file.Describe()} to '{file.Filename}'.");
return file;
}
public void ConnectToPeer(IOnlineCodexNode node)
@ -159,7 +159,7 @@ namespace CodexPlugin
private void Log(string msg)
{
//lifecycle.Log.Log($"{GetName()}: {msg}");
tools.GetLog().Log($"{GetName()}: {msg}");
}
}