diff --git a/CodexDistTestCore/K8sOperations.cs b/CodexDistTestCore/K8sOperations.cs index f9054b8..85c0de7 100644 --- a/CodexDistTestCore/K8sOperations.cs +++ b/CodexDistTestCore/K8sOperations.cs @@ -208,6 +208,7 @@ namespace CodexDistTestCore }, Spec = new V1PodSpec { + NodeSelector = CreateNodeSelector(offline), Containers = CreateDeploymentContainers(online, offline) } } @@ -217,6 +218,22 @@ namespace CodexDistTestCore online.Deployment = client.CreateNamespacedDeployment(deploymentSpec, K8sNamespace); } + private IDictionary CreateNodeSelector(OfflineCodexNodes offline) + { + switch (offline.Location) + { + case Location.Unspecified: + return new Dictionary(); + case Location.BensLaptop: + return new Dictionary { { "codex-test-location", "worker01" } }; + case Location.BensOldGamingMachine: + return new Dictionary { { "codex-test-location", "worker02" } }; + } + + Assert.Fail("Unknown location selected: " + offline.Location); + throw new InvalidOperationException(); + } + private List CreateDeploymentContainers(CodexNodeGroup online, OfflineCodexNodes offline) { var result = new List(); diff --git a/CodexDistTestCore/OfflineCodexNodes.cs b/CodexDistTestCore/OfflineCodexNodes.cs index d241d5f..9092618 100644 --- a/CodexDistTestCore/OfflineCodexNodes.cs +++ b/CodexDistTestCore/OfflineCodexNodes.cs @@ -2,7 +2,7 @@ { public interface IOfflineCodexNodes { - IOfflineCodexNodes At(CodexNodeLocation location); + IOfflineCodexNodes At(Location location); IOfflineCodexNodes WithLogLevel(CodexLogLevel level); IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node); IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota); @@ -18,7 +18,7 @@ Error } - public enum CodexNodeLocation + public enum Location { Unspecified, BensLaptop, @@ -30,7 +30,7 @@ private readonly IK8sManager k8SManager; public int NumberOfNodes { get; } - public CodexNodeLocation Location { get; private set; } + public Location Location { get; private set; } public CodexLogLevel? LogLevel { get; private set; } public IOnlineCodexNode? BootstrapNode { get; private set; } public ByteSize? StorageQuota { get; private set; } @@ -39,7 +39,7 @@ { this.k8SManager = k8SManager; NumberOfNodes = numberOfNodes; - Location = CodexNodeLocation.Unspecified; + Location = Location.Unspecified; } public ICodexNodeGroup BringOnline() @@ -47,7 +47,7 @@ return k8SManager.BringOnline(this); } - public IOfflineCodexNodes At(CodexNodeLocation location) + public IOfflineCodexNodes At(Location location) { Location = location; return this; diff --git a/Tests/BasicTests/SimpleTests.cs b/Tests/BasicTests/SimpleTests.cs index 0195267..b214d9b 100644 --- a/Tests/BasicTests/SimpleTests.cs +++ b/Tests/BasicTests/SimpleTests.cs @@ -6,70 +6,76 @@ namespace Tests.BasicTests [TestFixture] public class SimpleTests : DistTest { - [Test] - public void GetDebugInfo() - { - var dockerImage = new CodexDockerImage(); + //[Test] + //public void GetDebugInfo() + //{ + // var dockerImage = new CodexDockerImage(); - var node = SetupCodexNodes(1) - .BringOnline()[0]; + // var node = SetupCodexNodes(1) + // .BringOnline()[0]; - var debugInfo = node.GetDebugInfo(); + // var debugInfo = node.GetDebugInfo(); - Assert.That(debugInfo.spr, Is.Not.Empty); - Assert.That(debugInfo.codex.revision, Is.EqualTo(dockerImage.GetExpectedImageRevision())); - } + // Assert.That(debugInfo.spr, Is.Not.Empty); + // Assert.That(debugInfo.codex.revision, Is.EqualTo(dockerImage.GetExpectedImageRevision())); + //} - [Test] - public void OneClientTest() - { - var primary = SetupCodexNodes(1) - .BringOnline()[0]; + //[Test] + //public void OneClientTest() + //{ + // var primary = SetupCodexNodes(1) + // .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] - public void TwoClientsOnePodTest() - { - var group = SetupCodexNodes(2) - .BringOnline(); + //[Test] + //public void TwoClientsOnePodTest() + //{ + // var group = SetupCodexNodes(2) + // .BringOnline(); - var primary = group[0]; - var secondary = group[1]; + // var primary = group[0]; + // var secondary = group[1]; - PerformTwoClientTest(primary, secondary); - } + // PerformTwoClientTest(primary, secondary); + //} - [Test] - public void TwoClientsTwoPodsTest() - { - var primary = SetupCodexNodes(1) - .BringOnline()[0]; + //[Test] + //public void TwoClientsTwoPodsTest() + //{ + // var primary = SetupCodexNodes(1) + // .BringOnline()[0]; - var secondary = SetupCodexNodes(1) - .BringOnline()[0]; + // var secondary = SetupCodexNodes(1) + // .BringOnline()[0]; - PerformTwoClientTest(primary, secondary); - } + // PerformTwoClientTest(primary, secondary); + //} [Test] public void TwoClientsTwoLocationsTest() { var primary = SetupCodexNodes(1) - .At(CodexNodeLocation.BensLaptop) + .At(Location.BensLaptop) .BringOnline()[0]; var secondary = SetupCodexNodes(1) - .At(CodexNodeLocation.BensOldGamingMachine) + .At(Location.BensOldGamingMachine) .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); }