allow base index for nodeset to be configured

This commit is contained in:
gmega 2024-12-06 13:27:43 -03:00
parent 8605cce688
commit ff158a6547
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
3 changed files with 25 additions and 2 deletions

View File

@ -22,10 +22,11 @@ class DelugeNodeConfig(BaseModel):
class DelugeNodeSetConfig(BaseModel):
network_size: int = Field(gt=2)
network_size: int = Field(gte=2)
address: str
daemon_port: int
listen_ports: list[int] = Field(min_length=2, max_length=2)
first_node_index: int = 1
nodes: List[DelugeNodeConfig] = []
@model_validator(mode='after')
@ -36,7 +37,7 @@ class DelugeNodeSetConfig(BaseModel):
daemon_port=self.daemon_port,
listen_ports=self.listen_ports,
)
for i in range(1, self.network_size + 1)
for i in range(self.first_node_index, self.first_node_index + self.network_size)
]
return self

View File

@ -39,6 +39,27 @@ def test_should_expand_node_sets_into_simple_nodes():
),
]
def test_should_respect_first_node_index():
nodeset = DelugeNodeSetConfig(
address='deluge-{node_index}.local.svc',
network_size=2,
daemon_port=6080,
listen_ports=[6081, 6082],
first_node_index=5
)
assert nodeset.nodes == [
DelugeNodeConfig(
address='deluge-5.local.svc',
daemon_port=6080,
listen_ports=[6081, 6082],
),
DelugeNodeConfig(
address='deluge-6.local.svc',
daemon_port=6080,
listen_ports=[6081, 6082],
),
]
def test_should_build_experiment_from_config():
config_file = StringIO("""

View File

@ -7,6 +7,7 @@ deluge_experiment:
nodes:
network_size: ${NETWORK_SIZE}
first_node_index: 0
address: "${DELUGE_STATEFULSET}-{node_index}.${DELUGE_SERVICE}.${NAMESPACE}.svc.cluster.local"
daemon_port: 6890
listen_ports: [ 6891, 6892 ]