提交 0966d0ca 编写于 作者: wmmhello's avatar wmmhello

Merge branch 'develop' into fix/TD-5578

......@@ -5181,7 +5181,7 @@ static int64_t generateStbRowData(
dataLen += 1;
}
if (dataLen > remainderBufLen)
if (dataLen > (remainderBufLen - (DOUBLE_BUFF_LEN + 1)))
return 0;
}
......
#!/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: <support@taosdata.com>\nto: ${receiver}\nsubject: Query Performace Report ${branch} ${jemalloc} ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \
echo -e "From: <support@taosdata.com>\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
......@@ -257,6 +257,7 @@ python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py
python3 ./test.py -f query/nestquery_last_row.py
python3 ./test.py -f query/queryCnameDisplay.py
python3 ./test.py -f query/operator_cost.py
python3 ./test.py -f query/long_where_query.py
python3 test.py -f query/nestedQuery/queryWithSpread.py
#stream
......
......@@ -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
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import random
import string
import os
import time
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
class TDTestCase:
updatecfgDict={'maxSQLLength':1048576}
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1538548685000
self.num = 100
def get_random_string(self, length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
def run(self):
tdSql.prepare()
# test case for https://jira.taosdata.com:18080/browse/TD-5213
print("==============step1, regular table==============")
startTime = time.time()
sql = "create table regular_table_1(ts timestamp, "
for i in range(4094):
sql += "col00000111112222233333444445555566666777778888899999000000l%d int, " % (i + 1)
sql += "col4095 binary(22))"
tdLog.info(len(sql))
tdSql.execute(sql)
tdLog.info("========== test1.1 : test regular table in ( ) ==========")
sql = '''insert into regular_table_1(ts,col00000111112222233333444445555566666777778888899999000000l1) values(now,1);'''
tdSql.execute(sql)
sql = ''' select * from regular_table_1 where col00000111112222233333444445555566666777778888899999000000l1 in (1); '''
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
for i in range(self.num):
sql = "insert into regular_table_1 values(%d, "
for j in range(4094):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from regular_table_1")
tdSql.checkData(0, 0, self.num+1)
tdSql.query("select * from regular_table_1")
tdSql.checkRows(self.num+1)
tdSql.checkCols(4096)
#maxSQLLength 1048576
sql = "select * from regular_table_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(2,128840):
sql += "%d , " % (i + 1)
sql += "1 ,12345) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
tdSql.checkCols(4096)
#maxSQLLength 1048577--error
sql = "select * from regular_table_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(2,128840):
sql += "%d , " % (i + 1)
sql += "1 ,123456) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
tdLog.info("========== test1.2 : test regular table in (' ') ==========")
sql = '''insert into regular_table_1(ts,col4095) values(now,1);'''
tdSql.execute(sql)
sql = ''' select * from regular_table_1 where col4095 in ('1',"1"); '''
tdSql.query(sql)
tdSql.checkData(0, 4095, 1)
#maxSQLLength 1048576
sql = " select * from regular_table_1 where col4095 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 4095, 1)
tdSql.checkCols(4096)
#maxSQLLength 1048577--error
sql = " select * from regular_table_1 where col4095 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '123' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
print("==============step2, super table ==============")
startTime = time.time()
sql = "create stable stable_1(ts timestamp, "
for i in range(4090):
sql += "col00000111112222233333444445555566666777778888899999000000l%d int, " % (i + 1)
sql += "col4091 binary(22))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table table_1 using stable_1
tags('table_1' , '1' , '2' , '3' );'''
tdSql.execute(sql)
tdLog.info("========== test2.1 : test super table in ( ) ==========")
sql = '''insert into table_1(ts,col00000111112222233333444445555566666777778888899999000000l1) values(now,1);'''
tdSql.execute(sql)
sql = ''' select * from stable_1 where col00000111112222233333444445555566666777778888899999000000l1 in (1); '''
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
sql = ''' select * from table_1 where col00000111112222233333444445555566666777778888899999000000l1 in (1); '''
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
for i in range(self.num):
sql = "insert into table_1 values(%d, "
for j in range(4090):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from table_1")
tdSql.checkData(0, 0, self.num+1)
tdSql.query("select * from table_1")
tdSql.checkRows(self.num+1)
tdSql.checkCols(4092)
tdSql.query("select count(*) from stable_1")
tdSql.checkData(0, 0, self.num+1)
tdSql.query("select * from stable_1")
tdSql.checkRows(self.num+1)
tdSql.checkCols(4096)
#maxSQLLength 1048576
sql = "select * from table_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(128840):
sql += "%d , " % (i + 1)
sql += "1 ,12345) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
tdSql.checkCols(4092)
sql = "select * from stable_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(128840):
sql += "%d , " % (i + 1)
sql += "1 ,1234) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
tdSql.checkCols(4096)
#TD-5640
sql = "select * from stable_1 where tag_1 in ("
for i in range(128847):
sql += "%d , " % (i + 1)
sql += "1)order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 1, 1)
tdSql.checkCols(4096)
#maxSQLLength 1048577--error
sql = "select * from table_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(128840):
sql += "%d , " % (i + 1)
sql += "1 ,123456) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
sql = "select * from stable_1 where col00000111112222233333444445555566666777778888899999000000l1 in ("
for i in range(128840):
sql += "%d , " % (i + 1)
sql += "1 ,12345) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
sql = "select * from stable_1 where tag_1 in ("
for i in range(128847):
sql += "%d , " % (i + 1)
sql += "1) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
tdLog.info("========== tests2.2 : test super table in (' ') ==========")
sql = '''insert into table_1(ts,col4091) values(now,1);'''
tdSql.execute(sql)
sql = ''' select * from table_1 where col4091 in ('1',"1"); '''
tdSql.query(sql)
tdSql.checkData(0, 4091, 1)
#maxSQLLength 1048576
sql = " select * from table_1 where col4091 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1','123456' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 4091, 1)
tdSql.checkCols(4092)
sql = " select * from stable_1 where col4091 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1','12345' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 4091, 1)
tdSql.checkCols(4096)
#TD-5650
sql = " select * from stable_1 where loc in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '123','table_1' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.query(sql)
tdSql.checkData(0, 4092, 'table_1')
tdSql.checkCols(4096)
#maxSQLLength 1048577--error
sql = " select * from table_1 where col4091 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1','1234567' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
sql = " select * from stable_1 where col4091 in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1','123456' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
sql = " select * from stable_1 where loc in ("
for i in range(96328):
sql += " '%d' , " % (i + 1)
sql += " '1','1234567890' ) order by ts desc;"
#tdLog.info(sql)
tdLog.info(len(sql))
tdSql.error(sql)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
os.system("rm -rf query/long_where_query.py.sql")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -207,9 +207,9 @@ class TDTestCase:
sql = '''select distinct(t_ts) from stable_1;'''
tdSql.query(sql)
tdSql.checkRows(3)
# sql = '''select distinct(tbname) from stable_1;'''
# tdSql.query(sql)
# tdSql.checkRows(6)
sql = '''select distinct(tbname) from stable_1;'''
tdSql.query(sql)
tdSql.checkRows(6)
tdLog.info("========== operator=2(OP_DataBlocksOptScan) ==========")
sql = '''select last(q_int),first(q_int) from stable_1;'''
......
......@@ -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()
......@@ -79,7 +79,7 @@ class TDTestCase:
# merge result files
sleep(10)
sleep(5)
os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt")
os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt")
os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt")
......@@ -99,7 +99,7 @@ class TDTestCase:
# insert extral data
tdSql.execute("use subnsdb")
tdSql.execute("insert into tb0_0 values(now,100.1000,'subtest1',now-1s)")
sleep(1)
sleep(15)
os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt")
subTimes0 = self.subTimes("all_subscribe_res0.txt")
......
......@@ -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()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册