fix corrupted nodes

This commit is contained in:
Florin Barbu 2024-07-24 21:28:01 +03:00
parent 9332428129
commit d9ee2ff0d0
No known key found for this signature in database
GPG Key ID: 593D6DBC6D9E5095
4 changed files with 24 additions and 12 deletions

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ log/
.vscode
allure-results/
status-cli
test-*
/test-*
*.log
# Byte-compiled / optimized / DLL files

Binary file not shown.

View File

@ -5,7 +5,10 @@ from src.node.status_node import StatusNode
num_communities = 10
root_folder = "." # Set your root folder path here
archive_path = os.path.join(root_folder, "resources/nodes.tar")
resources_folder = os.path.join(root_folder, "resources")
# Ensure the resources folder exists
os.makedirs(resources_folder, exist_ok=True)
for i in range(num_communities):
port = str(6130 + i)
@ -30,8 +33,9 @@ for i in range(num_communities):
if os.path.exists(old_folder_path):
os.rename(old_folder_path, new_folder_path)
# Archive all folders starting with 'test-0x'
with tarfile.open(archive_path, "w") as tar:
for item in os.listdir(root_folder):
if item.startswith("test-0x") and os.path.isdir(os.path.join(root_folder, item)):
tar.add(os.path.join(root_folder, item), arcname=item)
# Archive the renamed folder
archive_name = f"{new_folder_name}.tar"
archive_path = os.path.join(resources_folder, archive_name)
with tarfile.open(archive_path, "w") as tar:
tar.add(new_folder_path, arcname=new_folder_name)

View File

@ -129,10 +129,18 @@ class StepsCommon:
return self.community_id_list
def setup_community_nodes(self, node_limit=None):
resources_folder = "./resources"
tar_files = [f for f in os.listdir(resources_folder) if f.endswith(".tar")]
# Use node_limit if you just need a limited number of nodes
# Extract the tar file
command = "tar -xvf resources/nodes.tar -C ./"
subprocess.run(command, shell=True, check=True)
if node_limit is not None:
tar_files = tar_files[:node_limit]
# Extract the nodes from the tar file
for tar_file in tar_files:
tar_path = os.path.join(resources_folder, tar_file)
command = f"tar -xvf {tar_path} -C ./"
subprocess.run(command, shell=True, check=True)
self.community_nodes = []
for root, dirs, files in os.walk("."):
@ -148,8 +156,6 @@ class StepsCommon:
port = node_name.split("_")[1]
status_node = StatusNode(name=node_name, port=port)
self.community_nodes.append({"node_uid": node_uid, "community_id": community_id, "status_node": status_node})
if node_limit and len(self.community_nodes) == node_limit:
break
# Start all nodes
for _, community_node in enumerate(self.community_nodes):
@ -157,6 +163,8 @@ class StepsCommon:
status_node = community_node["status_node"]
status_node.serve_account(node_uid)
delay(4)
return self.community_nodes
def join_created_communities(self):