From 422636f68b2a2e74ef7a1a18b472a5a1a58c4f0d Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Fri, 23 Dec 2022 11:52:05 +0300 Subject: [PATCH] Updates for local dev env runs Signed-off-by: Andrey Berezin --- .devenv.hosting.yaml | 18 ++++++++++++++++++ pytest_tests/helpers/cluster.py | 20 ++++++++++++++++++++ pytest_tests/testsuites/conftest.py | 7 +++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.devenv.hosting.yaml b/.devenv.hosting.yaml index 33a7614f..972a515b 100644 --- a/.devenv.hosting.yaml +++ b/.devenv.hosting.yaml @@ -7,6 +7,8 @@ hosts: container_name: s01 config_path: ../neofs-dev-env/services/storage/.storage.env wallet_path: ../neofs-dev-env/services/storage/wallet01.json + local_config_path: ./TemporaryDir/empty-password.yml + local_wallet_path: ../neofs-dev-env/services/storage/wallet01.json wallet_password: "" volume_name: storage_storage_s01 rpc_endpoint: s01.neofs.devenv:8080 @@ -17,6 +19,8 @@ hosts: container_name: s02 config_path: ../neofs-dev-env/services/storage/.storage.env wallet_path: ../neofs-dev-env/services/storage/wallet02.json + local_config_path: ./TemporaryDir/empty-password.yml + local_wallet_path: ../neofs-dev-env/services/storage/wallet02.json wallet_password: "" volume_name: storage_storage_s02 rpc_endpoint: s02.neofs.devenv:8080 @@ -27,6 +31,8 @@ hosts: container_name: s03 config_path: ../neofs-dev-env/services/storage/.storage.env wallet_path: ../neofs-dev-env/services/storage/wallet03.json + local_config_path: ./TemporaryDir/empty-password.yml + local_wallet_path: ../neofs-dev-env/services/storage/wallet03.json wallet_password: "" volume_name: storage_storage_s03 rpc_endpoint: s03.neofs.devenv:8080 @@ -37,6 +43,8 @@ hosts: container_name: s04 config_path: ../neofs-dev-env/services/storage/.storage.env wallet_path: ../neofs-dev-env/services/storage/wallet04.json + local_config_path: ./TemporaryDir/empty-password.yml + local_wallet_path: ../neofs-dev-env/services/storage/wallet04.json wallet_password: "" volume_name: storage_storage_s04 rpc_endpoint: s04.neofs.devenv:8080 @@ -47,6 +55,8 @@ hosts: container_name: s3_gate config_path: ../neofs-dev-env/services/s3_gate/.s3.env wallet_path: ../neofs-dev-env/services/s3_gate/wallet.json + local_config_path: ./TemporaryDir/password-s3.yml + local_wallet_path: ../neofs-dev-env/services/s3_gate/wallet.json wallet_password: "s3" endpoint: https://s3.neofs.devenv:8080 - name: http-gate01 @@ -54,6 +64,8 @@ hosts: container_name: http_gate config_path: ../neofs-dev-env/services/http_gate/.http.env wallet_path: ../neofs-dev-env/services/http_gate/wallet.json + local_config_path: ./TemporaryDir/password-other.yml + local_wallet_path: ../neofs-dev-env/services/http_gate/wallet.json wallet_password: "one" endpoint: http://http.neofs.devenv - name: ir01 @@ -61,12 +73,16 @@ hosts: container_name: ir01 config_path: ../neofs-dev-env/services/ir/.ir.env wallet_path: ../neofs-dev-env/services/ir/az.json + local_config_path: ./TemporaryDir/password-other.yml + local_wallet_path: ../neofs-dev-env/services/ir/az.json wallet_password: "one" - name: morph-chain01 attributes: container_name: morph_chain config_path: ../neofs-dev-env/services/morph_chain/protocol.privnet.yml wallet_path: ../neofs-dev-env/services/morph_chain/node-wallet.json + local_config_path: ./TemporaryDir/password-other.yml + local_wallet_path: ../neofs-dev-env/services/morph_chain/node-wallet.json wallet_password: "one" endpoint: http://morph-chain.neofs.devenv:30333 - name: main-chain01 @@ -74,6 +90,8 @@ hosts: container_name: main_chain config_path: ../neofs-dev-env/services/chain/protocol.privnet.yml wallet_path: ../neofs-dev-env/services/chain/node-wallet.json + local_config_path: ./TemporaryDir/password-other.yml + local_wallet_path: ../neofs-dev-env/services/chain/node-wallet.json wallet_password: "one" endpoint: http://main-chain.neofs.devenv:30333 - name: coredns01 diff --git a/pytest_tests/helpers/cluster.py b/pytest_tests/helpers/cluster.py index e6d95b2f..bc1d7dfb 100644 --- a/pytest_tests/helpers/cluster.py +++ b/pytest_tests/helpers/cluster.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from typing import Any import data_formatters +import yaml from neofs_testlib.blockchain import RPCClient from neofs_testlib.hosting import Host, Hosting from neofs_testlib.hosting.config import ServiceConfig @@ -237,6 +238,25 @@ class Cluster: def hosting(self) -> Hosting: return self._hosting + def _create_wallet_config(self, service: ServiceConfig) -> None: + wallet_path = service.attributes[_ConfigAttributes.LOCAL_WALLET_CONFIG] + wallet_password = service.attributes[_ConfigAttributes.WALLET_PASSWORD] + with open(wallet_path, "w") as file: + yaml.dump({"password": wallet_password}, file) + + def create_wallet_configs(self, hosting: Hosting) -> None: + configs = hosting.find_service_configs(".*") + for config in configs: + if _ConfigAttributes.LOCAL_WALLET_CONFIG in config.attributes: + self._create_wallet_config(config) + + def is_local_devevn(self) -> bool: + if len(self.hosting.hosts) == 1: + host = self.hosting.hosts[0] + if host.config.address == "localhost" and host.config.plugin_name == "docker": + return True + return False + @property def storage_nodes(self) -> list[StorageNode]: """ diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 7d00c64c..4d9de511 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -115,8 +115,11 @@ def wallet_factory(temp_directory: str, client_shell: Shell, cluster: Cluster) - @pytest.fixture(scope="session") -def cluster(hosting: Hosting) -> Cluster: - yield Cluster(hosting) +def cluster(temp_directory: str, hosting: Hosting) -> Cluster: + cluster = Cluster(hosting) + if cluster.is_local_devevn(): + cluster.create_wallet_configs(hosting) + yield cluster @pytest.fixture(scope="session", autouse=True)