mirror of
https://github.com/logos-co/nomos-e2e-tests.git
synced 2025-01-20 11:39:06 +00:00
test: node start
This commit is contained in:
parent
5b24271e2d
commit
10dd608cde
@ -15,25 +15,15 @@ def get_env_var(var_name, default=None):
|
||||
|
||||
|
||||
# Configuration constants. Need to be upercase to appear in reports
|
||||
DEFAULT_NOMOS = {
|
||||
"image": "nomos:latest",
|
||||
"volumes": "./testnet:/etc/nomos,./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z",
|
||||
"ports": "3000/udp,18080/tcp",
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_node.sh",
|
||||
}
|
||||
NOMOS_EXECUTOR = {
|
||||
"image": "nomos:latest",
|
||||
"volumes": "./testnet:/etc/nomos,./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z",
|
||||
"ports": "3000/udp,18080/tcp",
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_executor.sh",
|
||||
}
|
||||
NOMOS = "nomos"
|
||||
NOMOS_EXECUTOR = "nomos_executor"
|
||||
CFGSYNC = "cfgsync"
|
||||
|
||||
CFGSYNC = {"image": "nomos:latest", "volumes": "./testnet:/etc/nomos", "ports": "", "entrypoint": "/etc/nomos/scripts/run_cfgsync.sh"}
|
||||
|
||||
CFGSYNC = get_env_var("CFGSYNC", CFGSYNC)
|
||||
NODE_1 = get_env_var("NODE_1", DEFAULT_NOMOS)
|
||||
NODE_1 = get_env_var("NODE_1", NOMOS)
|
||||
NODE_2 = get_env_var("NODE_2", NOMOS_EXECUTOR)
|
||||
ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{DEFAULT_NOMOS},{DEFAULT_NOMOS}")
|
||||
NODE_3 = get_env_var("NODE_3", CFGSYNC)
|
||||
|
||||
ADDITIONAL_NODES = get_env_var("ADDITIONAL_NODES", f"{NOMOS},{NOMOS}")
|
||||
# more nodes need to follow the NODE_X pattern
|
||||
DOCKER_LOG_DIR = get_env_var("DOCKER_LOG_DIR", "./log/docker")
|
||||
NETWORK_NAME = get_env_var("NETWORK_NAME", "nomos")
|
||||
|
15
src/node/node_vars.py
Normal file
15
src/node/node_vars.py
Normal file
@ -0,0 +1,15 @@
|
||||
nomos_nodes = {
|
||||
"nomos": {
|
||||
"image": "nomos:latest",
|
||||
"volumes": ["./testnet:/etc/nomos", "./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_node.sh",
|
||||
},
|
||||
"nomos_executor": {
|
||||
"image": "nomos:latest",
|
||||
"volumes": ["./testnet:/etc/nomos", "./tests/kzgrs/kzgrs_test_params:/kzgrs_test_params:z"],
|
||||
"ports": ["3000/udp", "18080/tcp"],
|
||||
"entrypoint": "/etc/nomos/scripts/run_nomos_executor.sh",
|
||||
},
|
||||
"cfgsync": {"image": "nomos:latest", "volumes": ["./testnet:/etc/nomos"], "ports": "", "entrypoint": "/etc/nomos/scripts/run_cfgsync.sh"},
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from tenacity import retry, stop_after_delay, wait_fixed
|
||||
|
||||
from src.node.api_clients.rest import REST
|
||||
from src.node.docker_mananger import DockerManager
|
||||
from src.env_vars import DOCKER_LOG_DIR
|
||||
from src.node.node_vars import nomos_nodes
|
||||
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
@ -19,8 +22,13 @@ def sanitize_docker_flags(input_flags):
|
||||
|
||||
|
||||
class NomosNode:
|
||||
def __init__(self, docker_image, docker_log_prefix=""):
|
||||
self._image_name = docker_image
|
||||
def __init__(self, node_type, docker_log_prefix=""):
|
||||
print(nomos_nodes)
|
||||
self._image_name = nomos_nodes[node_type]["image"]
|
||||
self._internal_ports = nomos_nodes[node_type]["ports"]
|
||||
self._volumes = nomos_nodes[node_type]["volumes"]
|
||||
self._entrypoint = nomos_nodes[node_type]["entrypoint"]
|
||||
|
||||
self._log_path = os.path.join(DOCKER_LOG_DIR, f"{docker_log_prefix}__{self._image_name.replace('/', '_')}.log")
|
||||
self._docker_manager = DockerManager(self._image_name)
|
||||
self._container = None
|
||||
@ -29,3 +37,29 @@ class NomosNode:
|
||||
@retry(stop=stop_after_delay(60), wait=wait_fixed(0.1), reraise=True)
|
||||
def start(self, wait_for_node_sec=20, **kwargs):
|
||||
logger.debug("Starting Node...")
|
||||
self._docker_manager.create_network()
|
||||
self._ext_ip = self._docker_manager.generate_random_ext_ip()
|
||||
self._ports = self._docker_manager.generate_ports(count=len(self._internal_ports))
|
||||
self._udp_port = self._ports[0]
|
||||
self._tcp_port = self._ports[1]
|
||||
self._api = REST(self._tcp_port)
|
||||
|
||||
default_args = {
|
||||
"listen-address": "0.0.0.0",
|
||||
"log-level": "info",
|
||||
"nat": f"extip:{self._ext_ip}",
|
||||
}
|
||||
|
||||
logger.debug(f"Using volumes {self._volumes}")
|
||||
|
||||
self._container = self._docker_manager.start_container(
|
||||
self._docker_manager.image,
|
||||
ports=self._ports,
|
||||
args=default_args,
|
||||
log_path=self._log_path,
|
||||
container_ip=self._ext_ip,
|
||||
volumes=self._volumes,
|
||||
remove_container=True,
|
||||
)
|
||||
|
||||
logger.debug(f"Started container from image {self._image_name}")
|
||||
|
0
tests/data_integrity/__init__.py
Normal file
0
tests/data_integrity/__init__.py
Normal file
0
tests/e2e/__init__.py
Normal file
0
tests/e2e/__init__.py
Normal file
14
tests/e2e/test_2node_alive.py
Normal file
14
tests/e2e/test_2node_alive.py
Normal file
@ -0,0 +1,14 @@
|
||||
from src.env_vars import CFGSYNC, NODE_1, NODE_2
|
||||
from src.node.nomos_node import NomosNode
|
||||
|
||||
|
||||
class Test2NodeClAlive:
|
||||
def test_cluster_start(self):
|
||||
|
||||
self.node1 = NomosNode(CFGSYNC, f"node1_{1}")
|
||||
self.node2 = NomosNode(NODE_1, f"node2_{2}")
|
||||
self.node3 = NomosNode(NODE_2, f"node3_{3}")
|
||||
|
||||
self.node1.start()
|
||||
self.node2.start()
|
||||
self.node3.start()
|
Loading…
x
Reference in New Issue
Block a user