diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..c2a8e8190 --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module github.com/harmony-one/harmony diff --git a/test/cal_tps.sh b/test/cal_tps.sh new file mode 100755 index 000000000..79a6e18e6 --- /dev/null +++ b/test/cal_tps.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +function usage +{ + ME=$(basename $0) + cat< $log_folder/all-leaders.txt + find $log_folder -name validator-*.log > $log_folder/all-validators.txt + + echo ====== RESULTS ====== + results=$($ROOT/test/cal_tps.sh $log_folder/all-leaders.txt $log_folder/all-validators.txt) + echo $results | tee -a $LOG_FILE + echo $results > $log_folder/tps.log +} + function cleanup() { for pid in `/bin/ps -fu $USER| grep "harmony\|txgen\|soldier\|commander\|profiler\|beacon" | grep -v "grep" | grep -v "vi" | awk '{print $2}'`; do echo 'Killed process: '$pid - kill -9 $pid 2> /dev/null + $DRYRUN kill -9 $pid 2> /dev/null done } @@ -18,7 +30,7 @@ function killnode() { if [ -n "port" ]; then pid=$(/bin/ps -fu $USER | grep "harmony" | grep "$port" | awk '{print $2}') echo "killing node with port: $port" - kill -9 $pid 2> /dev/null + $DRYRUN kill -9 $pid 2> /dev/null echo "node with port: $port is killed" fi } @@ -38,6 +50,7 @@ USAGE: $ME [OPTIONS] config_file_name -m min_peers minimal number of peers to start consensus (default: $MIN) -s shards number of shards (default: $SHARDS) -k nodeport kill the node with specified port number (default: $KILLPORT) + -n dryrun mode (default: $DRYRUN) This script will build all the binaries and start harmony and txgen based on the configuration file. @@ -56,8 +69,9 @@ DURATION=90 MIN=5 SHARDS=2 KILLPORT=9004 +DRYRUN= -while getopts "hdtD:m:s:k:" option; do +while getopts "hdtD:m:s:k:n" option; do case $option in h) usage ;; d) DB='-db_supported' ;; @@ -66,6 +80,7 @@ while getopts "hdtD:m:s:k:" option; do m) MIN=$OPTARG ;; s) SHARDS=$OPTARG ;; k) KILLPORT=$OPTARG ;; + n) DRYRUN=echo ;; esac done @@ -97,9 +112,10 @@ t=`date +"%Y%m%d-%H%M%S"` log_folder="tmp_log/log-$t" mkdir -p $log_folder +LOG_FILE=$log_folder/r.log echo "launching beacon chain ..." -$ROOT/bin/beacon -numShards $SHARDS > $log_folder/beacon.log 2>&1 & +$DRYRUN $ROOT/bin/beacon -numShards $SHARDS > $log_folder/beacon.log 2>&1 | tee -a $LOG_FILE & sleep 1 #waiting for beaconchain # Start nodes @@ -107,7 +123,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do IFS=' ' read ip port mode shardID <<< $line #echo $ip $port $mode if [ "$mode" != "client" ]; then - $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN & + $DRYRUN $ROOT/bin/harmony -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN 2>&1 | tee -a $LOG_FILE & sleep 0.5 fi done < $config @@ -115,10 +131,14 @@ done < $config # Emulate node offline (sleep 45; killnode $KILLPORT) & -echo "launching txgen ..." if [ "$TXGEN" == "true" ]; then echo "launching txgen ..." - $ROOT/bin/txgen -log_folder $log_folder -duration $DURATION + line=$(grep client $config) + IFS=' ' read ip port mode shardID <<< $line + if [ "$mode" == "client" ]; then + $DRYRUN $ROOT/bin/txgen -log_folder $log_folder -duration $DURATION -ip $ip -port $port 2>&1 | tee -a $LOG_FILE + fi fi cleanup +check_result