fix test cases
This commit is contained in:
parent
04cacef2a3
commit
1fbbd30af3
|
@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -26,9 +26,9 @@ class TDTestCase:
|
||||||
self.dnode_list = {}
|
self.dnode_list = {}
|
||||||
self.ts = 1483200000000
|
self.ts = 1483200000000
|
||||||
self.db_name ='testdb'
|
self.db_name ='testdb'
|
||||||
self.replica = 1
|
self.replica = 1
|
||||||
self.vgroups = 2
|
self.vgroups = 2
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.row_nums = 100
|
self.row_nums = 100
|
||||||
|
|
||||||
def getBuildPath(self):
|
def getBuildPath(self):
|
||||||
|
@ -101,7 +101,7 @@ class TDTestCase:
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(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(5):
|
for i in range(5):
|
||||||
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
||||||
tdSql.query("show stables")
|
tdSql.query("show stables")
|
||||||
|
@ -145,7 +145,7 @@ class TDTestCase:
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(tb_nums):
|
for i in range(tb_nums):
|
||||||
sub_tbname = "sub_tb_{}".format(i)
|
sub_tbname = "sub_tb_{}".format(i)
|
||||||
tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i))
|
tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i))
|
||||||
|
@ -164,7 +164,7 @@ class TDTestCase:
|
||||||
tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1'))
|
tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1'))
|
||||||
tdSql.checkRows(tb_nums)
|
tdSql.checkRows(tb_nums)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.check_setup_cluster_status()
|
self.check_setup_cluster_status()
|
||||||
self.create_db_check_vgroups()
|
self.create_db_check_vgroups()
|
||||||
self.create_db_replica_1_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)
|
self.create_db_replica_1_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)
|
||||||
|
@ -176,4 +176,4 @@ class TDTestCase:
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
|
@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -30,9 +30,9 @@ class TDTestCase:
|
||||||
self.ts = 1483200000000
|
self.ts = 1483200000000
|
||||||
self.ts_step =1000
|
self.ts_step =1000
|
||||||
self.db_name ='testdb'
|
self.db_name ='testdb'
|
||||||
self.replica = 3
|
self.replica = 3
|
||||||
self.vgroups = 1
|
self.vgroups = 1
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.row_nums = 100
|
self.row_nums = 100
|
||||||
self.stop_dnode_id = None
|
self.stop_dnode_id = None
|
||||||
self.loop_restart_times = 5
|
self.loop_restart_times = 5
|
||||||
|
@ -110,7 +110,7 @@ class TDTestCase:
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(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(5):
|
for i in range(5):
|
||||||
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
||||||
tdSql.query("show stables")
|
tdSql.query("show stables")
|
||||||
|
@ -142,7 +142,7 @@ class TDTestCase:
|
||||||
tdSql.execute(drop_db_sql)
|
tdSql.execute(drop_db_sql)
|
||||||
tdSql.execute(create_db_sql)
|
tdSql.execute(create_db_sql)
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
|
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
@ -151,7 +151,7 @@ class TDTestCase:
|
||||||
tags (t1 int)
|
tags (t1 int)
|
||||||
'''.format(stablename)
|
'''.format(stablename)
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(tb_nums):
|
for i in range(tb_nums):
|
||||||
sub_tbname = "sub_{}_{}".format(stablename,i)
|
sub_tbname = "sub_{}_{}".format(stablename,i)
|
||||||
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
|
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
|
||||||
|
@ -162,11 +162,11 @@ class TDTestCase:
|
||||||
tdSql.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) ")
|
tdSql.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) ")
|
||||||
|
|
||||||
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
|
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
|
||||||
|
|
||||||
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
|
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
|
||||||
|
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
for row_num in range(append_nums):
|
for row_num in range(append_nums):
|
||||||
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
||||||
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
||||||
|
@ -174,9 +174,9 @@ class TDTestCase:
|
||||||
os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename))
|
os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename))
|
||||||
|
|
||||||
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
|
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
|
||||||
|
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
||||||
|
|
||||||
while not tdSql.queryResult:
|
while not tdSql.queryResult:
|
||||||
|
@ -184,8 +184,8 @@ class TDTestCase:
|
||||||
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
||||||
|
|
||||||
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
while not status_OK :
|
while not status_OK :
|
||||||
if count > self.try_check_times:
|
if count > self.try_check_times:
|
||||||
os.system("taos -s ' show {}.vgroups; '".format(dbname))
|
os.system("taos -s ' show {}.vgroups; '".format(dbname))
|
||||||
|
@ -199,14 +199,14 @@ class TDTestCase:
|
||||||
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
||||||
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
|
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
||||||
while not tdSql.queryResult:
|
while not tdSql.queryResult:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
||||||
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
||||||
count = 0
|
count = 0
|
||||||
while not status_OK :
|
while not status_OK :
|
||||||
if count > self.try_check_times:
|
if count > self.try_check_times:
|
||||||
os.system("taos -s ' show {}.vgroups;'".format(dbname))
|
os.system("taos -s ' show {}.vgroups;'".format(dbname))
|
||||||
|
@ -220,12 +220,12 @@ class TDTestCase:
|
||||||
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
||||||
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
|
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
def _get_stop_dnode_id(self,dbname):
|
def _get_stop_dnode_id(self,dbname):
|
||||||
tdSql.query("show {}.vgroups".format(dbname))
|
tdSql.query("show {}.vgroups".format(dbname))
|
||||||
vgroup_infos = tdSql.queryResult
|
vgroup_infos = tdSql.queryResult
|
||||||
for vgroup_info in vgroup_infos:
|
for vgroup_info in vgroup_infos:
|
||||||
leader_infos = vgroup_info[3:-4]
|
leader_infos = vgroup_info[3:-4]
|
||||||
# print(vgroup_info)
|
# print(vgroup_info)
|
||||||
for ind ,role in enumerate(leader_infos):
|
for ind ,role in enumerate(leader_infos):
|
||||||
if role =='follower':
|
if role =='follower':
|
||||||
|
@ -237,7 +237,7 @@ class TDTestCase:
|
||||||
return self.stop_dnode_id
|
return self.stop_dnode_id
|
||||||
|
|
||||||
def wait_stop_dnode_OK(self):
|
def wait_stop_dnode_OK(self):
|
||||||
|
|
||||||
def _get_status():
|
def _get_status():
|
||||||
newTdSql=tdCom.newTdSql()
|
newTdSql=tdCom.newTdSql()
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class TDTestCase:
|
||||||
if id == self.stop_dnode_id:
|
if id == self.stop_dnode_id:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="offline":
|
while status !="offline":
|
||||||
|
@ -260,7 +260,7 @@ class TDTestCase:
|
||||||
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
|
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):
|
||||||
|
|
||||||
def _get_status():
|
def _get_status():
|
||||||
newTdSql=tdCom.newTdSql()
|
newTdSql=tdCom.newTdSql()
|
||||||
status = ""
|
status = ""
|
||||||
|
@ -272,7 +272,7 @@ class TDTestCase:
|
||||||
if id == self.stop_dnode_id:
|
if id == self.stop_dnode_id:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="ready":
|
while status !="ready":
|
||||||
|
@ -366,7 +366,7 @@ class TDTestCase:
|
||||||
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
|
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
|
||||||
check_status = False
|
check_status = False
|
||||||
return check_status
|
return check_status
|
||||||
|
|
||||||
def sync_run_case(self):
|
def sync_run_case(self):
|
||||||
# stop follower and insert datas , update tables and create new stables
|
# stop follower and insert datas , update tables and create new stables
|
||||||
tdDnodes=cluster.dnodes
|
tdDnodes=cluster.dnodes
|
||||||
|
@ -376,19 +376,19 @@ class TDTestCase:
|
||||||
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
|
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.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)
|
||||||
|
|
||||||
# check rows of datas
|
# check rows of datas
|
||||||
|
|
||||||
self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
||||||
|
|
||||||
# begin stop dnode
|
# begin stop dnode
|
||||||
start = time.time()
|
start = time.time()
|
||||||
tdDnodes[self.stop_dnode_id-1].stoptaosd()
|
tdDnodes[self.stop_dnode_id-1].stoptaosd()
|
||||||
|
|
||||||
self.wait_stop_dnode_OK()
|
self.wait_stop_dnode_OK()
|
||||||
|
|
||||||
# append rows of stablename when dnode stop
|
# append rows of stablename when dnode stop
|
||||||
|
|
||||||
tbname = "sub_{}_{}".format(stablename , 0)
|
tbname = "sub_{}_{}".format(stablename , 0)
|
||||||
tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id))
|
tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id))
|
||||||
self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 )
|
self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 )
|
||||||
|
@ -401,20 +401,20 @@ class TDTestCase:
|
||||||
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
|
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
|
||||||
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
||||||
|
|
||||||
# begin start dnode
|
# begin start dnode
|
||||||
tdDnodes[self.stop_dnode_id-1].starttaosd()
|
tdDnodes[self.stop_dnode_id-1].starttaosd()
|
||||||
self.wait_start_dnode_OK()
|
self.wait_start_dnode_OK()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
time_cost = int(end -start)
|
time_cost = int(end -start)
|
||||||
if time_cost > self.max_restart_time:
|
if time_cost > self.max_restart_time:
|
||||||
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
||||||
|
|
||||||
# create new stables again
|
# create new stables again
|
||||||
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
||||||
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
|
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
|
||||||
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
||||||
self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
||||||
|
|
||||||
def unsync_run_case(self):
|
def unsync_run_case(self):
|
||||||
|
|
||||||
def _restart_dnode_of_db_unsync(dbname):
|
def _restart_dnode_of_db_unsync(dbname):
|
||||||
|
@ -428,18 +428,18 @@ class TDTestCase:
|
||||||
self.wait_start_dnode_OK()
|
self.wait_start_dnode_OK()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
time_cost = int(end-start)
|
time_cost = int(end-start)
|
||||||
|
|
||||||
if time_cost > self.max_restart_time:
|
if time_cost > self.max_restart_time:
|
||||||
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
||||||
|
|
||||||
|
|
||||||
def _create_threading(dbname):
|
def _create_threading(dbname):
|
||||||
self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,))
|
self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,))
|
||||||
return self.current_thread
|
return self.current_thread
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
|
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
|
||||||
'''
|
'''
|
||||||
tdDnodes=cluster.dnodes
|
tdDnodes=cluster.dnodes
|
||||||
for loop in range(self.loop_restart_times):
|
for loop in range(self.loop_restart_times):
|
||||||
|
@ -450,7 +450,7 @@ class TDTestCase:
|
||||||
|
|
||||||
tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name))
|
tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name))
|
||||||
|
|
||||||
# create sync threading and start it
|
# create sync threading and start it
|
||||||
self.current_thread = _create_threading(db_name)
|
self.current_thread = _create_threading(db_name)
|
||||||
self.current_thread.start()
|
self.current_thread.start()
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ class TDTestCase:
|
||||||
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
|
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
|
||||||
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
|
||||||
|
|
||||||
# create new stables again
|
# create new stables again
|
||||||
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
||||||
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
|
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
|
||||||
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
|
||||||
|
@ -478,7 +478,7 @@ class TDTestCase:
|
||||||
self.current_thread.join()
|
self.current_thread.join()
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# basic insert and check of cluster
|
# basic insert and check of cluster
|
||||||
self.check_setup_cluster_status()
|
self.check_setup_cluster_status()
|
||||||
|
@ -486,7 +486,7 @@ class TDTestCase:
|
||||||
# self.sync_run_case()
|
# self.sync_run_case()
|
||||||
self.unsync_run_case()
|
self.unsync_run_case()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
@ -494,4 +494,4 @@ class TDTestCase:
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
|
@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -30,9 +30,9 @@ class TDTestCase:
|
||||||
self.ts = 1483200000000
|
self.ts = 1483200000000
|
||||||
self.ts_step =1000
|
self.ts_step =1000
|
||||||
self.db_name ='testdb'
|
self.db_name ='testdb'
|
||||||
self.replica = 3
|
self.replica = 3
|
||||||
self.vgroups = 1
|
self.vgroups = 1
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.row_nums = 100
|
self.row_nums = 100
|
||||||
self.stop_dnode_id = None
|
self.stop_dnode_id = None
|
||||||
self.loop_restart_times = 5
|
self.loop_restart_times = 5
|
||||||
|
@ -40,7 +40,7 @@ class TDTestCase:
|
||||||
self.max_restart_time = 10
|
self.max_restart_time = 10
|
||||||
self.try_check_times = 10
|
self.try_check_times = 10
|
||||||
self.query_times = 100
|
self.query_times = 100
|
||||||
|
|
||||||
|
|
||||||
def getBuildPath(self):
|
def getBuildPath(self):
|
||||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
@ -103,7 +103,7 @@ class TDTestCase:
|
||||||
tdSql.execute(drop_db_sql)
|
tdSql.execute(drop_db_sql)
|
||||||
tdSql.execute(create_db_sql)
|
tdSql.execute(create_db_sql)
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
|
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
@ -112,7 +112,7 @@ class TDTestCase:
|
||||||
tags (t1 int)
|
tags (t1 int)
|
||||||
'''.format(stablename)
|
'''.format(stablename)
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(tb_nums):
|
for i in range(tb_nums):
|
||||||
sub_tbname = "sub_{}_{}".format(stablename,i)
|
sub_tbname = "sub_{}_{}".format(stablename,i)
|
||||||
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
|
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
|
||||||
|
@ -123,11 +123,11 @@ class TDTestCase:
|
||||||
tdSql.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) ")
|
tdSql.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) ")
|
||||||
|
|
||||||
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
|
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
|
||||||
|
|
||||||
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
|
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
|
||||||
|
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
for row_num in range(append_nums):
|
for row_num in range(append_nums):
|
||||||
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
||||||
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
|
||||||
|
@ -137,7 +137,7 @@ class TDTestCase:
|
||||||
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
|
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
|
||||||
|
|
||||||
tdSql.execute("use {}".format(dbname))
|
tdSql.execute("use {}".format(dbname))
|
||||||
|
|
||||||
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
||||||
|
|
||||||
while not tdSql.queryResult:
|
while not tdSql.queryResult:
|
||||||
|
@ -145,8 +145,8 @@ class TDTestCase:
|
||||||
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
|
||||||
|
|
||||||
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
while not status_OK :
|
while not status_OK :
|
||||||
if count > self.try_check_times:
|
if count > self.try_check_times:
|
||||||
os.system("taos -s ' show {}.vgroups; '".format(dbname))
|
os.system("taos -s ' show {}.vgroups; '".format(dbname))
|
||||||
|
@ -160,14 +160,14 @@ class TDTestCase:
|
||||||
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
|
||||||
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
|
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
||||||
while not tdSql.queryResult:
|
while not tdSql.queryResult:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
|
||||||
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
|
||||||
count = 0
|
count = 0
|
||||||
while not status_OK :
|
while not status_OK :
|
||||||
if count > self.try_check_times:
|
if count > self.try_check_times:
|
||||||
os.system("taos -s ' show {}.vgroups;'".format(dbname))
|
os.system("taos -s ' show {}.vgroups;'".format(dbname))
|
||||||
|
@ -186,7 +186,7 @@ class TDTestCase:
|
||||||
tdSql.query("show {}.vgroups".format(dbname))
|
tdSql.query("show {}.vgroups".format(dbname))
|
||||||
vgroup_infos = tdSql.queryResult
|
vgroup_infos = tdSql.queryResult
|
||||||
for vgroup_info in vgroup_infos:
|
for vgroup_info in vgroup_infos:
|
||||||
leader_infos = vgroup_info[3:-4]
|
leader_infos = vgroup_info[3:-4]
|
||||||
# print(vgroup_info)
|
# print(vgroup_info)
|
||||||
for ind ,role in enumerate(leader_infos):
|
for ind ,role in enumerate(leader_infos):
|
||||||
if role =='follower':
|
if role =='follower':
|
||||||
|
@ -198,7 +198,7 @@ class TDTestCase:
|
||||||
return self.stop_dnode_id
|
return self.stop_dnode_id
|
||||||
|
|
||||||
def wait_stop_dnode_OK(self):
|
def wait_stop_dnode_OK(self):
|
||||||
|
|
||||||
def _get_status():
|
def _get_status():
|
||||||
newTdSql=tdCom.newTdSql()
|
newTdSql=tdCom.newTdSql()
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class TDTestCase:
|
||||||
if id == self.stop_dnode_id:
|
if id == self.stop_dnode_id:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="offline":
|
while status !="offline":
|
||||||
|
@ -221,7 +221,7 @@ class TDTestCase:
|
||||||
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
|
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):
|
||||||
|
|
||||||
def _get_status():
|
def _get_status():
|
||||||
newTdSql=tdCom.newTdSql()
|
newTdSql=tdCom.newTdSql()
|
||||||
status = ""
|
status = ""
|
||||||
|
@ -233,7 +233,7 @@ class TDTestCase:
|
||||||
if id == self.stop_dnode_id:
|
if id == self.stop_dnode_id:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="ready":
|
while status !="ready":
|
||||||
|
@ -327,7 +327,7 @@ class TDTestCase:
|
||||||
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
|
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
|
||||||
check_status = False
|
check_status = False
|
||||||
return check_status
|
return check_status
|
||||||
|
|
||||||
|
|
||||||
def force_stop_dnode(self, dnode_id ):
|
def force_stop_dnode(self, dnode_id ):
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ class TDTestCase:
|
||||||
port = None
|
port = None
|
||||||
for dnode_info in tdSql.queryResult:
|
for dnode_info in tdSql.queryResult:
|
||||||
if dnode_id == dnode_info[0]:
|
if dnode_id == dnode_info[0]:
|
||||||
port = dnode_info[1].split(":")[-1]
|
port = dnode_info[1].split(":")[-1]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
@ -349,9 +349,9 @@ class TDTestCase:
|
||||||
os.system(ps_kill_taosd)
|
os.system(ps_kill_taosd)
|
||||||
|
|
||||||
def basic_query_task(self,dbname ,stablename):
|
def basic_query_task(self,dbname ,stablename):
|
||||||
|
|
||||||
sql = "select * from {}.{} ;".format(dbname , stablename)
|
sql = "select * from {}.{} ;".format(dbname , stablename)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
while count < self.query_times:
|
while count < self.query_times:
|
||||||
os.system(''' taos -s '{}' >>/dev/null '''.format(sql))
|
os.system(''' taos -s '{}' >>/dev/null '''.format(sql))
|
||||||
|
@ -364,18 +364,18 @@ class TDTestCase:
|
||||||
self.thread_list.append(task)
|
self.thread_list.append(task)
|
||||||
|
|
||||||
for thread in self.thread_list:
|
for thread in self.thread_list:
|
||||||
|
|
||||||
thread.start()
|
thread.start()
|
||||||
return self.thread_list
|
return self.thread_list
|
||||||
|
|
||||||
|
|
||||||
def stop_follower_when_query_going(self):
|
def stop_follower_when_query_going(self):
|
||||||
|
|
||||||
tdDnodes = cluster.dnodes
|
tdDnodes = cluster.dnodes
|
||||||
self.create_database(dbname = self.db_name ,replica_num= self.replica , vgroup_nums= 1)
|
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)
|
self.create_stable_insert_datas(dbname = self.db_name , stablename = "stb1" , tb_nums= self.tb_nums ,row_nums= self.row_nums)
|
||||||
|
|
||||||
# let query task start
|
# let query task start
|
||||||
self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' )
|
self.thread_list = self.multi_thread_query_task(10 ,self.db_name ,'stb1' )
|
||||||
|
|
||||||
# force stop follower
|
# force stop follower
|
||||||
|
@ -390,22 +390,22 @@ class TDTestCase:
|
||||||
self.wait_start_dnode_OK()
|
self.wait_start_dnode_OK()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
time_cost = int(end-start)
|
time_cost = int(end-start)
|
||||||
|
|
||||||
if time_cost > self.max_restart_time:
|
if time_cost > self.max_restart_time:
|
||||||
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
|
||||||
|
|
||||||
for thread in self.thread_list:
|
for thread in self.thread_list:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# basic check of cluster
|
# basic check of cluster
|
||||||
self.check_setup_cluster_status()
|
self.check_setup_cluster_status()
|
||||||
self.stop_follower_when_query_going()
|
self.stop_follower_when_query_going()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
@ -413,4 +413,4 @@ class TDTestCase:
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
|
@ -4,7 +4,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -13,7 +13,7 @@ from util.dnodes import TDDnodes
|
||||||
from util.dnodes import TDDnode
|
from util.dnodes import TDDnode
|
||||||
from util.cluster import *
|
from util.cluster import *
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -27,9 +27,9 @@ class TDTestCase:
|
||||||
self.dnode_list = {}
|
self.dnode_list = {}
|
||||||
self.ts = 1483200000000
|
self.ts = 1483200000000
|
||||||
self.db_name ='testdb'
|
self.db_name ='testdb'
|
||||||
self.replica = 1
|
self.replica = 1
|
||||||
self.vgroups = 2
|
self.vgroups = 2
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.row_nums = 100
|
self.row_nums = 100
|
||||||
self.max_vote_time_cost = 10 # seconds
|
self.max_vote_time_cost = 10 # seconds
|
||||||
self.stop_dnode = None
|
self.stop_dnode = None
|
||||||
|
@ -104,7 +104,7 @@ class TDTestCase:
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(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(5):
|
for i in range(5):
|
||||||
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
|
||||||
tdSql.query("show stables")
|
tdSql.query("show stables")
|
||||||
|
@ -133,7 +133,7 @@ class TDTestCase:
|
||||||
self.stop_dnode = random.sample(only_dnode_list , 1 )[0]
|
self.stop_dnode = random.sample(only_dnode_list , 1 )[0]
|
||||||
return self.stop_dnode
|
return self.stop_dnode
|
||||||
|
|
||||||
|
|
||||||
def check_vgroups_revote_leader(self,dbname):
|
def check_vgroups_revote_leader(self,dbname):
|
||||||
|
|
||||||
status = True
|
status = True
|
||||||
|
@ -145,7 +145,7 @@ class TDTestCase:
|
||||||
vgroup_status = []
|
vgroup_status = []
|
||||||
vgroups_leader_follower = vgroup_info[3:-4]
|
vgroups_leader_follower = vgroup_info[3:-4]
|
||||||
for ind , role in enumerate(vgroups_leader_follower):
|
for ind , role in enumerate(vgroups_leader_follower):
|
||||||
|
|
||||||
if ind%2==0:
|
if ind%2==0:
|
||||||
if role == stop_dnode_id and vgroups_leader_follower[ind+1]=="offline":
|
if role == stop_dnode_id and vgroups_leader_follower[ind+1]=="offline":
|
||||||
tdLog.notice("====== dnode {} has offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode))
|
tdLog.notice("====== dnode {} has offline , endpoint is {}".format(stop_dnode_id , self.stop_dnode))
|
||||||
|
@ -174,7 +174,7 @@ class TDTestCase:
|
||||||
if endpoint == self.stop_dnode:
|
if endpoint == self.stop_dnode:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="offline":
|
while status !="offline":
|
||||||
|
@ -184,7 +184,7 @@ class TDTestCase:
|
||||||
tdLog.notice("==== stop_dnode has stopped , endpoint is {}".format(self.stop_dnode))
|
tdLog.notice("==== stop_dnode has stopped , endpoint is {}".format(self.stop_dnode))
|
||||||
|
|
||||||
def wait_start_dnode_OK(self):
|
def wait_start_dnode_OK(self):
|
||||||
|
|
||||||
def _get_status():
|
def _get_status():
|
||||||
|
|
||||||
status = ""
|
status = ""
|
||||||
|
@ -196,7 +196,7 @@ class TDTestCase:
|
||||||
if endpoint == self.stop_dnode:
|
if endpoint == self.stop_dnode:
|
||||||
status = dnode_status
|
status = dnode_status
|
||||||
break
|
break
|
||||||
return status
|
return status
|
||||||
|
|
||||||
status = _get_status()
|
status = _get_status()
|
||||||
while status !="ready":
|
while status !="ready":
|
||||||
|
@ -205,8 +205,8 @@ class TDTestCase:
|
||||||
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
|
# tdLog.notice("==== stop dnode has not been stopped , endpoint is {}".format(self.stop_dnode))
|
||||||
tdLog.notice("==== stop_dnode has restart , endpoint is {}".format(self.stop_dnode))
|
tdLog.notice("==== stop_dnode has restart , endpoint is {}".format(self.stop_dnode))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def random_stop_One_dnode(self):
|
def random_stop_One_dnode(self):
|
||||||
self.stop_dnode = self._get_stop_dnode()
|
self.stop_dnode = self._get_stop_dnode()
|
||||||
stop_dnode_id = self.dnode_list[self.stop_dnode][0]
|
stop_dnode_id = self.dnode_list[self.stop_dnode][0]
|
||||||
|
@ -217,7 +217,7 @@ class TDTestCase:
|
||||||
# os.system("taos -s 'show dnodes;'")
|
# os.system("taos -s 'show dnodes;'")
|
||||||
|
|
||||||
def Restart_stop_dnode(self):
|
def Restart_stop_dnode(self):
|
||||||
|
|
||||||
tdDnodes=cluster.dnodes
|
tdDnodes=cluster.dnodes
|
||||||
stop_dnode_id = self.dnode_list[self.stop_dnode][0]
|
stop_dnode_id = self.dnode_list[self.stop_dnode][0]
|
||||||
tdDnodes[stop_dnode_id-1].starttaosd()
|
tdDnodes[stop_dnode_id-1].starttaosd()
|
||||||
|
@ -225,7 +225,7 @@ class TDTestCase:
|
||||||
# os.system("taos -s 'show dnodes;'")
|
# os.system("taos -s 'show dnodes;'")
|
||||||
|
|
||||||
def check_vgroups_init_done(self,dbname):
|
def check_vgroups_init_done(self,dbname):
|
||||||
|
|
||||||
status = True
|
status = True
|
||||||
|
|
||||||
tdSql.query("show {}.vgroups".format(dbname))
|
tdSql.query("show {}.vgroups".format(dbname))
|
||||||
|
@ -233,7 +233,7 @@ class TDTestCase:
|
||||||
vgroup_id = vgroup_info[0]
|
vgroup_id = vgroup_info[0]
|
||||||
vgroup_status = []
|
vgroup_status = []
|
||||||
for ind , role in enumerate(vgroup_info[3:-4]):
|
for ind , role in enumerate(vgroup_info[3:-4]):
|
||||||
|
|
||||||
if ind%2==0:
|
if ind%2==0:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -249,7 +249,7 @@ class TDTestCase:
|
||||||
while not status:
|
while not status:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
status = self.check_vgroups_init_done(dbname)
|
status = self.check_vgroups_init_done(dbname)
|
||||||
|
|
||||||
# tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
|
# tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
|
||||||
end = time.time()
|
end = time.time()
|
||||||
cost_time = end - start
|
cost_time = end - start
|
||||||
|
@ -257,10 +257,10 @@ class TDTestCase:
|
||||||
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
|
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
|
||||||
if cost_time >= self.max_vote_time_cost:
|
if cost_time >= self.max_vote_time_cost:
|
||||||
tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) )
|
tdLog.exit(" ==== database %s vote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) )
|
||||||
|
|
||||||
return cost_time
|
return cost_time
|
||||||
|
|
||||||
|
|
||||||
def revote_leader_time_costs(self,dbname):
|
def revote_leader_time_costs(self,dbname):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class TDTestCase:
|
||||||
while not status:
|
while not status:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
status = self.check_vgroups_revote_leader(dbname)
|
status = self.check_vgroups_revote_leader(dbname)
|
||||||
|
|
||||||
# tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
|
# tdLog.notice("=== database {} show vgroups vote the leader is in progress ===".format(dbname))
|
||||||
end = time.time()
|
end = time.time()
|
||||||
cost_time = end - start
|
cost_time = end - start
|
||||||
|
@ -276,10 +276,10 @@ class TDTestCase:
|
||||||
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
|
# os.system("taos -s 'show {}.vgroups;'".format(dbname))
|
||||||
if cost_time >= self.max_vote_time_cost:
|
if cost_time >= self.max_vote_time_cost:
|
||||||
tdLog.exit(" ==== database %s revote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) )
|
tdLog.exit(" ==== database %s revote the leaders cost too large time , cost time is %.3f second ===="%(dbname,cost_time) )
|
||||||
|
|
||||||
|
|
||||||
return cost_time
|
return cost_time
|
||||||
|
|
||||||
def exec_revote_action(self,dbname):
|
def exec_revote_action(self,dbname):
|
||||||
|
|
||||||
tdSql.query("show {}.vgroups".format(dbname))
|
tdSql.query("show {}.vgroups".format(dbname))
|
||||||
|
@ -296,13 +296,13 @@ class TDTestCase:
|
||||||
after_vgroups = set()
|
after_vgroups = set()
|
||||||
for vgroup_info in after_revote:
|
for vgroup_info in after_revote:
|
||||||
after_vgroups.add(vgroup_info[3:-4])
|
after_vgroups.add(vgroup_info[3:-4])
|
||||||
|
|
||||||
vote_act = set(set(after_vgroups)-set(before_vgroups))
|
vote_act = set(set(after_vgroups)-set(before_vgroups))
|
||||||
if not vote_act:
|
if not vote_act:
|
||||||
tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====")
|
tdLog.exit(" ===maybe revote not occured , there is no dnode offline ====")
|
||||||
else:
|
else:
|
||||||
for vgroup_info in vote_act:
|
for vgroup_info in vote_act:
|
||||||
for ind , role in enumerate(vgroup_info):
|
for ind , role in enumerate(vgroup_info):
|
||||||
if role==self.dnode_list[self.stop_dnode][0]:
|
if role==self.dnode_list[self.stop_dnode][0]:
|
||||||
|
|
||||||
if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info:
|
if vgroup_info[ind+1] =="offline" and "leader" in vgroup_info:
|
||||||
|
@ -322,7 +322,7 @@ class TDTestCase:
|
||||||
tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ")
|
tdLog.notice(" ====start check time cost about vgroups vote leaders ==== ")
|
||||||
tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost))
|
tdLog.notice(" ==== current max time cost is set value : {} =======".format(self.max_vote_time_cost))
|
||||||
|
|
||||||
# create database replica 3 vgroups 1
|
# create database replica 3 vgroups 1
|
||||||
|
|
||||||
db1 = 'db_1'
|
db1 = 'db_1'
|
||||||
create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1)
|
create_db_replica_3_vgroups_1 = "create database {} replica 3 vgroups 1".format(db1)
|
||||||
|
@ -346,13 +346,13 @@ class TDTestCase:
|
||||||
tdSql.execute(create_db_replica_3_vgroups_100)
|
tdSql.execute(create_db_replica_3_vgroups_100)
|
||||||
self.vote_leader_time_costs(db3)
|
self.vote_leader_time_costs(db3)
|
||||||
self.exec_revote_action(db3)
|
self.exec_revote_action(db3)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
|
def run(self):
|
||||||
self.check_setup_cluster_status()
|
self.check_setup_cluster_status()
|
||||||
self.test_init_vgroups_time_costs()
|
self.test_init_vgroups_time_costs()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,4 +361,4 @@ class TDTestCase:
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
|
Loading…
Reference in New Issue