2023-04-12 11:53:55 +00:00
|
|
|
|
using KubernetesWorkflow;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore.Codex
|
|
|
|
|
{
|
|
|
|
|
public class CodexAccess
|
|
|
|
|
{
|
2023-06-01 07:35:18 +00:00
|
|
|
|
private readonly TestLifecycle lifecycle;
|
2023-04-30 08:08:32 +00:00
|
|
|
|
|
2023-06-01 07:35:18 +00:00
|
|
|
|
public CodexAccess(TestLifecycle lifecycle, RunningContainer runningContainer)
|
2023-04-12 11:53:55 +00:00
|
|
|
|
{
|
2023-06-01 07:35:18 +00:00
|
|
|
|
this.lifecycle = lifecycle;
|
2023-04-13 07:33:10 +00:00
|
|
|
|
Container = runningContainer;
|
|
|
|
|
|
2023-06-21 06:28:40 +00:00
|
|
|
|
var address = lifecycle.Configuration.GetAddress(Container);
|
|
|
|
|
Node = new CodexNode(lifecycle.Log, lifecycle.TimeSet, address);
|
2023-04-18 13:33:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 06:28:40 +00:00
|
|
|
|
public RunningContainer Container { get; }
|
|
|
|
|
public CodexNode Node { get; }
|
2023-05-11 10:44:53 +00:00
|
|
|
|
|
2023-05-04 09:34:43 +00:00
|
|
|
|
public void EnsureOnline()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-06-21 06:28:40 +00:00
|
|
|
|
var debugInfo = Node.GetDebugInfo();
|
2023-05-04 09:34:43 +00:00
|
|
|
|
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;
|
2023-06-01 07:35:18 +00:00
|
|
|
|
lifecycle.Log.AddStringReplace(nodePeerId, nodeName);
|
|
|
|
|
lifecycle.Log.AddStringReplace(debugInfo.table.localNode.nodeId, nodeName);
|
2023-05-04 09:34:43 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2023-06-01 07:35:18 +00:00
|
|
|
|
lifecycle.Log.Error($"Failed to start codex node: {e}. Test infra failure.");
|
2023-05-04 09:34:43 +00:00
|
|
|
|
throw new InvalidOperationException($"Failed to start codex node. Test infra failure.", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 13:33:12 +00:00
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|