test: read config file from container as tar buffer

This commit is contained in:
Roman 2025-05-29 17:12:57 +08:00
parent ce3babf65f
commit 410eb43bdb
No known key found for this signature in database
GPG Key ID: 583BDF43C238B83E
2 changed files with 23 additions and 6 deletions

View File

@ -9,5 +9,4 @@ export CFG_FILE_PATH="/etc/nomos/config.yaml" \
LOG_LEVEL="INFO" \
RISC0_DEV_MODE=true
/usr/bin/cfgsync-client && \
exec /usr/bin/nomos-node /etc/nomos/config.yaml
exec /usr/bin/nomos-node /etc/nomos/config.yaml

View File

@ -1,4 +1,6 @@
import io
import json
import tarfile
import pytest
@ -29,11 +31,18 @@ class TestDataConfidentiality(StepsDataAvailability):
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()
# Join stream into bytes and load into a memory buffer
tar_bytes = io.BytesIO(b"".join(stream))
# Extract and write only the actual text file
with tarfile.open(fileobj=tar_bytes) as tar:
member = tar.getmembers()[0]
file_obj = tar.extractfile(member)
if file_obj:
with open("./cluster_config/config.yaml", "wb") as f:
f.write(file_obj.read())
self.node2.stop()
@ -48,3 +57,12 @@ class TestDataConfidentiality(StepsDataAvailability):
raise
delay(600)
# 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"