wip setting up for packing and upload

This commit is contained in:
ThatBen 2025-05-20 14:41:33 +02:00
parent 9e9b147b68
commit 74c44c4ef8
No known key found for this signature in database
GPG Key ID: E020A7DDCD52E1AB
3 changed files with 60 additions and 23 deletions

View File

@ -15,17 +15,18 @@
/// </summary>
public TimeSpan LogStartBeforeStorageContractStarts { get; } = TimeSpan.FromMinutes(1.0);
public string ElasticSearchUrl { get; } = $"https://es.testnet.codex.storage";
public string StorageNodesKubernetesNamespace = "codex";
public string[] StorageNodesKubernetesContainerNames = [
"codex-1-1",
//"codex-2-1",
//"codex-3-1",
//"codex-4-1",
//"codex-5-1",
//"codex-6-1",
//"codex-7-1",
//"codex-8-1",
//"codex-9-1",
"codex-2-1",
"codex-3-1",
"codex-4-1",
"codex-5-1",
"codex-6-1",
"codex-7-1",
"codex-8-1",
"codex-9-1",
"codex-10-1",
// "codex-validator-1-1",
];
@ -43,5 +44,22 @@
{ "0xE7EEb996B3c817cEd03d10cd64A1325DA33D92e7", "codex 09" },
{ "0xD25C7609e97F40b66E74c0FcEbeA06D09423CC7e", "codex 10" }
};
public string GetElasticSearchUsername()
{
return GetEnvVar("ES_USERNAME", "username");
}
public string GetElasticSearchPassword()
{
return GetEnvVar("ES_PASSWORD", "password");
}
private string GetEnvVar(string name, string defaultValue)
{
var v = Environment.GetEnvironmentVariable(name);
if (string.IsNullOrEmpty(v)) return defaultValue;
return v;
}
}
}

View File

@ -1,21 +1,22 @@
using Core;
using System.Text;
using Core;
using Logging;
using Utils;
using WebUtils;
namespace ContinuousTests
namespace TraceContract
{
public class ElasticSearchLogDownloader
{
private readonly ILog log;
private readonly IPluginTools tools;
private readonly string k8SNamespace;
private readonly Config config;
public ElasticSearchLogDownloader(ILog log, IPluginTools tools, string k8sNamespace)
public ElasticSearchLogDownloader(ILog log, IPluginTools tools, Config config)
{
this.log = log;
this.tools = tools;
k8SNamespace = k8sNamespace;
this.config = config;
}
public void Download(LogFile targetFile, string containerName, DateTime startUtc, DateTime endUtc)
@ -59,19 +60,29 @@ namespace ContinuousTests
.Replace("<STARTTIME>", start)
.Replace("<ENDTIME>", end)
.Replace("<CONTAINERNAME>", containerName)
.Replace("<NAMESPACENAME>", k8SNamespace);
.Replace("<NAMESPACENAME>", config.StorageNodesKubernetesNamespace);
}
private IEndpoint CreateElasticSearchEndpoint()
{
var serviceName = "elasticsearch";
var k8sNamespace = "monitoring";
var address = new Address("ElasticSearchEndpoint", $"http://{serviceName}.{k8sNamespace}.svc.cluster.local", 9200);
//var serviceName = "elasticsearch";
//var k8sNamespace = "monitoring";
//var address = new Address("ElasticSearchEndpoint", $"http://{serviceName}.{k8sNamespace}.svc.cluster.local", 9200);
var address = new Address("TestnetElasticSearchEndpoint", config.ElasticSearchUrl, 443);
var baseUrl = "";
var username = config.GetElasticSearchUsername();
var password = config.GetElasticSearchPassword();
var base64Creds = Convert.ToBase64String(
Encoding.ASCII.GetBytes($"{username}:{password}")
);
var http = tools.CreateHttp(address.ToString(), client =>
{
client.DefaultRequestHeaders.Add("kbn-xsrf", "reporting");
client.DefaultRequestHeaders.Add("Authorization", "Basic " + base64Creds);
});
return http.CreateEndpoint(address, baseUrl);

View File

@ -2,12 +2,20 @@
{
public class Input
{
public string PurchaseId { get; } =
// expired:
"a7fe97dc32216aba0cbe74b87beb3f919aa116090dd5e0d48085a1a6b0080e82";
public string PurchaseId
{
get
{
var v = Environment.GetEnvironmentVariable("PURCHASE_ID");
if (!string.IsNullOrEmpty(v)) return v;
// started:
//"066df09a3a2e2587cfd577a0e96186c915b113d02b331b06e56f808494cff2b4";
return
// expired:
"a7fe97dc32216aba0cbe74b87beb3f919aa116090dd5e0d48085a1a6b0080e82";
// started:
//"066df09a3a2e2587cfd577a0e96186c915b113d02b331b06e56f808494cff2b4";
}
}
}
}