Better logging still
This commit is contained in:
parent
a60124239c
commit
f866e5f648
|
@ -28,7 +28,6 @@ namespace CodexDistTestCore
|
||||||
var result = new TestFile(Path.Combine(Folder, Guid.NewGuid().ToString() + "_test.bin"));
|
var result = new TestFile(Path.Combine(Folder, Guid.NewGuid().ToString() + "_test.bin"));
|
||||||
File.Create(result.Filename).Close();
|
File.Create(result.Filename).Close();
|
||||||
activeFiles.Add(result);
|
activeFiles.Add(result);
|
||||||
log.Log($"Created test file '{result.Filename}'.");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +85,6 @@ namespace CodexDistTestCore
|
||||||
if (other == null) Assert.Fail("TestFile is null.");
|
if (other == null) Assert.Fail("TestFile is null.");
|
||||||
if (other == this || other!.Filename == Filename) Assert.Fail("TestFile is compared to itself.");
|
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 stream1 = new FileStream(Filename, FileMode.Open, FileAccess.Read);
|
||||||
using var stream2 = new FileStream(other.Filename, FileMode.Open, FileAccess.Read);
|
using var stream2 = new FileStream(other.Filename, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,20 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
public TestFile? DownloadContent(ContentId contentId)
|
public TestFile? DownloadContent(ContentId contentId)
|
||||||
{
|
{
|
||||||
Log($"Downloading for contentId: {contentId}");
|
Log($"Downloading for contentId: {contentId.Id}");
|
||||||
var file = fileManager.CreateEmptyTestFile();
|
var file = fileManager.CreateEmptyTestFile();
|
||||||
using var fileStream = File.OpenWrite(file.Filename);
|
DownloadToFile(contentId.Id, file);
|
||||||
using var downloadStream = Http().HttpGetStream("download/" + contentId.Id);
|
Log($"Downloaded file of size {file.GetFileSize()} to {file.Filename}");
|
||||||
downloadStream.CopyTo(fileStream);
|
|
||||||
Log($"Downloaded file of size {file.GetFileSize()}");
|
|
||||||
return file;
|
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()
|
private Http Http()
|
||||||
{
|
{
|
||||||
return new Http(ip: "127.0.0.1", port: Container.ServicePort, baseUrl: "/api/codex/v1");
|
return new Http(ip: "127.0.0.1", port: Container.ServicePort, baseUrl: "/api/codex/v1");
|
||||||
|
|
|
@ -30,8 +30,16 @@ namespace CodexDistTestCore
|
||||||
var result = TestContext.CurrentContext.Result;
|
var result = TestContext.CurrentContext.Result;
|
||||||
|
|
||||||
Log($"Finished: {GetTestName()} = {result.Outcome.Status}");
|
Log($"Finished: {GetTestName()} = {result.Outcome.Status}");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(result.Message))
|
||||||
|
{
|
||||||
|
Log(result.Message);
|
||||||
|
}
|
||||||
|
|
||||||
if (result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Failed)
|
if (result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Failed)
|
||||||
{
|
{
|
||||||
|
Log($"{result.StackTrace}");
|
||||||
|
|
||||||
var logWriter = new PodLogWriter(file);
|
var logWriter = new PodLogWriter(file);
|
||||||
logWriter.IncludeFullPodLogging(k8sManager);
|
logWriter.IncludeFullPodLogging(k8sManager);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue