cs-codex-dist-tests/Tests/CodexTests/ScalabilityTests/ScalabilityTests.cs

43 lines
1.4 KiB
C#
Raw Normal View History

2024-04-13 13:27:47 +00:00
using CodexPlugin;
using NUnit.Framework;
using Utils;
namespace CodexTests.ScalabilityTests;
[TestFixture]
public class ScalabilityTests : CodexDistTest
{
private const string PatchedImage = "codexstorage/nim-codex:sha-9aeac06-dist-tests";
private const string MasterImage = "codexstorage/nim-codex:sha-5380912-dist-tests";
[Test]
[Combinatorial]
public void ShouldMaintainFileInNetwork(
[Values(10, 20, 40, 80, 100)] int numberOfNodes,
[Values(100, 1000, 5000, 10000)] int fileSizeInMb,
[Values(true, false)] bool usePatchedImage
)
{
CodexContainerRecipe.DockerImageOverride = usePatchedImage ? PatchedImage : MasterImage;
2024-04-13 13:36:16 +00:00
2024-04-13 13:27:47 +00:00
var bootstrap = AddCodex();
var nodes = AddCodex(numberOfNodes - 1,
2024-04-13 13:36:16 +00:00
s => s.WithBootstrapNode(bootstrap).WithLogLevel(CodexLogLevel.Info)).ToList();
2024-04-13 13:27:47 +00:00
var uploader = nodes.PickOneRandom();
var downloader = nodes.PickOneRandom();
var testFile = GenerateTestFile(fileSizeInMb.MB());
var contentId = uploader.UploadFile(testFile);
var downloadedFile = downloader.DownloadContent(contentId);
downloadedFile!.AssertIsEqual(testFile);
uploader.Stop(true);
var otherDownloader = nodes.PickOneRandom();
downloadedFile = otherDownloader.DownloadContent(contentId);
downloadedFile!.AssertIsEqual(testFile);
}
}