diff --git a/tests/perftest-scripts/perftest-query.sh b/tests/perftest-scripts/perftest-query.sh index bcc944dadb4f8cce0e4c5ccc9aaab1dcd6a4f858..5b2c860122c1719d9cb3d1555580a786e0481da3 100755 --- a/tests/perftest-scripts/perftest-query.sh +++ b/tests/perftest-scripts/perftest-query.sh @@ -1,5 +1,6 @@ #!/bin/bash + branch= if [ x$1 != x ];then branch=$1 @@ -8,17 +9,19 @@ else echo "Please enter branch name as a parameter" exit 1 fi -jemalloc= + +type= if [ x$2 != x ];then - jemalloc=jemalloc + type=jemalloc echo "Building TDengine using jemalloc" else + type=glibc echo "Building TDengine using glibc" fi today=`date +"%Y%m%d"` -WORK_DIR=/home/ubuntu/pxiao -PERFORMANCE_TEST_REPORT=$WORK_DIR/TDengine/tests/performance-test-report-$today.log +WORK_DIR=/root/pxiao +PERFORMANCE_TEST_REPORT=$WORK_DIR/TDengine/tests/performance-report-$branch-$type-$today.log # Coloured Echoes # function red_echo { echo -e "\033[31m$@\033[0m"; } # @@ -64,52 +67,41 @@ function buildTDengine { echo "REMOTE: $REMOTE_COMMIT" if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then echo "repo up-to-date" + fi + + git pull > /dev/null 2>&1 + if [ $type = "jemalloc" ];then + echo "git submodule update --init --recursive" + git submodule update --init --recursive + fi + LOCAL_COMMIT=`git rev-parse --short @` + cd debug + rm -rf * + if [ $type = "jemalloc" ];then + echo "cmake .. -DJEMALLOC_ENABLED=true > /dev/null" + cmake .. -DJEMALLOC_ENABLED=true > /dev/null else - echo "repo need to pull" - git pull > /dev/null 2>&1 - - LOCAL_COMMIT=`git rev-parse --short @` - if [ $jemalloc = "jemalloc" ];then - echo "git submodule update --init --recursive" - git submodule update --init --recursive - fi - - cd debug - rm -rf * - - if [ $jemalloc = "jemalloc" ];then - echo "cmake .. -DJEMALLOC_ENABLED=true > /dev/null" - cmake .. -DJEMALLOC_ENABLED=true > /dev/null - else - cmake .. > /dev/null - fi - make && make install > /dev/null + cmake .. > /dev/null fi + make > /dev/null 2>&1 + make install > /dev/null 2>&1 + echo "Build TDengine on remote server" + ssh perftest "./buildTDengine.sh $branch > /dev/null" } function runQueryPerfTest { [ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT - nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 & + nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 & echoInfo "Wait TDengine to start" sleep 60 echoInfo "Run Performance Test" - cd $WORK_DIR/TDengine/tests/pytest - - python3 query/queryPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT + cd $WORK_DIR/TDengine/tests/pytest - mkdir -p /var/lib/perf/ - mkdir -p /var/log/perf/ - rm -rf /var/lib/perf/* - rm -rf /var/log/perf/* - nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 & - echoInfo "Wait TDengine to start" - sleep 10 - echoInfo "Run Performance Test" - cd $WORK_DIR/TDengine/tests/pytest + python3 query/queryPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT - python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT + python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT - python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT + python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT } @@ -122,8 +114,7 @@ function sendReport { sed -i 's/\x1b\[[0-9;]*m//g' $PERFORMANCE_TEST_REPORT BODY_CONTENT=`cat $PERFORMANCE_TEST_REPORT` - - echo -e "From: \nto: ${receiver}\nsubject: Query Performace Report ${branch} ${jemalloc} ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ + echo -e "From: \nto: ${receiver}\nsubject: Query Performace Report ${branch} ${jemalloc} commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \ (cat - && uuencode $PERFORMANCE_TEST_REPORT performance-test-report-$today.log) | \ /usr/sbin/ssmtp "${receiver}" && echo "Report Sent!" } @@ -136,4 +127,4 @@ stopTaosd echoInfo "Send Report" sendReport -echoInfo "End of Test" +echoInfo "End of Test" \ No newline at end of file diff --git a/tests/pytest/insert/insertFromCSVPerformance.py b/tests/pytest/insert/insertFromCSVPerformance.py index e1f741bd1203e93cd25832866f97be2e87d2b37d..f3b9c2734d321fb8c9d374ee16fd7ee99388bc36 100644 --- a/tests/pytest/insert/insertFromCSVPerformance.py +++ b/tests/pytest/insert/insertFromCSVPerformance.py @@ -22,11 +22,12 @@ import argparse import os.path class insertFromCSVPerformace: - def __init__(self, commitID, dbName, stbName, branchName): + def __init__(self, commitID, dbName, tbName, branchName, buildType): self.commitID = commitID self.dbName = dbName - self.stbName = stbName + self.tbName = tbName self.branchName = branchName + self.type = buildType self.ts = 1500074556514 self.host = "127.0.0.1" self.user = "root" @@ -35,9 +36,15 @@ class insertFromCSVPerformace: self.conn = taos.connect( self.host, self.user, - self.password, + self.password, self.config) - + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) + def writeCSV(self): with open('test3.csv','w', encoding='utf-8', newline='') as csvFile: writer = csv.writer(csvFile, dialect='excel') @@ -52,47 +59,43 @@ class insertFromCSVPerformace: data = data.drop([0]) data.to_csv("ordered.csv", header = False, index = False) - def createTables(self): - cursor = self.conn.cursor() - - cursor.execute("create database if not exists %s" % self.dbName) - cursor.execute("use %s" % self.dbName) - cursor.execute("create table if not exists %s(ts timestamp, in_order_time float, out_of_order_time float, commit_id binary(50)) tags(branch binary(50))" % self.stbName) - cursor.execute("create table if not exists %s using %s tags('%s')" % (self.branchName, self.stbName, self.branchName)) - - cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)") - cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)") - - cursor.close() - def run(self): cursor = self.conn.cursor() + cursor.execute("create database if not exists %s" % self.dbName) cursor.execute("use %s" % self.dbName) print("==================== CSV insert performance ====================") totalTime = 0 for i in range(10): + cursor.execute("drop table if exists t1") cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)") startTime = time.time() cursor.execute("insert into t1 file 'outoforder.csv'") - totalTime += time.time() - startTime - cursor.execute("drop table if exists t1") + totalTime += time.time() - startTime out_of_order_time = (float) (totalTime / 10) print("Out of Order - Insert time: %f" % out_of_order_time) totalTime = 0 for i in range(10): + cursor.execute("drop table if exists t2") cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)") startTime = time.time() cursor.execute("insert into t2 file 'ordered.csv'") - totalTime += time.time() - startTime - cursor.execute("drop table if exists t2") + totalTime += time.time() - startTime in_order_time = (float) (totalTime / 10) print("In order - Insert time: %f" % in_order_time) - cursor.execute("insert into %s values(now, %f, %f, '%s')" % (self.branchName, in_order_time, out_of_order_time, self.commitID)) - + cursor.close() + + + cursor2 = self.conn2.cursor() + cursor2.execute("create database if not exists %s" % self.dbName) + cursor2.execute("use %s" % self.dbName) + cursor2.execute("create table if not exists %s(ts timestamp, in_order_time float, out_of_order_time float, commit_id binary(50), branch binary(50), type binary(20))" % self.tbName) + cursor2.execute("insert into %s values(now, %f, %f, '%s', '%s', '%s')" % (self.tbName, in_order_time, out_of_order_time, self.commitID, self.branchName, self.type)) + cursor2.close() + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( @@ -111,7 +114,7 @@ if __name__ == '__main__': help='Database name to be created (default: perf)') parser.add_argument( '-t', - '--stable-name', + '--table-name', action='store', default='csv_insert', type=str, @@ -123,9 +126,14 @@ if __name__ == '__main__': default='develop', type=str, help='branch name (default: develop)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') args = parser.parse_args() - perftest = insertFromCSVPerformace(args.commit_id, args.database_name, args.stable_name, args.branch_name) - - perftest.createTables() + perftest = insertFromCSVPerformace(args.commit_id, args.database_name, args.table_name, args.branch_name, args.build_type) perftest.run() \ No newline at end of file diff --git a/tests/pytest/query/queryPerformance.py b/tests/pytest/query/queryPerformance.py index 2aa760624fcfdb511b92d511326df8938dc45c2d..1d4e6a2f0f4bd8a107ab49f88ee7ce6a80259b8a 100644 --- a/tests/pytest/query/queryPerformance.py +++ b/tests/pytest/query/queryPerformance.py @@ -20,12 +20,14 @@ import argparse class taosdemoQueryPerformace: - def __init__(self, clearCache, commitID, dbName, stbName, tbPerfix): + def __init__(self, clearCache, commitID, dbName, stbName, tbPerfix, branch, type): self.clearCache = clearCache self.commitID = commitID self.dbName = dbName self.stbName = stbName self.tbPerfix = tbPerfix + self.branch = branch + self.type = type self.host = "127.0.0.1" self.user = "root" self.password = "taosdata" @@ -35,50 +37,56 @@ class taosdemoQueryPerformace: self.user, self.password, self.config) + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) def createPerfTables(self): - cursor = self.conn.cursor() - cursor.execute("create database if not exists %s" % self.dbName) - cursor.execute("use %s" % self.dbName) - cursor.execute("create table if not exists %s(ts timestamp, query_time float, commit_id binary(50)) tags(query_id int, query_sql binary(300))" % self.stbName) + cursor2 = self.conn2.cursor() + cursor2.execute("create database if not exists %s" % self.dbName) + cursor2.execute("use %s" % self.dbName) + cursor2.execute("create table if not exists %s(ts timestamp, query_time float, commit_id binary(50), branch binary(50), type binary(20)) tags(query_id int, query_sql binary(300))" % self.stbName) sql = "select count(*) from test.meters" tableid = 1 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select avg(f1), max(f2), min(f3) from test.meters" tableid = 2 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select count(*) from test.meters where loc='beijing'" tableid = 3 - cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10" tableid = 4 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)" tableid = 5 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select last_row(*) from meters" tableid = 6 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select * from meters" tableid = 7 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'" tableid = 8 - cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - + cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + sql = "select last(*) from meters" tableid = 9 - cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) + cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - cursor.close() + cursor2.close() def query(self): cursor = self.conn.cursor() @@ -100,20 +108,20 @@ class taosdemoQueryPerformace: # root permission is required os.system("echo 3 > /proc/sys/vm/drop_caches") - startTime = time.time() + startTime = time.time() cursor2.execute(sql) totalTime += time.time() - startTime - cursor2.close() + cursor2.close() print("query time for: %s %f seconds" % (sql, totalTime / 100)) - cursor3 = self.conn.cursor() - cursor3.execute("insert into %s.%s values(now, %f, '%s')" % (self.dbName, table_name, totalTime / 100, self.commitID)) + cursor3 = self.conn2.cursor() + cursor3.execute("insert into %s.%s values(now, %f, '%s', '%s', '%s')" % (self.dbName, table_name, totalTime / 100, self.commitID, self.branch, self.type)) cursor3.close() cursor.close() if __name__ == '__main__': - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser() parser.add_argument( '-r', '--remove-cache', @@ -148,8 +156,22 @@ if __name__ == '__main__': default='q', type=str, help='table name perfix (default: q)') + parser.add_argument( + '-b', + '--git-branch', + action='store', + default='master', + type=str, + help='git branch (default: master)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') args = parser.parse_args() - perftest = taosdemoQueryPerformace(args.remove_cache, args.commit_id, args.database_name, args.stable_name, args.table_perfix) + perftest = taosdemoQueryPerformace(args.remove_cache, args.commit_id, args.database_name, args.stable_name, args.table_perfix, args.git_branch, args.build_type) perftest.createPerfTables() perftest.query() diff --git a/tests/pytest/tools/taosdemoPerformance.py b/tests/pytest/tools/taosdemoPerformance.py index c8293ee31f713e34a7d974c23f8bec0b375847f1..9d9b29c0175d81e7b06e0bb676a85f16ffda12df 100644 --- a/tests/pytest/tools/taosdemoPerformance.py +++ b/tests/pytest/tools/taosdemoPerformance.py @@ -20,9 +20,11 @@ from util.log import tdLog from util.sql import tdSql class taosdemoPerformace: - def __init__(self, commitID, dbName): + def __init__(self, commitID, dbName, branch, type): self.commitID = commitID self.dbName = dbName + self.branch = branch + self.type = type self.host = "127.0.0.1" self.user = "root" self.password = "taosdata" @@ -33,6 +35,12 @@ class taosdemoPerformace: self.password, self.config) self.insertDB = "insertDB" + self.host2 = "192.168.1.179" + self.conn2 = taos.connect( + host = self.host2, + user = self.user, + password = self.password, + config = self.config) def generateJson(self): db = { @@ -122,12 +130,9 @@ class taosdemoPerformace: return buildPath def insertData(self): - buildPath = self.getBuildPath() if (buildPath == ""): tdLog.exit("taosdemo not found!") - else: - tdLog.info("taosdemo found in %s" % buildPath) binPath = buildPath + "/build/bin/" os.system( @@ -153,11 +158,11 @@ class taosdemoPerformace: os.system("[ -f taosdemoperf.txt ] && rm taosdemoperf.txt") def createTablesAndStoreData(self): - cursor = self.conn.cursor() + cursor = self.conn2.cursor() cursor.execute("create database if not exists %s" % self.dbName) cursor.execute("use %s" % self.dbName) - cursor.execute("create table if not exists taosdemo_perf (ts timestamp, create_table_time float, insert_records_time float, records_per_second float, commit_id binary(50), avg_delay float, max_delay float, min_delay float)") + cursor.execute("create table if not exists taosdemo_perf (ts timestamp, create_table_time float, insert_records_time float, records_per_second float, commit_id binary(50), avg_delay float, max_delay float, min_delay float, branch binary(50), type binary(20))") print("==================== taosdemo performance ====================") print("create tables time: %f" % float(self.createTableTime)) print("insert records time: %f" % float(self.insertRecordsTime)) @@ -165,19 +170,14 @@ class taosdemoPerformace: print("avg delay: %f" % float(self.avgDelay)) print("max delay: %f" % float(self.maxDelay)) print("min delay: %f" % float(self.minDelay)) - cursor.execute( - "insert into taosdemo_perf values(now, %f, %f, %f, '%s', %f, %f, %f)" % - (float( - self.createTableTime), float( - self.insertRecordsTime), float( - self.recordsPerSecond), self.commitID, float( - self.avgDelay), float( - self.maxDelay), float( - self.minDelay))) - cursor.execute("drop database if exists %s" % self.insertDB) - + cursor.execute("insert into taosdemo_perf values(now, %f, %f, %f, '%s', %f, %f, %f, '%s', '%s')" % + (float(self.createTableTime), float(self.insertRecordsTime), float(self.recordsPerSecond), + self.commitID, float(self.avgDelay), float(self.maxDelay), float(self.minDelay), self.branch, self.type)) cursor.close() + cursor1 = self.conn.cursor() + cursor1.execute("drop database if exists %s" % self.insertDB) + cursor1.close() if __name__ == '__main__': parser = argparse.ArgumentParser() @@ -194,9 +194,22 @@ if __name__ == '__main__': default='perf', type=str, help='Database name to be created (default: perf)') - + parser.add_argument( + '-b', + '--git-branch', + action='store', + default='master', + type=str, + help='git branch (default: master)') + parser.add_argument( + '-T', + '--build-type', + action='store', + default='glibc', + type=str, + help='build type (default: glibc)') args = parser.parse_args() - perftest = taosdemoPerformace(args.commit_id, args.database_name) + perftest = taosdemoPerformace(args.commit_id, args.database_name, args.git_branch, args.build_type) perftest.insertData() perftest.createTablesAndStoreData()