cs-codex-dist-tests/CodexDistTestCore/CodexNodeContainer.cs

49 lines
1.8 KiB
C#
Raw Normal View History

2023-03-21 14:17:48 +00:00
namespace CodexDistTestCore
{
public class CodexNodeContainer
{
2023-03-22 09:38:10 +00:00
public CodexNodeContainer(string name, int servicePort, string servicePortName, int apiPort, string containerPortName, int discoveryPort, int listenPort, string dataDir)
2023-03-21 14:17:48 +00:00
{
Name = name;
ServicePort = servicePort;
2023-03-22 09:38:10 +00:00
ServicePortName = servicePortName;
2023-03-21 14:17:48 +00:00
ApiPort = apiPort;
ContainerPortName = containerPortName;
DiscoveryPort = discoveryPort;
ListenPort = listenPort;
DataDir = dataDir;
}
public string Name { get; }
public int ServicePort { get; }
2023-03-22 09:38:10 +00:00
public string ServicePortName { get; }
2023-03-21 14:17:48 +00:00
public int ApiPort { get; }
public string ContainerPortName { get; }
public int DiscoveryPort { get; }
public int ListenPort { get; }
public string DataDir { get; }
}
public class CodexNodeContainerFactory
{
private readonly NumberSource containerNameSource = new NumberSource(1);
private readonly NumberSource servicePortSource = new NumberSource(30001);
private readonly NumberSource codexPortSource = new NumberSource(8080);
public CodexNodeContainer CreateNext()
{
var n = containerNameSource.GetNextNumber();
return new CodexNodeContainer(
name: $"codex-node{n}",
servicePort: servicePortSource.GetNextNumber(),
2023-03-22 09:38:10 +00:00
servicePortName: $"node{n}",
2023-03-21 14:17:48 +00:00
apiPort: codexPortSource.GetNextNumber(),
containerPortName: $"api-{n}",
discoveryPort: codexPortSource.GetNextNumber(),
listenPort: codexPortSource.GetNextNumber(),
dataDir: $"datadir{n}"
);
}
}
}