Removes BringOnline method

This commit is contained in:
benbierens 2023-04-25 12:52:11 +02:00
parent f94f4a6d22
commit 62f4eed221
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
9 changed files with 60 additions and 58 deletions

View File

@ -13,26 +13,17 @@ namespace DistTestCore
ICodexSetup EnableMetrics(); ICodexSetup EnableMetrics();
ICodexSetup EnableMarketplace(TestToken initialBalance); ICodexSetup EnableMarketplace(TestToken initialBalance);
ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther); ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther);
ICodexNodeGroup BringOnline();
} }
public class CodexSetup : CodexStartupConfig, ICodexSetup public class CodexSetup : CodexStartupConfig, ICodexSetup
{ {
private readonly CodexStarter starter;
public int NumberOfNodes { get; } public int NumberOfNodes { get; }
public CodexSetup(CodexStarter starter, int numberOfNodes) public CodexSetup(int numberOfNodes)
{ {
this.starter = starter;
NumberOfNodes = numberOfNodes; NumberOfNodes = numberOfNodes;
} }
public ICodexNodeGroup BringOnline()
{
return starter.BringOnline(this);
}
public ICodexSetup At(Location location) public ICodexSetup At(Location location)
{ {
Location = location; Location = location;

View File

@ -77,9 +77,33 @@ namespace DistTestCore
return lifecycle.FileManager.GenerateTestFile(size); return lifecycle.FileManager.GenerateTestFile(size);
} }
public ICodexSetup SetupCodexNodes(int numberOfNodes) public IOnlineCodexNode SetupCodexNode()
{ {
return new CodexSetup(lifecycle.CodexStarter, numberOfNodes); return SetupCodexNode(s => { });
}
public IOnlineCodexNode SetupCodexNode(Action<ICodexSetup> setup)
{
return SetupCodexNodes(1, setup)[0];
}
public ICodexNodeGroup SetupCodexNodes(int numberOfNodes)
{
return SetupCodexNodes(numberOfNodes, s => { });
}
public ICodexNodeGroup SetupCodexNodes(int numberOfNodes, Action<ICodexSetup> setup)
{
var codexSetup = new CodexSetup(numberOfNodes);
setup(codexSetup);
return BringOnline(codexSetup);
}
public ICodexNodeGroup BringOnline(ICodexSetup codexSetup)
{
return lifecycle.CodexStarter.BringOnline((CodexSetup)codexSetup);
} }
private void CreateNewTestLifecycle() private void CreateNewTestLifecycle()

View File

@ -16,6 +16,7 @@ namespace DistTestCore
ICodexNodeLog DownloadLog(); ICodexNodeLog DownloadLog();
IMetricsAccess Metrics { get; } IMetricsAccess Metrics { get; }
IMarketplaceAccess Marketplace { get; } IMarketplaceAccess Marketplace { get; }
ICodexSetup BringOffline();
} }
public class OnlineCodexNode : IOnlineCodexNode public class OnlineCodexNode : IOnlineCodexNode
@ -89,6 +90,11 @@ namespace DistTestCore
return lifecycle.DownloadLog(this); return lifecycle.DownloadLog(this);
} }
public ICodexSetup BringOffline()
{
return Group.BringOffline();
}
private string GetPeerMultiAddress(OnlineCodexNode peer, CodexDebugResponse peerInfo) private string GetPeerMultiAddress(OnlineCodexNode peer, CodexDebugResponse peerInfo)
{ {
var multiAddress = peerInfo.addrs.First(); var multiAddress = peerInfo.addrs.First();

View File

@ -10,10 +10,9 @@ namespace TestsLong.BasicTests
[Test, UseLongTimeouts] [Test, UseLongTimeouts]
public void OneClientLargeFileTest() public void OneClientLargeFileTest()
{ {
var primary = SetupCodexNodes(1) var primary = SetupCodexNode(s => s
.WithLogLevel(CodexLogLevel.Warn) .WithLogLevel(CodexLogLevel.Warn)
.WithStorageQuota(20.GB()) .WithStorageQuota(20.GB()));
.BringOnline()[0];
var testFile = GenerateTestFile(10.GB()); var testFile = GenerateTestFile(10.GB());

View File

@ -9,9 +9,7 @@ namespace TestsLong.BasicTests
[Test, UseLongTimeouts] [Test, UseLongTimeouts]
public void TestInfraShouldHave1000AddressSpacesPerPod() public void TestInfraShouldHave1000AddressSpacesPerPod()
{ {
var group = SetupCodexNodes(1000) var group = SetupCodexNodes(1000, s => s.EnableMetrics()); // Increases use of port address space per node.
.EnableMetrics() // Increases use of port address space per node.
.BringOnline();
var nodeIds = group.Select(n => n.GetDebugInfo().id).ToArray(); var nodeIds = group.Select(n => n.GetDebugInfo().id).ToArray();
@ -24,7 +22,7 @@ namespace TestsLong.BasicTests
{ {
for (var i = 0; i < 20; i++) for (var i = 0; i < 20; i++)
{ {
var n = SetupCodexNodes(1).BringOnline()[0]; var n = SetupCodexNode();
Assert.That(!string.IsNullOrEmpty(n.GetDebugInfo().id)); Assert.That(!string.IsNullOrEmpty(n.GetDebugInfo().id));
} }
@ -33,10 +31,9 @@ namespace TestsLong.BasicTests
[Test, UseLongTimeouts] [Test, UseLongTimeouts]
public void DownloadConsistencyTest() public void DownloadConsistencyTest()
{ {
var primary = SetupCodexNodes(1) var primary = SetupCodexNode(s => s
.WithLogLevel(CodexLogLevel.Trace) .WithLogLevel(CodexLogLevel.Trace)
.WithStorageQuota(2.MB()) .WithStorageQuota(2.MB()));
.BringOnline()[0];
var testFile = GenerateTestFile(1.MB()); var testFile = GenerateTestFile(1.MB());

View File

@ -11,9 +11,7 @@ namespace Tests.BasicTests
[Test] [Test]
public void CodexLogExample() public void CodexLogExample()
{ {
var primary = SetupCodexNodes(1) var primary = SetupCodexNode(s => s.WithLogLevel(CodexLogLevel.Trace));
.WithLogLevel(CodexLogLevel.Trace)
.BringOnline()[0];
primary.UploadFile(GenerateTestFile(5.MB())); primary.UploadFile(GenerateTestFile(5.MB()));
@ -25,13 +23,8 @@ namespace Tests.BasicTests
[Test] [Test]
public void TwoMetricsExample() public void TwoMetricsExample()
{ {
var group = SetupCodexNodes(2) var group = SetupCodexNodes(2, s => s.EnableMetrics());
.EnableMetrics() var group2 = SetupCodexNodes(2, s => s.EnableMetrics());
.BringOnline();
var group2 = SetupCodexNodes(2)
.EnableMetrics()
.BringOnline();
var primary = group[0]; var primary = group[0];
var secondary = group[1]; var secondary = group[1];
@ -50,19 +43,17 @@ namespace Tests.BasicTests
[Test] [Test]
public void MarketplaceExample() public void MarketplaceExample()
{ {
var primary = SetupCodexNodes(1) var primary = SetupCodexNode(s => s
.WithLogLevel(CodexLogLevel.Trace) .WithLogLevel(CodexLogLevel.Trace)
.WithStorageQuota(11.GB()) .WithStorageQuota(11.GB())
.EnableMarketplace(initialBalance: 234.TestTokens()) .EnableMarketplace(initialBalance: 234.TestTokens()));
.BringOnline()[0];
primary.Marketplace.AssertThatBalance(Is.EqualTo(234.TestTokens())); primary.Marketplace.AssertThatBalance(Is.EqualTo(234.TestTokens()));
var secondary = SetupCodexNodes(1) var secondary = SetupCodexNode(s => s
.WithLogLevel(CodexLogLevel.Trace) .WithLogLevel(CodexLogLevel.Trace)
.WithBootstrapNode(primary) .WithBootstrapNode(primary)
.EnableMarketplace(initialBalance: 1000.TestTokens()) .EnableMarketplace(initialBalance: 1000.TestTokens()));
.BringOnline()[0];
primary.Marketplace.MakeStorageAvailable( primary.Marketplace.MakeStorageAvailable(
size: 10.GB(), size: 10.GB(),

View File

@ -9,7 +9,7 @@ namespace Tests.BasicTests
[Test] [Test]
public void OneClientTest() public void OneClientTest()
{ {
var primary = SetupCodexNodes(1).BringOnline()[0]; var primary = SetupCodexNode();
PerformOneClientTest(primary); PerformOneClientTest(primary);
} }
@ -17,11 +17,11 @@ namespace Tests.BasicTests
[Test] [Test]
public void RestartTest() public void RestartTest()
{ {
var group = SetupCodexNodes(1).BringOnline(); var primary = SetupCodexNode();
var setup = group.BringOffline(); var setup = primary.BringOffline();
var primary = setup.BringOnline()[0]; primary = BringOnline(setup)[0];
PerformOneClientTest(primary); PerformOneClientTest(primary);
} }

View File

@ -10,7 +10,7 @@ namespace Tests.BasicTests
[Test] [Test]
public void TwoClientsOnePodTest() public void TwoClientsOnePodTest()
{ {
var group = SetupCodexNodes(2).BringOnline(); var group = SetupCodexNodes(2);
var primary = group[0]; var primary = group[0];
var secondary = group[1]; var secondary = group[1];
@ -21,9 +21,8 @@ namespace Tests.BasicTests
[Test] [Test]
public void TwoClientsTwoPodsTest() public void TwoClientsTwoPodsTest()
{ {
var primary = SetupCodexNodes(1).BringOnline()[0]; var primary = SetupCodexNode();
var secondary = SetupCodexNode();
var secondary = SetupCodexNodes(1).BringOnline()[0];
PerformTwoClientTest(primary, secondary); PerformTwoClientTest(primary, secondary);
} }
@ -32,13 +31,8 @@ namespace Tests.BasicTests
[Ignore("Requires Location map to be configured for k8s cluster.")] [Ignore("Requires Location map to be configured for k8s cluster.")]
public void TwoClientsTwoLocationsTest() public void TwoClientsTwoLocationsTest()
{ {
var primary = SetupCodexNodes(1) var primary = SetupCodexNode(s => s.At(Location.BensLaptop));
.At(Location.BensLaptop) var secondary = SetupCodexNode(s => s.At(Location.BensOldGamingMachine));
.BringOnline()[0];
var secondary = SetupCodexNodes(1)
.At(Location.BensOldGamingMachine)
.BringOnline()[0];
PerformTwoClientTest(primary, secondary); PerformTwoClientTest(primary, secondary);
} }

View File

@ -11,8 +11,8 @@ namespace Tests.DurabilityTests
[Test] [Test]
public void BootstrapNodeDisappearsTest() public void BootstrapNodeDisappearsTest()
{ {
var bootstrapNode = SetupCodexNodes(1).BringOnline(); var bootstrapNode = SetupCodexNode();
var group = SetupCodexNodes(2).WithBootstrapNode(bootstrapNode[0]).BringOnline(); var group = SetupCodexNodes(2, s => s.WithBootstrapNode(bootstrapNode));
var primary = group[0]; var primary = group[0];
var secondary = group[1]; var secondary = group[1];
@ -31,10 +31,10 @@ namespace Tests.DurabilityTests
[Test] [Test]
public void DataRetentionTest() public void DataRetentionTest()
{ {
var bootstrapNode = SetupCodexNodes(1).WithLogLevel(CodexLogLevel.Trace).BringOnline()[0]; var bootstrapNode = SetupCodexNode(s => s.WithLogLevel(CodexLogLevel.Trace));
var startGroup = SetupCodexNodes(2).WithLogLevel(CodexLogLevel.Trace).WithBootstrapNode(bootstrapNode).BringOnline(); var startGroup = SetupCodexNodes(2, s => s.WithLogLevel(CodexLogLevel.Trace).WithBootstrapNode(bootstrapNode));
var finishGroup = SetupCodexNodes(10).WithLogLevel(CodexLogLevel.Trace).WithBootstrapNode(bootstrapNode).BringOnline(); var finishGroup = SetupCodexNodes(10, s => s.WithLogLevel(CodexLogLevel.Trace).WithBootstrapNode(bootstrapNode));
var file = GenerateTestFile(10.MB()); var file = GenerateTestFile(10.MB());