From ca8eabfc3511c01da463c8fa72d26ac0ba5c0ce2 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 11 Feb 2025 16:11:14 +0800 Subject: [PATCH] fix: use 4 node instead of 5 node cluster - fix test_da_identify_retrieve_missing_columns --- ...{cfgsync-5node.yaml => cfgsync-4node.yaml} | 2 +- src/cli/nomos_cli.py | 2 +- src/steps/common.py | 9 +++--- tests/data_integrity/test_data_integrity.py | 29 ++++++++++--------- 4 files changed, 22 insertions(+), 20 deletions(-) rename cluster_config/{cfgsync-5node.yaml => cfgsync-4node.yaml} (98%) diff --git a/cluster_config/cfgsync-5node.yaml b/cluster_config/cfgsync-4node.yaml similarity index 98% rename from cluster_config/cfgsync-5node.yaml rename to cluster_config/cfgsync-4node.yaml index dde1f71..68a9878 100644 --- a/cluster_config/cfgsync-5node.yaml +++ b/cluster_config/cfgsync-4node.yaml @@ -1,5 +1,5 @@ port: 4400 -n_hosts: 5 +n_hosts: 4 timeout: 30 # ConsensusConfig related parameters diff --git a/src/cli/nomos_cli.py b/src/cli/nomos_cli.py index 2f83ead..7ff564d 100644 --- a/src/cli/nomos_cli.py +++ b/src/cli/nomos_cli.py @@ -85,7 +85,7 @@ class NomosCli: self._container = None logger.debug("Container killed.") - def run_reconstruct(self, input_values=None, decode_only=True): + def run_reconstruct(self, input_values=None, decode_only=False): keywords = ["Reconstructed data"] self.run(input_values) diff --git a/src/steps/common.py b/src/steps/common.py index 90e734f..c9ed0cf 100644 --- a/src/steps/common.py +++ b/src/steps/common.py @@ -52,16 +52,15 @@ class StepsCommon: raise @pytest.fixture(scope="function") - def setup_5_node_cluster(self, request): + def setup_4_node_cluster(self, request): logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") - prepare_cluster_config(5) + prepare_cluster_config(4) self.node1 = NomosNode(CFGSYNC, "cfgsync") self.node2 = NomosNode(NOMOS, "nomos_node_0") self.node3 = NomosNode(NOMOS, "nomos_node_1") self.node4 = NomosNode(NOMOS, "nomos_node_2") - self.node5 = NomosNode(NOMOS, "nomos_node_3") - self.node6 = NomosNode(NOMOS_EXECUTOR, "nomos_node_4") - self.main_nodes.extend([self.node1, self.node2, self.node3, self.node4, self.node5, self.node6]) + self.node5 = NomosNode(NOMOS_EXECUTOR, "nomos_node_3") + self.main_nodes.extend([self.node1, self.node2, self.node3, self.node4, self.node5]) start_nodes(self.main_nodes) try: diff --git a/tests/data_integrity/test_data_integrity.py b/tests/data_integrity/test_data_integrity.py index 1b7166a..4908bb7 100644 --- a/tests/data_integrity/test_data_integrity.py +++ b/tests/data_integrity/test_data_integrity.py @@ -1,4 +1,5 @@ import json +import random import pytest @@ -14,27 +15,29 @@ logger = get_custom_logger(__name__) class TestDataIntegrity(StepsDataAvailability): main_nodes = [] - @pytest.mark.skip(reason="Waiting for PR https://github.com/logos-co/nomos-node/pull/994") - @pytest.mark.usefixtures("setup_5_node_cluster") + @pytest.mark.usefixtures("setup_4_node_cluster") def test_da_identify_retrieve_missing_columns(self): + delay(5) self.disperse_data(DATA_TO_DISPERSE[0], [0] * 31 + [1], [0] * 8) - received_data = [] - # Get data only from half of nodes - for node in self.main_nodes[2:4]: - received_data.append(self.get_data_range(node, [0] * 31 + [1], [0] * 8, [0] * 7 + [3])) + delay(20) + # Select one target node at random to get blob data for 1/2 columns + selected_node = self.main_nodes[random.randint(1, 3)] + rcv_data = self.get_data_range(selected_node, [0] * 31 + [1], [0] * 8, [0] * 7 + [5]) + rcv_data_json = json.dumps(rcv_data) - # Use received blob data to reconstruct the original data - # nomos-cli reconstruct command required - reconstructed_data = [] - assert DATA_TO_DISPERSE[0] == bytes(reconstructed_data).decode("utf-8") + cli = NomosCli(command="reconstruct") + reconstructed_data = cli.run_reconstruct(input_values=[rcv_data_json]) + + assert DATA_TO_DISPERSE[0] == reconstructed_data, "Reconstructed data are not same with original data" @pytest.mark.usefixtures("setup_2_node_cluster") def test_da_sampling_determines_data_presence(self): self.disperse_data(DATA_TO_DISPERSE[0], [0] * 31 + [1], [0] * 8) delay(5) - received_data = self.get_data_range(self.node2, [0] * 31 + [1], [0] * 8, [0] * 7 + [5]) - rcv_data_json = json.dumps(received_data) + rcv_data = self.get_data_range(self.node2, [0] * 31 + [1], [0] * 8, [0] * 7 + [5]) + rcv_data_json = json.dumps(rcv_data) + cli = NomosCli(command="reconstruct") - decoded_data = cli.run_reconstruct(input_values=[rcv_data_json]) + decoded_data = cli.run_reconstruct(input_values=[rcv_data_json], decode_only=True) assert DATA_TO_DISPERSE[0] == decoded_data, "Retrieved data are not same with original data"