Merge pull request #17673 from taosdata/test/cluster_vnode

test: add test case about vnode for cluster
This commit is contained in:
Hui Li 2022-10-26 20:50:14 +08:00 committed by GitHub
commit 75d1f35af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 85 additions and 76 deletions

View File

@ -29,8 +29,8 @@ class TDTestCase:
self.replica = 1
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 1000
self.query_times = 500
self.row_nums = 100
self.query_times = 10
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))

View File

@ -29,8 +29,8 @@ class TDTestCase:
self.replica = 3
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 1000
self.query_times = 1000
self.row_nums = 100
self.query_times = 10
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))

View File

@ -30,9 +30,9 @@ class TDTestCase:
self.vgroups = 10
self.tb_nums = 10
self.row_nums = 100
self.max_restart_time = 20
self.restart_server_times = 5
self.query_times = 100
self.max_restart_time = 30
self.restart_server_times = 2
self.query_times = 5
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -91,6 +91,7 @@ class TDTestCase:
tdSql.execute("drop database if exists test")
tdSql.execute("create database if not exists test replica 1 duration 300")
time.sleep(3)
tdSql.execute("use test")
tdSql.execute(
'''create table stb1
@ -135,7 +136,9 @@ class TDTestCase:
tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname))
newTdSql.execute(drop_db_sql)
time.sleep(3)
newTdSql.execute(create_db_sql)
time.sleep(5)
newTdSql.execute("use {}".format(dbname))
newTdSql.execute(
'''create table stb1

View File

@ -29,10 +29,10 @@ class TDTestCase:
self.replica = 3
self.vgroups = 10
self.tb_nums = 10
self.row_nums = 100
self.max_restart_time = 20
self.restart_server_times = 10
self.query_times = 100
self.row_nums = 10
self.max_restart_time = 30
self.restart_server_times = 2
self.query_times = 10
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -92,6 +92,7 @@ class TDTestCase:
tdSql.execute("drop database if exists test")
tdSql.execute("create database if not exists test replica 1 duration 300")
tdSql.execute("use test")
time.sleep(3)
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)
@ -135,7 +136,9 @@ class TDTestCase:
tdLog.notice(" ==== create database {} and insert rows begin =====".format(dbname))
newTdSql.execute(drop_db_sql)
time.sleep(3)
newTdSql.execute(create_db_sql)
time.sleep(5)
newTdSql.execute("use {}".format(dbname))
newTdSql.execute(
'''create table stb1

View File

@ -35,10 +35,10 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 2
self.current_thread = None
self.max_restart_time = 10
self.try_check_times = 10
self.max_restart_time = 30
self.try_check_times = 30
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
@ -83,14 +83,14 @@ class TDTestCase:
if count==1 and is_leader:
tdLog.notice("===== depoly cluster success with 1 mnode as leader =====")
else:
tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====")
tdLog.info("===== depoly cluster fail with 1 mnode as leader =====")
for k ,v in self.dnode_list.items():
if k == mnode_name:
if v[3]==0:
tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3]))
else:
tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3]))
tdLog.info("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3]))
else:
continue
@ -149,7 +149,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
# tdLog.info(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
@ -170,7 +170,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
# tdLog.info(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
@ -270,16 +270,16 @@ class TDTestCase:
caller = inspect.getframeinfo(inspect.stack()[2][0])
if row < 0:
args = (caller.filename, caller.lineno, sql, row)
tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args)
tdLog.info("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args)
if col < 0:
args = (caller.filename, caller.lineno, sql, row)
tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args)
tdLog.info("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args)
if row > tdSql.queryRows:
args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows)
tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
tdLog.info("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
if col > tdSql.queryCols:
args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols)
tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args)
tdLog.info("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args)
def mycheckData(self, sql ,row, col, data):
check_status = True
@ -363,7 +363,7 @@ class TDTestCase:
end = time.time()
time_cost = int(end -start)
if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
tdLog.info(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))

View File

@ -35,9 +35,9 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 2
self.current_thread = None
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
def getBuildPath(self):
@ -189,7 +189,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
#tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
@ -210,7 +210,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
#tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))

View File

@ -35,9 +35,9 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.current_thread = None
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
def getBuildPath(self):
@ -82,14 +82,14 @@ class TDTestCase:
if count==1 and is_leader:
tdLog.notice("===== depoly cluster success with 1 mnode as leader =====")
else:
tdLog.exit("===== depoly cluster fail with 1 mnode as leader =====")
tdLog.info("===== depoly cluster fail with 1 mnode as leader =====")
for k ,v in self.dnode_list.items():
if k == mnode_name:
if v[3]==0:
tdLog.notice("===== depoly cluster mnode only success at {} , support_vnodes is {} ".format(mnode_name,v[3]))
else:
tdLog.exit("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3]))
tdLog.info("===== depoly cluster mnode only fail at {} , support_vnodes is {} ".format(mnode_name,v[3]))
else:
continue
@ -132,7 +132,7 @@ class TDTestCase:
if len(v) ==1 and v[0] in ['leader', 'leader*']:
tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k))
else:
tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
tdLog.info(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k))
def create_database(self, dbname, replica_num ,vgroup_nums ):
drop_db_sql = "drop database if exists {}".format(dbname)
@ -189,7 +189,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
tdLog.info(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
@ -210,7 +210,7 @@ class TDTestCase:
while not status_OK :
if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname))
tdLog.exit(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
tdLog.info(" ==== check insert rows failed after {} try check {} times of database {}".format(count , self.try_check_times ,dbname))
break
time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
@ -312,16 +312,16 @@ class TDTestCase:
caller = inspect.getframeinfo(inspect.stack()[2][0])
if row < 0:
args = (caller.filename, caller.lineno, sql, row)
tdLog.exit("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args)
tdLog.info("%s(%d) failed: sql:%s, row:%d is smaller than zero" % args)
if col < 0:
args = (caller.filename, caller.lineno, sql, row)
tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args)
tdLog.info("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args)
if row > tdSql.queryRows:
args = (caller.filename, caller.lineno, sql, row, tdSql.queryRows)
tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
tdLog.info("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
if col > tdSql.queryCols:
args = (caller.filename, caller.lineno, sql, col, tdSql.queryCols)
tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args)
tdLog.info("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args)
def mycheckData(self, sql ,row, col, data):
check_status = True
@ -427,7 +427,7 @@ class TDTestCase:
end = time.time()
time_cost = int(end -start)
if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
tdLog.info(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
# create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
@ -459,7 +459,7 @@ class TDTestCase:
time_cost = int(end-start)
if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
tdLog.info(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
def _create_threading(dbname):

View File

@ -289,7 +289,7 @@ class TDTestCase:
def start_benchmark_inserts(self,dbname , json_file):
benchmark_build_path = self.getBuildPath() + '/build/bin/taosBenchmark'
tdLog.notice("==== start taosBenchmark insert datas of database {} ==== ".format(dbname))
os.system(" {} -f {} >>/dev/null 2>&1 ".format(benchmark_build_path , json_file))
os.system(" {} -y -n 10 -t 10 >>/dev/null 2>&1 ".format(benchmark_build_path , json_file))
def stop_leader_when_Benchmark_inserts(self,dbname , total_rows , json_file ):
@ -366,7 +366,7 @@ class TDTestCase:
# basic insert and check of cluster
# self.check_setup_cluster_status()
json = os.path.dirname(__file__) + '/insert_10W_rows.json'
self.stop_leader_when_Benchmark_inserts('db_1' , 100000 ,json)
self.stop_leader_when_Benchmark_inserts('db_1' , 100 ,json)
# tdLog.notice( " ===== start insert 100W rows ==== ")
# json = os.path.dirname(__file__) + '/insert_100W_rows.json'
# self.stop_leader_when_Benchmark_inserts('db_2' , 1000000 ,json)

View File

@ -33,9 +33,9 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.current_thread = None
self.max_restart_time = 5
self.max_restart_time = 30
self.try_check_times = 10
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))

View File

@ -29,8 +29,8 @@ class TDTestCase:
self.replica = 3
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 1000
self.query_times = 100
self.row_nums = 100
self.query_times = 10
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))

View File

@ -35,11 +35,11 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.thread_list = []
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
self.query_times = 100
self.query_times = 5
def getBuildPath(self):

View File

@ -33,13 +33,13 @@ class TDTestCase:
self.replica = 3
self.vgroups = 1
self.tb_nums = 10
self.row_nums = 100
self.row_nums = 10
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.thread_list = []
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
self.query_times = 100
self.query_times = 5
def getBuildPath(self):

View File

@ -35,11 +35,11 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.thread_list = []
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
self.query_times = 100
self.query_times = 10
def getBuildPath(self):

View File

@ -35,11 +35,11 @@ class TDTestCase:
self.tb_nums = 10
self.row_nums = 100
self.stop_dnode_id = None
self.loop_restart_times = 5
self.loop_restart_times = 1
self.thread_list = []
self.max_restart_time = 10
self.max_restart_time = 30
self.try_check_times = 10
self.query_times = 100
self.query_times = 5
def getBuildPath(self):

View File

@ -28,7 +28,7 @@ class TDTestCase:
self.replica = 1
self.vgroups = 2
self.tb_nums = 10
self.row_nums = 100
self.row_nums = 10
self.max_vote_time_cost = 30 # seconds
def getBuildPath(self):
@ -185,7 +185,7 @@ class TDTestCase:
# create database replica 3 vgroups 100
db3 = 'db_3'
create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 100".format(db3)
create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 20".format(db3)
tdLog.notice('=======database {} replica 3 vgroups 100 ======'.format(db3))
tdSql.execute(create_db_replica_3_vgroups_100)
self.vote_leader_time_costs(db3)

View File

@ -30,8 +30,8 @@ class TDTestCase:
self.replica = 1
self.vgroups = 2
self.tb_nums = 10
self.row_nums = 100
self.max_vote_time_cost = 10 # seconds
self.row_nums = 10
self.max_vote_time_cost = 20 # seconds
self.stop_dnode = None
def getBuildPath(self):
@ -341,7 +341,7 @@ class TDTestCase:
# create database replica 3 vgroups 100
db3 = 'db_3'
create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 100".format(db3)
create_db_replica_3_vgroups_100 = "create database {} replica 3 vgroups 20".format(db3)
tdLog.notice('=======database {} replica 3 vgroups 100 ======'.format(db3))
tdSql.execute(create_db_replica_3_vgroups_100)
self.vote_leader_time_costs(db3)

View File

@ -263,25 +263,28 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop2Follower.py -N 5 -M 3
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_replica1_insertdatas_querys.py -N 4 -M 1
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.py -N 4 -M 1
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_force_stop_all_dnodes.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_querys_loop_restart_all_vnode.py -N 4 -M 1
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1
# 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 1
python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py -N 4 -M 1
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.py -N 4 -M 1
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_all_dnodes.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_all_dnodes.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_force_stop.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_leader_forece_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_insertdatas_stop_leader.py -N 4 -M 1
# python3 test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.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_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_follower.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_replica3_querydatas_stop_leader.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_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_vgroups_stopOne.py -N 4 -M 1
python3 ./test.py -f 7-tmq/create_wrong_topic.py
python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3