mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-02 13:33:07 +00:00
packaging
This commit is contained in:
parent
74c44c4ef8
commit
873e4750ab
@ -55,6 +55,11 @@
|
||||
return GetEnvVar("ES_PASSWORD", "password");
|
||||
}
|
||||
|
||||
public string GetOuputFolder()
|
||||
{
|
||||
return GetEnvVar("OUTPUT_FOLDER", "/tmp");
|
||||
}
|
||||
|
||||
private string GetEnvVar(string name, string defaultValue)
|
||||
{
|
||||
var v = Environment.GetEnvironmentVariable(name);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using System.IO.Compression;
|
||||
using System.Numerics;
|
||||
using CodexContractsPlugin.ChainMonitor;
|
||||
using CodexContractsPlugin.Marketplace;
|
||||
using Logging;
|
||||
@ -24,15 +25,17 @@ namespace TraceContract
|
||||
private readonly List<Entry> entries = new();
|
||||
private readonly string folder;
|
||||
private readonly List<string> files = new();
|
||||
private readonly Input input;
|
||||
private readonly Config config;
|
||||
|
||||
public Output(ILog log, Input input, Config config)
|
||||
{
|
||||
folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
var filename = Path.Combine(folder, $"Contract_{input.PurchaseId}");
|
||||
var filename = Path.Combine(folder, $"contract_{input.PurchaseId}");
|
||||
var fileLog = new FileLog(filename);
|
||||
files.Add(fileLog.FullFilename);
|
||||
files.Add(fileLog.FullFilename + ".log");
|
||||
foreach (var pair in config.LogReplacements)
|
||||
{
|
||||
fileLog.AddStringReplace(pair.Key, pair.Value);
|
||||
@ -41,6 +44,8 @@ namespace TraceContract
|
||||
|
||||
log.Log($"Logging to '{filename}'");
|
||||
this.log = new LogSplitter(fileLog, log);
|
||||
this.input = input;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public void LogRequestCreated(RequestEvent requestEvent)
|
||||
@ -94,6 +99,13 @@ namespace TraceContract
|
||||
foreach (var e in sorted) Write(e);
|
||||
}
|
||||
|
||||
public LogFile CreateNodeLogTargetFile(string node)
|
||||
{
|
||||
var file = log.CreateSubfile(node);
|
||||
files.Add(file.Filename);
|
||||
return file;
|
||||
}
|
||||
|
||||
private void Write(Entry e)
|
||||
{
|
||||
log.Log($"[{Time.FormatTimestamp(e.Utc)}] {e.Msg}");
|
||||
@ -104,16 +116,19 @@ namespace TraceContract
|
||||
Add(call.Block.Utc, $"Reserve-slot called. Index: {call.SlotIndex} Host: '{call.FromAddress}'");
|
||||
}
|
||||
|
||||
public string Package()
|
||||
{
|
||||
var outputFolder = config.GetOuputFolder();
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
var filename = Path.Combine(outputFolder, $"contract_{input.PurchaseId}.zip");
|
||||
|
||||
ZipFile.CreateFromDirectory(folder, filename);
|
||||
return filename;
|
||||
}
|
||||
|
||||
private void Add(DateTime utc, string msg)
|
||||
{
|
||||
entries.Add(new Entry(utc, msg));
|
||||
}
|
||||
|
||||
public LogFile CreateNodeLogTargetFile(string node)
|
||||
{
|
||||
var file = log.CreateSubfile(node);
|
||||
files.Add(file.Filename);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using BlockchainUtils;
|
||||
using CodexContractsPlugin;
|
||||
using CodexContractsPlugin.Marketplace;
|
||||
using ContinuousTests;
|
||||
using Core;
|
||||
using GethPlugin;
|
||||
using Logging;
|
||||
@ -56,7 +55,9 @@ namespace TraceContract
|
||||
Log("Downloading storage nodes logs for the request timerange...");
|
||||
DownloadStorageNodeLogs(requestTimeRange, entryPoint.Tools);
|
||||
|
||||
// package everything
|
||||
Log("Packaging...");
|
||||
var zipFilename = output.Package();
|
||||
Log($"Saved to '{zipFilename}'");
|
||||
|
||||
entryPoint.Decommission(false, false, false);
|
||||
Log("Done");
|
||||
@ -87,8 +88,9 @@ namespace TraceContract
|
||||
Log($"Downloading logs from '{node}'...");
|
||||
|
||||
var targetFile = output.CreateNodeLogTargetFile(node);
|
||||
var downloader = new ElasticSearchLogDownloader(log, tools, config.StorageNodesKubernetesNamespace);
|
||||
downloader.Download(targetFile, node, start, requestTimeRange.To);
|
||||
targetFile.Write("TODO!");
|
||||
//var downloader = new ElasticSearchLogDownloader(log, tools, config);
|
||||
//downloader.Download(targetFile, node, start, requestTimeRange.To);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user