forked from thulab/iot-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-benchmark.sh
executable file
·108 lines (90 loc) · 4.64 KB
/
cli-benchmark.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
if [ -z "${BENCHMARK_HOME}" ]; then
export BENCHMARK_HOME="$(cd "`dirname "$0"`"/.; pwd)"
fi
#IMPORTANT: to use this script, make sure you have password-free ssh access to 127.0.0.1 and the server of database service
# if not you need to use the following command:
# ssh-keygen -t rsa
# ssh-copy-id [hostname]@[IP]
#configure the related path and host name
IOTDB_HOME=/home/liurui/github/iotdb/iotdb/bin
REMOTE_BENCHMARK_HOME=/home/liurui/github/iotdb-benchmark
HOST_NAME=liurui
IS_SSH_CHANGE_PORT=false
SSH_PORT=2222
#extract parameters from config.properties
IP=$(grep "HOST" $BENCHMARK_HOME/conf/config.properties)
FLAG_AND_DATA_PATH=$(grep "DB_DATA_PATH" $BENCHMARK_HOME/conf/config.properties)
SERVER_HOST=$HOST_NAME@${IP#*=}
DB_DATA_PATH=${FLAG_AND_DATA_PATH#*=}
CLIENT_DB_DATA_PATH_LINE=$(grep "DB_DATA_PATH" $BENCHMARK_HOME/conf/clientSystemInfo.properties)
CLIENT_DB_DATA_PATH=${CLIENT_DB_DATA_PATH_LINE#*=}
#get mode parameter
#sed -i 's/SERVER_MODE *= *true/SERVER_MODE=false/g' $BENCHMARK_HOME/conf/config.properties
BENCHMARK_WORK_MODE=$(grep "BENCHMARK_WORK_MODE" $BENCHMARK_HOME/conf/config.properties)
DB=$(grep "DB_SWITCH" $BENCHMARK_HOME/conf/config.properties)
echo Testing ${DB#*=} ...
#prepare for client system info recording benchmark
if [ -d $CLIENT_DB_DATA_PATH ]; then
ssh [email protected] "sh $CLIENT_DB_DATA_PATH/iotdb-benchmark/ser_cli-benchmark.sh > /dev/null 2>&1 &"
else
ssh [email protected] "mkdir $CLIENT_DB_DATA_PATH;cp -r ${BENCHMARK_HOME} $CLIENT_DB_DATA_PATH"
ssh [email protected] "sh $CLIENT_DB_DATA_PATH/iotdb-benchmark/ser_cli-benchmark.sh > /dev/null 2>&1 &"
fi
#synchronize config server benchmark
if [ "${IS_SSH_CHANGE_PORT#*=}" = "true" ]; then
ssh -p $SSH_PORT $SERVER_HOST "rm $REMOTE_BENCHMARK_HOME/conf/config.properties"
scp -P $SSH_PORT $BENCHMARK_HOME/conf/config.properties $SERVER_HOST:$REMOTE_BENCHMARK_HOME/conf
ssh -p $SSH_PORT $SERVER_HOST "sh $REMOTE_BENCHMARK_HOME/ser-benchmark.sh > /dev/null 2>&1 &"
if [ "${DB#*=}" = "IoTDB" -a "${BENCHMARK_WORK_MODE#*=}" = "insertTestWithDefaultPath" ]; then
COMMIT_ID=$(ssh -p $SSH_PORT $SERVER_HOST "cd $DB_DATA_PATH;git rev-parse HEAD")
sed -i "s/^VERSION.*$/VERSION=${COMMIT_ID}/g" $BENCHMARK_HOME/conf/config.properties
echo "initial database in server..."
ssh -p $SSH_PORT $SERVER_HOST "cd $DB_DATA_PATH;rm -rf data;sh $IOTDB_HOME/stop-server.sh;sleep 2"
ssh -p $SSH_PORT $SERVER_HOST "cd $DB_DATA_PATH;sh $IOTDB_HOME/start-server.sh > /dev/null 2>&1 &"
echo 'wait a few seconds for lauching IoTDB...'
sleep 20
fi
echo '------Client Test Begin Time------'
date
cd bin
sh startup.sh -cf ../conf/config.properties
wait
#stop server system information recording
ssh -p $SSH_PORT $SERVER_HOST "touch $DB_DATA_PATH/log_stop_flag"
else
#If IP is localhost not trigger off server mode
if [ "${IP#*=}" != "127.0.0.1" ]; then
ssh $SERVER_HOST "rm $REMOTE_BENCHMARK_HOME/conf/config.properties"
scp $BENCHMARK_HOME/conf/config.properties $SERVER_HOST:$REMOTE_BENCHMARK_HOME/conf
#start server system information recording
ssh $SERVER_HOST "sh $REMOTE_BENCHMARK_HOME/ser-benchmark.sh > /dev/null 2>&1 &"
fi
if [ "${DB#*=}" = "IoTDB" -a "${BENCHMARK_WORK_MODE#*=}" = "insertTestWithDefaultPath" ]; then
COMMIT_ID=$(ssh $SERVER_HOST "cd $DB_DATA_PATH;git rev-parse HEAD")
sed -i "s/^VERSION.*$/VERSION=${COMMIT_ID}/g" $BENCHMARK_HOME/conf/config.properties
echo "initial database in server..."
ssh $SERVER_HOST "cd $DB_DATA_PATH;rm -rf data;sh $IOTDB_HOME/stop-server.sh;sleep 2"
ssh $SERVER_HOST "cd $DB_DATA_PATH;sh $IOTDB_HOME/start-server.sh > /dev/null 2>&1 &"
echo 'wait a few seconds for lauching IoTDB...'
sleep 20
fi
echo '------Client Test Begin Time------'
date
cd bin
sh startup.sh -cf ../conf/config.properties
wait
if [ "${IP#*=}" != "127.0.0.1" ]; then
#stop server system information recording
ssh $SERVER_HOST "touch $DB_DATA_PATH/log_stop_flag"
fi
fi
#ssh $SERVER_HOST "grep Statistic $DB_DATA_PATH/logs/log_info.log | tail -n 1 " >> $BENCHMARK_HOME/logs/MemoryMonitor.log
#if [ "${DB#*=}" = "IoTDB" -a "${BENCHMARK_WORK_MODE#*=}" = "insertTestWithDefaultPath" ]; then
#ssh $SERVER_HOST "tail -n 2 $REMOTE_BENCHMARK_HOME/logs/log_info.log" >> $BENCHMARK_HOME/logs/log_info.log
#ssh $SERVER_HOST "tail -n 1 $REMOTE_BENCHMARK_HOME/logs/log_info.log" >> $BENCHMARK_HOME/logs/log_result_info.txt
#fi
##stop system info recording on client machine
touch $CLIENT_DB_DATA_PATH/log_stop_flag
echo '------Client Test Complete Time------'
date