From c9e4c2c7bbded6a745e981e75f7cd1d234e74b22 Mon Sep 17 00:00:00 2001 From: "a.berezin" Date: Tue, 25 Jun 2024 18:56:10 +0300 Subject: [PATCH] [#251] Update get object nodes command call Signed-off-by: a.berezin --- src/frostfs_testlib/cli/frostfs_cli/object.py | 1 + src/frostfs_testlib/steps/cli/object.py | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/frostfs_testlib/cli/frostfs_cli/object.py b/src/frostfs_testlib/cli/frostfs_cli/object.py index 5d5bd91..55c92be 100644 --- a/src/frostfs_testlib/cli/frostfs_cli/object.py +++ b/src/frostfs_testlib/cli/frostfs_cli/object.py @@ -362,6 +362,7 @@ class FrostfsCliObject(CliCommand): trace: bool = False, root: bool = False, verify_presence_all: bool = False, + json: bool = False, ttl: Optional[int] = None, xhdr: Optional[dict] = None, timeout: Optional[str] = None, diff --git a/src/frostfs_testlib/steps/cli/object.py b/src/frostfs_testlib/steps/cli/object.py index b84a3a2..7de7a71 100644 --- a/src/frostfs_testlib/steps/cli/object.py +++ b/src/frostfs_testlib/steps/cli/object.py @@ -722,21 +722,27 @@ def get_object_nodes( cli = FrostfsCli(shell, FROSTFS_CLI_EXEC, wallet_config) - result_object_nodes = cli.object.nodes( + response = cli.object.nodes( rpc_endpoint=endpoint, cid=cid, oid=oid, bearer=bearer, ttl=1 if is_direct else None, + json=True, xhdr=xhdr, timeout=timeout, verify_presence_all=verify_presence_all, ) - parsing_output = parse_cmd_table(result_object_nodes.stdout, "|") - list_object_nodes = [ - node for node in parsing_output if node["should_contain_object"] == "true" and node["actually_contains_object"] == "true" - ] + response_json = json.loads(response.stdout) + # Currently, the command will show expected and confirmed nodes. + # And we (currently) count only nodes which are both expected and confirmed + object_nodes_id = { + required_node + for data_object in response_json["data_objects"] + for required_node in data_object["required_nodes"] + if required_node in data_object["confirmed_nodes"] + } netmap_nodes_list = parse_netmap_output( cli.netmap.snapshot( @@ -745,14 +751,11 @@ def get_object_nodes( ).stdout ) netmap_nodes = [ - netmap_node - for object_node in list_object_nodes - for netmap_node in netmap_nodes_list - if object_node["node_id"] == netmap_node.node_id + netmap_node for object_node in object_nodes_id for netmap_node in netmap_nodes_list if object_node == netmap_node.node_id ] - result = [ + object_nodes = [ cluster_node for netmap_node in netmap_nodes for cluster_node in cluster.cluster_nodes if netmap_node.node == cluster_node.host_ip ] - return result + return object_nodes