Debugging two-client test
This commit is contained in:
parent
457951c561
commit
686cdc88e2
|
@ -19,20 +19,20 @@ namespace CodexDistTests.BasicTests
|
|||
//[Test]
|
||||
//public void TwoClientTest()
|
||||
//{
|
||||
// var primaryNodex = SetupCodexNode()
|
||||
// var primary = SetupCodexNode()
|
||||
// .WithLogLevel(CodexLogLevel.Warn)
|
||||
// .WithStorageQuota(1024 * 1024)
|
||||
// .BringOnline();
|
||||
|
||||
// var secondaryNodex = SetupCodexNode()
|
||||
// .WithBootstrapNode(primaryNodex)
|
||||
// var secondary = SetupCodexNode()
|
||||
// .WithBootstrapNode(primary)
|
||||
// .BringOnline();
|
||||
|
||||
// var testFile = GenerateTestFile(1024 * 1024);
|
||||
|
||||
// var contentId = primaryNodex.UploadFile(testFile);
|
||||
// var contentId = primary.UploadFile(testFile);
|
||||
|
||||
// var downloadedFile = secondaryNodex.DownloadContent(contentId);
|
||||
// var downloadedFile = secondary.DownloadContent(contentId);
|
||||
|
||||
// testFile.AssertIsEqual(downloadedFile);
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
using k8s.Models;
|
||||
|
||||
namespace CodexDistTests.TestCore
|
||||
{
|
||||
public class CodexDockerImage
|
||||
{
|
||||
public string GetImageTag()
|
||||
{
|
||||
return "thatbenbierens/nim-codex:sha-c9a62de";
|
||||
}
|
||||
|
||||
public List<V1EnvVar> CreateEnvironmentVariables(OfflineCodexNode node)
|
||||
{
|
||||
var formatter = new EnvFormatter();
|
||||
formatter.Create(node);
|
||||
return formatter.Result;
|
||||
}
|
||||
|
||||
private class EnvFormatter
|
||||
{
|
||||
public List<V1EnvVar> Result { get; } = new List<V1EnvVar>();
|
||||
|
||||
public void Create(OfflineCodexNode node)
|
||||
{
|
||||
if (node.BootstrapNode != null)
|
||||
{
|
||||
var debugInfo = node.BootstrapNode.GetDebugInfo();
|
||||
AddVar("BOOTSTRAP_SPR", debugInfo.spr);
|
||||
}
|
||||
if (node.LogLevel != null)
|
||||
{
|
||||
AddVar("LOG_LEVEL", node.LogLevel.ToString()!.ToUpperInvariant());
|
||||
}
|
||||
if (node.StorageQuota != null)
|
||||
{
|
||||
AddVar("STORAGE_QUOTA", node.StorageQuota.ToString()!);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddVar(string key, string value)
|
||||
{
|
||||
Result.Add(new V1EnvVar
|
||||
{
|
||||
Name = key,
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,8 +17,8 @@ namespace CodexDistTests.TestCore
|
|||
[TearDown]
|
||||
public void TearDownDistTest()
|
||||
{
|
||||
fileManager.DeleteAllTestFiles();
|
||||
k8sManager.DeleteAllResources();
|
||||
fileManager.DeleteAllTestFiles();
|
||||
}
|
||||
|
||||
public TestFile GenerateTestFile(int size = 1024)
|
||||
|
|
|
@ -16,9 +16,15 @@ namespace CodexDistTests.TestCore
|
|||
private readonly Random random = new Random();
|
||||
private readonly List<TestFile> activeFiles = new List<TestFile>();
|
||||
|
||||
public FileManager()
|
||||
{
|
||||
if (!Directory.Exists(Folder)) Directory.CreateDirectory(Folder);
|
||||
}
|
||||
|
||||
public TestFile CreateEmptyTestFile()
|
||||
{
|
||||
var result = new TestFile(Path.Combine(Folder, Guid.NewGuid().ToString() + "_test.bin"));
|
||||
File.Create(result.Filename).Close();
|
||||
activeFiles.Add(result);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace CodexDistTests.TestCore
|
|||
public class K8sManager : IK8sManager
|
||||
{
|
||||
private const string k8sNamespace = "codex-test-namespace";
|
||||
private const string codexDockerImage = "thatbenbierens/nim-codex:sha-c9a62de";
|
||||
private readonly CodexDockerImage dockerImage = new CodexDockerImage();
|
||||
private readonly IFileManager fileManager;
|
||||
private int freePort;
|
||||
private int nodeOrderNumber;
|
||||
|
@ -36,7 +36,7 @@ namespace CodexDistTests.TestCore
|
|||
var codexNode = new OnlineCodexNode(node, fileManager, activeNode.Port);
|
||||
activeNodes.Add(codexNode, activeNode);
|
||||
|
||||
CreateDeployment(activeNode, client);
|
||||
CreateDeployment(activeNode, client, node);
|
||||
CreateService(activeNode, client);
|
||||
|
||||
WaitUntilOnline(activeNode, client);
|
||||
|
@ -162,7 +162,7 @@ namespace CodexDistTests.TestCore
|
|||
|
||||
#region Deployment management
|
||||
|
||||
private void CreateDeployment(ActiveNode node, Kubernetes client)
|
||||
private void CreateDeployment(ActiveNode node, Kubernetes client, OfflineCodexNode codexNode)
|
||||
{
|
||||
var deploymentSpec = new V1Deployment
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ namespace CodexDistTests.TestCore
|
|||
new V1Container
|
||||
{
|
||||
Name = node.GetContainerName(),
|
||||
Image = codexDockerImage,
|
||||
Image = dockerImage.GetImageTag(),
|
||||
Ports = new List<V1ContainerPort>
|
||||
{
|
||||
new V1ContainerPort
|
||||
|
@ -197,14 +197,7 @@ namespace CodexDistTests.TestCore
|
|||
Name = node.GetContainerPortName()
|
||||
}
|
||||
},
|
||||
Env = new List<V1EnvVar>// todo
|
||||
{
|
||||
new V1EnvVar
|
||||
{
|
||||
Name = "LOG_LEVEL",
|
||||
Value = "WARN"
|
||||
}
|
||||
}
|
||||
Env = dockerImage.CreateEnvironmentVariables(codexNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue