Better logging still

This commit is contained in:
benbierens 2023-03-22 09:50:24 +01:00
parent a60124239c
commit f866e5f648
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 18 additions and 8 deletions

View File

@ -28,7 +28,6 @@ namespace CodexDistTestCore
var result = new TestFile(Path.Combine(Folder, Guid.NewGuid().ToString() + "_test.bin"));
File.Create(result.Filename).Close();
activeFiles.Add(result);
log.Log($"Created test file '{result.Filename}'.");
return result;
}
@ -86,8 +85,6 @@ namespace CodexDistTestCore
if (other == null) Assert.Fail("TestFile is null.");
if (other == this || other!.Filename == Filename) Assert.Fail("TestFile is compared to itself.");
if (GetFileSize() != other.GetFileSize()) Assert.Fail("file sizes unequal?");
using var stream1 = new FileStream(Filename, FileMode.Open, FileAccess.Read);
using var stream2 = new FileStream(other.Filename, FileMode.Open, FileAccess.Read);

View File

@ -45,15 +45,20 @@ namespace CodexDistTestCore
public TestFile? DownloadContent(ContentId contentId)
{
Log($"Downloading for contentId: {contentId}");
Log($"Downloading for contentId: {contentId.Id}");
var file = fileManager.CreateEmptyTestFile();
using var fileStream = File.OpenWrite(file.Filename);
using var downloadStream = Http().HttpGetStream("download/" + contentId.Id);
downloadStream.CopyTo(fileStream);
Log($"Downloaded file of size {file.GetFileSize()}");
DownloadToFile(contentId.Id, file);
Log($"Downloaded file of size {file.GetFileSize()} to {file.Filename}");
return file;
}
private void DownloadToFile(string contentId, TestFile file)
{
using var fileStream = File.OpenWrite(file.Filename);
using var downloadStream = Http().HttpGetStream("download/" + contentId);
downloadStream.CopyTo(fileStream);
}
private Http Http()
{
return new Http(ip: "127.0.0.1", port: Container.ServicePort, baseUrl: "/api/codex/v1");

View File

@ -30,8 +30,16 @@ namespace CodexDistTestCore
var result = TestContext.CurrentContext.Result;
Log($"Finished: {GetTestName()} = {result.Outcome.Status}");
if (!string.IsNullOrEmpty(result.Message))
{
Log(result.Message);
}
if (result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Failed)
{
Log($"{result.StackTrace}");
var logWriter = new PodLogWriter(file);
logWriter.IncludeFullPodLogging(k8sManager);
}