fix test cases
This commit is contained in:
parent
352a62c2d4
commit
bd5381f8e7
|
@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -18,7 +18,7 @@ class MyDnodes(TDDnodes):
|
|||
super(MyDnodes,self).__init__()
|
||||
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
||||
self.simDeployed = False
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
noConn = True
|
||||
def init(self,conn ,logSql):
|
||||
|
@ -29,7 +29,7 @@ class TDTestCase:
|
|||
self.host=self.master_dnode.cfgDict["fqdn"]
|
||||
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
|
||||
tdSql.init(conn1.cursor())
|
||||
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -46,12 +46,12 @@ class TDTestCase:
|
|||
buildPath = root[:len(root) - len("/build/bin")]
|
||||
break
|
||||
return buildPath
|
||||
|
||||
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
|
||||
testCluster = False
|
||||
valgrind = 0
|
||||
valgrind = 0
|
||||
hostname = socket.gethostname()
|
||||
dnodes = []
|
||||
start_port = 6030
|
||||
|
@ -63,7 +63,7 @@ class TDTestCase:
|
|||
dnode.addExtraCfg("monitorFqdn", hostname)
|
||||
dnode.addExtraCfg("monitorPort", 7043)
|
||||
dnodes.append(dnode)
|
||||
|
||||
|
||||
self.TDDnodes = MyDnodes(dnodes)
|
||||
self.TDDnodes.init("")
|
||||
self.TDDnodes.setTestCluster(testCluster)
|
||||
|
@ -71,11 +71,11 @@ class TDTestCase:
|
|||
self.TDDnodes.stopAll()
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.deploy(dnode.index,{})
|
||||
|
||||
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.starttaosd(dnode.index)
|
||||
|
||||
# create cluster
|
||||
# create cluster
|
||||
for dnode in self.TDDnodes.dnodes[1:]:
|
||||
# print(dnode.cfgDict)
|
||||
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
|
||||
|
@ -84,7 +84,7 @@ class TDTestCase:
|
|||
cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\""
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
time.sleep(2)
|
||||
tdLog.info(" create cluster done! ")
|
||||
|
||||
|
@ -94,7 +94,7 @@ class TDTestCase:
|
|||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||
tdSql.checkData(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -120,7 +120,7 @@ class TDTestCase:
|
|||
)
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
|
||||
|
||||
tdSql.query('show databases;')
|
||||
tdSql.checkData(2,5,'off')
|
||||
tdSql.error("alter database db strict 'off'")
|
||||
|
@ -135,7 +135,7 @@ class TDTestCase:
|
|||
return taos.connect(host=host, port=int(port), config=config_dir)
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.five_dnode_one_mnode()
|
||||
|
||||
|
@ -145,4 +145,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -3,7 +3,7 @@ from paramiko import HostKeys
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -19,7 +19,7 @@ class MyDnodes(TDDnodes):
|
|||
super(MyDnodes,self).__init__()
|
||||
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
||||
self.simDeployed = False
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self,conn ,logSql):
|
||||
|
@ -48,7 +48,7 @@ class TDTestCase:
|
|||
buildPath = root[:len(root) - len("/build/bin")]
|
||||
break
|
||||
return buildPath
|
||||
|
||||
|
||||
def insert_data(self,count):
|
||||
# fisrt add data : db\stable\childtable\general table
|
||||
for couti in count:
|
||||
|
@ -70,10 +70,10 @@ class TDTestCase:
|
|||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
|
||||
testCluster = False
|
||||
valgrind = 0
|
||||
valgrind = 0
|
||||
hostname = socket.gethostname()
|
||||
tdLog.debug(hostname)
|
||||
dnodes = []
|
||||
|
@ -88,7 +88,7 @@ class TDTestCase:
|
|||
dnode.addExtraCfg("monitorPort", 7043)
|
||||
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||
dnodes.append(dnode)
|
||||
|
||||
|
||||
self.TDDnodes = MyDnodes(dnodes)
|
||||
self.TDDnodes.init("")
|
||||
self.TDDnodes.setTestCluster(testCluster)
|
||||
|
@ -96,11 +96,11 @@ class TDTestCase:
|
|||
self.TDDnodes.stopAll()
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.deploy(dnode.index,{})
|
||||
|
||||
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.starttaosd(dnode.index)
|
||||
|
||||
# create cluster
|
||||
# create cluster
|
||||
for dnode in self.TDDnodes.dnodes[1:]:
|
||||
# tdLog.debug(dnode.cfgDict)
|
||||
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
|
||||
|
@ -109,7 +109,7 @@ class TDTestCase:
|
|||
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
|
||||
tdLog.debug(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
time.sleep(2)
|
||||
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
|
||||
|
||||
|
@ -118,8 +118,8 @@ class TDTestCase:
|
|||
while count < 10:
|
||||
time.sleep(1)
|
||||
tdSql.query("show mnodes;")
|
||||
if tdSql.checkRows(3) :
|
||||
tdLog.debug("mnode is three nodes")
|
||||
if tdSql.checkRows(3) :
|
||||
tdLog.debug("mnode is three nodes")
|
||||
if tdSql.queryResult[0][2]=='leader' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
|
@ -129,20 +129,20 @@ class TDTestCase:
|
|||
if tdSql.queryResult[1][2]=='leader':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
tdLog.debug("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
elif tdSql.queryResult[0][2]=='follower' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='leader':
|
||||
tdLog.debug("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
count+=1
|
||||
else:
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
tdLog.debug("three mnodes is not ready in 10s ")
|
||||
return -1
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,3,'ready')
|
||||
tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
|
@ -169,11 +169,11 @@ class TDTestCase:
|
|||
count+=1
|
||||
else:
|
||||
tdLog.debug("stop mnodes on dnode 2 failed in 10s ")
|
||||
return -1
|
||||
return -1
|
||||
tdSql.error("drop mnode on dnode 1;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'offline')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -200,8 +200,8 @@ class TDTestCase:
|
|||
return -1
|
||||
tdSql.error("drop mnode on dnode 2;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -229,8 +229,8 @@ class TDTestCase:
|
|||
tdLog.debug("stop mnodes on dnode 3 failed in 10s")
|
||||
return -1
|
||||
tdSql.error("drop mnode on dnode 3;")
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -249,8 +249,8 @@ class TDTestCase:
|
|||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||
tdSql.checkData(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -270,8 +270,8 @@ class TDTestCase:
|
|||
tdSql.query("show dnodes;")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
|
||||
# drop follower of mnode
|
||||
dropcount =0
|
||||
# drop follower of mnode
|
||||
dropcount =0
|
||||
while dropcount <= 10:
|
||||
for i in range(1,3):
|
||||
tdLog.debug("drop mnode on dnode %d"%(i+1))
|
||||
|
@ -306,7 +306,7 @@ class TDTestCase:
|
|||
return taos.connect(host=host, port=int(port), config=config_dir)
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# tdLog.debug(self.master_dnode.cfgDict)
|
||||
self.buildcluster(5)
|
||||
self.five_dnode_three_mnode()
|
||||
|
@ -316,4 +316,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -12,13 +12,13 @@ from util.dnodes import TDDnode
|
|||
from util.cluster import *
|
||||
sys.path.append("./6-cluster")
|
||||
from clusterCommonCreate import *
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
|
||||
import time
|
||||
import socket
|
||||
import subprocess
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
import threading
|
||||
import time
|
||||
import inspect
|
||||
import ctypes
|
||||
|
@ -56,7 +56,7 @@ class TDTestCase:
|
|||
if res == 0:
|
||||
raise ValueError("invalid thread id")
|
||||
elif res != 1:
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# and you should call it again with exc=NULL to revert the effect"""
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||
|
@ -67,7 +67,7 @@ class TDTestCase:
|
|||
|
||||
def insertData(self,countstart,countstop):
|
||||
# fisrt add data : db\stable\childtable\general table
|
||||
|
||||
|
||||
for couti in range(countstart,countstop):
|
||||
tdLog.debug("drop database if exists db%d" %couti)
|
||||
tdSql.execute("drop database if exists db%d" %couti)
|
||||
|
@ -107,13 +107,13 @@ class TDTestCase:
|
|||
'ctbPrefix': 'ctb',
|
||||
'ctbNum': 1,
|
||||
}
|
||||
|
||||
|
||||
dnodeNumbers=int(dnodeNumbers)
|
||||
mnodeNums=int(mnodeNums)
|
||||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("show dnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
|
@ -128,7 +128,7 @@ class TDTestCase:
|
|||
tdSql.execute("create mnode on dnode 3")
|
||||
clusterComCheck.checkMnodeStatus(3)
|
||||
|
||||
# add some error operations and
|
||||
# add some error operations and
|
||||
tdLog.info("Confirm the status of the dnode again")
|
||||
tdSql.error("create mnode on dnode 2")
|
||||
tdSql.query("show dnodes;")
|
||||
|
@ -149,7 +149,7 @@ class TDTestCase:
|
|||
for tr in threads:
|
||||
tr.start()
|
||||
|
||||
tdLog.info("Take turns stopping Mnodes ")
|
||||
tdLog.info("Take turns stopping Mnodes ")
|
||||
while stopcount < restartNumbers:
|
||||
tdLog.info(" restart loop: %d"%stopcount )
|
||||
if stopRole == "mnode":
|
||||
|
@ -157,7 +157,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
elif stopRole == "vnode":
|
||||
for i in range(vnodeNumbers):
|
||||
tdDnodes[i+mnodeNums].stoptaosd()
|
||||
|
@ -169,7 +169,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
|
||||
# dnodeNumbers don't include database of schema
|
||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||
|
@ -180,7 +180,7 @@ class TDTestCase:
|
|||
tdLog.exit("one or more of dnodes failed to start ")
|
||||
# self.check3mnode()
|
||||
stopcount+=1
|
||||
|
||||
|
||||
for tr in threads:
|
||||
tr.join()
|
||||
tdLog.info("check dnode number:")
|
||||
|
@ -196,7 +196,7 @@ class TDTestCase:
|
|||
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='dnode')
|
||||
|
||||
|
@ -205,4 +205,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -12,13 +12,13 @@ from util.dnodes import TDDnode
|
|||
from util.cluster import *
|
||||
sys.path.append("./6-cluster")
|
||||
from clusterCommonCreate import *
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
|
||||
import time
|
||||
import socket
|
||||
import subprocess
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
import threading
|
||||
import time
|
||||
import inspect
|
||||
import ctypes
|
||||
|
@ -56,7 +56,7 @@ class TDTestCase:
|
|||
if res == 0:
|
||||
raise ValueError("invalid thread id")
|
||||
elif res != 1:
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# and you should call it again with exc=NULL to revert the effect"""
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||
|
@ -82,13 +82,13 @@ class TDTestCase:
|
|||
'ctbPrefix': 'ctb',
|
||||
'ctbNum': 1,
|
||||
}
|
||||
|
||||
|
||||
dnodeNumbers=int(dnodeNumbers)
|
||||
mnodeNums=int(mnodeNums)
|
||||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
|
||||
allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
|
||||
|
||||
|
||||
tdLog.info("first check dnode and mnode")
|
||||
tdSql.query("show dnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
|
@ -103,14 +103,14 @@ class TDTestCase:
|
|||
tdSql.execute("create mnode on dnode 3")
|
||||
clusterComCheck.checkMnodeStatus(3)
|
||||
|
||||
# add some error operations and
|
||||
# add some error operations and
|
||||
tdLog.info("Confirm the status of the dnode again")
|
||||
tdSql.error("create mnode on dnode 2")
|
||||
tdSql.query("show dnodes;")
|
||||
print(tdSql.queryResult)
|
||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||
|
||||
tdLog.info("create database and stable")
|
||||
tdLog.info("create database and stable")
|
||||
tdDnodes=cluster.dnodes
|
||||
stopcount =0
|
||||
threads=[]
|
||||
|
@ -122,7 +122,7 @@ class TDTestCase:
|
|||
for tr in threads:
|
||||
tr.start()
|
||||
|
||||
tdLog.info("Take turns stopping Mnodes ")
|
||||
tdLog.info("Take turns stopping Mnodes ")
|
||||
while stopcount < restartNumbers:
|
||||
tdLog.info(" restart loop: %d"%stopcount )
|
||||
if stopRole == "mnode":
|
||||
|
@ -130,7 +130,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
elif stopRole == "vnode":
|
||||
for i in range(vnodeNumbers):
|
||||
tdDnodes[i+mnodeNums].stoptaosd()
|
||||
|
@ -142,7 +142,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
|
||||
# dnodeNumbers don't include database of schema
|
||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||
|
@ -153,14 +153,14 @@ class TDTestCase:
|
|||
tdLog.exit("one or more of dnodes failed to start ")
|
||||
# self.check3mnode()
|
||||
stopcount+=1
|
||||
|
||||
|
||||
for tr in threads:
|
||||
tr.join()
|
||||
tdLog.info("check dnode number:")
|
||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||
tdSql.query("show databases")
|
||||
tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2))
|
||||
|
||||
|
||||
# tdLog.info("check DB Rows:")
|
||||
# clusterComCheck.checkDbRows(allDbNumbers)
|
||||
# tdLog.info("check DB Status on by on")
|
||||
|
@ -168,7 +168,7 @@ class TDTestCase:
|
|||
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode')
|
||||
|
||||
|
@ -177,4 +177,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -18,7 +18,7 @@ import time
|
|||
import socket
|
||||
import subprocess
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
import threading
|
||||
import time
|
||||
import inspect
|
||||
import ctypes
|
||||
|
@ -54,7 +54,7 @@ class TDTestCase:
|
|||
if res == 0:
|
||||
raise ValueError("invalid thread id")
|
||||
elif res != 1:
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# and you should call it again with exc=NULL to revert the effect"""
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||
|
@ -65,7 +65,7 @@ class TDTestCase:
|
|||
|
||||
def insert_data(self,countstart,countstop):
|
||||
# fisrt add data : db\stable\childtable\general table
|
||||
|
||||
|
||||
for couti in range(countstart,countstop):
|
||||
tdLog.debug("drop database if exists db%d" %couti)
|
||||
tdSql.execute("drop database if exists db%d" %couti)
|
||||
|
@ -96,7 +96,7 @@ class TDTestCase:
|
|||
for i in range(stableCount):
|
||||
tdSql.query("select count(*) from %s%d"%(stbname,i))
|
||||
tdSql.checkData(0,0,rowsPerSTable)
|
||||
return
|
||||
return
|
||||
|
||||
def checkdnodes(self,dnodenumber):
|
||||
count=0
|
||||
|
@ -104,8 +104,8 @@ class TDTestCase:
|
|||
time.sleep(1)
|
||||
statusReadyBumber=0
|
||||
tdSql.query("show dnodes;")
|
||||
if tdSql.checkRows(dnodenumber) :
|
||||
print("dnode is %d nodes"%dnodenumber)
|
||||
if tdSql.checkRows(dnodenumber) :
|
||||
print("dnode is %d nodes"%dnodenumber)
|
||||
for i in range(dnodenumber):
|
||||
if tdSql.queryResult[i][4] !='ready' :
|
||||
status=tdSql.queryResult[i][4]
|
||||
|
@ -122,15 +122,15 @@ class TDTestCase:
|
|||
else:
|
||||
print("%d mnodes is not ready in 10s "%dnodenumber)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def check3mnode(self):
|
||||
count=0
|
||||
while count < 10:
|
||||
time.sleep(1)
|
||||
tdSql.query("show mnodes;")
|
||||
if tdSql.checkRows(3) :
|
||||
print("mnode is three nodes")
|
||||
if tdSql.checkRows(3) :
|
||||
print("mnode is three nodes")
|
||||
if tdSql.queryResult[0][2]=='leader' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
|
@ -140,19 +140,19 @@ class TDTestCase:
|
|||
if tdSql.queryResult[1][2]=='leader':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
print("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
elif tdSql.queryResult[0][2]=='follower' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='leader':
|
||||
print("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
count+=1
|
||||
else:
|
||||
print("three mnodes is not ready in 10s ")
|
||||
return -1
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,3,'ready')
|
||||
tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
|
@ -182,8 +182,8 @@ class TDTestCase:
|
|||
return -1
|
||||
tdSql.error("drop mnode on dnode 1;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'offline')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -210,8 +210,8 @@ class TDTestCase:
|
|||
return -1
|
||||
tdSql.error("drop mnode on dnode 2;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -239,8 +239,8 @@ class TDTestCase:
|
|||
print("stop mnodes on dnode 3 failed in 10s")
|
||||
return -1
|
||||
tdSql.error("drop mnode on dnode 3;")
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -258,15 +258,15 @@ class TDTestCase:
|
|||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||
tdSql.checkData(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
|
||||
|
||||
def five_dnode_three_mnode(self,dnodenumber):
|
||||
tdSql.query("show dnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||
tdSql.checkData(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -281,15 +281,15 @@ class TDTestCase:
|
|||
tdSql.error("create mnode on dnode 2")
|
||||
tdSql.query("show dnodes;")
|
||||
print(tdSql.queryResult)
|
||||
tdLog.debug("stop all of mnode ")
|
||||
tdLog.debug("stop all of mnode ")
|
||||
|
||||
# seperate vnode and mnode in different dnodes.
|
||||
# create database and stable
|
||||
stopcount =0
|
||||
stopcount =0
|
||||
while stopcount < 2:
|
||||
for i in range(dnodenumber):
|
||||
# threads=[]
|
||||
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
|
||||
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
|
||||
threads=threading.Thread(target=self.insert_data, args=(i,i+1))
|
||||
threads.start()
|
||||
self.TDDnodes.stoptaosd(i+1)
|
||||
|
@ -306,13 +306,13 @@ class TDTestCase:
|
|||
return False
|
||||
# self.check3mnode()
|
||||
self.check3mnode()
|
||||
|
||||
|
||||
|
||||
stopcount+=1
|
||||
self.check3mnode()
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# print(self.master_dnode.cfgDict)
|
||||
self.five_dnode_three_mnode(5)
|
||||
|
||||
|
@ -321,4 +321,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
|||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
|
@ -13,7 +13,7 @@ import time
|
|||
import socket
|
||||
import subprocess
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
import threading
|
||||
import time
|
||||
import inspect
|
||||
import ctypes
|
||||
|
@ -36,7 +36,7 @@ class TDTestCase:
|
|||
self.host=self.master_dnode.cfgDict["fqdn"]
|
||||
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
|
||||
tdSql.init(conn1.cursor())
|
||||
|
||||
|
||||
|
||||
def getBuildPath(self):
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
@ -62,7 +62,7 @@ class TDTestCase:
|
|||
if res == 0:
|
||||
raise ValueError("invalid thread id")
|
||||
elif res != 1:
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# """if it returns a number greater than one, you're in trouble,
|
||||
# and you should call it again with exc=NULL to revert the effect"""
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
|
||||
raise SystemError("PyThreadState_SetAsyncExc failed")
|
||||
|
@ -73,7 +73,7 @@ class TDTestCase:
|
|||
|
||||
def insert_data(self,countstart,countstop):
|
||||
# fisrt add data : db\stable\childtable\general table
|
||||
|
||||
|
||||
for couti in range(countstart,countstop):
|
||||
tdLog.debug("drop database if exists db%d" %couti)
|
||||
tdSql.execute("drop database if exists db%d" %couti)
|
||||
|
@ -95,10 +95,10 @@ class TDTestCase:
|
|||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
def depoly_cluster(self ,dnodes_nums):
|
||||
|
||||
testCluster = False
|
||||
valgrind = 0
|
||||
valgrind = 0
|
||||
hostname = socket.gethostname()
|
||||
dnodes = []
|
||||
start_port = 6030
|
||||
|
@ -112,7 +112,7 @@ class TDTestCase:
|
|||
dnode.addExtraCfg("monitorPort", 7043)
|
||||
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
|
||||
dnodes.append(dnode)
|
||||
|
||||
|
||||
self.TDDnodes = MyDnodes(dnodes)
|
||||
self.TDDnodes.init("")
|
||||
self.TDDnodes.setTestCluster(testCluster)
|
||||
|
@ -120,11 +120,11 @@ class TDTestCase:
|
|||
self.TDDnodes.stopAll()
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.deploy(dnode.index,{})
|
||||
|
||||
|
||||
for dnode in self.TDDnodes.dnodes:
|
||||
self.TDDnodes.starttaosd(dnode.index)
|
||||
|
||||
# create cluster
|
||||
# create cluster
|
||||
for dnode in self.TDDnodes.dnodes[1:]:
|
||||
# tdLog.debug(dnode.cfgDict)
|
||||
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
|
||||
|
@ -133,7 +133,7 @@ class TDTestCase:
|
|||
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
|
||||
tdLog.debug(cmd)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
time.sleep(2)
|
||||
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
|
||||
|
||||
|
@ -143,8 +143,8 @@ class TDTestCase:
|
|||
time.sleep(1)
|
||||
statusReadyBumber=0
|
||||
tdSql.query("show dnodes;")
|
||||
if tdSql.checkRows(dnodenumber) :
|
||||
tdLog.debug("dnode is %d nodes"%dnodenumber)
|
||||
if tdSql.checkRows(dnodenumber) :
|
||||
tdLog.debug("dnode is %d nodes"%dnodenumber)
|
||||
for i in range(dnodenumber):
|
||||
if tdSql.queryResult[i][4] !='ready' :
|
||||
status=tdSql.queryResult[i][4]
|
||||
|
@ -161,15 +161,15 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.debug("%d mnodes is not ready in 10s "%dnodenumber)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def check3mnode(self):
|
||||
count=0
|
||||
while count < 10:
|
||||
time.sleep(1)
|
||||
tdSql.query("show mnodes;")
|
||||
if tdSql.checkRows(3) :
|
||||
tdLog.debug("mnode is three nodes")
|
||||
if tdSql.checkRows(3) :
|
||||
tdLog.debug("mnode is three nodes")
|
||||
if tdSql.queryResult[0][2]=='leader' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
|
@ -179,19 +179,19 @@ class TDTestCase:
|
|||
if tdSql.queryResult[1][2]=='leader':
|
||||
if tdSql.queryResult[2][2]=='follower':
|
||||
tdLog.debug("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
elif tdSql.queryResult[0][2]=='follower' :
|
||||
if tdSql.queryResult[1][2]=='follower':
|
||||
if tdSql.queryResult[2][2]=='leader':
|
||||
tdLog.debug("three mnodes is ready in 10s")
|
||||
break
|
||||
break
|
||||
count+=1
|
||||
else:
|
||||
tdLog.debug("three mnodes is not ready in 10s ")
|
||||
return -1
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,3,'ready')
|
||||
tdSql.checkData(1,1,'%s:6130'%self.host)
|
||||
|
@ -221,8 +221,8 @@ class TDTestCase:
|
|||
return -1
|
||||
tdSql.error("drop mnode on dnode 1;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'offline')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -249,8 +249,8 @@ class TDTestCase:
|
|||
return -1
|
||||
tdSql.error("drop mnode on dnode 2;")
|
||||
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -278,8 +278,8 @@ class TDTestCase:
|
|||
tdLog.debug("stop mnodes on dnode 3 failed in 10s")
|
||||
return -1
|
||||
tdSql.error("drop mnode on dnode 3;")
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -296,8 +296,8 @@ class TDTestCase:
|
|||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||
tdSql.checkData(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query("show mnodes;")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
tdSql.checkData(0,3,'ready')
|
||||
|
@ -312,13 +312,13 @@ class TDTestCase:
|
|||
tdSql.error("create mnode on dnode 2")
|
||||
tdSql.query("show dnodes;")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
tdLog.debug("stop all of mnode ")
|
||||
tdLog.debug("stop all of mnode ")
|
||||
|
||||
stopcount =0
|
||||
stopcount =0
|
||||
while stopcount <= 2:
|
||||
for i in range(dnodenumber):
|
||||
# threads=[]
|
||||
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
|
||||
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
|
||||
threads=threading.Thread(target=self.insert_data, args=((stopcount+i)*2,(i+stopcount)*2+2))
|
||||
threads.start()
|
||||
self.TDDnodes.stoptaosd(i+1)
|
||||
|
@ -344,7 +344,7 @@ class TDTestCase:
|
|||
return taos.connect(host=host, port=int(port), config=config_dir)
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
# tdLog.debug(self.master_dnode.cfgDict)
|
||||
self.buildcluster(5)
|
||||
self.five_dnode_three_mnode(5)
|
||||
|
@ -354,4 +354,4 @@ class TDTestCase:
|
|||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
|
|
|
@ -37,23 +37,23 @@ class ClusterComCreate:
|
|||
tdSql.init(conn.cursor())
|
||||
# tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||
|
||||
def initConsumerTable(self,cdbName='cdb'):
|
||||
def initConsumerTable(self,cdbName='cdb'):
|
||||
tdLog.info("create consume database, and consume info table, and consume result table")
|
||||
tdSql.query("create database if not exists %s vgroups 1"%(cdbName))
|
||||
tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
|
||||
tdSql.query("drop table if exists %s.consumeresult "%(cdbName))
|
||||
tdSql.query("drop table if exists %s.notifyinfo "%(cdbName))
|
||||
tdSql.query("drop table if exists %s.notifyinfo "%(cdbName))
|
||||
|
||||
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
|
||||
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||
tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName)
|
||||
|
||||
def initConsumerInfoTable(self,cdbName='cdb'):
|
||||
def initConsumerInfoTable(self,cdbName='cdb'):
|
||||
tdLog.info("drop consumeinfo table")
|
||||
tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
|
||||
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
|
||||
|
||||
def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'):
|
||||
def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'):
|
||||
sql = "insert into %s.consumeinfo values "%cdbName
|
||||
sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit)
|
||||
tdLog.info("consume info sql: %s"%sql)
|
||||
|
@ -68,11 +68,11 @@ class ClusterComCreate:
|
|||
break
|
||||
else:
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
for i in range(expectRows):
|
||||
tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3)))
|
||||
resultList.append(tdSql.getData(i , 3))
|
||||
|
||||
|
||||
return resultList
|
||||
|
||||
def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0):
|
||||
|
@ -82,14 +82,14 @@ class ClusterComCreate:
|
|||
logFile = cfgPath + '/../log/valgrind-tmq.log'
|
||||
shellCmd = 'nohup valgrind --log-file=' + logFile
|
||||
shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes '
|
||||
|
||||
|
||||
if (platform.system().lower() == 'windows'):
|
||||
shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath
|
||||
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||
shellCmd += "> nul 2>&1 &"
|
||||
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||
shellCmd += "> nul 2>&1 &"
|
||||
else:
|
||||
shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||
shellCmd += "> /dev/null 2>&1 &"
|
||||
tdLog.info(shellCmd)
|
||||
os.system(shellCmd)
|
||||
|
@ -142,7 +142,7 @@ class ClusterComCreate:
|
|||
tdLog.debug("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
|
||||
tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
|
||||
tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i))
|
||||
return
|
||||
return
|
||||
|
||||
def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1):
|
||||
tsql.execute("use %s" %dbName)
|
||||
|
@ -153,14 +153,14 @@ class ClusterComCreate:
|
|||
tagValue = 'beijing'
|
||||
if (i % 2 == 0):
|
||||
tagValue = 'shanghai'
|
||||
|
||||
|
||||
sql += " %s_%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue)
|
||||
if (i > 0) and (i%100 == 0):
|
||||
tsql.execute(sql)
|
||||
sql = pre_create
|
||||
if sql != pre_create:
|
||||
tsql.execute(sql)
|
||||
|
||||
|
||||
tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
|
||||
return
|
||||
|
||||
|
@ -189,7 +189,7 @@ class ClusterComCreate:
|
|||
#print("insert sql:%s"%sql)
|
||||
tsql.execute(sql)
|
||||
tdLog.debug("insert data ............ [OK]")
|
||||
return
|
||||
return
|
||||
|
||||
def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||
tdLog.debug("start to insert data ............")
|
||||
|
@ -235,7 +235,7 @@ class ClusterComCreate:
|
|||
ctbDict[i] = 0
|
||||
|
||||
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||
rowsOfCtb = 0
|
||||
rowsOfCtb = 0
|
||||
while rowsOfCtb < rowsPerTbl:
|
||||
for i in range(ctbNum):
|
||||
sql += " %s.%s_%d values "%(dbName,ctbPrefix,i)
|
||||
|
@ -262,7 +262,7 @@ class ClusterComCreate:
|
|||
startTs = int(round(t * 1000))
|
||||
|
||||
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||
rowsOfSql = 0
|
||||
rowsOfSql = 0
|
||||
for i in range(ctbNum):
|
||||
sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i)
|
||||
for j in range(rowsPerTbl):
|
||||
|
@ -294,7 +294,7 @@ class ClusterComCreate:
|
|||
for i in range(ctbNum):
|
||||
tbName = '%s%s'%(ctbPrefix,i)
|
||||
tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl'])
|
||||
return
|
||||
return
|
||||
|
||||
def threadFunction(self, **paraDict):
|
||||
# create new connector for new tdSql instance in my thread
|
||||
|
|
Loading…
Reference in New Issue