add test case
This commit is contained in:
parent
d0ade067b2
commit
e0f9dc1dce
|
@ -192,6 +192,10 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/like.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/like.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/like.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/match.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/match.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/match.py -Q 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/match.py -Q 4
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py -Q 3
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
import taos
|
||||
import sys
|
||||
import datetime
|
||||
import inspect
|
||||
import threading
|
||||
import time
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.common import tdCom
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
|
||||
def initConnection(self):
|
||||
self.records = 10000000
|
||||
self.numOfTherads = 50
|
||||
self.ts = 1537146000000
|
||||
self.host = "127.0.0.1"
|
||||
self.user = "root"
|
||||
self.password = "taosdata"
|
||||
self.config = "/home/xp/git/TDengine/sim/dnode1/cfg"
|
||||
self.conn = taos.connect(
|
||||
self.host,
|
||||
self.user,
|
||||
self.password,
|
||||
self.config)
|
||||
|
||||
def initDB(self):
|
||||
tdSql.execute("drop database if exists db")
|
||||
tdSql.execute("create database if not exists db")
|
||||
|
||||
def stopTest(self):
|
||||
tdSql.execute("drop database if exists db")
|
||||
|
||||
def insertData(self, threadID):
|
||||
cursor = self.conn.cursor()
|
||||
print("Thread %d: starting" % threadID)
|
||||
base = 200000 * threadID
|
||||
for i in range(200):
|
||||
query = "insert into tb values"
|
||||
for j in range(1000):
|
||||
query += "(%d, %d, 'test')" % (self.ts + base + i * 1000 + j, base + i * 1000 + j)
|
||||
cursor.execute(query)
|
||||
cursor.close()
|
||||
print("Thread %d: finishing" % threadID)
|
||||
|
||||
def threadTest(self, threadID):
|
||||
print(f"Thread {threadID} starting...")
|
||||
tdsqln = tdCom.newTdSql()
|
||||
for i in range(2, 50):
|
||||
tdsqln.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*{i}dx'")
|
||||
tdsqln.checkRows(0)
|
||||
for i in range(100):
|
||||
tdsqln.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*1x'")
|
||||
tdsqln.checkRows(2)
|
||||
|
||||
tdsqln.query("select * from db.t1x")
|
||||
tdsqln.checkRows(5)
|
||||
|
||||
tdsqln.query("select * from db.t1x where c1 match '_c'")
|
||||
tdsqln.checkRows(2)
|
||||
|
||||
tdsqln.query("select * from db.t1x where c1 match '%__c'")
|
||||
tdsqln.checkRows(0)
|
||||
|
||||
print(f"Thread {threadID} finished.")
|
||||
|
||||
def match_test(self):
|
||||
tdSql.execute("create table db.t1x (ts timestamp, c1 varchar(100))")
|
||||
tdSql.execute("create table db.t_1x (ts timestamp, c1 varchar(100))")
|
||||
|
||||
tdSql.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*1x'")
|
||||
tdSql.checkRows(2)
|
||||
for i in range(2, 50):
|
||||
tdSql.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*{i}x'")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query("insert into db.t1x values(now, 'abc'), (now+1s, 'a%c'),(now+2s, 'a_c'),(now+3s, '_c'),(now+4s, '%c')")
|
||||
|
||||
tdSql.query("select * from db.t1x")
|
||||
tdSql.checkRows(5)
|
||||
|
||||
tdSql.query("select * from db.t1x where c1 match '_c'")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.query("select * from db.t1x where c1 match '%__c'")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
threads = []
|
||||
for i in range(10):
|
||||
t = threading.Thread(target=self.threadTest, args=(i,))
|
||||
threads.append(t)
|
||||
t.start()
|
||||
|
||||
time.sleep(31)
|
||||
|
||||
tdSql.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*1x'")
|
||||
tdSql.checkRows(2)
|
||||
for i in range(2, 50):
|
||||
tdSql.query(f"select distinct table_name from information_schema.ins_columns where table_name match 't.*{i}x'")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query("select * from db.t1x")
|
||||
tdSql.checkRows(5)
|
||||
|
||||
tdSql.query("select * from db.t1x where c1 match '_c'")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.query("select * from db.t1x where c1 match '%__c'")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.execute("create table db.t3x (ts timestamp, c1 varchar(100))")
|
||||
|
||||
tdSql.execute("insert into db.t3x values(now, '我是中文'), (now+1s, '我是_中文'), (now+2s, '我是%中文'), (now+3s, '%中文'),(now+4s, '_中文')")
|
||||
tdSql.query("select * from db.t3x where c1 match '%中文'")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.query("select * from db.t3x where c1 match '中文'")
|
||||
tdSql.checkRows(5)
|
||||
|
||||
for thread in threads:
|
||||
print(f"Thread waitting for finish...")
|
||||
thread.join()
|
||||
|
||||
print(f"Mutithread test finished.")
|
||||
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("==========start match_test run ...............")
|
||||
tdSql.prepare(replica = self.replicaVar)
|
||||
|
||||
self.initConnection()
|
||||
|
||||
self.initDB()
|
||||
self.match_test()
|
||||
|
||||
self.stopTest()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -104,6 +104,10 @@ python3 ./test.py -f 2-query/like.py
|
|||
python3 ./test.py -f 2-query/like.py -Q 2
|
||||
python3 ./test.py -f 2-query/like.py -Q 3
|
||||
python3 ./test.py -f 2-query/like.py -Q 4
|
||||
python3 ./test.py -f 2-query/match.py
|
||||
python3 ./test.py -f 2-query/match.py -Q 2
|
||||
python3 ./test.py -f 2-query/match.py -Q 3
|
||||
python3 ./test.py -f 2-query/match.py -Q 4
|
||||
python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3 -i False
|
||||
python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3 -i False
|
||||
python3 ./test.py -f 3-enterprise/restore/restoreMnode.py -N 5 -M 3 -i False
|
||||
|
|
Loading…
Reference in New Issue