提交 0f96df1f 编写于 作者: haoranc's avatar haoranc

add testcase of async subscirbe and max sql num

上级 288e8fcd
{
"filetype":"subscribe",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"databases": "db",
"confirm_parameter_prompt": "no",
"specified_table_query":
{
"concurrent":2,
"mode":"async",
"interval":0,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from stb00_0",
"result": "./subscribe_res0.txt"
},
{
"sql": "select ts from stb00_1",
"result": "./subscribe_res1.txt"
}]
},
"super_table_query":
{
"stblname": "stb0",
"threads":2,
"mode":"async",
"interval":10000,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ",
"result": "./subscribe_res2.txt"
},
{
"sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ",
"result": "./subscribe_res3.txt"
}]
}
}
\ No newline at end of file
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 4,
"thread_count_create_tbl": 4,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 0,
"num_of_records_per_req": 3000,
"max_sql_len": 1024000,
"databases": [{
"dbinfo": {
"name": "db",
"drop": "yes",
"replica": 1,
"days": 10,
"cache": 16,
"blocks": 8,
"precision": "ms",
"keep": 365,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
},
"super_tables": [{
"name": "stb0",
"child_table_exists":"no",
"childtable_count": 200,
"childtable_prefix": "stb00_",
"auto_create_table": "no",
"batch_create_tbl_num": 10,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset": 0,
"interlace_rows": 0,
"insert_interval": 0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1000,
"start_timestamp": "2021-02-25 10:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "BINARY", "len": 1, "count":1}, {"type": "BINARY", "len": 3, "count":1}, {"type": "INT"}, {"type": "DOUBLE", "count":1}],
"tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}]
}]
}]
}
\ No newline at end of file
{
"filetype":"subscribe",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"databases": "db",
"confirm_parameter_prompt": "no",
"specified_table_query":
{
"concurrent":2,
"mode":"sync",
"interval":0,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from stb00_0",
"result": "./subscribe_res0.txt"
},
{
"sql": "select * from stb00_1",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_2",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_3",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_4",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_5",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_6",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_7",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_8",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_9",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_10 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_11 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_12 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_13 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_14 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_15 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_16 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_17 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_18 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_19 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_20 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_21 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_22 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_23 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_24 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_25 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_26 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_27 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_28 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_29 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_30 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_31 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_32 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_33 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_34 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_35 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_36 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_37 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_38 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_39 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_40 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_41 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_42 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_43 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_44 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_45 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_46 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_47 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_48 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_49 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_50 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_51 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_52 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_53 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_54 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_55 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_56 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_57 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_58 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_59 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_60",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_61",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_62",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_63",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_64",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_65",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_66",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_67",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_68",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_69",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_70 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_71 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_72 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_73 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_74 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_75 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_76 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_77 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_78 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_79 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_80 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_81 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_82 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_83 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_84 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_85 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_86 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_87 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_88 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_89 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_90 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_91 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_92 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_93 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_94 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_95 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_96 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_97 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_98 ",
"result": "./query_res0.txt"
},
{
"sql": "select * from stb00_99 ",
"result": "./query_res0.txt"
}]
},
"super_table_query":
{
"stblname": "stb0",
"threads":2,
"mode":"sync",
"interval":10000,
"restart":"yes",
"keepProgress":"yes",
"sqls": [
{
"sql": "select * from xxxx where ts >= '2021-02-25 10:00:01.000' ",
"result": "./subscribe_res2.txt"
},
{
"sql": "select * from xxxx where ts > '2021-02-25 10:00:04.000' ",
"result": "./subscribe_res3.txt"
}]
}
}
\ No newline at end of file
......@@ -49,13 +49,14 @@ class TDTestCase:
command = 'cat %s |wc -l'% filename
times = int(subprocess.getstatusoutput(command)[1])
return times
def assertCheck(self,filename,queryResult,expectResult):
# 检查
def assertCheck(self,filename,subResult,expectResult):
self.filename = filename
self.queryResult = queryResult
self.subResult = subResult
self.expectResult = expectResult
args0 = (filename, queryResult, expectResult)
assert queryResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0
args0 = (filename, subResult, expectResult)
assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0
def run(self):
buildPath = self.getBuildPath()
......@@ -66,52 +67,59 @@ class TDTestCase:
binPath = buildPath+ "/build/bin/"
# clear env
os.system("ps -ef |grep 'taosdemoAllTest/sub.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
os.system("ps -ef |grep 'taosdemoAllTest/subSync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
sleep(1)
os.system("rm -rf ./subscribe_res*")
os.system("rm -rf ./all_subscribe_res*")
# subscribe: resultfile
os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath)
os.system("nohup %staosdemo -f tools/taosdemoAllTest/sub.json &" % binPath)
query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/sub.json" |grep -v "grep"|awk \'{print $2}\'')[1])
# insert extral data
tdSql.execute("use db")
tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)")
tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)")
sleep(5)
# merge result files
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")
# # subscribe: async
# os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath)
# os.system("nohup %staosdemo -f tools/taosdemoAllTest/subSync.json &" % binPath)
# query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subSync.json" |grep -v "grep"|awk \'{print $2}\'')[1])
# # insert extral data
# tdSql.execute("use db")
# tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)")
# tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)")
# sleep(5)
# # merge result files
# 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")
# os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt")
# correct subscribeTimes testcase
subTimes0 = self.subTimes("all_subscribe_res0.txt")
self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22)
# # correct subscribeTimes testcase
# subTimes0 = self.subTimes("all_subscribe_res0.txt")
# self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22)
# subTimes1 = self.subTimes("all_subscribe_res1.txt")
# self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24)
subTimes1 = self.subTimes("all_subscribe_res1.txt")
self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24)
# subTimes2 = self.subTimes("all_subscribe_res2.txt")
# self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21)
subTimes2 = self.subTimes("all_subscribe_res2.txt")
self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21)
# subTimes3 = self.subTimes("all_subscribe_res3.txt")
# self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13)
# correct data testcase
# # correct data testcase
os.system("kill -9 %d" % query_pid)
# os.system("kill -9 %d" % query_pid)
# sleep(3)
# os.system("rm -rf ./subscribe_res*")
# os.system("rm -rf ./all_subscribe*")
# # query times less than or equal to 100
# os.system("%staosdemo -f tools/taosdemoAllTest/QuerySpeciMutisql100.json" % binPath)
# os.system("%staosdemo -f tools/taosdemoAllTest/QuerySuperMutisql100.json" % binPath)
# query times less than or equal to 100
os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath)
os.system("%staosdemo -f tools/taosdemoAllTest/subSyncMaxsql100.json" % binPath)
# delete useless files
os.system("rm -rf ./insert_res.txt")
os.system("rm -rf tools/taosdemoAllTest/*.py.sql")
os.system("rm -rf ./querySystemInfo*")
os.system("rm -rf ./subscribe_res*")
os.system("rm -rf ./all_subscribe*")
os.system("rm -rf ./test_query_res0.txt")
# os.system("rm -rf ./subscribe_res*")
# os.system("rm -rf ./all_subscribe*")
def stop(self):
tdSql.close()
......
###################################################################
# 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 sys
import os
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import time
from datetime import datetime
import subprocess
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
# 获取订阅次数
def subTimes(self,filename):
self.filename = filename
command = 'cat %s |wc -l'% filename
times = int(subprocess.getstatusoutput(command)[1])
return times
def assertCheck(self,filename,queryResult,expectResult):
self.filename = filename
self.queryResult = queryResult
self.expectResult = expectResult
args0 = (filename, queryResult, expectResult)
assert queryResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0
def run(self):
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/"
# clear env
os.system("ps -ef |grep 'taosdemoAllTest/subAsync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
sleep(1)
os.system("rm -rf ./subscribe_res*")
os.system("rm -rf ./all_subscribe_res*")
# subscribe: resultfile
os.system("%staosdemo -f tools/taosdemoAllTest/subInsertdata.json" % binPath)
os.system("nohup %staosdemo -f tools/taosdemoAllTest/subAsync.json &" % binPath)
query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subAsync.json" |grep -v "grep"|awk \'{print $2}\'')[1])
# insert extral data
tdSql.execute("use db")
tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)")
tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)")
sleep(5)
# merge result files
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")
os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt")
# correct subscribeTimes testcase
subTimes0 = self.subTimes("all_subscribe_res0.txt")
self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22)
subTimes1 = self.subTimes("all_subscribe_res1.txt")
self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24)
subTimes2 = self.subTimes("all_subscribe_res2.txt")
self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21)
subTimes3 = self.subTimes("all_subscribe_res3.txt")
self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13)
# correct data testcase
os.system("kill -9 %d" % query_pid)
# # query times less than or equal to 100
# os.system("%staosdemo -f tools/taosdemoAllTest/QuerySpeciMutisql100.json" % binPath)
# os.system("%staosdemo -f tools/taosdemoAllTest/QuerySuperMutisql100.json" % binPath)
# delete useless files
os.system("rm -rf ./insert_res.txt")
os.system("rm -rf tools/taosdemoAllTest/*.py.sql")
os.system("rm -rf ./subscribe_res*")
os.system("rm -rf ./all_subscribe*")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册