From 355602e74c836d011e2e6b284fcab0212d8ec3e7 Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Sat, 12 Aug 2023 21:34:40 -0400 Subject: [PATCH] Fix load test according to adding a new load node, fixes #544 Signed-off-by: Evgeniy Zayats --- pytest_tests/helpers/k6.py | 4 +--- pytest_tests/resources/load_params.py | 26 +++++++++++---------- pytest_tests/steps/load.py | 28 +++++++++++------------ pytest_tests/testsuites/load/test_load.py | 14 +++++------- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/pytest_tests/helpers/k6.py b/pytest_tests/helpers/k6.py index e6e5a72de..7470fcd32 100644 --- a/pytest_tests/helpers/k6.py +++ b/pytest_tests/helpers/k6.py @@ -49,7 +49,6 @@ class LoadResults: class K6: def __init__(self, load_params: LoadParams, shell: Shell): - self.load_params = load_params self.shell = shell @@ -68,7 +67,7 @@ def process_dir(self) -> str: def k6_dir(self) -> str: if not self._k6_dir: self._k6_dir = self.shell.exec( - r"sudo find . -name 'k6' -exec dirname {} \; -quit" + r"sudo find / -name 'k6' -exec dirname {} \; -quit" ).stdout.strip("\n") return self._k6_dir @@ -126,7 +125,6 @@ def _generate_env_variables(self, load_params: LoadParams, k6_dir: str) -> str: @allure.step("Start K6 on initiator") def start(self) -> None: - self._k6_dir = self.k6_dir command = ( f"{self.k6_dir}/k6 run {self._generate_env_variables(self.load_params, self.k6_dir)} " diff --git a/pytest_tests/resources/load_params.py b/pytest_tests/resources/load_params.py index 9a3b62228..e27602321 100644 --- a/pytest_tests/resources/load_params.py +++ b/pytest_tests/resources/load_params.py @@ -1,9 +1,11 @@ import os # Load node parameters -LOAD_NODES = os.getenv("LOAD_NODES", "").split(",") -LOAD_NODE_SSH_USER = os.getenv("LOAD_NODE_SSH_USER", "root") -LOAD_NODE_SSH_PRIVATE_KEY_PATH = os.getenv("LOAD_NODE_SSH_PRIVATE_KEY_PATH") +LOAD_NODES = os.getenv("LOAD_NODES", "127.0.0.1").split(",") +LOAD_NODE_SSH_USER = os.getenv("LOAD_NODE_SSH_USER", "k6") +LOAD_NODE_SSH_PRIVATE_KEY_PATH = os.getenv( + "LOAD_NODE_SSH_PRIVATE_KEY_PATH", "../neofs-dev-env/services/k6_node/id_ed25519" +) BACKGROUND_WRITERS_COUNT = os.getenv("BACKGROUND_WRITERS_COUNT", 10) BACKGROUND_READERS_COUNT = os.getenv("BACKGROUND_READERS_COUNT", 10) BACKGROUND_OBJ_SIZE = os.getenv("BACKGROUND_OBJ_SIZE", 1024) @@ -11,17 +13,17 @@ # Load run parameters -OBJ_SIZE = os.getenv("OBJ_SIZE", "1000").split(",") -CONTAINERS_COUNT = os.getenv("CONTAINERS_COUNT", "1").split(",") +OBJ_SIZE = [int(o) for o in os.getenv("OBJ_SIZE", "1000").split(",")] +CONTAINERS_COUNT = [int(c) for c in os.getenv("CONTAINERS_COUNT", "1").split(",")] OUT_FILE = os.getenv("OUT_FILE", "1mb_200.json").split(",") -OBJ_COUNT = os.getenv("OBJ_COUNT", "4").split(",") -WRITERS = os.getenv("WRITERS", "200").split(",") -READERS = os.getenv("READER", "0").split(",") -DELETERS = os.getenv("DELETERS", "0").split(",") -LOAD_TIME = os.getenv("LOAD_TIME", "200").split(",") +OBJ_COUNT = [int(o) for o in os.getenv("OBJ_COUNT", "4").split(",")] +WRITERS = [int(w) for w in os.getenv("WRITERS", "200").split(",")] +READERS = [int(r) for r in os.getenv("READER", "0").split(",")] +DELETERS = [int(d) for d in os.getenv("DELETERS", "0").split(",")] +LOAD_TIME = [int(ld) for ld in os.getenv("LOAD_TIME", "200").split(",")] LOAD_TYPE = os.getenv("LOAD_TYPE", "grpc").split(",") -LOAD_NODES_COUNT = os.getenv("LOAD_NODES_COUNT", "1").split(",") -STORAGE_NODE_COUNT = os.getenv("STORAGE_NODE_COUNT", "4").split(",") +LOAD_NODES_COUNT = [int(ldc) for ldc in os.getenv("LOAD_NODES_COUNT", "1").split(",")] +STORAGE_NODE_COUNT = [int(s) for s in os.getenv("STORAGE_NODE_COUNT", "4").split(",")] CONTAINER_PLACEMENT_POLICY = os.getenv( "CONTAINER_PLACEMENT_POLICY", "REP 1 IN X CBF 1 SELECT 1 FROM * AS X" ) diff --git a/pytest_tests/steps/load.py b/pytest_tests/steps/load.py index 9cd2fbd90..c0d3caae9 100644 --- a/pytest_tests/steps/load.py +++ b/pytest_tests/steps/load.py @@ -40,7 +40,12 @@ def start_stopped_nodes(): @allure.title("Init s3 client") def init_s3_client( - load_nodes: list, login: str, pkey: str, container_placement_policy: str, hosting: Hosting + load_nodes: list, + login: str, + pkey: str, + container_placement_policy: str, + hosting: Hosting, + ssh_port: int, ): service_configs = hosting.find_service_configs(STORAGE_NODE_SERVICE_NAME_REGEX) host = hosting.get_host_by_service(service_configs[0].name) @@ -52,7 +57,7 @@ def init_s3_client( node_endpoint = service_configs[0].attributes["rpc_endpoint"] # prompt_pattern doesn't work at the moment for load_node in load_nodes: - ssh_client = SSHShell(host=load_node, login=login, private_key_path=pkey) + ssh_client = SSHShell(host=load_node, port=ssh_port, login=login, private_key_path=pkey) path = ssh_client.exec(r"sudo find . -name 'k6' -exec dirname {} \; -quit").stdout.strip( "\n" ) @@ -88,16 +93,6 @@ def init_s3_client( ssh_client.exec("aws configure", CommandOptions(interactive_inputs=configure_input)) -@allure.title("Clear cache and data from storage nodes") -def clear_cache_and_data(hosting: Hosting): - service_configs = hosting.find_service_configs(STORAGE_NODE_SERVICE_NAME_REGEX) - for service_config in service_configs: - host = hosting.get_host_by_service(service_config.name) - host.stop_service(service_config.name) - host.delete_storage_node_data(service_config.name) - host.start_service(service_config.name) - - @allure.title("Prepare objects") def prepare_objects(k6_instance: K6): k6_instance.prepare() @@ -105,11 +100,16 @@ def prepare_objects(k6_instance: K6): @allure.title("Prepare K6 instances and objects") def prepare_k6_instances( - load_nodes: list, login: str, pkey: str, load_params: LoadParams, prepare: bool = True + load_nodes: list, + login: str, + pkey: str, + load_params: LoadParams, + ssh_port: int, + prepare: bool = True, ) -> list[K6]: k6_load_objects = [] for load_node in load_nodes: - ssh_client = SSHShell(host=load_node, login=login, private_key_path=pkey) + ssh_client = SSHShell(port=ssh_port, host=load_node, login=login, private_key_path=pkey) k6_load_object = K6(load_params, ssh_client) k6_load_objects.append(k6_load_object) for k6_load_object in k6_load_objects: diff --git a/pytest_tests/testsuites/load/test_load.py b/pytest_tests/testsuites/load/test_load.py index 69ba426aa..a2852a8b4 100644 --- a/pytest_tests/testsuites/load/test_load.py +++ b/pytest_tests/testsuites/load/test_load.py @@ -8,7 +8,6 @@ ) from k6 import LoadParams from load import ( - clear_cache_and_data, get_services_endpoints, init_s3_client, multi_node_k6_run, @@ -37,18 +36,16 @@ ENDPOINTS_ATTRIBUTES = { "http": {"regex": HTTP_GATE_SERVICE_NAME_REGEX, "endpoint_attribute": "endpoint"}, - "grpc": {"regex": STORAGE_NODE_SERVICE_NAME_REGEX, "endpoint_attribute": "rpc_endpoint"}, + "grpc": {"regex": STORAGE_NODE_SERVICE_NAME_REGEX, "endpoint_attribute": "endpoint_data0"}, "s3": {"regex": S3_GATE_SERVICE_NAME_REGEX, "endpoint_attribute": "endpoint"}, } @pytest.mark.load -@pytest.mark.skip(reason="https://github.com/nspcc-dev/neofs-testcases/issues/544") @pytest.mark.nspcc_dev__neofs_testcases__issue_544 class TestLoad(ClusterTestBase): @pytest.fixture(autouse=True) - def clear_cache_and_data(self, hosting: Hosting): - clear_cache_and_data(hosting=hosting) + def restore_nodes(self, hosting: Hosting): yield start_stopped_nodes() @@ -61,6 +58,7 @@ def init_s3_client(self, hosting: Hosting): pkey=LOAD_NODE_SSH_PRIVATE_KEY_PATH, hosting=hosting, container_placement_policy=CONTAINER_PLACEMENT_POLICY, + ssh_port=2222, ) @pytest.mark.parametrize("obj_size, out_file", list(zip(OBJ_SIZE, OUT_FILE))) @@ -73,7 +71,6 @@ def init_s3_client(self, hosting: Hosting): @pytest.mark.parametrize("load_nodes_count", LOAD_NODES_COUNT) @pytest.mark.benchmark @pytest.mark.grpc - @pytest.mark.skip(reason="https://github.com/nspcc-dev/neofs-testcases/issues/544") @pytest.mark.nspcc_dev__neofs_testcases__issue_544 def test_custom_load( self, @@ -100,8 +97,8 @@ def test_custom_load( with allure.step("Get endpoints"): endpoints_list = get_services_endpoints( hosting=hosting, - service_name_regex=ENDPOINTS_ATTRIBUTES[LOAD_TYPE]["regex"], - endpoint_attribute=ENDPOINTS_ATTRIBUTES[LOAD_TYPE]["endpoint_attribute"], + service_name_regex=ENDPOINTS_ATTRIBUTES[load_type]["regex"], + endpoint_attribute=ENDPOINTS_ATTRIBUTES[load_type]["endpoint_attribute"], ) endpoints = ",".join(endpoints_list[:node_count]) load_params = LoadParams( @@ -122,6 +119,7 @@ def test_custom_load( login=LOAD_NODE_SSH_USER, pkey=LOAD_NODE_SSH_PRIVATE_KEY_PATH, load_params=load_params, + ssh_port=2222, ) with allure.step("Run load"): multi_node_k6_run(k6_load_instances)