wired up except for container log access

This commit is contained in:
ThatBen 2025-01-15 16:05:57 +01:00
parent ee0193c879
commit 0aac2d8e98
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
15 changed files with 48 additions and 14 deletions

View File

@ -31,7 +31,7 @@ namespace CodexPlugin
public void Stop(bool waitTillStopped)
{
CrashWatcher.Stop();
processControl.Stop(instance);
processControl.Stop(instance, waitTillStopped);
// Prevents accidental use after stop:
instance = null!;
}
@ -203,6 +203,16 @@ namespace CodexPlugin
//);
}
public Address GetApiEndpoint()
{
return instance.ApiEndpoint;
}
public Address GetListenEndpoint()
{
return instance.ListenEndpoint;
}
public Address? GetMetricsEndpoint()
{
return instance.GetMetricsEndpoint();

View File

@ -13,6 +13,7 @@ namespace CodexPlugin
DateTime StartUtc { get; }
Address DiscoveryEndpoint { get; }
Address ApiEndpoint { get; }
Address ListenEndpoint { get; }
void DeleteDataDirFolder();
EthAccount? GetEthAccount();
Address? GetMetricsEndpoint();
@ -37,6 +38,7 @@ namespace CodexPlugin
DiscoveryEndpoint = container.GetAddress(CodexContainerRecipe.DiscoveryPortTag);
ApiEndpoint = container.GetAddress(CodexContainerRecipe.ApiPortTag);
ListenEndpoint = container.GetAddress(CodexContainerRecipe.ListenPortTag);
if (pod.StartupConfig.Get<CodexSetup>().MetricsEnabled)
{
@ -50,6 +52,7 @@ namespace CodexPlugin
public DateTime StartUtc { get; }
public Address DiscoveryEndpoint { get; }
public Address ApiEndpoint { get; }
public Address ListenEndpoint { get; }
public void DeleteDataDirFolder()
{

View File

@ -11,6 +11,7 @@ namespace CodexPlugin
public interface ICodexNode : IHasMetricsScrapeTarget, IHasEthAddress
{
string GetName();
string GetImageName();
string GetPeerId();
DebugInfo GetDebugInfo(bool log = false);
string GetSpr();
@ -36,6 +37,8 @@ namespace CodexPlugin
EthAccount EthAccount { get; }
Address GetDiscoveryEndpoint();
Address GetApiEndpoint();
Address GetListenEndpoint();
/// <summary>
/// Warning! The node is not usable after this.
@ -119,6 +122,11 @@ namespace CodexPlugin
return codexAccess.GetName();
}
public string GetImageName()
{
return codexAccess.GetImageName();
}
public string GetPeerId()
{
return peerId;
@ -269,6 +277,16 @@ namespace CodexPlugin
return codexAccess.GetDiscoveryEndpoint();
}
public Address GetApiEndpoint()
{
return codexAccess.GetApiEndpoint();
}
public Address GetListenEndpoint()
{
return codexAccess.GetListenEndpoint();
}
public bool HasCrashed()
{
return codexAccess.CrashWatcher.HasCrashed();

View File

@ -72,7 +72,7 @@ namespace CodexPlugin
private void Log(string msg)
{
log.Log($"{codexAccess.Container.Containers.Single().Name} {msg}");
log.Log($"{codexAccess.GetName()} {msg}");
}
}

View File

@ -4,6 +4,7 @@ using DistTestCore;
using FileUtils;
using Logging;
using MetricsPlugin;
using Utils;
namespace ContinuousTests
{
@ -53,7 +54,7 @@ namespace ContinuousTests
return CreateMetricsAccess(target.MetricsScrapeTarget);
}
public IMetricsAccess CreateMetricsAccess(IMetricsScrapeTarget target)
public IMetricsAccess CreateMetricsAccess(Address target)
{
if (Configuration.CodexDeployment.PrometheusContainer == null) throw new Exception("Expected prometheus to be part of Codex deployment.");

View File

@ -68,7 +68,7 @@ namespace ContinuousTests
{
var serviceName = "elasticsearch";
var k8sNamespace = "monitoring";
var address = new Address($"http://{serviceName}.{k8sNamespace}.svc.cluster.local", 9200);
var address = new Address("ElasticSearchEndpoint", $"http://{serviceName}.{k8sNamespace}.svc.cluster.local", 9200);
var baseUrl = "";
var http = tools.CreateHttp(address.ToString(), client =>

View File

@ -40,7 +40,7 @@ namespace ContinuousTests
var entryPoint = CreateEntryPoint();
// We have to be sure that the transient node we start is using the same image as whatever's already in the deployed network.
// Therefore, we use the image of the bootstrap node.
CodexContainerRecipe.DockerImageOverride = bootstrapNode.Container.Recipe.Image;
CodexContainerRecipe.DockerImageOverride = bootstrapNode.GetImageName();
try
{

View File

@ -285,7 +285,7 @@ namespace ContinuousTests
private string GetContainerNames()
{
if (handle.Test.RequiredNumberOfNodes == -1) return "(All Nodes)";
return $"({string.Join(",", nodes.Select(n => n.Container.Name))})";
return $"({string.Join(",", nodes.Select(n => n.GetName()))})";
}
private ICodexNode[] CreateRandomNodes()

View File

@ -98,8 +98,8 @@ namespace ContinuousTests
{
cancelToken.ThrowIfCancellationRequested();
var address = n.Container.GetAddress(CodexContainerRecipe.ApiPortTag);
log.Log($"Checking {n.Container.Name} @ '{address}'...");
var address = n.GetApiEndpoint();
log.Log($"Checking {n.GetName()} @ '{address}'...");
if (EnsureOnline(log, n))
{

View File

@ -38,7 +38,7 @@ namespace CodexReleaseTests.DataTests
private Process StartCurlUploadProcess(ICodexNode node, TrackedFile file)
{
var apiAddress = node.Container.GetAddress(CodexContainerRecipe.ApiPortTag);
var apiAddress = node.GetApiEndpoint();
var codexUrl = $"{apiAddress}/api/codex/v1/data";
var filePath = file.Filename;
return Process.Start("curl", $"-X POST {codexUrl} -H \"Content-Type: application/octet-stream\" -T {filePath}");

View File

@ -36,7 +36,7 @@ namespace CodexReleaseTests.MarketTests
request.WaitForStorageContractStarted();
AssertContractSlotsAreFilledByHosts(request, hosts);
hosts.BringOffline(waitTillStopped: true);
hosts.Stop(waitTillStopped: true);
WaitForSlotFreedEvents();

View File

@ -51,7 +51,7 @@ namespace CodexReleaseTests.NodeTests
public void AnnounceAddress()
{
var node = StartCodex();
var addr = node.Container.GetInternalAddress(CodexContainerRecipe.ListenPortTag);
var addr = node.GetListenEndpoint();
var info = node.GetDebugInfo();

View File

@ -94,6 +94,7 @@ public class Program
var port = Convert.ToInt32(endpoint.Substring(splitIndex + 1));
var address = new Address(
logName: $"cdx@{host}:{port}",
host: host,
port: port
);

View File

@ -172,6 +172,7 @@ namespace BiblioTech
var port = Convert.ToInt32(endpoint.Substring(splitIndex + 1));
var address = new Address(
logName: $"cdx@{host}:{port}",
host: host,
port: port
);

View File

@ -201,12 +201,12 @@ namespace CodexNetDeployer
private void CheckContainerRestarts(List<CodexNodeStartResult> startResults)
{
var crashes = new List<RunningContainer>();
var crashes = new List<ICodexNode>();
Log("Starting container crash check...");
foreach (var startResult in startResults)
{
var hasCrashed = startResult.CodexNode.HasCrashed();
if (hasCrashed) crashes.Add(startResult.CodexNode.Container);
if (hasCrashed) crashes.Add(startResult.CodexNode);
}
if (!crashes.Any())
@ -216,7 +216,7 @@ namespace CodexNetDeployer
else
{
Log(
$"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.Name))}");
$"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.GetName()))}");
throw new Exception("Deployment failed: One or more containers crashed.");
}
}