mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-10 11:06:42 +00:00
test for location selection
This commit is contained in:
parent
d68a264f35
commit
40aaf42106
@ -208,6 +208,7 @@ namespace CodexDistTestCore
|
|||||||
},
|
},
|
||||||
Spec = new V1PodSpec
|
Spec = new V1PodSpec
|
||||||
{
|
{
|
||||||
|
NodeSelector = CreateNodeSelector(offline),
|
||||||
Containers = CreateDeploymentContainers(online, offline)
|
Containers = CreateDeploymentContainers(online, offline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,6 +218,22 @@ namespace CodexDistTestCore
|
|||||||
online.Deployment = client.CreateNamespacedDeployment(deploymentSpec, K8sNamespace);
|
online.Deployment = client.CreateNamespacedDeployment(deploymentSpec, K8sNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IDictionary<string, string> CreateNodeSelector(OfflineCodexNodes offline)
|
||||||
|
{
|
||||||
|
switch (offline.Location)
|
||||||
|
{
|
||||||
|
case Location.Unspecified:
|
||||||
|
return new Dictionary<string, string>();
|
||||||
|
case Location.BensLaptop:
|
||||||
|
return new Dictionary<string, string> { { "codex-test-location", "worker01" } };
|
||||||
|
case Location.BensOldGamingMachine:
|
||||||
|
return new Dictionary<string, string> { { "codex-test-location", "worker02" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.Fail("Unknown location selected: " + offline.Location);
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
private List<V1Container> CreateDeploymentContainers(CodexNodeGroup online, OfflineCodexNodes offline)
|
private List<V1Container> CreateDeploymentContainers(CodexNodeGroup online, OfflineCodexNodes offline)
|
||||||
{
|
{
|
||||||
var result = new List<V1Container>();
|
var result = new List<V1Container>();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public interface IOfflineCodexNodes
|
public interface IOfflineCodexNodes
|
||||||
{
|
{
|
||||||
IOfflineCodexNodes At(CodexNodeLocation location);
|
IOfflineCodexNodes At(Location location);
|
||||||
IOfflineCodexNodes WithLogLevel(CodexLogLevel level);
|
IOfflineCodexNodes WithLogLevel(CodexLogLevel level);
|
||||||
IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node);
|
IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node);
|
||||||
IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota);
|
IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota);
|
||||||
@ -18,7 +18,7 @@
|
|||||||
Error
|
Error
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CodexNodeLocation
|
public enum Location
|
||||||
{
|
{
|
||||||
Unspecified,
|
Unspecified,
|
||||||
BensLaptop,
|
BensLaptop,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
private readonly IK8sManager k8SManager;
|
private readonly IK8sManager k8SManager;
|
||||||
|
|
||||||
public int NumberOfNodes { get; }
|
public int NumberOfNodes { get; }
|
||||||
public CodexNodeLocation Location { get; private set; }
|
public Location Location { get; private set; }
|
||||||
public CodexLogLevel? LogLevel { get; private set; }
|
public CodexLogLevel? LogLevel { get; private set; }
|
||||||
public IOnlineCodexNode? BootstrapNode { get; private set; }
|
public IOnlineCodexNode? BootstrapNode { get; private set; }
|
||||||
public ByteSize? StorageQuota { get; private set; }
|
public ByteSize? StorageQuota { get; private set; }
|
||||||
@ -39,7 +39,7 @@
|
|||||||
{
|
{
|
||||||
this.k8SManager = k8SManager;
|
this.k8SManager = k8SManager;
|
||||||
NumberOfNodes = numberOfNodes;
|
NumberOfNodes = numberOfNodes;
|
||||||
Location = CodexNodeLocation.Unspecified;
|
Location = Location.Unspecified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICodexNodeGroup BringOnline()
|
public ICodexNodeGroup BringOnline()
|
||||||
@ -47,7 +47,7 @@
|
|||||||
return k8SManager.BringOnline(this);
|
return k8SManager.BringOnline(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IOfflineCodexNodes At(CodexNodeLocation location)
|
public IOfflineCodexNodes At(Location location)
|
||||||
{
|
{
|
||||||
Location = location;
|
Location = location;
|
||||||
return this;
|
return this;
|
||||||
|
@ -6,70 +6,76 @@ namespace Tests.BasicTests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class SimpleTests : DistTest
|
public class SimpleTests : DistTest
|
||||||
{
|
{
|
||||||
[Test]
|
//[Test]
|
||||||
public void GetDebugInfo()
|
//public void GetDebugInfo()
|
||||||
{
|
//{
|
||||||
var dockerImage = new CodexDockerImage();
|
// var dockerImage = new CodexDockerImage();
|
||||||
|
|
||||||
var node = SetupCodexNodes(1)
|
// var node = SetupCodexNodes(1)
|
||||||
.BringOnline()[0];
|
// .BringOnline()[0];
|
||||||
|
|
||||||
var debugInfo = node.GetDebugInfo();
|
// var debugInfo = node.GetDebugInfo();
|
||||||
|
|
||||||
Assert.That(debugInfo.spr, Is.Not.Empty);
|
// Assert.That(debugInfo.spr, Is.Not.Empty);
|
||||||
Assert.That(debugInfo.codex.revision, Is.EqualTo(dockerImage.GetExpectedImageRevision()));
|
// Assert.That(debugInfo.codex.revision, Is.EqualTo(dockerImage.GetExpectedImageRevision()));
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void OneClientTest()
|
//public void OneClientTest()
|
||||||
{
|
//{
|
||||||
var primary = SetupCodexNodes(1)
|
// var primary = SetupCodexNodes(1)
|
||||||
.BringOnline()[0];
|
// .BringOnline()[0];
|
||||||
|
|
||||||
var testFile = GenerateTestFile(1.MB());
|
// var testFile = GenerateTestFile(1.MB());
|
||||||
|
|
||||||
var contentId = primary.UploadFile(testFile);
|
// var contentId = primary.UploadFile(testFile);
|
||||||
|
|
||||||
var downloadedFile = primary.DownloadContent(contentId);
|
// var downloadedFile = primary.DownloadContent(contentId);
|
||||||
|
|
||||||
testFile.AssertIsEqual(downloadedFile);
|
// testFile.AssertIsEqual(downloadedFile);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void TwoClientsOnePodTest()
|
//public void TwoClientsOnePodTest()
|
||||||
{
|
//{
|
||||||
var group = SetupCodexNodes(2)
|
// var group = SetupCodexNodes(2)
|
||||||
.BringOnline();
|
// .BringOnline();
|
||||||
|
|
||||||
var primary = group[0];
|
// var primary = group[0];
|
||||||
var secondary = group[1];
|
// var secondary = group[1];
|
||||||
|
|
||||||
PerformTwoClientTest(primary, secondary);
|
// PerformTwoClientTest(primary, secondary);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void TwoClientsTwoPodsTest()
|
//public void TwoClientsTwoPodsTest()
|
||||||
{
|
//{
|
||||||
var primary = SetupCodexNodes(1)
|
// var primary = SetupCodexNodes(1)
|
||||||
.BringOnline()[0];
|
// .BringOnline()[0];
|
||||||
|
|
||||||
var secondary = SetupCodexNodes(1)
|
// var secondary = SetupCodexNodes(1)
|
||||||
.BringOnline()[0];
|
// .BringOnline()[0];
|
||||||
|
|
||||||
PerformTwoClientTest(primary, secondary);
|
// PerformTwoClientTest(primary, secondary);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TwoClientsTwoLocationsTest()
|
public void TwoClientsTwoLocationsTest()
|
||||||
{
|
{
|
||||||
var primary = SetupCodexNodes(1)
|
var primary = SetupCodexNodes(1)
|
||||||
.At(CodexNodeLocation.BensLaptop)
|
.At(Location.BensLaptop)
|
||||||
.BringOnline()[0];
|
.BringOnline()[0];
|
||||||
|
|
||||||
var secondary = SetupCodexNodes(1)
|
var secondary = SetupCodexNodes(1)
|
||||||
.At(CodexNodeLocation.BensOldGamingMachine)
|
.At(Location.BensOldGamingMachine)
|
||||||
.BringOnline()[0];
|
.BringOnline()[0];
|
||||||
|
|
||||||
|
var debugInfo = primary.GetDebugInfo();
|
||||||
|
Assert.That(debugInfo.spr, Is.Not.Empty);
|
||||||
|
|
||||||
|
var debugInfo2 = secondary.GetDebugInfo();
|
||||||
|
Assert.That(debugInfo2.spr, Is.Not.Empty);
|
||||||
|
|
||||||
PerformTwoClientTest(primary, secondary);
|
PerformTwoClientTest(primary, secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user