Stops test run when cleanup fails

This commit is contained in:
benbierens 2023-03-20 10:37:03 +01:00
parent f64fd79b23
commit 3b782d0e37
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 25 additions and 8 deletions

View File

@ -53,9 +53,6 @@ namespace CodexDistTests.BasicTests
// var downloadedFile = secondary.DownloadContent(contentId);
// testFile.AssertIsEqual(downloadedFile);
// // Test files are automatically deleted.
// // Online nodes are automatically destroyed.
//}
}
}

View File

@ -10,15 +10,30 @@ namespace CodexDistTests.TestCore
[SetUp]
public void SetUpDistTest()
{
fileManager = new FileManager();
k8sManager = new K8sManager(fileManager);
if (GlobalTestFailure.HasFailed)
{
Assert.Inconclusive("Skip test: Previous test failed during clean up.");
}
else
{
fileManager = new FileManager();
k8sManager = new K8sManager(fileManager);
}
}
[TearDown]
public void TearDownDistTest()
{
k8sManager.DeleteAllResources();
fileManager.DeleteAllTestFiles();
try
{
k8sManager.DeleteAllResources();
fileManager.DeleteAllTestFiles();
}
catch (Exception ex)
{
Console.WriteLine("Cleanup has failed." + ex.Message);
GlobalTestFailure.HasFailed = true;
}
}
public TestFile GenerateTestFile(int size = 1024)
@ -31,4 +46,9 @@ namespace CodexDistTests.TestCore
return new OfflineCodexNode(k8sManager);
}
}
public static class GlobalTestFailure
{
public static bool HasFailed { get; set; } = false;
}
}

View File

@ -257,7 +257,7 @@ namespace CodexDistTests.TestCore
private void DeleteNamespace(Kubernetes client)
{
if (activeNamespace == null) return;
client.DeleteNamespace(activeNamespace.Name());
client.DeleteNamespace(activeNamespace.Name(), null, null, gracePeriodSeconds: 0);
activeNamespace = null;
}