Debugging downloader in cluster
This commit is contained in:
parent
adbd481c7c
commit
a69bea47af
@ -74,6 +74,8 @@ namespace ContinuousTests
|
||||
return GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
public IPluginTools Tools { get; internal set; }
|
||||
}
|
||||
|
||||
public enum TestFailMode
|
||||
|
@ -37,7 +37,7 @@ namespace ContinuousTests
|
||||
var queryTemplate = CreateQueryTemplate(container, startUtc, endUtc);
|
||||
|
||||
targetFile.Write($"Downloading '{container.Name}' to '{targetFile.FullFilename}'.");
|
||||
var reconstructor = new LogReconstructor(targetFile, http, queryTemplate);
|
||||
var reconstructor = new LogReconstructor(log, targetFile, http, queryTemplate);
|
||||
reconstructor.DownloadFullLog();
|
||||
|
||||
log.Log("Log download finished.");
|
||||
@ -50,10 +50,13 @@ namespace ContinuousTests
|
||||
var end = endUtc.ToString("o");
|
||||
|
||||
var source = "{ \"sort\": [ { \"@timestamp\": { \"order\": \"asc\" } } ], \"fields\": [ { \"field\": \"@timestamp\", \"format\": \"strict_date_optional_time\" }, { \"field\": \"pod_name\" }, { \"field\": \"message\" } ], \"size\": <SIZE>, <SEARCHAFTER> \"_source\": false, \"query\": { \"bool\": { \"must\": [], \"filter\": [ { \"range\": { \"@timestamp\": { \"format\": \"strict_date_optional_time\", \"gte\": \"<STARTTIME>\", \"lte\": \"<ENDTIME>\" } } }, { \"match_phrase\": { \"pod_name\": \"<PODNAME>\" } } ] } } }";
|
||||
return source
|
||||
var result = source
|
||||
.Replace("<STARTTIME>", start)
|
||||
.Replace("<ENDTIME>", end)
|
||||
.Replace("<PODNAME>", podName);
|
||||
|
||||
log.Log($"query template: '{result}'");
|
||||
return result;
|
||||
}
|
||||
|
||||
private IHttp CreateElasticSearchHttp()
|
||||
@ -62,6 +65,9 @@ namespace ContinuousTests
|
||||
var k8sNamespace = "monitoring";
|
||||
var address = new Address($"http://{serviceName}.{k8sNamespace}.svc.cluster.local", 9200);
|
||||
var baseUrl = "";
|
||||
|
||||
log.Log("elastic search: " + address.Host + ":" + address.Port);
|
||||
|
||||
return tools.CreateHttp(address, baseUrl, client =>
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("kbn-xsrf", "reporting");
|
||||
@ -71,6 +77,7 @@ namespace ContinuousTests
|
||||
public class LogReconstructor
|
||||
{
|
||||
private readonly List<LogQueueEntry> queue = new List<LogQueueEntry>();
|
||||
private readonly ILog log;
|
||||
private readonly LogFile targetFile;
|
||||
private readonly IHttp http;
|
||||
private readonly string queryTemplate;
|
||||
@ -79,8 +86,9 @@ namespace ContinuousTests
|
||||
private int lastHits = 1;
|
||||
private ulong lastLogLine = 0;
|
||||
|
||||
public LogReconstructor(LogFile targetFile, IHttp http, string queryTemplate)
|
||||
public LogReconstructor(ILog log, LogFile targetFile, IHttp http, string queryTemplate)
|
||||
{
|
||||
this.log = log;
|
||||
this.targetFile = targetFile;
|
||||
this.http = http;
|
||||
this.queryTemplate = queryTemplate;
|
||||
@ -101,8 +109,12 @@ namespace ContinuousTests
|
||||
.Replace("<SIZE>", sizeOfPage.ToString())
|
||||
.Replace("<SEARCHAFTER>", searchAfter);
|
||||
|
||||
log.Log($"query with size {sizeOfPage} and searchAfter '{searchAfter}'.");
|
||||
|
||||
var response = http.HttpPostString<SearchResponse>("_search", query);
|
||||
|
||||
log.Log("number of hits: " + response.hits.hits.Length);
|
||||
|
||||
lastHits = response.hits.hits.Length;
|
||||
if (lastHits > 0)
|
||||
{
|
||||
|
@ -210,6 +210,7 @@ namespace ContinuousTests
|
||||
{
|
||||
Log($" > Running TestMoment '{name}'");
|
||||
handle.Test.Initialize(nodes, fixtureLog, entryPoint.Tools.GetFileManager(), config, cancelToken);
|
||||
handle.Test.Tools = entryPoint.Tools;
|
||||
}
|
||||
|
||||
private void DecommissionTest()
|
||||
|
@ -26,6 +26,10 @@ namespace ContinuousTests.Tests
|
||||
|
||||
var dl = Nodes[0].DownloadContent(cid);
|
||||
file.AssertIsEqual(dl);
|
||||
|
||||
var targetFile = Log.CreateSubfile();
|
||||
var downloader = new ElasticSearchLogDownloader(Tools, Log);
|
||||
downloader.Download(targetFile, Nodes[0].Container, DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)), DateTime.UtcNow.AddMinutes(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user