test: customized node

This commit is contained in:
Roman 2025-05-29 16:49:33 +08:00
parent 5b2ee81883
commit ce3babf65f
No known key found for this signature in database
GPG Key ID: 583BDF43C238B83E
5 changed files with 37 additions and 12 deletions

View File

@ -0,0 +1,13 @@
#!/bin/sh
set -e
export CFG_FILE_PATH="/etc/nomos/config.yaml" \
CFG_SERVER_ADDR="http://cfgsync:4400" \
CFG_HOST_IP=$(hostname -i) \
CFG_HOST_IDENTIFIER="validator-$(hostname -i)" \
LOG_LEVEL="INFO" \
RISC0_DEV_MODE=true
/usr/bin/cfgsync-client && \
exec /usr/bin/nomos-node /etc/nomos/config.yaml

View File

@ -21,6 +21,7 @@ NOMOS_IMAGE = get_env_var("NOMOS_IMAGE", DEFAULT_NOMOS_IMAGE)
DEFAULT_PROXY_IMAGE = "bitnami/configurable-http-proxy:latest"
HTTP_PROXY_IMAGE = get_env_var("HTTP_PROXY_IMAGE", DEFAULT_PROXY_IMAGE)
NOMOS_CUSTOM = "nomos_custom"
NOMOS = "nomos"
NOMOS_EXECUTOR = "nomos_executor"
CFGSYNC = "cfgsync"

View File

@ -1,6 +1,12 @@
from src.env_vars import NOMOS_IMAGE
nomos_nodes = {
"nomos_custom": {
"image": NOMOS_IMAGE,
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
"ports": ["3000/udp", "18080/tcp"],
"entrypoint": "/etc/nomos/scripts/run_customized_node.sh",
},
"nomos": {
"image": NOMOS_IMAGE,
"volumes": ["cluster_config:/etc/nomos", "./kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],

View File

@ -128,6 +128,9 @@ class NomosNode:
def name(self):
return self._container_name
def get_archive(self, path):
return self._container.get_archive(path)
def api_port(self):
return self._tcp_port

View File

@ -3,7 +3,7 @@ import json
import pytest
from src.client.nomos_cli import NomosCli
from src.env_vars import CONSENSUS_SLOT_TIME, NOMOS
from src.env_vars import CONSENSUS_SLOT_TIME, NOMOS, NOMOS_CUSTOM
from src.libs.common import delay, to_app_id, to_index
from src.libs.custom_logger import get_custom_logger
from src.node.nomos_node import NomosNode
@ -27,22 +27,24 @@ class TestDataConfidentiality(StepsDataAvailability):
decoded_data = NomosCli(command="reconstruct").run(input_values=[rcv_data_json], decode_only=True)
assert DATA_TO_DISPERSE[1] == decoded_data, "Retrieved data are not same with original data"
# Copy the config file from first node
cfg_file = open("./cluster_config/config.yaml", "wb")
stream, _stat = self.node2.get_archive("/config.yaml")
for chunk in stream:
cfg_file.write(chunk)
cfg_file.close()
self.node2.stop()
# Start new node with the same IP address
self.nodeX = NomosNode(NOMOS, "nomos_node_0")
# Start new node with the same hostname and configuration
self.nodeX = NomosNode(NOMOS_CUSTOM, "nomos_node_0")
self.nodeX.start()
try:
ensure_nodes_ready(self.nodeX)
self.nodeX.ensure_ready()
except Exception as ex:
logger.error(f"REST service did not become ready in time: {ex}")
raise
delay(CONSENSUS_SLOT_TIME)
self.disperse_data(DATA_TO_DISPERSE[2], to_app_id(2), to_index(0))
delay(CONSENSUS_SLOT_TIME)
try:
rcv_data = self.get_data_range(self.nodeX, to_app_id(2), to_index(0), to_index(5))
except AssertionError as ae:
assert "Get data range response is empty" in str(ae), "Get data range response should be empty"
delay(600)