-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract sync test utils into dedicated module
- Loading branch information
1 parent
87da2e6
commit 1474279
Showing
3 changed files
with
52 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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,43 @@ | ||
def execute_sync_test(plan, peer_node, sync_timeout_seconds, target_block_number): | ||
""" | ||
Executes the sync test against a peer node: | ||
1. Creates a tester service | ||
2. Runs the sync test | ||
3. Returns the test results | ||
""" | ||
# Create and run tester service | ||
tester_service = plan.add_service( | ||
"sync-tester", | ||
config=ServiceConfig( | ||
image=ImageBuildSpec( | ||
image_name="sync-test", | ||
build_context_dir="./../../tester", | ||
), | ||
) | ||
) | ||
|
||
plan.print("Starting the sync tester...") | ||
plan.exec(tester_service.name, ExecRecipe( | ||
["node", "index.mjs", "http://" + peer_node.ip_address + ":6061", str(sync_timeout_seconds), str(target_block_number)] | ||
)) | ||
|
||
def cleanup_services(plan): | ||
""" | ||
Cleans up all services after the test is complete | ||
""" | ||
services = plan.get_services(description="Fetching running services") | ||
for service in services: | ||
plan.print("Found service: " + service.name + " at " + service.ip_address) | ||
plan.remove_service( | ||
name=service.name, | ||
description="Removing service " + service.name | ||
) | ||
|
||
def run_sync_test(plan, feeder_node, peer_node, sync_timeout_seconds, target_block_number): | ||
""" | ||
Orchestrates the complete sync test process: | ||
1. Executes the sync test | ||
2. Cleans up all services | ||
""" | ||
execute_sync_test(plan, peer_node, sync_timeout_seconds, target_block_number) | ||
cleanup_services(plan) |