提交 85552c46 编写于 作者: W wenzhouwww@live.cn

update case and push to CI run

上级 6c1cd18c
......@@ -29,7 +29,8 @@ class TDTestCase:
self.replica = 1
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 2000
self.row_nums = 1000
self.query_times = 1000
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
......@@ -160,8 +161,8 @@ class TDTestCase:
def check_insert_status(self, dbname, tb_nums , row_nums):
newTdSql=tdCom.newTdSql()
def check_insert_status(self, newTdSql ,dbname, tb_nums , row_nums):
# newTdSql=tdCom.newTdSql()
newTdSql.execute("use {}".format(dbname))
newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1'))
# tdSql.checkData(0 , 0 , tb_nums*row_nums)
......@@ -169,10 +170,10 @@ class TDTestCase:
# tdSql.checkRows(tb_nums)
def loop_query_constantly(self, times , db_name, tb_nums ,row_nums):
newTdSql=tdCom.newTdSql()
for loop_time in range(times):
tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time))
self.check_insert_status( db_name, tb_nums , row_nums)
self.check_insert_status( newTdSql , db_name, tb_nums , row_nums)
def run(self):
self.check_setup_cluster_status()
......@@ -187,7 +188,7 @@ class TDTestCase:
time.sleep(0.1)
tdSql.query(" show {}.stables ".format(self.db_name))
reading = threading.Thread(target = self.loop_query_constantly, args=(1000,self.db_name , self.tb_nums , self.row_nums))
reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums))
reading.start()
writing.join()
......
......@@ -181,20 +181,34 @@ class TDTestCase:
tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self , dbname , role):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role == role:
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self ,newTdSql ):
......
......@@ -29,7 +29,8 @@ class TDTestCase:
self.replica = 3
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 2000
self.row_nums = 1000
self.query_times = 1000
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
......@@ -153,6 +154,8 @@ class TDTestCase:
# insert datas about new database
for row_num in range(row_nums):
if row_num %100 ==0:
tdLog.info(" === writing is going now === ")
ts = self.ts + 1000*row_num
newTdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
......@@ -160,8 +163,8 @@ class TDTestCase:
def check_insert_status(self, dbname, tb_nums , row_nums):
newTdSql=tdCom.newTdSql()
def check_insert_status(self, newTdSql ,dbname, tb_nums , row_nums):
newTdSql.execute("use {}".format(dbname))
newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1'))
# tdSql.checkData(0 , 0 , tb_nums*row_nums)
......@@ -169,10 +172,10 @@ class TDTestCase:
# tdSql.checkRows(tb_nums)
def loop_query_constantly(self, times , db_name, tb_nums ,row_nums):
newTdSql=tdCom.newTdSql()
for loop_time in range(times):
tdLog.debug(" === query is going ,this is {}_th query === ".format(loop_time))
self.check_insert_status( db_name, tb_nums , row_nums)
self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums)
def run(self):
self.check_setup_cluster_status()
......@@ -187,7 +190,7 @@ class TDTestCase:
time.sleep(0.1)
tdSql.query(" show {}.stables ".format(self.db_name))
reading = threading.Thread(target = self.loop_query_constantly, args=(1000,self.db_name , self.tb_nums , self.row_nums))
reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums))
reading.start()
writing.join()
......
......@@ -29,7 +29,7 @@ class TDTestCase:
self.replica = 3
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 1000
self.row_nums = 500
self.max_restart_time = 20
self.restart_server_times = 10
self.dnode_index = 0
......@@ -312,6 +312,7 @@ class TDTestCase:
tdLog.notice(" === this is {}_th restart taosd === ".format(loop_time))
# begin start dnode
start = time.time()
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK(newTdSql)
time.sleep(5)
......
......@@ -163,10 +163,25 @@ class TDTestCase:
tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname))
def _get_stop_dnode_id(self , dbname , dnode_role):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
......
......@@ -162,11 +162,25 @@ class TDTestCase:
tdLog.notice(" ==== create database {} and insert rows execute end =====".format(dbname))
def _get_stop_dnode_id(self , dbname , dnode_role):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
......
......@@ -181,20 +181,34 @@ class TDTestCase:
tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self , dbname , role):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role == role:
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self ,newTdSql ):
......
......@@ -221,20 +221,35 @@ class TDTestCase:
tdLog.debug(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self , dbname , dnode_role):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if dnode_role == role:
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self ,newTdSql):
......
......@@ -221,19 +221,34 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='follower':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self ,newTdSql):
......@@ -376,7 +391,7 @@ class TDTestCase:
stablename = 'stable_{}'.format(loop)
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name)
self.stop_dnode_id = self._get_stop_dnode_id(db_name ,"follower")
# print("dnode_id:" , self.stop_dnode_id )
# check rows of datas
......@@ -423,7 +438,7 @@ class TDTestCase:
newTdSql=tdCom.newTdSql()
start = time.time()
tdDnodes=cluster.dnodes
self.stop_dnode_id = self._get_stop_dnode_id(dbname)
self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower")
# print("dnode_id:" , self.stop_dnode_id )
# begin restart dnode
tdDnodes[self.stop_dnode_id-1].stoptaosd()
......
......@@ -221,25 +221,40 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='follower':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
def wait_stop_dnode_OK(self , newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
......@@ -259,10 +274,10 @@ class TDTestCase:
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self):
def wait_start_dnode_OK(self , newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
dnode_infos = newTdSql.queryResult
......@@ -370,12 +385,13 @@ class TDTestCase:
def sync_run_case(self):
# stop follower and insert datas , update tables and create new stables
tdDnodes=cluster.dnodes
newTdSql=tdCom.newTdSql()
for loop in range(self.loop_restart_times):
db_name = "sync_db_{}".format(loop)
stablename = 'stable_{}'.format(loop)
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name)
self.stop_dnode_id = self._get_stop_dnode_id(db_name,"follower")
# check rows of datas
......@@ -385,7 +401,7 @@ class TDTestCase:
start = time.time()
tdDnodes[self.stop_dnode_id-1].forcestop()
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
# append rows of stablename when dnode stop
......@@ -403,7 +419,7 @@ class TDTestCase:
# begin start dnode
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end -start)
if time_cost > self.max_restart_time:
......@@ -420,17 +436,21 @@ class TDTestCase:
def _restart_dnode_of_db_unsync(dbname):
start = time.time()
tdDnodes=cluster.dnodes
self.stop_dnode_id = self._get_stop_dnode_id(dbname)
newTdSql=tdCom.newTdSql()
self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower")
# print(self.stop_dnode_id)
while not self.stop_dnode_id:
# print(self.stop_dnode_id)
time.sleep(0.5)
self.stop_dnode_id = self._get_stop_dnode_id(dbname)
self.stop_dnode_id = self._get_stop_dnode_id(dbname,"follower")
# begin restart dnode
# force stop taosd by kill -9
self.force_stop_dnode(self.stop_dnode_id)
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
os.system(" taos -s 'show dnodes;' ")
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end-start)
......
......@@ -177,26 +177,40 @@ class TDTestCase:
continue
def _get_stop_dnode_id(self,dbname):
newTdSql=tdCom.newTdSql()
newTdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = newTdSql.queryResult
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='leader':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
def wait_stop_dnode_OK(self , newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
......@@ -216,10 +230,10 @@ class TDTestCase:
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self):
def wait_start_dnode_OK(self,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
dnode_infos = newTdSql.queryResult
......@@ -316,7 +330,7 @@ class TDTestCase:
tdLog.debug(" === database {} has write {} rows at least ====".format(dbname,total_rows/10))
self.stop_dnode_id = self._get_stop_dnode_id(dbname)
self.stop_dnode_id = self._get_stop_dnode_id(dbname ,"leader")
# prepare stop leader of database
before_leader_infos = self.get_leader_infos(dbname)
......
......@@ -304,26 +304,40 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
newTdSql=tdCom.newTdSql()
newTdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = newTdSql.queryResult
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='leader':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
def wait_stop_dnode_OK(self ,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
......@@ -343,10 +357,10 @@ class TDTestCase:
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self):
def wait_start_dnode_OK(self,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
dnode_infos = newTdSql.queryResult
......@@ -421,12 +435,13 @@ class TDTestCase:
def sync_run_case(self):
# stop follower and insert datas , update tables and create new stables
tdDnodes=cluster.dnodes
newTdSql=tdCom.newTdSql()
for loop in range(self.loop_restart_times):
db_name = "sync_db_{}".format(loop)
stablename = 'stable_{}'.format(loop)
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name)
self.stop_dnode_id = self._get_stop_dnode_id(db_name ,"leader")
# check rows of datas
......@@ -439,7 +454,7 @@ class TDTestCase:
# force stop taosd by kill -9
self.force_stop_dnode(self.stop_dnode_id)
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
# vote leaders check
......@@ -474,7 +489,7 @@ class TDTestCase:
# begin start dnode
start = time.time()
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end -start)
if time_cost > self.max_restart_time:
......@@ -491,14 +506,15 @@ class TDTestCase:
def _restart_dnode_of_db_unsync(dbname):
tdDnodes=cluster.dnodes
self.stop_dnode_id = self._get_stop_dnode_id(dbname)
newTdSql=tdCom.newTdSql()
self.stop_dnode_id = self._get_stop_dnode_id(dbname ,"leader" )
# begin restart dnode
# force stop taosd by kill -9
# get leader info before stop
before_leader_infos = self.get_leader_infos(db_name)
self.force_stop_dnode(self.stop_dnode_id)
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
# check revote leader when restart servers
# get leader info after stop
......@@ -530,7 +546,7 @@ class TDTestCase:
tdDnodes[self.stop_dnode_id-1].starttaosd()
start = time.time()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end-start)
......
......@@ -30,6 +30,7 @@ class TDTestCase:
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 2000
self.query_times = 100
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
......@@ -160,8 +161,8 @@ class TDTestCase:
def check_insert_status(self, dbname, tb_nums , row_nums):
newTdSql=tdCom.newTdSql()
def check_insert_status(self,newTdSql , dbname, tb_nums , row_nums):
# newTdSql=tdCom.newTdSql()
newTdSql.execute("use {}".format(dbname))
newTdSql.query("select count(*) from {}.{}".format(dbname,'stb1'))
# tdSql.checkData(0 , 0 , tb_nums*row_nums)
......@@ -175,12 +176,12 @@ class TDTestCase:
self.check_insert_status( db_name, tb_nums , row_nums)
def loop_create_databases(self, times , tb_nums , row_nums):
newTdSql=tdCom.newTdSql()
for loop_time in range(times):
tdLog.debug(" === create database and insert datas is going ,this is {}_th create === ".format(loop_time))
db_name = 'loop_db_{}'.format(loop_time)
self.create_db_replica_3_insertdatas(db_name , self.replica , self.vgroups , tb_nums , row_nums)
self.check_insert_status( db_name, tb_nums , row_nums)
self.check_insert_status( newTdSql ,db_name, tb_nums , row_nums)
def run(self):
self.check_setup_cluster_status()
......@@ -199,7 +200,7 @@ class TDTestCase:
time.sleep(0.1)
tdSql.query(" show {}.stables ".format(self.db_name))
reading = threading.Thread(target = self.loop_query_constantly, args=(1000,self.db_name , self.tb_nums , self.row_nums))
reading = threading.Thread(target = self.loop_query_constantly, args=(self.query_times,self.db_name , self.tb_nums , self.row_nums))
reading.start()
create_db = threading.Thread(target = self.loop_create_databases, args=(10, 10 , 10))
......
......@@ -182,25 +182,40 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='follower':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
def wait_stop_dnode_OK(self ,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
......@@ -220,10 +235,10 @@ class TDTestCase:
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self):
def wait_start_dnode_OK(self ,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
dnode_infos = newTdSql.queryResult
......@@ -372,6 +387,7 @@ class TDTestCase:
def stop_follower_when_query_going(self):
tdDnodes = cluster.dnodes
newTdSql=tdCom.newTdSql()
self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums)
......@@ -381,13 +397,13 @@ class TDTestCase:
# force stop follower
for loop in range(self.loop_restart_times):
tdLog.debug(" ==== this is {}_th restart follower of database {} ==== ".format(loop ,self.db_name))
self.stop_dnode_id = self._get_stop_dnode_id(self.db_name)
self.stop_dnode_id = self._get_stop_dnode_id(self.db_name,"follower" )
tdDnodes[self.stop_dnode_id-1].stoptaosd()
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
start = time.time()
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end-start)
......
......@@ -182,19 +182,34 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='follower':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
......
......@@ -182,19 +182,34 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='leader':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self,newTdSql):
......
......@@ -182,25 +182,40 @@ class TDTestCase:
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1
def _get_stop_dnode_id(self,dbname):
def _get_stop_dnode_id(self,dbname ,dnode_role):
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
status = False
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
while status!=True :
time.sleep(0.1)
tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos:
if "error" not in vgroup_info:
status = True
else:
status = False
# print(status)
for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4]
# print(vgroup_info)
for ind ,role in enumerate(leader_infos):
if role =='leader':
if role == dnode_role:
# print(ind,leader_infos)
self.stop_dnode_id = leader_infos[ind-1]
break
return self.stop_dnode_id
def wait_stop_dnode_OK(self):
def wait_stop_dnode_OK(self ,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
......@@ -242,10 +257,10 @@ class TDTestCase:
break
return check_status
def wait_start_dnode_OK(self):
def wait_start_dnode_OK(self ,newTdSql):
def _get_status():
newTdSql=tdCom.newTdSql()
# newTdSql=tdCom.newTdSql()
status = ""
newTdSql.query("show dnodes")
dnode_infos = newTdSql.queryResult
......@@ -406,6 +421,7 @@ class TDTestCase:
def stop_follower_when_query_going(self):
tdDnodes = cluster.dnodes
newTdSql=tdCom.newTdSql()
self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums)
......@@ -419,7 +435,7 @@ class TDTestCase:
# get leader info before stop
before_leader_infos = self.get_leader_infos(self.db_name)
self.stop_dnode_id = self._get_stop_dnode_id(self.db_name)
self.stop_dnode_id = self._get_stop_dnode_id(self.db_name ,"leader")
self.force_stop_dnode(self.stop_dnode_id)
......@@ -437,11 +453,11 @@ class TDTestCase:
time_cost = end - start
tdLog.debug(" ==== revote leader of database {} cost time {} ====".format(self.db_name , time_cost))
self.wait_stop_dnode_OK()
self.wait_stop_dnode_OK(newTdSql)
start = time.time()
tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK()
self.wait_start_dnode_OK(newTdSql)
end = time.time()
time_cost = int(end-start)
......
......@@ -19,4 +19,28 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
# test case of vnode
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower.py  -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_follower_force_stop.py  -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_querydatas_stop_leader_force_stop.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py -N 4 -M 1
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py   -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.py -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M
python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py -N 4 -M 1
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册