From eb8ca83bdaeb1cef421f81bc0ea1d52311fbf287 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 22 Feb 2021 01:58:52 +0000 Subject: [PATCH] [TD-2984] : combine taosdemo and taosdemox. --- tests/pytest/tools/taosdemoTest.py | 17 +++++++++++------ tests/pytest/tools/taosdemoTest2.py | 13 +++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/pytest/tools/taosdemoTest.py b/tests/pytest/tools/taosdemoTest.py index 090d2075cf..1cb2f71d8f 100644 --- a/tests/pytest/tools/taosdemoTest.py +++ b/tests/pytest/tools/taosdemoTest.py @@ -23,9 +23,10 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - + self.numberOfTables = 10000 self.numberOfRecords = 100 + def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -38,9 +39,10 @@ class TDTestCase: if ("taosd" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + buildPath = root[:len(root) - len("/build/bin")] break return buildPath + def run(self): tdSql.prepare() buildPath = self.getBuildPath() @@ -48,17 +50,20 @@ class TDTestCase: tdLog.exit("taosd not found!") else: tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - os.system("%staosdemo -y -M -t %d -n %d -x" % (binPath,self.numberOfTables, self.numberOfRecords)) + binPath = buildPath + "/build/bin/" + os.system("%staosdemo -y -M -t %d -n %d -x" % + (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.execute("use test") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) - tdSql.query("select sum(col1) from test.meters interval(1h) sliding(30m)") + tdSql.query( + "select sum(col1) from test.meters interval(1h) sliding(30m)") tdSql.checkRows(2) - tdSql.query("select apercentile(col1, 1) from test.meters interval(10s)") + tdSql.query( + "select apercentile(col1, 1) from test.meters interval(10s)") tdSql.checkRows(1) tdSql.error("select loc, count(loc) from test.meters") diff --git a/tests/pytest/tools/taosdemoTest2.py b/tests/pytest/tools/taosdemoTest2.py index 1e492aa8fc..cf2ac9b806 100644 --- a/tests/pytest/tools/taosdemoTest2.py +++ b/tests/pytest/tools/taosdemoTest2.py @@ -31,11 +31,12 @@ class TDTestCase: def insertDataAndAlterTable(self, threadID): if(threadID == 0): - os.system("yes | taosdemo -t %d -n %d -x" % (self.numberOfTables, self.numberOfRecords)) + os.system("taosdemo -y -t %d -n %d -x" % + (self.numberOfTables, self.numberOfRecords)) if(threadID == 1): time.sleep(2) print("use test") - tdSql.execute("use test") + tdSql.execute("use test") # check if all the tables have heen created while True: tdSql.query("show tables") @@ -52,19 +53,19 @@ class TDTestCase: print("number of records: %d" % rows) if(rows > 0): break - time.sleep(1) + time.sleep(1) print("alter table test.meters add column f4 int") tdSql.execute("alter table test.meters add column f4 int") print("insert into test.t0 values (now, 1, 2, 3, 4)") tdSql.execute("insert into test.t0 values (now, 1, 2, 3, 4)") - def run(self): + def run(self): tdSql.prepare() t1 = threading.Thread(target=self.insertDataAndAlterTable, args=(0, )) t2 = threading.Thread(target=self.insertDataAndAlterTable, args=(1, )) - t1.start() + t1.start() t2.start() t1.join() t2.join() @@ -78,4 +79,4 @@ class TDTestCase: tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) -- GitLab