cs-codex-dist-tests/DistTestCore/Codex/CodexAccess.cs

41 lines
1.4 KiB
C#
Raw Normal View History

2023-04-12 11:53:55 +00:00
using KubernetesWorkflow;
namespace DistTestCore.Codex
{
public class CodexAccess
{
private readonly TestLifecycle lifecycle;
2023-04-30 08:08:32 +00:00
public CodexAccess(TestLifecycle lifecycle, RunningContainer runningContainer)
2023-04-12 11:53:55 +00:00
{
this.lifecycle = lifecycle;
2023-04-13 07:33:10 +00:00
Container = runningContainer;
var address = lifecycle.Configuration.GetAddress(Container);
Node = new CodexNode(lifecycle.Log, lifecycle.TimeSet, address);
}
public RunningContainer Container { get; }
public CodexNode Node { get; }
2023-05-11 10:44:53 +00:00
public void EnsureOnline()
{
try
{
var debugInfo = Node.GetDebugInfo();
if (debugInfo == null || string.IsNullOrEmpty(debugInfo.id)) throw new InvalidOperationException("Unable to get debug-info from codex node at startup.");
var nodePeerId = debugInfo.id;
var nodeName = Container.Name;
lifecycle.Log.AddStringReplace(nodePeerId, nodeName);
lifecycle.Log.AddStringReplace(debugInfo.table.localNode.nodeId, nodeName);
}
catch (Exception e)
{
lifecycle.Log.Error($"Failed to start codex node: {e}. Test infra failure.");
throw new InvalidOperationException($"Failed to start codex node. Test infra failure.", e);
}
}
}
2023-04-12 11:53:55 +00:00
}