forked from solana-labs/bench-tps-dos-test
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.sh
executable file
·96 lines (86 loc) · 3.53 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -ex
## Directory settings
dos_program_dir=$(pwd)
source utils.sh
# shellcheck source=/dev/null
source "env-artifact.sh"
echo ----- stage: machines and build and upload mango-simulation ---
cd "$dos_program_dir"
# shellcheck source=/dev/null
source create-instance.sh
create_machines "$NUM_CLIENT"
echo ----- stage: build dependency mango_bencher configure_mango for machine------
client_num=1
# ARTIFACT_BUCKET must in the step
artifact_bucket="$ARTIFACT_BUCKET/$BUILDKITE_PIPELINE_ID/$BUILDKITE_BUILD_ID/$BUILDKITE_JOB_ID"
artifact_file="$ENV_ARTIFACT_FILE"
for sship in "${instance_ip[@]}"
do
[[ $client_num -eq 1 ]] && arg1="true" || arg1="false"
# run start-build-dependency.sh which in agent machine
ret_build_dependency=$(ssh -i id_ed25519_dos_test -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" sol@"$sship" 'bash -s' < start-build-dependency.sh "$arg1" "$artifact_bucket" "$artifact_file")
(( client_num++ )) || true
done
echo ----- stage: run bench-tps test ---
client_num=1
for sship in "${instance_ip[@]}"
do
# run start-dos-test.sh which in client machine
ret_run_dos=$(ssh -i id_ed25519_dos_test -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" sol@$sship "nohup /home/sol/start-dos-test.sh 1> start-dos-test.nohup 2> start-dos-test.nohup &")
(( client_num++ )) || true
done
# # Get Time Start
start_time=$(date -u +%s)
start_time_adjust=$(get_time_after $start_time 5)
echo ----- stage: wait for bencher concurrently ------
sleep $DURATION
echo ----- stage: check finish of process ---
sleep 5
for sship in "${instance_ip[@]}"
do
ret_pid=$(ssh -i id_ed25519_dos_test -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" sol@$sship 'pgrep --full "bash /home/sol/start-dos-test.sh*"' > pid.txt) || true
pid=$(cat pid.txt)
[[ $pid == "" ]] && echo "$sship has finished run bench-tps" || echo "pid=$pid"
while [ "$pid" != "" ]
do
sleep $TERMINATION_CHECK_INTERVAL
ret_pid=$(ssh -i id_ed25519_dos_test -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" sol@$sship 'pgrep --full "bash /home/sol/start-dos-test.sh*"' > pid.txt) || true
pid=$(cat pid.txt)
[[ $pid == "" ]] && echo "$sship has finished run bench-tps" || echo "pid=$pid"
done
done
estimate_stop_time=$(get_time_after $start_time $DURATION)
### Get Time Stop
stop_time=$(date -u +%s)
stop_time_adjust=$(get_time_before $stop_time 5)
echo ----- stage: DOS report ------
testnet_version=$(get_testnet_ver $ENDPOINT)
echo "START_TIME=${start_time}" >> env-artifact.sh
echo "START_TIME2=${start_time_adjust}" >> env-artifact.sh
echo "STOP_TIME=${stop_time}" >> env-artifact.sh
echo "STOP_TIME2=${stop_time_adjust}" >> env-artifact.sh
echo "CLUSTER_VERSION=$testnet_version" >> env-artifact.sh
echo "BUILDKITE_BUILD_URL=$BUILDKITE_BUILD_URL" >> env-artifact.sh
for n in "${instance_name[@]}"
do
printf -v instances "%s %s " $instances $n
done
echo "INSTANCES=\"$instances\"" >>env-artifact.sh
CLUSTER_VERSION=$(get_testnet_ver $ENDPOINT)
echo "CLUSTER_VERSION=$CLUSTER_VERSION" >> env-artifact.sh
ret_dos_report=$(exec ./dos-report.sh)
echo ----- stage: upload logs ------
cnt=1
for sship in "${instance_ip[@]}"
do
ret_pre_build=$(ssh -i id_ed25519_dos_test -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" sol@$sship /home/sol/start-upload-logs.sh $cnt)
(( cnt++ )) || true
done
sleep 5
echo ----- stage: delete instances ------
if [[ "$KEEP_INSTANCES" != "true" ]];then
echo ----- stage: delete instances ------
delete_machines
fi
exit 0