-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test/data availability and integrity #2
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
231a391
test: add api endpoints
romanzac a5a3f17
test: setup main nodes fixture
romanzac 2fc0cd1
test: use setup_main_nodes fixture
romanzac 0d32bcd
test: add main_nodes as cluster setup
romanzac b424456
fix: test data set to list
romanzac 0eac80f
fix: convert string into list of bytes
romanzac b83019c
fix: app_id should be list of 32 integers
romanzac 1025e36
fix: index should be list of 8 integers
romanzac 53bb790
test: get_data_range
romanzac a56dbfc
fix: remove hardcoded values from disperse_dat
romanzac b028574
fix: add data extraction and decoding
romanzac 578efed
fix: decode data bytes
romanzac 536864e
fix: access response.content
romanzac c5f82e6
test: debug received data
romanzac 01b6025
test: use json response
romanzac be897bf
test: show response
romanzac 77ce25c
test: let the test decode data
romanzac 7cdcc0d
test: type as bytes before decoding
romanzac d021e52
fix: main nodes setup to 2 node cl setup
romanzac c6a8b44
fix: add 5 node cluster config
romanzac 696a6b2
test: default config for 5 nodes temporarily
romanzac ca1686a
test: more robust volume initialization
romanzac 56a4f6b
fix: find executor node
romanzac 4bc7c74
test: retrieve data from half of nodes
romanzac 82abae7
fix: retrieve data from second node
romanzac 1b0731f
fix: copy appropriate config for desired cluster
romanzac 5f68514
fix: optimize setup fixtures
romanzac 0c91fe7
fix: add padding for dispersal data
romanzac 2738c9e
fix: remove unused logger
romanzac b4d32df
fix: skip tests pending on Nomos node changes
romanzac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
port: 4400 | ||
n_hosts: 2 | ||
timeout: 30 | ||
|
||
# ConsensusConfig related parameters | ||
security_param: 10 | ||
active_slot_coeff: 0.9 | ||
|
||
# DaConfig related parameters | ||
subnetwork_size: 2 | ||
dispersal_factor: 2 | ||
num_samples: 1 | ||
num_subnets: 2 | ||
old_blobs_check_interval_secs: 5 | ||
blobs_validity_duration_secs: 60 | ||
global_params_path: "/kzgrs_test_params" | ||
|
||
# Tracing | ||
tracing_settings: | ||
logger: Stdout | ||
tracing: !Otlp | ||
endpoint: http://tempo:4317/ | ||
sample_ratio: 0.5 | ||
service_name: node | ||
filter: !EnvFilter | ||
filters: | ||
nomos: debug | ||
metrics: !Otlp | ||
endpoint: http://prometheus:9090/api/v1/otlp/v1/metrics | ||
host_identifier: node | ||
level: INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
port: 4400 | ||
n_hosts: 5 | ||
timeout: 30 | ||
|
||
# ConsensusConfig related parameters | ||
security_param: 10 | ||
active_slot_coeff: 0.9 | ||
|
||
# DaConfig related parameters | ||
subnetwork_size: 2 | ||
dispersal_factor: 2 | ||
num_samples: 1 | ||
num_subnets: 2 | ||
old_blobs_check_interval_secs: 5 | ||
blobs_validity_duration_secs: 60 | ||
global_params_path: "/kzgrs_test_params" | ||
|
||
# Tracing | ||
tracing_settings: | ||
logger: Stdout | ||
tracing: !Otlp | ||
endpoint: http://tempo:4317/ | ||
sample_ratio: 0.5 | ||
service_name: node | ||
filter: !EnvFilter | ||
filters: | ||
nomos: debug | ||
metrics: !Otlp | ||
endpoint: http://prometheus:9090/api/v1/otlp/v1/metrics | ||
host_identifier: node | ||
level: INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
port: 4400 | ||
n_hosts: 2 | ||
n_hosts: 5 | ||
timeout: 30 | ||
|
||
# ConsensusConfig related parameters | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,71 @@ | ||
import inspect | ||
import os | ||
import shutil | ||
|
||
import pytest | ||
|
||
from src.env_vars import NODE_1, NODE_2 | ||
from src.env_vars import CFGSYNC, NOMOS, NOMOS_EXECUTOR | ||
from src.libs.custom_logger import get_custom_logger | ||
from src.node.nomos_node import NomosNode | ||
|
||
logger = get_custom_logger(__name__) | ||
|
||
|
||
def prepare_cluster_config(node_count): | ||
cwd = os.getcwd() | ||
config_dir = "cluster_config" | ||
src = f"{cwd}/{config_dir}/cfgsync-{node_count}node.yaml" | ||
dst = f"{cwd}/{config_dir}/cfgsync.yaml" | ||
shutil.copyfile(src, dst) | ||
|
||
|
||
def start_nodes(nodes): | ||
for node in nodes: | ||
node.start() | ||
|
||
|
||
def ensure_nodes_ready(nodes): | ||
for node in nodes: | ||
node.ensure_ready() | ||
|
||
|
||
class StepsCommon: | ||
@pytest.fixture(scope="function", autouse=True) | ||
def cluster_setup(self): | ||
logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") | ||
self.main_nodes = [] | ||
|
||
@pytest.fixture(scope="function") | ||
def setup_2_node_cluster(self, request): | ||
logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") | ||
prepare_cluster_config(2) | ||
self.node1 = NomosNode(CFGSYNC, "cfgsync") | ||
self.node2 = NomosNode(NOMOS, "nomos_node_0") | ||
self.node3 = NomosNode(NOMOS_EXECUTOR, "nomos_node_1") | ||
self.main_nodes.extend([self.node1, self.node2, self.node3]) | ||
start_nodes(self.main_nodes) | ||
|
||
try: | ||
ensure_nodes_ready(self.main_nodes[2:]) | ||
except Exception as ex: | ||
logger.error(f"REST service did not become ready in time: {ex}") | ||
raise | ||
|
||
@pytest.fixture(scope="function") | ||
def setup_main_nodes(self, request): | ||
def setup_5_node_cluster(self, request): | ||
logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") | ||
self.node1 = NomosNode(NODE_1, f"node1_{request.cls.test_id}") | ||
self.node1.start() | ||
self.node2 = NomosNode(NODE_2, f"node2_{request.cls.test_id}") | ||
self.node2.start() | ||
self.main_nodes.extend([self.node1, self.node2]) | ||
prepare_cluster_config(5) | ||
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]) | ||
start_nodes(self.main_nodes) | ||
|
||
try: | ||
ensure_nodes_ready(self.main_nodes[2:]) | ||
except Exception as ex: | ||
logger.error(f"REST service did not become ready in time: {ex}") | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import allure | ||
|
||
from src.env_vars import NOMOS_EXECUTOR | ||
from src.steps.common import StepsCommon | ||
|
||
|
||
def add_padding(orig_bytes): | ||
block_size = 31 | ||
""" | ||
Pads a list of bytes (integers in [0..255]) using a PKCS#7-like scheme: | ||
- The value of each padded byte is the number of bytes padded. | ||
- If the original data is already a multiple of the block size, | ||
an additional full block of bytes (each the block size) is added. | ||
""" | ||
original_len = len(orig_bytes) | ||
padding_needed = block_size - (original_len % block_size) | ||
# If the data is already a multiple of block_size, add a full block of padding | ||
if padding_needed == 0: | ||
padding_needed = block_size | ||
|
||
# Each padded byte will be equal to padding_needed | ||
padded_bytes = orig_bytes + [padding_needed] * padding_needed | ||
return padded_bytes | ||
|
||
|
||
def prepare_dispersal_request(data, app_id, index): | ||
data_bytes = data.encode("utf-8") | ||
padded_bytes = add_padding(list(data_bytes)) | ||
dispersal_data = {"data": padded_bytes, "metadata": {"app_id": app_id, "index": index}} | ||
return dispersal_data | ||
|
||
|
||
def prepare_get_range_request(app_id, start_index, end_index): | ||
query_data = {"app_id": app_id, "range": {"start": start_index, "end": end_index}} | ||
return query_data | ||
|
||
|
||
class StepsDataAvailability(StepsCommon): | ||
|
||
def find_executor_node(self): | ||
executor = {} | ||
for node in self.main_nodes: | ||
if node.node_type() == NOMOS_EXECUTOR: | ||
executor = node | ||
return executor | ||
|
||
@allure.step | ||
def disperse_data(self, data, app_id, index): | ||
request = prepare_dispersal_request(data, app_id, index) | ||
executor = self.find_executor_node() | ||
try: | ||
executor.send_dispersal_request(request) | ||
except Exception as ex: | ||
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex) | ||
|
||
@allure.step | ||
def get_data_range(self, node, app_id, start, end): | ||
response = [] | ||
query = prepare_get_range_request(app_id, start, end) | ||
try: | ||
response = node.send_get_data_range_request(query) | ||
except Exception as ex: | ||
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex) | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
class TestDataIntegrity: | ||
import pytest | ||
|
||
from src.steps.da import StepsDataAvailability | ||
from src.test_data import DATA_TO_DISPERSE | ||
|
||
|
||
class TestDataIntegrity(StepsDataAvailability): | ||
main_nodes = [] | ||
|
||
def test_cluster_start(self): | ||
for node in self.main_nodes: | ||
print(node) | ||
@pytest.mark.skip(reason="Waiting for PR https://github.com/logos-co/nomos-node/pull/994") | ||
@pytest.mark.usefixtures("setup_5_node_cluster") | ||
def test_da_identify_retrieve_missing_columns(self): | ||
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])) | ||
|
||
# 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") | ||
|
||
@pytest.mark.skip(reason="Waiting for Nomos testnet images could evolve blockchain") | ||
@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) | ||
received_data = self.get_data_range(self.node2, [0] * 31 + [1], [0] * 8, [0] * 7 + [5]) | ||
assert DATA_TO_DISPERSE[0] == bytes(received_data[0][1]).decode("utf-8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
import pytest | ||
|
||
from src.env_vars import CFGSYNC, NOMOS, NOMOS_EXECUTOR | ||
from src.libs.custom_logger import get_custom_logger | ||
from src.node.nomos_node import NomosNode | ||
from src.steps.common import StepsCommon | ||
|
||
logger = get_custom_logger(__name__) | ||
|
||
|
||
class Test2NodeClAlive: | ||
class Test2NodeClAlive(StepsCommon): | ||
@pytest.mark.usefixtures("setup_2_node_cluster") | ||
def test_cluster_start(self): | ||
|
||
self.node1 = NomosNode(CFGSYNC, "cfgsync") | ||
self.node2 = NomosNode(NOMOS, "nomos_node_0") | ||
self.node3 = NomosNode(NOMOS_EXECUTOR, "nomos_node_1") | ||
|
||
self.node1.start() | ||
self.node2.start() | ||
self.node3.start() | ||
|
||
try: | ||
self.node2.ensure_ready() | ||
self.node3.ensure_ready() | ||
except Exception as ex: | ||
logger.error(f"REST service did not become ready in time: {ex}") | ||
raise | ||
logger.debug("Two node cluster started successfully!") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but
bytes(reconstructed_data).decode("utf-8")
is empty string and DATA_TO_DISPERSE[0] should be "Hello World!"what are we asserting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the nomos-cli should be called to reconstruct the data from received blobs. PR in nomos-node repo logos-co/nomos-node#994. I would assume nomos-cli as our "first to go" verification tool. We might think about being independent, with our own tooling, however this would come at certain cost. We can discuss more during meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but now the assert will not pass, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests skipped at b4d32df