cs-codex-dist-tests/TestCore/DistTest.cs

57 lines
1.4 KiB
C#
Raw Normal View History

using NUnit.Framework;
namespace CodexDistTests.TestCore
{
public abstract class DistTest
{
private FileManager fileManager = null!;
private K8sManager k8sManager = null!;
[SetUp]
public void SetUpDistTest()
{
2023-03-20 09:37:03 +00:00
if (GlobalTestFailure.HasFailed)
{
Assert.Inconclusive("Skip test: Previous test failed during clean up.");
}
else
{
2023-03-20 10:37:02 +00:00
TestLog.BeginTest();
2023-03-20 09:37:03 +00:00
fileManager = new FileManager();
k8sManager = new K8sManager(fileManager);
}
}
[TearDown]
public void TearDownDistTest()
{
2023-03-20 09:37:03 +00:00
try
{
2023-03-20 10:37:02 +00:00
TestLog.EndTest(k8sManager);
2023-03-20 09:37:03 +00:00
k8sManager.DeleteAllResources();
fileManager.DeleteAllTestFiles();
}
catch (Exception ex)
{
2023-03-20 10:37:02 +00:00
TestLog.Error("Cleanup failed: " + ex.Message);
2023-03-20 09:37:03 +00:00
GlobalTestFailure.HasFailed = true;
}
}
public TestFile GenerateTestFile(int size = 1024)
{
return fileManager.GenerateTestFile(size);
}
public IOfflineCodexNode SetupCodexNode()
{
return new OfflineCodexNode(k8sManager);
}
}
2023-03-20 09:37:03 +00:00
public static class GlobalTestFailure
{
public static bool HasFailed { get; set; } = false;
}
}