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 namespace CodexPlugin
{ {
public interface ICodexNodeFactory public interface ICodexNodeFactory
@ -8,6 +9,13 @@ namespace CodexPlugin
public class CodexNodeFactory : ICodexNodeFactory public class CodexNodeFactory : ICodexNodeFactory
{ {
private readonly IPluginTools tools;
public CodexNodeFactory(IPluginTools tools)
{
this.tools = tools;
}
//private readonly TestLifecycle lifecycle; //private readonly TestLifecycle lifecycle;
//private readonly IMetricsAccessFactory metricsAccessFactory; //private readonly IMetricsAccessFactory metricsAccessFactory;
//private readonly IMarketplaceAccessFactory marketplaceAccessFactory; //private readonly IMarketplaceAccessFactory marketplaceAccessFactory;
@ -23,7 +31,7 @@ namespace CodexPlugin
{ {
//var metricsAccess = metricsAccessFactory.CreateMetricsAccess(access.Container); //var metricsAccess = metricsAccessFactory.CreateMetricsAccess(access.Container);
//var marketplaceAccess = marketplaceAccessFactory.CreateMarketplaceAccess(access); //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 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); return CreateCodexGroup(/*codexSetup,*/ containers, codexNodeFactory);
//lifecycle.SetCodexVersion(group.Version); //lifecycle.SetCodexVersion(group.Version);

View File

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