2
0
mirror of synced 2025-01-11 17:14:25 +00:00

Adds test to capture upload-interrupt node crash.

This commit is contained in:
Ben 2024-10-09 09:11:04 +02:00
parent fc9249da20
commit 2e9d7641a3
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
2 changed files with 45 additions and 3 deletions

View File

@ -71,6 +71,10 @@
task();
return;
}
catch (OperationCanceledException)
{
return;
}
catch (Exception ex)
{
var failure = CaptureFailure(ex);

View File

@ -1,5 +1,7 @@
using CodexPlugin;
using FileUtils;
using NUnit.Framework;
using System.Diagnostics;
using Utils;
namespace CodexTests.BasicTests
@ -10,11 +12,47 @@ namespace CodexTests.BasicTests
[Test]
public void OneClientTest()
{
var primary = StartCodex();
var node = StartCodex();
PerformOneClientTest(primary);
PerformOneClientTest(node);
LogNodeStatus(primary);
LogNodeStatus(node);
}
[Test]
public void InterruptUploadTest()
{
var tasks = new List<Task<bool>>();
for (var i = 0; i < 10; i++)
{
tasks.Add(Task<bool>.Run(() => RunInterruptUploadTest()));
}
Task.WaitAll(tasks.ToArray());
Assert.That(tasks.Select(t => t.Result).All(r => r == true));
}
private bool RunInterruptUploadTest()
{
var node = StartCodex();
var file = GenerateTestFile(300.MB());
var process = StartCurlUploadProcess(node, file);
Thread.Sleep(500);
process.Kill();
Thread.Sleep(1000);
var log = Ci.DownloadLog(node);
return !log.GetLinesContaining("Unhandled exception in async proc, aborting").Any();
}
private Process StartCurlUploadProcess(ICodexNode node, TrackedFile file)
{
var apiAddress = node.Container.GetAddress(CodexContainerRecipe.ApiPortTag);
var codexUrl = $"{apiAddress}/api/codex/v1/data";
var filePath = file.Filename;
return Process.Start("curl", $"-X POST {codexUrl} -H \"Content-Type: application/octet-stream\" -T {filePath}");
}
private void PerformOneClientTest(ICodexNode primary)