-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(network): create readme and run scripts for stress test
- Loading branch information
1 parent
acf13b2
commit a45386c
Showing
3 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
crates/papyrus_network/src/bin/network_stress_test/README.md
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,36 @@ | ||
## Network Stress Test | ||
|
||
# Setup and Run Stress Test | ||
|
||
1. **Create Remote Engines** | ||
|
||
Create 5 gcloud VM instances. Make sure to have the necessary RAM and disk space. Each instance should be named in the following pattern: | ||
|
||
``` | ||
<instance-name>-0, ... ,<instance-name>-4 | ||
``` | ||
|
||
2. **Set Bootstrap Node** | ||
|
||
Find the internal IP of your bootstrap node in the VM instances chart on google cloud console. Paste it into the test_config.json file into the bootstrap_peer_multaddr value instead of it's placeholder. | ||
|
||
3. **Install Rust and clone repository** | ||
|
||
For all 5 instances run: | ||
|
||
``` | ||
gcloud compute ssh <instance-name>-0 --project <project-name> -- 'cd <path-to-repo> && sudo apt install -y git unzip clang && curl https://sh.rustup.rs -sSf | sh -s -- -y && source "$HOME/.cargo/env" && git clone https://github.com/starkware-libs/sequencer.git; cd sequencer && sudo scripts/dependencies.sh cargo build --release -p papyrus_network --bin network_stress_test' | ||
``` | ||
4. **Run test** | ||
|
||
``` | ||
PROJECT_ID=<project-name> BASE_INSTANCE_NAME=<instance-name> BASE_PATH=<base-path-to-sequencer> ZONE=<zone> ./run_nw_stress_test.sh | ||
``` | ||
|
||
# Pull repo updates to virtual machines | ||
|
||
Run: | ||
|
||
``` | ||
PROJECT_ID=<project-name> BASE_INSTANCE_NAME=<instance-name> BASE_PATH=<base-path-to-sequencer> ZONE=<zone> ./pull_stress_test.sh | ||
``` |
21 changes: 21 additions & 0 deletions
21
crates/papyrus_network/src/bin/network_stress_test/pull_stress_test.sh
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,21 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z "$BASE_INSTANCE_NAME" || -z "$PROJECT_ID" || -z "$BASE_PATH" || -z "$ZONE" ]]; then | ||
echo "Error: BASE_INSTANCE_NAME, PROJECT_ID, and PATH must be set." | ||
echo "Instance name must be set in the format 'base-instance-name-0'... 'base-instance-name-4'." | ||
exit 1 | ||
fi | ||
|
||
PATH_TO_REPO="$BASE_PATH/sequencer" | ||
|
||
# Loop over instances from 0 to 4 | ||
for i in {0..4}; do | ||
( | ||
INSTANCE_NAME="${BASE_INSTANCE_NAME}-${i}" | ||
echo "Connecting to $INSTANCE_NAME..." | ||
|
||
gcloud compute ssh "$INSTANCE_NAME" --project "$PROJECT_ID" --zone "$ZONE" -- "cd $PATH_TO_REPO && git pull" | ||
|
||
echo "Finished with $INSTANCE_NAME." | ||
) & | ||
done |
118 changes: 118 additions & 0 deletions
118
crates/papyrus_network/src/bin/network_stress_test/run_nw_stress_test.sh
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,118 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z "$BASE_INSTANCE_NAME" || -z "$PROJECT_ID" || -z "$BASE_PATH" || -z "$ZONE" ]]; then | ||
echo "Error: BASE_INSTANCE_NAME, PROJECT_ID, ZONE, and PATH must be set." | ||
echo "Instance name must be set in the format 'base-instance-name-0'... 'base-instance-name-4'." | ||
exit 1 | ||
fi | ||
|
||
# Project ID and base instance name | ||
PATH_TO_REPO="$BASE_PATH/sequencer" | ||
PATH_TO_ENV="$BASE_PATH/.cargo/env" | ||
|
||
# Commands to execute on each instance | ||
COMMAND_PATH_BOOT="cd ${PATH_TO_REPO} && source ${PATH_TO_ENV} && cargo run --release -p papyrus_network --bin network_stress_test" | ||
COMMAND_PATH="cd ${PATH_TO_REPO} && source ${PATH_TO_ENV} && cargo run --release -p papyrus_network --bin network_stress_test -- crates/papyrus_network/src/bin/network_stress_test/test_config.json" | ||
|
||
|
||
# Store the process IDs of all opened processes | ||
declare -a process_pids | ||
|
||
# Start the boot command on the first instance (instance 0) | ||
( | ||
echo "Starting boot command on ${BASE_INSTANCE_NAME}-0..." | ||
gcloud compute ssh "${BASE_INSTANCE_NAME}-0" --project "${PROJECT_ID}" --zone "${ZONE}" -- "${COMMAND_PATH_BOOT}" | ||
echo "Boot command finished on ${BASE_INSTANCE_NAME}-0." | ||
) & | ||
process_pids+=($!) # Store the PID of the background process | ||
|
||
# Run the command on instances 1 to 4 | ||
for i in {1..4}; do | ||
( | ||
echo "Starting command on ${BASE_INSTANCE_NAME}-${i}..." | ||
gcloud compute ssh "${BASE_INSTANCE_NAME}-${i}" --project "${PROJECT_ID}" --zone "${ZONE}" -- "${COMMAND_PATH}" | ||
echo "Command finished on ${BASE_INSTANCE_NAME}-${i}." | ||
) & | ||
process_pids+=($!) # Store the PID of the background process | ||
done | ||
|
||
# Wait for all commands to complete | ||
for pid in "${process_pids[@]}"; do | ||
wait "$pid" | ||
done | ||
echo "All commands completed." | ||
|
||
# Retrieve the bootstrap output from instance 0 | ||
echo "Retrieving bootstrap output from ${BASE_INSTANCE_NAME}-0..." | ||
gcloud compute ssh "${BASE_INSTANCE_NAME}-0" --project "${PROJECT_ID}" --zone "${ZONE}" -- "cat ${PATH_TO_REPO}/crates/papyrus_network/src/bin/network_stress_test/bootstrap_output.csv" > output.csv | ||
echo "Bootstrap output saved as bootstrap_output.csv." | ||
|
||
# Retrieve output.csv files from each instance with an incremented filename | ||
for i in {1..4}; do | ||
( | ||
echo "Retrieving output.csv from ${BASE_INSTANCE_NAME}-${i}..." | ||
gcloud compute ssh "${BASE_INSTANCE_NAME}-${i}" --project "${PROJECT_ID}" --zone "${ZONE}" -- "cat ${PATH_TO_REPO}/crates/papyrus_network/src/bin/network_stress_test/output.csv" > output${i}.csv | ||
echo "Retrieved output.csv from ${BASE_INSTANCE_NAME}-${i} and saved as output${i}.csv." | ||
) & | ||
done | ||
|
||
# Wait for file retrieval processes to complete | ||
wait | ||
echo "All output files retrieved." | ||
# #!/bin/bash | ||
|
||
# # Project ID and base instance name | ||
# PROJECT_ID="starkware-dev" | ||
# BASE_INSTANCE_NAME="eitan-m-broadcast-stress-test" | ||
|
||
# # Commands to execute on each instance | ||
# COMMAND_PATH_BOOT="cd /home/eitan_m_starkware_co/sequencer && source /home/eitan_m_starkware_co/.cargo/env && cargo run --release -p papyrus_network --bin network_stress_test" | ||
# COMMAND_PATH="cd /home/eitan_m_starkware_co/sequencer && source /home/eitan_m_starkware_co/.cargo/env && cargo run --release -p papyrus_network --bin network_stress_test -- crates/papyrus_network/src/bin/network_stress_test/test_config.json" | ||
|
||
# # Zone for the instances | ||
# ZONE="us-central1-c" | ||
|
||
# # Store the process IDs of all opened processes | ||
# declare -a process_pids | ||
|
||
# # Start the boot command on the first instance (instance 0) | ||
# ( | ||
# echo "Starting boot command on ${BASE_INSTANCE_NAME}-0..." | ||
# gcloud compute ssh "${BASE_INSTANCE_NAME}-0" --project "${PROJECT_ID}" --zone "${ZONE}" -- "${COMMAND_PATH_BOOT}" | ||
# echo "Boot command finished on ${BASE_INSTANCE_NAME}-0." | ||
# ) & | ||
# process_pids+=($!) # Store the PID of the background process | ||
|
||
# # Run the command on instances 1 to 4 | ||
# for i in {1..4}; do | ||
# ( | ||
# echo "Starting command on ${BASE_INSTANCE_NAME}-${i}..." | ||
# gcloud compute ssh "${BASE_INSTANCE_NAME}-${i}" --project "${PROJECT_ID}" --zone "${ZONE}" -- "${COMMAND_PATH}" | ||
# echo "Command finished on ${BASE_INSTANCE_NAME}-${i}." | ||
# ) & | ||
# process_pids+=($!) # Store the PID of the background process | ||
# done | ||
|
||
# # Wait for all commands to complete | ||
# for pid in "${process_pids[@]}"; do | ||
# wait "$pid" | ||
# done | ||
# echo "All commands completed." | ||
|
||
# # Retrieve the bootstrap output from instance 0 | ||
# echo "Retrieving bootstrap output from ${BASE_INSTANCE_NAME}-0..." | ||
# gcloud compute ssh "${BASE_INSTANCE_NAME}-0" --project "${PROJECT_ID}" --zone "${ZONE}" -- 'cat /home/eitan_m_starkware_co/sequencer/crates/papyrus_network/src/bin/network_stress_test/bootstrap_output.csv' > bootstrap_output.csv | ||
# echo "Bootstrap output saved as bootstrap_output.csv." | ||
|
||
# # Retrieve output.csv files from each instance with an incremented filename | ||
# for i in {1..4}; do | ||
# ( | ||
# echo "Retrieving output.csv from ${BASE_INSTANCE_NAME}-${i}..." | ||
# gcloud compute ssh "${BASE_INSTANCE_NAME}-${i}" --project "${PROJECT_ID}" --zone "${ZONE}" -- 'cat /home/eitan_m_starkware_co/sequencer/crates/papyrus_network/src/bin/network_stress_test/output.csv' > output${i}.csv | ||
# echo "Retrieved output.csv from ${BASE_INSTANCE_NAME}-${i} and saved as output${i}.csv." | ||
# ) & | ||
# done | ||
|
||
# # Wait for file retrieval processes to complete | ||
# wait | ||
# echo "All output files retrieved." |