-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ct to load test framework (#1959)
* add ct to load test framework * comment out receiver account creation for now * - add ct account population script - add ct query client - add 4 types of ct messages for load test * - script updates * - add error handling * script updates * formatting * disable state writing for transfers * add metrics * Revert "add metrics" This reverts commit a7814b1. * self review fixes
- Loading branch information
Showing
7 changed files
with
197 additions
and
34 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
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,51 @@ | ||
import os | ||
import json | ||
import subprocess | ||
import logging | ||
from concurrent.futures import ThreadPoolExecutor, as_completed | ||
|
||
# Configure logging | ||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | ||
|
||
def read_files_and_run_command(directory, max_threads=10): | ||
with ThreadPoolExecutor(max_workers=max_threads) as executor: | ||
futures = [] | ||
for filename in os.listdir(directory): | ||
file_path = os.path.join(directory, filename) | ||
if os.path.isfile(file_path) and filename.endswith('.json'): | ||
with open(file_path, 'r') as file: | ||
data = json.load(file) | ||
mnemonic = data.get('mnemonic') | ||
if mnemonic: | ||
file_prefix = filename.split('.')[0] | ||
logging.info(f"Processing file: {filename}") | ||
futures.append(executor.submit(run_commands, mnemonic, file_prefix)) | ||
|
||
for future in as_completed(futures): | ||
try: | ||
future.result() | ||
except Exception as e: | ||
logging.error(f"Error occurred: {e}") | ||
|
||
def run_commands(mnemonic, file_prefix): | ||
commands = [ | ||
f"printf '{mnemonic}\n12345678\n' | ~/go/bin/seid keys add {file_prefix} --recover", | ||
f"printf '12345678\n' | ~/go/bin/seid tx ct init-account usei --from {file_prefix} --fees 20000usei -y -b block", | ||
f"printf '12345678\n' | ~/go/bin/seid tx ct deposit usei 1000000000 --from {file_prefix} --fees 20000usei -y -b block", | ||
f"printf '12345678\n' | ~/go/bin/seid tx ct apply-pending-balance usei --from {file_prefix} --fees 20000usei -y", | ||
f"printf '12345678\n' | ~/go/bin/seid keys delete {file_prefix} -y" | ||
] | ||
for cmd in commands: | ||
logging.info(f"Running command: {cmd}") | ||
process = subprocess.Popen(cmd, stdin=subprocess.PIPE, text=True, shell=True, start_new_session=True) | ||
stdout, stderr = process.communicate() | ||
if process.returncode == 0: | ||
logging.info(f"Command succeeded: {cmd}") | ||
else: | ||
logging.error(f"Command failed: {cmd}\nError: {stderr}") | ||
|
||
if __name__ == "__main__": | ||
directory = '/root/test_accounts' | ||
logging.info(f"Starting to process directory: {directory}") | ||
read_files_and_run_command(directory, max_threads=50) | ||
logging.info("Finished processing directory") |
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