Updates parser for new counter format.
This commit is contained in:
parent
6a96bd7639
commit
1bca2bb928
|
@ -37,17 +37,6 @@ namespace Core
|
|||
return logHandler.DownloadLog();
|
||||
}
|
||||
|
||||
public Stream MonitorLog(IHasContainer container)
|
||||
{
|
||||
return MonitorLog(container.Container);
|
||||
}
|
||||
|
||||
public Stream MonitorLog(RunningContainer container)
|
||||
{
|
||||
var workflow = entryPoint.Tools.CreateWorkflow();
|
||||
return workflow.MonitorContainerLog(container);
|
||||
}
|
||||
|
||||
public string ExecuteContainerCommand(IHasContainer containerSource, string command, params string[] args)
|
||||
{
|
||||
return ExecuteContainerCommand(containerSource.Container, command, args);
|
||||
|
|
|
@ -57,12 +57,6 @@ namespace KubernetesWorkflow
|
|||
logHandler.Log(stream);
|
||||
}
|
||||
|
||||
public Stream MonitorContainerLog(RunningContainer container)
|
||||
{
|
||||
log.Debug();
|
||||
return client.Run(c => c.ReadNamespacedPodLog(container.Pod.PodInfo.Name, K8sNamespace, container.Recipe.Name, follow: true, sinceSeconds: 1));
|
||||
}
|
||||
|
||||
public string ExecuteCommand(RunningPod pod, string containerName, string command, params string[] args)
|
||||
{
|
||||
var cmdAndArgs = $"{containerName}: {command} ({string.Join(",", args)})";
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace KubernetesWorkflow
|
|||
CrashWatcher CreateCrashWatcher(RunningContainer container);
|
||||
void Stop(RunningContainers runningContainers);
|
||||
void DownloadContainerLog(RunningContainer container, ILogHandler logHandler, int? tailLines = null);
|
||||
Stream MonitorContainerLog(RunningContainer container);
|
||||
string ExecuteCommand(RunningContainer container, string command, params string[] args);
|
||||
void DeleteNamespace();
|
||||
void DeleteNamespacesStartingWith(string namespacePrefix);
|
||||
|
@ -84,14 +83,6 @@ namespace KubernetesWorkflow
|
|||
});
|
||||
}
|
||||
|
||||
public Stream MonitorContainerLog(RunningContainer container)
|
||||
{
|
||||
return K8s(controller =>
|
||||
{
|
||||
return controller.MonitorContainerLog(container);
|
||||
});
|
||||
}
|
||||
|
||||
public string ExecuteCommand(RunningContainer container, string command, params string[] args)
|
||||
{
|
||||
return K8s(controller =>
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace ContinuousTests
|
|||
private const int sizeOfPage = 2000;
|
||||
private string searchAfter = "";
|
||||
private int lastHits = 1;
|
||||
private int lastLogLine = -1;
|
||||
private ulong lastLogLine = 0;
|
||||
|
||||
public LogReconstructor(LogFile targetFile, IHttp http, string queryTemplate)
|
||||
{
|
||||
|
@ -115,13 +115,28 @@ namespace ContinuousTests
|
|||
private void AddHitToQueue(SearchHitEntry hit)
|
||||
{
|
||||
var message = hit.fields.message.Single();
|
||||
var sub = message.Substring(0, 12);
|
||||
if (int.TryParse(sub, out int number))
|
||||
var number = ParseCountNumber(message);
|
||||
if (number != null)
|
||||
{
|
||||
queue.Add(new LogQueueEntry(message, number));
|
||||
queue.Add(new LogQueueEntry(message, number.Value));
|
||||
}
|
||||
}
|
||||
|
||||
private ulong? ParseCountNumber(string message)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message)) return null;
|
||||
var tokens = message.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (!tokens.Any()) return null;
|
||||
var countToken = tokens.SingleOrDefault(t => t.StartsWith("count="));
|
||||
if (countToken == null) return null;
|
||||
var number = countToken.Substring(6);
|
||||
if (ulong.TryParse(number, out ulong value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void UpdateSearchAfter(SearchResponse response)
|
||||
{
|
||||
var uniqueSearchNumbers = response.hits.hits.Select(h => h.sort.Single()).Distinct().ToList();
|
||||
|
@ -141,7 +156,7 @@ namespace ContinuousTests
|
|||
{
|
||||
while (queue.Any())
|
||||
{
|
||||
var wantedNumber = lastLogLine + 1;
|
||||
ulong wantedNumber = lastLogLine + 1;
|
||||
DeleteOldEntries(wantedNumber);
|
||||
|
||||
var currentEntry = queue.FirstOrDefault(e => e.Number == wantedNumber);
|
||||
|
@ -167,21 +182,21 @@ namespace ContinuousTests
|
|||
targetFile.WriteRaw(currentEntry.Message);
|
||||
}
|
||||
|
||||
private void DeleteOldEntries(int wantedNumber)
|
||||
private void DeleteOldEntries(ulong wantedNumber)
|
||||
{
|
||||
queue.RemoveAll(e => e.Number < wantedNumber);
|
||||
}
|
||||
|
||||
public class LogQueueEntry
|
||||
{
|
||||
public LogQueueEntry(string message, int number)
|
||||
public LogQueueEntry(string message, ulong number)
|
||||
{
|
||||
Message = message;
|
||||
Number = number;
|
||||
}
|
||||
|
||||
public string Message { get; }
|
||||
public int Number { get; }
|
||||
public ulong Number { get; }
|
||||
}
|
||||
|
||||
public class SearchResponse
|
||||
|
|
Loading…
Reference in New Issue