提交 48eacced 编写于 作者: W wenzhouwww@live.cn

remove abnormal test case and repeat it into cluster case for TestNG

上级 e0fd6cbe
###################################################################
# Copyright (c) 2020 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from http import client
import taos
import time
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import random
class TDTestCase:
def __init__(self):
self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record
self.num = 10
self.Loop = 10
self.loop_alter = 100
def caseDescription(self):
'''
case1 <wenzhouwww>: this is an abnormal case for always change schema
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
# Loop
tdSql.execute("drop database if exists testdb")
tdSql.execute("create database testdb")
tdSql.execute("use testdb")
tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)")
tdSql.query("describe testdb.st")
# insert data
for cur in range(self.num):
tdSql.execute("insert into tb_%d using st tags(%d) values(%d, %d)"%(cur,cur, self.ts+1000*cur,cur))
tdSql.execute("insert into tb_set using st tags(%d) values(%d, %d)"%(cur,self.ts+1000*cur,cur))
client_0 = taos.connect().cursor() # global conn
client_1 = taos.connect().cursor()
client_2 = taos.connect().cursor()
add_tag_list = []
for i in range(self.loop_alter):
sql= "alter stable testdb.st add tag new_tag%d int"%i
add_tag_list.append(sql)
change_tag_list = []
for i in range(self.loop_alter+1):
sql = " alter stable testdb.st change tag new_tag%d new_tag_%d"%(i,i)
change_tag_list.append(sql)
set_tag_list = []
for i in range(self.loop_alter):
sql = "alter table testdb.tb_set set tag new_tag_%d=%d"%(i,i*10)
set_tag_list.append(sql)
drop_tag_list = []
for i in range(self.loop_alter):
sql = "alter stable testdb.st drop tag new_tag_%d"%(i)
drop_tag_list.append(sql)
for i in range(self.loop_alter):
add_sql = add_tag_list[i]
change_sql = change_tag_list[i]
set_sql = set_tag_list[i]
drop_sql = drop_tag_list[i]
execute_list= [add_sql,change_sql,set_sql,drop_sql]
for ind,sql in enumerate(execute_list):
if sql ==drop_sql:
if i%5 !=0:
continue
else:
pass
if ind%3==0:
# client_0.execute("reset query cache")
client_0.execute(sql)
print(" client_0 runing sqls : %s" %sql )
elif ind%3==1:
# client_1.execute("reset query cache")
client_1.execute(sql)
print(" client_1 runing sqls : %s" %sql )
elif ind%3==2:
# client_2.execute("reset query cache")
client_2.execute(sql)
print(" client_2 runing sqls : %s" %sql )
else:
client_0.execute(sql)
print(" client_0 runing sqls : %s" %sql )
query_sqls = ["select count(*) from testdb.st group by ind",
"describe testdb.st",
"select count(*) from testdb.st group by tbname"]
reset_sql = "reset query cache"
if i%10 ==0:
tdSql.execute(reset_sql)
client_0.execute(reset_sql)
client_1.execute(reset_sql)
client_2.execute(reset_sql)
for sql in query_sqls:
if sql =="describe testdb.st":
print("==========================\n")
print("==========describe=======\n")
print("==========================\n")
client_0.execute(sql)
res = client_0.fetchall()
print("client 0 res :", res) if res else print("empty")
client_1.execute(sql)
res = client_0.fetchall()
print("client 1 res :", res) if res else print("empty")
client_2.execute(sql)
res = client_2.fetchall()
print("client 2 res :", res) if res else print("empty")
else:
client_0.execute(sql)
client_1.execute(sql)
client_2.execute(sql)
tdLog.notice("===== this is the %d_th loop alter tags is going now ===="%i )
client_1.close()
client_2.close()
client_0.close()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# Copyright (c) 2020 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import taos
import time
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def __init__(self):
self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record
self.num = 10
self.Loop = 100
def caseDescription(self):
'''
case1 <wenzhouwww>: this is an abnormal case for loop restart taosd
and basic this query ,it will run 4 client to change schema ,run always ;
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def basic_insert(self):
tdSql.execute("create database if not exists testdb")
tdSql.execute("use testdb")
tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)")
for i in range(self.num):
tdSql.execute("insert into sub_%s using st tags(%d) values (%d , %d );"%(str(i),i,self.ts+10000*i,i))
def basic_query(self):
for i in range(self.num):
tdSql.query("select count(*) from testdb.sub_%s"%str(i))
tdSql.checkData(0,0,1)
tdSql.query("select count(*) from testdb.st")
tdSql.checkRows(1)
def run(self):
# Loop
for loop_step in range(self.Loop):
# run basic query and insert
# kill all
os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1")
tdDnodes.start(1)
if loop_step ==0:
self.basic_insert()
else:
tdSql.execute("insert into sub_10 using st tags(10) values(now ,10)")
# another client
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
os.system('taos -s "select count(*) from testdb.sub_100;"')
self.basic_query()
sleep(2)
tdDnodes.stopAll()
tdLog.info(" this is the %s_th loop restart taosd going " % loop_step)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# Copyright (c) 2020 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from http import client
import taos
import time
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import random
class TDTestCase:
def __init__(self):
self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record
self.num = 10
self.Loop = 100
global client
def caseDescription(self):
'''
case1 <wenzhouwww>: this is an abnormal case for loop restart taosd
between restart taosd ,there is an query and is insert is going on
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
# Loop
tdSql.execute("drop database if exists testdb")
client = taos.connect().cursor() # global conn
# tdSql.execute("create database testdb")
# tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)")
# tdSql.query("describe testdb.st")
# result = tdSql.getResult("describe testdb.st")
# print(result)
# tdSql.execute("alter stable testdb.st add tag new_tags int")
# result = tdSql.getResult("describe testdb.st")
# print(result)
# tdSql.execute("alter stable testdb.st change tag new_tags alter_tag")
# result = tdSql.getResult("describe testdb.st")
# print(result)
for loop_step in range(self.Loop):
# run basic query and insert
# kill all
os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1")
tdDnodes.start(1)
tdSql.execute("create database if not exists testdb")
tdSql.execute("use testdb")
if loop_step <1:
tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)")
tdSql.execute("create stable st%d (ts timestamp , value int) tags (ind int)"%loop_step)
for cur in range(self.num):
tdSql.execute("insert into tb_%d using st%d tags(%d) values(now, %d)"%(loop_step,loop_step,loop_step, cur))
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
os.system('taos -s "select count(*) from testdb.sub_100;"')
os.system('taos -s "describe testdb.sub_100;"')
os.system('show databases\G')
# another client
client_1 = taos.connect().cursor()
client_2 = taos.connect().cursor()
alter_dict = {"days" : int(random.randint(1,5)) ,
"keep":int(random.randint(10,20)) ,
"precision":"ns",
"blocks" : int(random.randint(1,6)*2),
"quorum": int(random.randint(0,3)),
"comp":int(random.randint(0,3)),
"minrows":int(random.randint(1,3)*100),
"replica":int(random.randint(1,3))
}
alter_list = ['days', 'keep', 'precision', 'blocks', 'quorum', 'comp', 'minrows', 'replica']
random_key = random.sample(alter_list, 1)[0]
sql = "alter database {} {} {}".format("testdb", random_key, alter_dict[random_key])
for alter_db in range(100):
alter_list = ['days', 'keep', 'precision', 'blocks', 'quorum', 'comp', 'minrows', 'replica']
random_key = random.sample(alter_list, 1)[0]
sql = "alter database {} {} {}".format("testdb", random_key, alter_dict[random_key])
if alter_db%3==0:
# client_0.execute("reset query cache")
try:
client.execute(sql)
client.fetchall()
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
except :
pass
print(" client runing sqls : %s" %sql )
elif alter_db%3==1:
# client_1.execute("reset query cache")
try:
client_1.execute(sql)
client_1.fetchall()
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
except :
pass
print(" client_1 runing sqls : %s" %sql )
elif alter_db%3==2:
try:
# client_2.execute("reset query cache")
client_2.execute(sql)
client_2.fetchall()
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
except:
pass
print(" client_2 runing sqls : %s" %sql )
else:
try:
client.execute(sql)
client.fetchall()
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
except:
pass
print(" client runing sqls : %s" %sql )
os.system("taos -s 'show databases;'")
sleep(2)
tdDnodes.stopAll()
tdLog.notice(" this is the %s_th loop restart taosd going " % loop_step)
client_1.close()
client_2.close()
client.close()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# Copyright (c) 2020 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from http import client
import taos
import time
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
import random
class TDTestCase:
def __init__(self):
self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record
self.num = 10
self.Loop = 100
global client
def caseDescription(self):
'''
case1 <wenzhouwww>: this is an abnormal case for loop restart taosd
between restart taosd ,there is an query and is insert is going on
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
# Loop
tdSql.execute("drop database if exists testdb")
client = taos.connect().cursor() # global conn
# tdSql.execute("create database testdb")
# tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)")
# tdSql.query("describe testdb.st")
# result = tdSql.getResult("describe testdb.st")
# print(result)
# tdSql.execute("alter stable testdb.st add tag new_tags int")
# result = tdSql.getResult("describe testdb.st")
# print(result)
# tdSql.execute("alter stable testdb.st change tag new_tags alter_tag")
# result = tdSql.getResult("describe testdb.st")
# print(result)
for loop_step in range(self.Loop):
# run basic query and insert
# kill all
os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1")
tdDnodes.start(1)
tdSql.execute("create database if not exists testdb")
tdSql.execute("use testdb")
if loop_step <1:
tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)")
tdSql.execute("create stable st%d (ts timestamp , value int) tags (ind int)"%loop_step)
for cur in range(self.num):
tdSql.execute("insert into tb_%d using st%d tags(%d) values(%d, %d)"%(loop_step,loop_step,loop_step, self.ts+1000*cur,cur))
os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"')
os.system('taos -s "select count(*) from testdb.sub_100;"')
os.system('taos -s "describe testdb.sub_100;"')
# another client
client_1 = taos.connect().cursor()
client_2 = taos.connect().cursor()
alter_tag = [
" alter stable testdb.st%d add tag new_tags int "%loop_step,
" alter stable testdb.st%d change tag new_tags alter_tag"%loop_step,
" alter stable testdb.st%d drop tag alter_tag"%loop_step,
"ALTER TABLE testdb.sub_100 SET TAG ind=%d"%(loop_step*10)
]
print(alter_tag[0])
client_1.execute(alter_tag[0])
os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] )
# clinet1
os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] )
# client_1.execute("reset query cache;")
client_1.execute(" describe testdb.st%d"%loop_step)
res = client_1.fetchall()
# clinet2
os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] )
print(alter_tag[1])
client_2.execute(alter_tag[1])
# client_2.execute("reset query cache")
client_2.execute("describe testdb.st%d"%loop_step)
res = client_2.fetchall()
client_2.execute("select * from testdb.st%d"%loop_step)
res = client_2.fetchall()
client.execute("show databases;")
# client.execute("reset query cache")
client.execute("describe testdb.st%d"%loop_step)
print(alter_tag[2])
client.execute(alter_tag[2])
res = client.fetchall_row()
sleep(2)
tdDnodes.stopAll()
tdLog.notice(" this is the %s_th loop restart taosd going " % loop_step)
client_1.close()
client_2.close()
client.close()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册