2023-03-19 09:49:03 +00:00
|
|
|
|
using NUnit.Framework;
|
2023-03-17 10:43:29 +00:00
|
|
|
|
|
|
|
|
|
namespace CodexDistTests.TestCore
|
|
|
|
|
{
|
|
|
|
|
public abstract class DistTest
|
|
|
|
|
{
|
2023-03-19 09:49:03 +00:00
|
|
|
|
private FileManager fileManager = null!;
|
|
|
|
|
private K8sManager k8sManager = null!;
|
2023-03-17 10:43:29 +00:00
|
|
|
|
|
2023-03-19 09:49:03 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUpDistTest()
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
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);
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-19 09:49:03 +00:00
|
|
|
|
[TearDown]
|
|
|
|
|
public void TearDownDistTest()
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
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;
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-19 09:49:03 +00:00
|
|
|
|
public TestFile GenerateTestFile(int size = 1024)
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
2023-03-19 09:49:03 +00:00
|
|
|
|
return fileManager.GenerateTestFile(size);
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
|
2023-03-19 09:49:03 +00:00
|
|
|
|
public IOfflineCodexNode SetupCodexNode()
|
|
|
|
|
{
|
|
|
|
|
return new OfflineCodexNode(k8sManager);
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-20 09:37:03 +00:00
|
|
|
|
|
|
|
|
|
public static class GlobalTestFailure
|
|
|
|
|
{
|
|
|
|
|
public static bool HasFailed { get; set; } = false;
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|