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

test:add testcase of mnode clusters

上级 e048047e
...@@ -68,6 +68,7 @@ class TDTestCase: ...@@ -68,6 +68,7 @@ class TDTestCase:
my_file = Path(f"{packagePath}/{packageName}") my_file = Path(f"{packagePath}/{packageName}")
if not my_file.exists(): if not my_file.exists():
print(f"{packageName} is not exists") print(f"{packageName} is not exists")
tdLog.info(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}")
os.system(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}") os.system(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}")
else: else:
print(f"{packageName} has been exists") print(f"{packageName} has been exists")
......
...@@ -161,6 +161,19 @@ class TDTestCase: ...@@ -161,6 +161,19 @@ class TDTestCase:
stableName= '%s_%d'%(paraDict['stbName'],i) stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
for i in range(5):
clusterComCreate.createUser(newTdSql,f"user{i}",f"pass{i}")
userTdSql=tdCom.newTdSql(user=f"user{i}",password=f"pass{i}")
clusterComCreate.alterUser(userTdSql,f"user{i}",f"pass{i+1}")
clusterComCreate.deleteUser(newTdSql,f"user{i}")
for j in range(5):
i=100
clusterComCreate.createUser(newTdSql,f"user{i}",f"pass{i}")
userTdSql=tdCom.newTdSql(user=f"user{i}",password=f"pass{i}")
clusterComCreate.alterUser(userTdSql,f"user{i}",f"pass{i+1}")
clusterComCreate.deleteUser(newTdSql,f"user{i}")
for tr in threads: for tr in threads:
tr.start() tr.start()
for tr in threads: for tr in threads:
......
...@@ -67,29 +67,11 @@ class TDTestCase: ...@@ -67,29 +67,11 @@ class TDTestCase:
self._async_raise(thread.ident, SystemExit) self._async_raise(thread.ident, SystemExit)
def insertData(self,countstart,countstop): def reCreateUser(self, tdsql, count, user, passwd):
# fisrt add data : db\stable\childtable\general table clusterComCreate.createUser(tdsql,f"{user}{count}",f"{passwd}{count}")
userTdSql=tdCom.newTdSql(user=f"{user}{count}",password=f"{passwd}{count}")
for couti in range(countstart,countstop): clusterComCreate.alterUser(userTdSql,f"{user}{count}",f"{passwd}{count+1}")
tdLog.debug("drop database if exists db%d" %couti) clusterComCreate.deleteUser(tdsql,f"{user}{count}")
tdSql.execute("drop database if exists db%d" %couti)
print("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("create database if not exists db%d replica 1 duration 300" %couti)
tdSql.execute("use db%d" %couti)
tdSql.execute(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole): def fiveDnodeThreeMnode(self,dnodeNumbers,mnodeNums,restartNumbers,stopRole):
...@@ -161,6 +143,8 @@ class TDTestCase: ...@@ -161,6 +143,8 @@ class TDTestCase:
stableName= '%s_%d'%(paraDict['stbName'],i) stableName= '%s_%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
threads.append(threading.Thread(target=self.reCreateUser,args=(newTdSql,i,"user","passwd")))
for tr in threads: for tr in threads:
tr.start() tr.start()
......
...@@ -142,7 +142,19 @@ class ClusterComCreate: ...@@ -142,7 +142,19 @@ class ClusterComCreate:
tsql.execute("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,1, vgroups, replica)) tsql.execute("create database if not exists %s_%d vgroups %d replica %d"%(dbNameIndex,1, vgroups, replica))
tdLog.debug("complete to create database %s_%d"%(dbNameIndex,1)) tdLog.debug("complete to create database %s_%d"%(dbNameIndex,1))
def createUser(self,tsql,user,password):
tdLog.info(f"create new user f{user}")
tsql.execute(f"CREATE USER {user} PASS '{password}';")
def alterUser(self,tsql,user,password):
tdLog.info(f"alter user {user} pass '{password}'")
tsql.execute(f"alter USER {user} pass '{password}' ;")
def deleteUser(self,tsql,user):
tdLog.info(f"drop user f{user}")
tsql.execute(f"DROP USER {user} ;")
def create_stable(self,tsql, dbName,stbName): def create_stable(self,tsql, dbName,stbName):
tsql.execute("create table if not exists %s.%s (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbName, stbName)) tsql.execute("create table if not exists %s.%s (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbName, stbName))
tdLog.debug("complete to create %s.%s" %(dbName, stbName)) tdLog.debug("complete to create %s.%s" %(dbName, stbName))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册