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):
|
||||
return len(self.value)
|
||||
|
||||
@classmethod
|
||||
def is_valid(cls, value):
|
||||
try:
|
||||
cls(value)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture(scope=_SCOPE)
|
||||
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 .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]:
|
||||
|
@ -43,12 +43,22 @@ def _host_config(name: str, containers: list, fixtures: Mapping[str, Any]) -> No
|
|||
"services": [],
|
||||
"clis": [],
|
||||
}
|
||||
if not Component.is_valid(name):
|
||||
return
|
||||
|
||||
if name == "storage":
|
||||
for index, container in enumerate(containers):
|
||||
host = _from_template(host_template)
|
||||
host["services"].append(
|
||||
{
|
||||
host["services"].append(_service_config(**locals()))
|
||||
host["attributes"]["component_tests_container"] = container
|
||||
host["address"] = container.ip
|
||||
host["hostname"] = container.name
|
||||
yield host
|
||||
|
||||
|
||||
def _service_config(name, index, container, **kw):
|
||||
match name:
|
||||
case "storage":
|
||||
return {
|
||||
"name": f"frostfs-storage_{index:02}",
|
||||
"attributes": {
|
||||
"control_endpoint": f"{container.ip}:8801",
|
||||
|
@ -59,16 +69,8 @@ def _host_config(name: str, containers: list, fixtures: Mapping[str, Any]) -> No
|
|||
"wallet_path": container.config["node"]["wallet"]["path"],
|
||||
},
|
||||
}
|
||||
)
|
||||
host["attributes"]["component_tests_container"] = container
|
||||
host["address"] = container.ip
|
||||
host["hostname"] = container.name
|
||||
yield host
|
||||
elif name == "neogo":
|
||||
for index, container in enumerate(containers):
|
||||
host = _from_template(host_template)
|
||||
host["services"].append(
|
||||
{
|
||||
case "neogo":
|
||||
return {
|
||||
"name": f"neo-go_{index:02}",
|
||||
"attributes": {
|
||||
"endpoint_internal0": f"http://{container.ip}:30333",
|
||||
|
@ -78,16 +80,8 @@ def _host_config(name: str, containers: list, fixtures: Mapping[str, Any]) -> No
|
|||
"wallet_path": container.config["ApplicationConfiguration"]["Consensus"]["UnlockWallet"]["Path"],
|
||||
},
|
||||
}
|
||||
)
|
||||
host["attributes"]["component_tests_container"] = container
|
||||
host["address"] = container.ip
|
||||
host["hostname"] = container.name
|
||||
yield host
|
||||
elif name == "innerring":
|
||||
for index, container in enumerate(containers):
|
||||
host = _from_template(host_template)
|
||||
host["services"].append(
|
||||
{
|
||||
case "innerring":
|
||||
return {
|
||||
"name": f"frostfs-ir_{index:02}",
|
||||
"attributes": {
|
||||
"wallet_config": container.wallet_config,
|
||||
|
@ -95,11 +89,8 @@ def _host_config(name: str, containers: list, fixtures: Mapping[str, Any]) -> No
|
|||
"wallet_path": container.config["wallet"]["path"],
|
||||
},
|
||||
}
|
||||
)
|
||||
host["attributes"]["component_tests_container"] = container
|
||||
host["address"] = container.ip
|
||||
host["hostname"] = container.name
|
||||
yield host
|
||||
case _:
|
||||
raise NotImplementedError(f"service config not implemented: {name}")
|
||||
|
||||
|
||||
def _from_template(template: Mapping[str, Any]) -> Mapping[str, Any]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue