Can enable metrics on codex node startup.
This commit is contained in:
parent
8c16ae3385
commit
4fb0e7c281
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
public class CodexNodeContainer
|
||||
{
|
||||
public CodexNodeContainer(string name, int servicePort, string servicePortName, int apiPort, string containerPortName, int discoveryPort, int listenPort, string dataDir)
|
||||
public CodexNodeContainer(string name, int servicePort, string servicePortName, int apiPort, string containerPortName, int discoveryPort, int listenPort, string dataDir, int metricsPort)
|
||||
{
|
||||
Name = name;
|
||||
ServicePort = servicePort;
|
||||
|
@ -12,6 +12,7 @@
|
|||
DiscoveryPort = discoveryPort;
|
||||
ListenPort = listenPort;
|
||||
DataDir = dataDir;
|
||||
MetricsPort = metricsPort;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
@ -22,6 +23,7 @@
|
|||
public int DiscoveryPort { get; }
|
||||
public int ListenPort { get; }
|
||||
public string DataDir { get; }
|
||||
public int MetricsPort { get; }
|
||||
}
|
||||
|
||||
public class CodexGroupNumberSource
|
||||
|
@ -57,7 +59,7 @@
|
|||
this.groupContainerFactory = groupContainerFactory;
|
||||
}
|
||||
|
||||
public CodexNodeContainer CreateNext()
|
||||
public CodexNodeContainer CreateNext(OfflineCodexNodes offline)
|
||||
{
|
||||
var n = containerNameSource.GetNextNumber();
|
||||
return new CodexNodeContainer(
|
||||
|
@ -68,8 +70,15 @@
|
|||
containerPortName: $"api-{n}",
|
||||
discoveryPort: codexPortSource.GetNextNumber(),
|
||||
listenPort: codexPortSource.GetNextNumber(),
|
||||
dataDir: $"datadir{n}"
|
||||
dataDir: $"datadir{n}",
|
||||
metricsPort: GetMetricsPort(offline)
|
||||
);
|
||||
}
|
||||
|
||||
private int GetMetricsPort(OfflineCodexNodes offline)
|
||||
{
|
||||
if (offline.MetricsEnabled) return codexPortSource.GetNextNumber();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ namespace CodexDistTestCore.Config
|
|||
{
|
||||
public List<V1EnvVar> Result { get; } = new List<V1EnvVar>();
|
||||
|
||||
public void Create(OfflineCodexNodes node, CodexNodeContainer environment)
|
||||
public void Create(OfflineCodexNodes node, CodexNodeContainer container)
|
||||
{
|
||||
AddVar("API_PORT", environment.ApiPort.ToString());
|
||||
AddVar("DATA_DIR", environment.DataDir);
|
||||
AddVar("DISC_PORT", environment.DiscoveryPort.ToString());
|
||||
AddVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{environment.ListenPort}");
|
||||
AddVar("API_PORT", container.ApiPort.ToString());
|
||||
AddVar("DATA_DIR", container.DataDir);
|
||||
AddVar("DISC_PORT", container.DiscoveryPort.ToString());
|
||||
AddVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{container.ListenPort}");
|
||||
|
||||
if (node.BootstrapNode != null)
|
||||
{
|
||||
|
@ -45,6 +45,11 @@ namespace CodexDistTestCore.Config
|
|||
{
|
||||
AddVar("STORAGE_QUOTA", node.StorageQuota.SizeInBytes.ToString()!);
|
||||
}
|
||||
if (node.MetricsEnabled)
|
||||
{
|
||||
AddVar("METRICS_ADDR", "0.0.0.0");
|
||||
AddVar("METRICS_PORT", container.MetricsPort.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void AddVar(string key, string value)
|
||||
|
|
|
@ -60,18 +60,18 @@
|
|||
|
||||
private CodexNodeGroup CreateOnlineCodexNodes(OfflineCodexNodes offline)
|
||||
{
|
||||
var containers = CreateContainers(offline.NumberOfNodes);
|
||||
var containers = CreateContainers(offline);
|
||||
var online = containers.Select(c => new OnlineCodexNode(log, fileManager, c)).ToArray();
|
||||
var result = new CodexNodeGroup(log, codexGroupNumberSource.GetNextCodexNodeGroupNumber(), offline, this, online);
|
||||
onlineCodexNodeGroups.Add(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private CodexNodeContainer[] CreateContainers(int number)
|
||||
private CodexNodeContainer[] CreateContainers(OfflineCodexNodes offline)
|
||||
{
|
||||
var factory = new CodexNodeContainerFactory(codexGroupNumberSource);
|
||||
var containers = new List<CodexNodeContainer>();
|
||||
for (var i = 0; i < number; i++) containers.Add(factory.CreateNext());
|
||||
for (var i = 0; i < offline.NumberOfNodes; i++) containers.Add(factory.CreateNext(offline));
|
||||
return containers.ToArray();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
IOfflineCodexNodes WithLogLevel(CodexLogLevel level);
|
||||
IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node);
|
||||
IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota);
|
||||
IOfflineCodexNodes EnableMetrics();
|
||||
ICodexNodeGroup BringOnline();
|
||||
}
|
||||
|
||||
|
@ -34,12 +35,14 @@
|
|||
public CodexLogLevel? LogLevel { get; private set; }
|
||||
public IOnlineCodexNode? BootstrapNode { get; private set; }
|
||||
public ByteSize? StorageQuota { get; private set; }
|
||||
public bool MetricsEnabled { get; private set; }
|
||||
|
||||
public OfflineCodexNodes(IK8sManager k8SManager, int numberOfNodes)
|
||||
{
|
||||
this.k8SManager = k8SManager;
|
||||
NumberOfNodes = numberOfNodes;
|
||||
Location = Location.Unspecified;
|
||||
MetricsEnabled = false;
|
||||
}
|
||||
|
||||
public ICodexNodeGroup BringOnline()
|
||||
|
@ -71,6 +74,12 @@
|
|||
return this;
|
||||
}
|
||||
|
||||
public IOfflineCodexNodes EnableMetrics()
|
||||
{
|
||||
MetricsEnabled = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public string Describe()
|
||||
{
|
||||
var args = string.Join(',', DescribeArgs());
|
||||
|
|
|
@ -8,7 +8,9 @@ namespace LongTests.BasicTests
|
|||
[Test, UseLongTimeouts]
|
||||
public void TestInfraShouldHave1000AddressSpacesPerPod()
|
||||
{
|
||||
var group = SetupCodexNodes(1000).BringOnline();
|
||||
var group = SetupCodexNodes(1000)
|
||||
.EnableMetrics() // Increases use of port address space per node.
|
||||
.BringOnline();
|
||||
|
||||
var nodeIds = group.Select(n => n.GetDebugInfo().id).ToArray();
|
||||
|
||||
|
|
|
@ -79,6 +79,17 @@ namespace Tests.BasicTests
|
|||
PerformTwoClientTest(primary, secondary);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MetricsExample()
|
||||
{
|
||||
var group = SetupCodexNodes(1)
|
||||
.EnableMetrics()
|
||||
.BringOnline();
|
||||
|
||||
var metrics = BeginGatheringMetrics(group);
|
||||
|
||||
}
|
||||
|
||||
private void PerformTwoClientTest(IOnlineCodexNode primary, IOnlineCodexNode secondary)
|
||||
{
|
||||
primary.ConnectToPeer(secondary);
|
||||
|
|
Loading…
Reference in New Issue