Fixes pod logging for multiple codex nodes.
This commit is contained in:
parent
e9168dc168
commit
5ccc3f0177
|
@ -39,7 +39,7 @@ namespace CodexDistTestCore
|
||||||
public OnlineCodexNode[] Nodes { get; }
|
public OnlineCodexNode[] Nodes { get; }
|
||||||
public V1Deployment? Deployment { get; set; }
|
public V1Deployment? Deployment { get; set; }
|
||||||
public V1Service? Service { get; set; }
|
public V1Service? Service { get; set; }
|
||||||
public List<string> ActivePodNames { get; } = new List<string>();
|
public string? PodName { get; set; }
|
||||||
|
|
||||||
public CodexNodeContainer[] GetContainers()
|
public CodexNodeContainer[] GetContainers()
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,29 +50,34 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
public void FetchAllPodsLogs(CodexNodeGroup[] onlines, IPodLogsHandler logHandler)
|
public void FetchAllPodsLogs(CodexNodeGroup[] onlines, IPodLogsHandler logHandler)
|
||||||
{
|
{
|
||||||
|
var logNumberSource = new NumberSource(0);
|
||||||
foreach (var online in onlines)
|
foreach (var online in onlines)
|
||||||
{
|
{
|
||||||
var nodeDescription = online.Describe();
|
foreach (var node in online)
|
||||||
foreach (var podName in online.ActivePodNames)
|
|
||||||
{
|
{
|
||||||
var stream = client.ReadNamespacedPodLog(podName, K8sNamespace);
|
WritePodLogs(online, node, logHandler, logNumberSource);
|
||||||
logHandler.Log(online.OrderNumber, $"{nodeDescription}:{podName}", stream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WritePodLogs(CodexNodeGroup online, IOnlineCodexNode node, IPodLogsHandler logHandler, NumberSource logNumberSource)
|
||||||
|
{
|
||||||
|
var n = (OnlineCodexNode)node;
|
||||||
|
var nodeDescription = $"{online.Describe()} contains {n.GetName()}";
|
||||||
|
|
||||||
|
var stream = client.ReadNamespacedPodLog(online.PodName, K8sNamespace, n.Container.Name);
|
||||||
|
logHandler.Log(logNumberSource.GetNextNumber(), nodeDescription, stream);
|
||||||
|
}
|
||||||
|
|
||||||
private void AssignActivePodNames(CodexNodeGroup online)
|
private void AssignActivePodNames(CodexNodeGroup online)
|
||||||
{
|
{
|
||||||
var pods = client.ListNamespacedPod(K8sNamespace);
|
var pods = client.ListNamespacedPod(K8sNamespace);
|
||||||
var podNames = pods.Items.Select(p => p.Name());
|
var podNames = pods.Items.Select(p => p.Name());
|
||||||
foreach (var podName in podNames)
|
|
||||||
{
|
var newPodNames = podNames.Where(p => !knownPods.Contains(p)).ToArray();
|
||||||
if (!knownPods.Contains(podName))
|
Assert.That(newPodNames.Length, Is.EqualTo(1), "Expected only 1 pod to be created. Test infra failure.");
|
||||||
{
|
|
||||||
knownPods.Add(podName);
|
online.PodName = newPodNames.Single();
|
||||||
online.ActivePodNames.Add(podName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Waiting
|
#region Waiting
|
||||||
|
|
|
@ -27,10 +27,15 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
public CodexNodeContainer Container { get; }
|
public CodexNodeContainer Container { get; }
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
{
|
||||||
|
return $"<{Container.Name}>";
|
||||||
|
}
|
||||||
|
|
||||||
public CodexDebugResponse GetDebugInfo()
|
public CodexDebugResponse GetDebugInfo()
|
||||||
{
|
{
|
||||||
var response = Http().HttpGetJson<CodexDebugResponse>("debug/info");
|
var response = Http().HttpGetJson<CodexDebugResponse>("debug/info");
|
||||||
Log($"Got DebugInfo with id: {response.id}.");
|
Log($"Got DebugInfo with id: '{response.id}'.");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,16 +48,16 @@ namespace CodexDistTestCore
|
||||||
{
|
{
|
||||||
Assert.Fail("Node failed to store block.");
|
Assert.Fail("Node failed to store block.");
|
||||||
}
|
}
|
||||||
Log($"Uploaded file. Received contentId: {response}.");
|
Log($"Uploaded file. Received contentId: '{response}'.");
|
||||||
return new ContentId(response);
|
return new ContentId(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestFile? DownloadContent(ContentId contentId)
|
public TestFile? DownloadContent(ContentId contentId)
|
||||||
{
|
{
|
||||||
Log($"Downloading for contentId: {contentId.Id}...");
|
Log($"Downloading for contentId: '{contentId.Id}'...");
|
||||||
var file = fileManager.CreateEmptyTestFile();
|
var file = fileManager.CreateEmptyTestFile();
|
||||||
DownloadToFile(contentId.Id, file);
|
DownloadToFile(contentId.Id, file);
|
||||||
Log($"Downloaded file of size {file.GetFileSize()} to {file.Filename}.");
|
Log($"Downloaded file of size {file.GetFileSize()} to '{file.Filename}'.");
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +65,7 @@ namespace CodexDistTestCore
|
||||||
{
|
{
|
||||||
var peer = (OnlineCodexNode)node;
|
var peer = (OnlineCodexNode)node;
|
||||||
|
|
||||||
Log($"Connecting to peer <{peer.Container.Name}>...");
|
Log($"Connecting to peer {peer.GetName()}...");
|
||||||
var peerInfo = node.GetDebugInfo();
|
var peerInfo = node.GetDebugInfo();
|
||||||
var peerId = peerInfo.id;
|
var peerId = peerInfo.id;
|
||||||
var peerMultiAddress = GetPeerMultiAddress(peer, peerInfo);
|
var peerMultiAddress = GetPeerMultiAddress(peer, peerInfo);
|
||||||
|
@ -68,7 +73,7 @@ namespace CodexDistTestCore
|
||||||
var response = Http().HttpGetString($"connect/{peerId}?addrs={peerMultiAddress}");
|
var response = Http().HttpGetString($"connect/{peerId}?addrs={peerMultiAddress}");
|
||||||
|
|
||||||
Assert.That(response, Is.EqualTo(SuccessfullyConnectedMessage), "Unable to connect codex nodes.");
|
Assert.That(response, Is.EqualTo(SuccessfullyConnectedMessage), "Unable to connect codex nodes.");
|
||||||
Log($"Successfully connected to peer <{peer.Container.Name}>.");
|
Log($"Successfully connected to peer {peer.GetName()}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPeerMultiAddress(OnlineCodexNode peer, CodexDebugResponse peerInfo)
|
private string GetPeerMultiAddress(OnlineCodexNode peer, CodexDebugResponse peerInfo)
|
||||||
|
@ -93,7 +98,7 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
private void Log(string msg)
|
private void Log(string msg)
|
||||||
{
|
{
|
||||||
log.Log($"<{Container.Name}>: {msg}");
|
log.Log($"{GetName()}: {msg}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue