diff --git a/tests/system-test/2-query/db.py b/tests/system-test/2-query/db.py index e2c056cd5b..588609e524 100644 --- a/tests/system-test/2-query/db.py +++ b/tests/system-test/2-query/db.py @@ -2,10 +2,12 @@ import taos import sys import datetime import inspect +import threading from util.log import * from util.sql import * from util.cases import * +from util.common import tdCom import random @@ -60,6 +62,33 @@ class TDTestCase: tdSql.query("show dnode 1 variables like '____debugFlag'") tdSql.checkRows(2) + def threadTest(self, threadID): + print(f"Thread {threadID} starting...") + tdsqln = tdCom.newTdSql() + for i in range(100): + tdsqln.query(f"desc db1.stb_1") + tdsqln.checkRows(3) + + print(f"Thread {threadID} finished.") + + def case3(self): + tdSql.execute("create database db1") + tdSql.execute("create table db1.stb (ts timestamp, c1 varchar(100)) tags(t1 int)") + tdSql.execute("create table db1.stb_1 using db1.stb tags(1)") + + threads = [] + for i in range(10): + t = threading.Thread(target=self.threadTest, args=(i,)) + threads.append(t) + t.start() + + for thread in threads: + print(f"Thread waitting for finish...") + thread.join() + + print(f"Mutithread test finished.") + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare(replica = self.replicaVar) @@ -70,6 +99,10 @@ class TDTestCase: tdLog.printNoPrefix("==========start case2 run ...............") self.case2() tdLog.printNoPrefix("==========end case2 run ...............") + + tdLog.printNoPrefix("==========start case3 run ...............") + self.case3() + tdLog.printNoPrefix("==========end case3 run ...............") def stop(self): tdSql.close()