-
Notifications
You must be signed in to change notification settings - Fork 1
chore: Sync data availability and integrity tests with latest Nomos node changes #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ae11280
fix: remove skip for test_da_sampling_determines_data_presence
romanzac a5a04b2
fix: set default docker image
romanzac 3ee9852
test: reconstruct command
romanzac f3a5117
test: nomos cli wrapper
romanzac b84df0a
fix: command composition
romanzac f227425
fix: close rest connection
romanzac 5ad2456
fix: refactor api_clients
romanzac d05a078
fix: refactor docker_manager
romanzac 0ce5280
fix: add log stream parsing
romanzac c84f461
fix: add remove_padding
romanzac ca8eabf
fix: use 4 node instead of 5 node cluster
romanzac 51d108c
fix: add response content check
romanzac 9e85b0a
fix: adjust delays
romanzac 3189548
test: test_data_integrity in workflow
romanzac 1144a7a
fix: move prune-vm into correct dir
romanzac e55e6b6
fix: checkout first
romanzac 4824aff
fix: change to public image
romanzac eb51c6b
fix: rename workflow
romanzac ebd56ce
fix: indexing for ensure_nodes_ready
romanzac d340256
fix: refactor run for NomosCli
romanzac cdc7836
fix: conversion functions for index and app_id
romanzac f74002c
test: with different data
romanzac f7d54c8
fix: change data to assert
romanzac 9c61ae1
fix: move command param to kwargs
romanzac 5a8455c
fix: refactor stop and kill
romanzac 4b0678a
fix: reduce params in start_container
romanzac dd3c820
test: daily workflow
romanzac b8719dd
test: rename daily workflow
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 hidden or 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,27 @@ | ||
# Inspired by https://github.com/AdityaGarg8/remove-unwanted-software | ||
# to free up disk space. Currently removes Dotnet, Android and Haskell. | ||
name: Remove unwanted software | ||
description: Default GitHub runners come with a lot of unnecessary software | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Disk space report before modification | ||
shell: bash | ||
run: | | ||
echo "==> Available space before cleanup" | ||
echo | ||
df -h | ||
- name: Maximize build disk space | ||
shell: bash | ||
run: | | ||
set -euo pipefail | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /usr/local/lib/android | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf /usr/local/.ghcup | ||
- name: Disk space report after modification | ||
shell: bash | ||
run: | | ||
echo "==> Available space after cleanup" | ||
echo | ||
df -h |
This file contains hidden or 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,11 @@ | ||
name: Nomos E2E Tests Daily | ||
|
||
on: | ||
schedule: | ||
- cron: '0 4 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-common: | ||
uses: ./.github/workflows/test_common.yml | ||
|
This file contains hidden or 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,32 @@ | ||
name: E2E Tests Common | ||
|
||
on: | ||
workflow_call: | ||
|
||
env: | ||
FORCE_COLOR: "1" | ||
|
||
jobs: | ||
tests: | ||
name: tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Remove unwanted software | ||
uses: ./.github/actions/prune-vm | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
cache: 'pip' | ||
|
||
- run: | | ||
pip install -r requirements.txt | ||
mkdir -p kzgrs | ||
wget https://raw.githubusercontent.com/logos-co/nomos-node/master/tests/kzgrs/kzgrs_test_params -O kzgrs/kzgrs_test_params | ||
|
||
- name: Run tests | ||
run: | | ||
pytest |
2 changes: 1 addition & 1 deletion
2
cluster_config/cfgsync-5node.yaml → cluster_config/cfgsync-4node.yaml
This file contains hidden or 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: 5 | ||
n_hosts: 4 | ||
timeout: 30 | ||
|
||
# ConsensusConfig related parameters | ||
|
This file contains hidden or 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: 5 | ||
n_hosts: 2 | ||
timeout: 30 | ||
|
||
# ConsensusConfig related parameters | ||
|
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
Empty file.
This file contains hidden or 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,11 @@ | ||
from src.env_vars import NOMOS_IMAGE | ||
|
||
nomos_cli = { | ||
"reconstruct": { | ||
"image": NOMOS_IMAGE, | ||
"flags": [{"--app-blobs": [0]}], # Value [] is a list of indexes into list of values required for the flag | ||
"volumes": [], | ||
"ports": [], | ||
"entrypoint": "", | ||
}, | ||
} |
This file contains hidden or 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,111 @@ | ||
import json | ||
import os | ||
import re | ||
|
||
from src.data_storage import DS | ||
from src.libs.common import generate_log_prefix | ||
from src.libs.custom_logger import get_custom_logger | ||
from tenacity import retry, stop_after_delay, wait_fixed | ||
|
||
from src.cli.cli_vars import nomos_cli | ||
from src.docker_manager import DockerManager, stop, kill | ||
from src.env_vars import DOCKER_LOG_DIR, NOMOS_CLI | ||
from src.steps.da import remove_padding | ||
|
||
logger = get_custom_logger(__name__) | ||
|
||
|
||
class NomosCli: | ||
def __init__(self, **kwargs): | ||
if "command" not in kwargs: | ||
raise ValueError("The command parameter is required") | ||
|
||
command = kwargs["command"] | ||
if command not in nomos_cli: | ||
raise ValueError("Unknown command provided") | ||
|
||
logger.debug(f"Cli is going to be initialized with this config {nomos_cli[command]}") | ||
self._command = command | ||
self._image_name = nomos_cli[command]["image"] | ||
self._internal_ports = nomos_cli[command]["ports"] | ||
self._volumes = nomos_cli[command]["volumes"] | ||
self._entrypoint = nomos_cli[command]["entrypoint"] | ||
|
||
container_name = "nomos-cli-" + generate_log_prefix() | ||
self._log_path = os.path.join(DOCKER_LOG_DIR, f"{container_name}__{self._image_name.replace('/', '_')}.log") | ||
self._docker_manager = DockerManager(self._image_name) | ||
self._container_name = container_name | ||
self._container = None | ||
|
||
cwd = os.getcwd() | ||
self._volumes = [cwd + "/" + volume for volume in self._volumes] | ||
|
||
def run(self, input_values=None, **kwargs): | ||
logger.debug(f"NomosCli starting with log path {self._log_path}") | ||
|
||
self._port_map = {} | ||
|
||
cmd = [NOMOS_CLI, self._command] | ||
for flag in nomos_cli[self._command]["flags"]: | ||
for f, indexes in flag.items(): | ||
cmd.append(f) | ||
for j in indexes: | ||
cmd.append(input_values[j]) | ||
|
||
logger.debug(f"NomosCli command to run {cmd}") | ||
|
||
self._container = self._docker_manager.start_container( | ||
self._docker_manager.image, | ||
port_bindings=self._port_map, | ||
args=None, | ||
log_path=self._log_path, | ||
volumes=self._volumes, | ||
entrypoint=self._entrypoint, | ||
remove_container=True, | ||
name=self._container_name, | ||
command=cmd, | ||
) | ||
|
||
DS.nomos_nodes.append(self) | ||
|
||
match self._command: | ||
case "reconstruct": | ||
decode_only = kwargs.get("decode_only", False) | ||
return self.reconstruct(input_values=input_values, decode_only=decode_only) | ||
case _: | ||
return | ||
|
||
def reconstruct(self, input_values=None, decode_only=False): | ||
keywords = ["Reconstructed data"] | ||
|
||
log_stream = self._container.logs(stream=True) | ||
|
||
matches = self._docker_manager.search_log_for_keywords(self._log_path, keywords, False, log_stream) | ||
assert len(matches) > 0, f"Reconstructed data not found {matches}" | ||
|
||
# Use regular expression that captures the byte list after "Reconstructed data" | ||
result = re.sub(r".*Reconstructed data\s*(\[[^\]]+\]).*", r"\1", matches[keywords[0]][0]) | ||
|
||
result_bytes = [] | ||
try: | ||
result_bytes = json.loads(result) | ||
except Exception as ex: | ||
logger.debug(f"Conversion to bytes failed with exception {ex}") | ||
|
||
if decode_only: | ||
result_bytes = result_bytes[:-31] | ||
|
||
result_bytes = remove_padding(result_bytes) | ||
result = bytes(result_bytes).decode("utf-8") | ||
|
||
DS.nomos_nodes.remove(self) | ||
|
||
return result | ||
|
||
@retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) | ||
def stop(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed at 5a8455c |
||
self._container = stop(self._container) | ||
|
||
@retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) | ||
def kill(self): | ||
self._container = kill(self._container) |
This file contains hidden or 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 hidden or 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
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.
would be good to have some error handling to exit with a meaningfull message if command is not a key of nomos_cli
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.
Fixed at 9c61ae1