Skip to content

Commit 2d90349

Browse files
committed
Updates autobootstrap fixture for parallel running.
1 parent c4b6d01 commit 2d90349

File tree

6 files changed

+32
-25
lines changed

6 files changed

+32
-25
lines changed

ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace CodexPlugin
77
{
88
public class CodexContainerRecipe : ContainerRecipeFactory
99
{
10-
private const string DefaultDockerImage = "codexstorage/nim-codex:sha-cda52af-dist-tests";
10+
private const string DefaultDockerImage = "codexstorage/nim-codex:sha-032d7e7-dist-tests";
1111
public const string ApiPortTag = "codex_api_port";
1212
public const string ListenPortTag = "codex_listen_port";
1313
public const string MetricsPortTag = "codex_metrics_port";

ProjectPlugins/CodexPlugin/CodexNode.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ public void EnsureOnlineGetVersionResponse()
244244
Version = debugInfo.Version;
245245
}
246246

247+
public override string ToString()
248+
{
249+
return $"CodexNode:{GetName()}";
250+
}
251+
247252
private string[] GetPeerMultiAddresses(CodexNode peer, DebugInfo peerInfo)
248253
{
249254
// The peer we want to connect is in a different pod.
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
11
using CodexPlugin;
2+
using DistTestCore;
23
using NUnit.Framework;
34

45
namespace CodexTests
56
{
67
public class AutoBootstrapDistTest : CodexDistTest
78
{
9+
private readonly Dictionary<TestLifecycle, ICodexNode> bootstrapNodes = new Dictionary<TestLifecycle, ICodexNode>();
10+
811
[SetUp]
912
public void SetUpBootstrapNode()
1013
{
11-
BootstrapNode = StartCodex(s => s.WithName("BOOTSTRAP"));
14+
var tl = Get();
15+
if (!bootstrapNodes.ContainsKey(tl))
16+
{
17+
bootstrapNodes.Add(tl, StartCodex(s => s.WithName("BOOTSTRAP_" + tl.TestNamespace)));
18+
}
1219
}
1320

1421
[TearDown]
1522
public void TearDownBootstrapNode()
1623
{
17-
BootstrapNode = null;
24+
bootstrapNodes.Remove(Get());
1825
}
1926

2027
protected override void OnCodexSetup(ICodexSetup setup)
2128
{
22-
if (BootstrapNode != null) setup.WithBootstrapNode(BootstrapNode);
29+
var node = BootstrapNode;
30+
if (node != null) setup.WithBootstrapNode(node);
2331
}
2432

25-
protected ICodexNode? BootstrapNode { get; private set; }
26-
33+
protected ICodexNode? BootstrapNode
34+
{
35+
get
36+
{
37+
var tl = Get();
38+
if (bootstrapNodes.TryGetValue(tl, out var node))
39+
{
40+
return node;
41+
}
42+
return null;
43+
}
44+
}
2745
}
2846
}

Tests/CodexTests/BasicTests/PyramidTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class PyramidTests : CodexDistTest
1717
public void PyramidTest()
1818
{
1919
var size = 5.MB();
20-
var numberOfLayers = 4;
20+
var numberOfLayers = 3;
2121

2222
var bottomLayer = StartLayers(numberOfLayers);
2323

Tests/CodexTests/BasicTests/ThreeClientTest.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ public void ThreeClient()
2222
testFile.AssertIsEqual(downloadedFile);
2323
}
2424

25-
[Test]
26-
[CreateTranscript(nameof(SwarmTest))]
27-
public void SwarmTest()
28-
{
29-
var uploader = StartCodex(s => s.WithName("uploader"));
30-
var downloaders = StartCodex(5, s => s.WithName("downloader"));
31-
32-
var file = GenerateTestFile(100.MB());
33-
var cid = uploader.UploadFile(file);
34-
35-
var result = Parallel.ForEach(downloaders, d =>
36-
{
37-
d.DownloadContent(cid);
38-
});
39-
40-
Assert.That(result.IsCompleted);
41-
}
42-
4325
[Test]
4426
public void DownloadingUnknownCidDoesNotCauseCrash()
4527
{

Tests/DistTestCore/TestLifecycle.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet,
2222
Log = log;
2323
Configuration = configuration;
2424
TimeSet = timeSet;
25+
TestNamespace = testNamespace;
2526
TestStart = DateTime.UtcNow;
2627

2728
entryPoint = new EntryPoint(log, configuration.GetK8sConfiguration(timeSet, this, testNamespace), configuration.GetFileManagerFolder(), timeSet);
@@ -36,6 +37,7 @@ public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet,
3637
public TestLog Log { get; }
3738
public Configuration Configuration { get; }
3839
public ITimeSet TimeSet { get; }
40+
public string TestNamespace { get; }
3941
public bool WaitForCleanup { get; }
4042
public CoreInterface CoreInterface { get; }
4143

0 commit comments

Comments
 (0)