forked from TrueCloudLab/frostfs-testlib
WIP: Refactor service config to be more DRY
Signed-off-by: Vitaliy Potyarkin <v.potyarkin@yadro.com>
This commit is contained in:
parent
1b4bb29662
commit
4c4520f81f
2 changed files with 56 additions and 57 deletions
|
@ -81,6 +81,14 @@ class Component(Enum):
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.value)
|
return len(self.value)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_valid(cls, value):
|
||||||
|
try:
|
||||||
|
cls(value)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope=_SCOPE)
|
@pytest.fixture(scope=_SCOPE)
|
||||||
def _deployment(_deployment_dir) -> dict:
|
def _deployment(_deployment_dir) -> dict:
|
||||||
|
|
|
@ -14,7 +14,7 @@ from frostfs_testlib.storage.cluster import Cluster, ClusterNode
|
||||||
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
from frostfs_testlib.storage.dataclasses.wallet import WalletInfo
|
||||||
|
|
||||||
from .container import ContainerizedService # TODO: move fixtures into testlib
|
from .container import ContainerizedService # TODO: move fixtures into testlib
|
||||||
from .fixtures import _new_wallet, _wallet_public_key
|
from .fixtures import Component, _new_wallet, _wallet_public_key
|
||||||
|
|
||||||
|
|
||||||
def dynamic_hosting_config(**fixtures) -> dict[str, Any]:
|
def dynamic_hosting_config(**fixtures) -> dict[str, Any]:
|
||||||
|
@ -43,63 +43,54 @@ def _host_config(name: str, containers: list, fixtures: Mapping[str, Any]) -> No
|
||||||
"services": [],
|
"services": [],
|
||||||
"clis": [],
|
"clis": [],
|
||||||
}
|
}
|
||||||
|
if not Component.is_valid(name):
|
||||||
|
return
|
||||||
|
|
||||||
if name == "storage":
|
for index, container in enumerate(containers):
|
||||||
for index, container in enumerate(containers):
|
host = _from_template(host_template)
|
||||||
host = _from_template(host_template)
|
host["services"].append(_service_config(**locals()))
|
||||||
host["services"].append(
|
host["attributes"]["component_tests_container"] = container
|
||||||
{
|
host["address"] = container.ip
|
||||||
"name": f"frostfs-storage_{index:02}",
|
host["hostname"] = container.name
|
||||||
"attributes": {
|
yield host
|
||||||
"control_endpoint": f"{container.ip}:8801",
|
|
||||||
"endpoint_data0": f"{container.ip}:8802",
|
|
||||||
"endpoint_prometheus": f"{container.ip}:9090",
|
def _service_config(name, index, container, **kw):
|
||||||
"wallet_config": container.wallet_config,
|
match name:
|
||||||
"wallet_password": container.config["node"]["wallet"]["password"],
|
case "storage":
|
||||||
"wallet_path": container.config["node"]["wallet"]["path"],
|
return {
|
||||||
},
|
"name": f"frostfs-storage_{index:02}",
|
||||||
}
|
"attributes": {
|
||||||
)
|
"control_endpoint": f"{container.ip}:8801",
|
||||||
host["attributes"]["component_tests_container"] = container
|
"endpoint_data0": f"{container.ip}:8802",
|
||||||
host["address"] = container.ip
|
"endpoint_prometheus": f"{container.ip}:9090",
|
||||||
host["hostname"] = container.name
|
"wallet_config": container.wallet_config,
|
||||||
yield host
|
"wallet_password": container.config["node"]["wallet"]["password"],
|
||||||
elif name == "neogo":
|
"wallet_path": container.config["node"]["wallet"]["path"],
|
||||||
for index, container in enumerate(containers):
|
},
|
||||||
host = _from_template(host_template)
|
}
|
||||||
host["services"].append(
|
case "neogo":
|
||||||
{
|
return {
|
||||||
"name": f"neo-go_{index:02}",
|
"name": f"neo-go_{index:02}",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"endpoint_internal0": f"http://{container.ip}:30333",
|
"endpoint_internal0": f"http://{container.ip}:30333",
|
||||||
"endpoint_prometheus": f"{container.ip}:20001",
|
"endpoint_prometheus": f"{container.ip}:20001",
|
||||||
"wallet_config": container.wallet_config,
|
"wallet_config": container.wallet_config,
|
||||||
"wallet_password": container.config["ApplicationConfiguration"]["Consensus"]["UnlockWallet"]["Password"],
|
"wallet_password": container.config["ApplicationConfiguration"]["Consensus"]["UnlockWallet"]["Password"],
|
||||||
"wallet_path": container.config["ApplicationConfiguration"]["Consensus"]["UnlockWallet"]["Path"],
|
"wallet_path": container.config["ApplicationConfiguration"]["Consensus"]["UnlockWallet"]["Path"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
case "innerring":
|
||||||
host["attributes"]["component_tests_container"] = container
|
return {
|
||||||
host["address"] = container.ip
|
"name": f"frostfs-ir_{index:02}",
|
||||||
host["hostname"] = container.name
|
"attributes": {
|
||||||
yield host
|
"wallet_config": container.wallet_config,
|
||||||
elif name == "innerring":
|
"wallet_password": container.config["wallet"]["password"],
|
||||||
for index, container in enumerate(containers):
|
"wallet_path": container.config["wallet"]["path"],
|
||||||
host = _from_template(host_template)
|
},
|
||||||
host["services"].append(
|
}
|
||||||
{
|
case _:
|
||||||
"name": f"frostfs-ir_{index:02}",
|
raise NotImplementedError(f"service config not implemented: {name}")
|
||||||
"attributes": {
|
|
||||||
"wallet_config": container.wallet_config,
|
|
||||||
"wallet_password": container.config["wallet"]["password"],
|
|
||||||
"wallet_path": container.config["wallet"]["path"],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
host["attributes"]["component_tests_container"] = container
|
|
||||||
host["address"] = container.ip
|
|
||||||
host["hostname"] = container.name
|
|
||||||
yield host
|
|
||||||
|
|
||||||
|
|
||||||
def _from_template(template: Mapping[str, Any]) -> Mapping[str, Any]:
|
def _from_template(template: Mapping[str, Any]) -> Mapping[str, Any]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue