ContainerizedService: Use the same file path inside container by default

Signed-off-by: Vitaliy Potyarkin <v.potyarkin@yadro.com>
This commit is contained in:
Vitaliy Potyarkin 2025-05-12 16:24:44 +03:00
parent d55026fe13
commit f3bda0cc9b
5 changed files with 33 additions and 23 deletions

View file

@ -102,11 +102,13 @@ class ContainerizedService:
socket._sock.close()
socket.close()
def add_file(self, src: Path, dest: Path) -> None:
def add_file(self, src: Path, dest: Path = None) -> None:
"""
Add file from local filesystem into a running container.
Keeps a copy of the whole file in memory (TODO: stream directly from disk).
"""
if dest is None:
dest = src
file = tarfile.TarInfo(str(dest))
file.size = Path(src).stat().st_size
if file.size > (64 << 20):
@ -120,8 +122,10 @@ class ContainerizedService:
archive.seek(0)
self._container.put_archive("/", archive)
def add_directory(self, src: Path, dest: Path) -> None:
def add_directory(self, src: Path, dest: Path = None) -> None:
"""Add all files from directory (one by one)."""
if dest is None:
dest = src
dest = Path(dest)
for root, _, files in os.walk(src):
root = Path(root)

View file

@ -364,6 +364,7 @@ def neogo_config(neogo_deployment, adm_config, alphabet_wallets):
dict(
letter=letter,
index=index,
wallet=alphabet_dir / f"{letter}.json",
password=credentials[letter],
)
)
@ -395,14 +396,15 @@ def neogo(neogo_deployment, neogo_config, alphabet_deployment, frostfs_adm, _net
nodes = []
for index in range(neogo_deployment.node_count):
letter = glagolic[index]
config_file = config_dir / f"{letter}.json"
node = ContainerizedService(
command=f"neo-go node --config-file /neogo/{letter}.json --privnet --debug",
command=f"neo-go node --config-file '{config_file}' --privnet --debug",
image=f"{neogo_deployment.image}:{neogo_deployment.version}",
name=f"{neogo_deployment.prefix}{index+1}",
network=_network,
)
node.add_file(wallet_dir / f"{letter}.json", f"/wallet/{letter}.json")
node.add_file(config_dir / f"{letter}.json", f"/neogo/{letter}.json")
node.add_file(wallet_dir / f"{letter}.json")
node.add_file(config_file)
node.start()
nodes.append(node)
@ -433,8 +435,8 @@ def frostfs_adm(adm_deployment, adm_config, alphabet_deployment, _network):
network=_network,
)
wallet_dir = alphabet_deployment.dir
adm.add_directory(wallet_dir, wallet_dir)
adm.add_file(config_file, config_file)
adm.add_directory(wallet_dir)
adm.add_file(config_file)
yield adm
adm.destroy()
@ -446,7 +448,7 @@ def frostfs_bootstrap(frostfs_contract, frostfs_adm, neogo) -> Mapping[str, str]
def morph(command: str) -> str:
output[command] = frostfs_adm(f"morph {command}")
frostfs_adm.add_directory(frostfs_contract, frostfs_contract)
frostfs_adm.add_directory(frostfs_contract)
morph(f"init --contracts '{frostfs_contract}'")
morph(
"ape add-rule-chain "
@ -512,6 +514,7 @@ def innerring_config(innerring_deployment, neogo, adm_config, alphabet_wallets):
dict(
letter=letter,
index=index,
wallet=alphabet_dir / f"{letter}.json",
password=credentials[letter],
neogo=neogo[index].name,
)
@ -533,15 +536,16 @@ def innerring(innerring_deployment, innerring_config, frostfs_locode, frostfs_bo
nodes = []
for index in range(alphabet_deployment.node_count):
letter = glagolic[index]
config_file = config_dir / f"{letter}.json"
node = ContainerizedService(
command=f"frostfs-ir --config /innerring/{letter}.json",
command=f"frostfs-ir --config '{config_file}'",
image=f"{innerring_deployment.image}:{innerring_deployment.version}",
name=f"{innerring_deployment.prefix}{index+1}",
network=_network,
)
node.add_file(wallet_dir / f"{letter}.json", f"/wallet/{letter}.json")
node.add_file(config_dir / f"{letter}.json", f"/innerring/{letter}.json")
node.add_file(frostfs_locode, f"/innerring/locode.db")
node.add_file(wallet_dir / f"{letter}.json")
node.add_file(config_file)
node.add_file(frostfs_locode, "/innerring/locode.db")
node.start()
nodes.append(node)
yield nodes
@ -582,7 +586,7 @@ def storage_config(storage_deployment, neogo, frostfs_adm, innerring):
_update(config, override)
with open(storage_deployment.dir / f"config-{index}.json", "w") as c:
json.dump(config, c, ensure_ascii=False, indent=True, sort_keys=True)
frostfs_adm.add_file(wallet, wallet)
frostfs_adm.add_file(wallet)
frostfs_adm(f"morph refill-gas --storage-wallet '{wallet}' --gas 50.0")
configs.append(config)
yield configs, storage_deployment.dir
@ -594,14 +598,15 @@ def storage(storage_deployment, storage_config, frostfs_adm, _network):
nodes = []
configs, _ = storage_config
for index, config in enumerate(configs):
config_file = storage_deployment.dir / f"config-{index}.json"
node = ContainerizedService(
command=f"frostfs-node --config /storage/config.json",
command=f"frostfs-node --config '{config_file}'",
image=f"{storage_deployment.image}:{storage_deployment.version}",
name=f"{storage_deployment.prefix}{index+1}",
network=_network,
)
node.add_file(config["node"]["wallet"]["path"], config["node"]["wallet"]["path"])
node.add_file(storage_deployment.dir / f"config-{index}.json", f"/storage/config.json")
node.add_file(config["node"]["wallet"]["path"])
node.add_file(config_file)
node.start()
nodes.append(node)
for index, node in enumerate(nodes):
@ -655,14 +660,15 @@ def httpgw(httpgw_deployment, httpgw_config, _network):
nodes = []
configs, _ = httpgw_config
for index, config in enumerate(configs):
config_file = httpgw_deployment.dir / f"config-{index}.json"
node = ContainerizedService(
command=f"frostfs-http-gw --config /httpgw/config.json",
command=f"frostfs-http-gw --config '{config_file}'",
image=f"{httpgw_deployment.image}:{httpgw_deployment.version}",
name=f"{httpgw_deployment.prefix}{index+1}",
network=_network,
)
node.add_file(config["wallet"]["path"], config["wallet"]["path"])
node.add_file(httpgw_deployment.dir / f"config-{index}.json", f"/httpgw/config.json")
node.add_file(config["wallet"]["path"])
node.add_file(config_file)
node.start()
nodes.append(node)
ready = re.compile(r"starting server.*\:80")

View file

@ -9,7 +9,7 @@ control:
# Wallet settings
wallet:
path: /wallet/{letter}.json
path: {wallet}
password: {password}
# Profiler section

View file

@ -46,7 +46,7 @@ ApplicationConfiguration:
Consensus:
Enabled: true
UnlockWallet:
Path: "/wallet/{letter}.json"
Path: "{wallet}"
Password: "{password}"
RPC:
Addresses:
@ -58,7 +58,7 @@ ApplicationConfiguration:
P2PNotary:
Enabled: true
UnlockWallet:
Path: "/wallet/{letter}.json"
Path: "{wallet}"
Password: "{password}"
Prometheus:
Addresses:

View file

@ -43,7 +43,7 @@ node:
attribute_0: "User-Agent:FrostFS component tests"
attribute_1: "Price:{price}"
persistent_state:
path: /storage/state
path: /storage.state
grpc:
- endpoint: :8802