From a21de0d76f87cdb76acbf71b6780222eb3e5805f Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 25 Oct 2022 14:22:56 +0800 Subject: [PATCH] test: add data and topic of taosdshell cases --- tests/system-test/0-others/taosdShell.py | 109 ++++++++++++++--------- tests/system-test/fulltest.sh | 62 ++++++++----- tests/system-test/test.py | 42 ++++++++- 3 files changed, 150 insertions(+), 63 deletions(-) diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py index 6d62420efe..fd93958a64 100644 --- a/tests/system-test/0-others/taosdShell.py +++ b/tests/system-test/0-others/taosdShell.py @@ -106,12 +106,39 @@ class TDTestCase: tdLog.printNoPrefix("%s"%taosdCmd) os.system(f"{taosdCmd}") - def run(self): - tdSql.prepare() - # time.sleep(2) - tdSql.query("create user testpy pass 'testpy'") + def preData(self): + # database\stb\tb\chiild-tb\rows\topics + tdSql.execute("create user testpy pass 'testpy'") + tdSql.execute("drop database if exists db0;") + tdSql.execute("create database db0;") + tdSql.execute("use db0;") + tdSql.execute("create table if not exists db0.stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned);") + tdSql.execute("create table db0.ct1 using db0.stb tags(1000);") + tdSql.execute("create table db0.ct2 using db0.stb tags(2000);") + tdSql.execute("create table if not exists db0.ntb (ts timestamp, c1 int, c2 float, c3 double) ;") + tdSql.query("show db0.stables;") + tdSql.execute("insert into db0.ct1 values(now+0s, 10, 2.0, 3.0);") + tdSql.execute("insert into db0.ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3);") + tdSql.execute("insert into db0.ntb values(now+2s, 10, 2.0, 3.0);") + tdSql.execute("create sma index sma_index_name1 on db0.stb function(max(c1),max(c2),min(c1)) interval(6m,10s) sliding(6m);") + tdSql.execute("create topic tpc1 as select * from db0.ct2; ") - #hostname = socket.gethostname() + + #stream + tdSql.execute("drop database if exists source_db;") + tdSql.query("create database source_db vgroups 3;") + tdSql.query("use source_db") + tdSql.query("create table if not exists source_db.stb (ts timestamp, k int) tags (a int);") + tdSql.query("create table source_db.ct1 using source_db.stb tags(1000);create table source_db.ct2 using source_db.stb tags(2000);create table source_db.ct3 using source_db.stb tags(3000);") + tdSql.query("create stream s1 into source_db.output_stb as select _wstart AS start, min(k), max(k), sum(k) from source_db.stb interval(10m);") + + + + + def run(self): + # tdSql.prepare() + # time.sleep(2) + self.preData() #tdLog.info ("hostname: %s" % hostname) buildPath = self.getBuildPath() @@ -128,54 +155,56 @@ class TDTestCase: # keyDict['h'] = self.hostname # keyDict['c'] = cfgPath # keyDict['P'] = self.serverPort - tdDnodes.stop(1) - - startAction = " --help" + startAction = " -s -c " + taosdCfgPath tdLog.printNoPrefix("================================ parameter: %s"%startAction) self.taosdCommandExe(startAction,taosdCmdRun) - startAction = " -h" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandExe(startAction,taosdCmdRun) + # tdDnodes.stop(1) - startAction=" -a jsonFile:./taosdCaseTmp.json" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - os.system("echo \'{\"queryPolicy\":\"3\"}\' > taosdCaseTmp.json") - self.taosdCommandStop(startAction,taosdCmdRun) + # startAction = " --help" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandExe(startAction,taosdCmdRun) - startAction = " -a jsonFile:./taosdCaseTmp.json -C " - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandExe(startAction,taosdCmdRun) + # startAction = " -h" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandExe(startAction,taosdCmdRun) - os.system("rm -rf taosdCaseTmp.json") + # startAction=" -a jsonFile:./taosdCaseTmp.json" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # os.system("echo \'{\"queryPolicy\":\"3\"}\' > taosdCaseTmp.json") + # self.taosdCommandStop(startAction,taosdCmdRun) - startAction = " -c " + taosdCfgPath - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandStop(startAction,taosdCmdRun) + # startAction = " -a jsonFile:./taosdCaseTmp.json -C " + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandExe(startAction,taosdCmdRun) - startAction = " -s" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandExe(startAction,taosdCmdRun) + # os.system("rm -rf taosdCaseTmp.json") - startAction = " -e TAOS_QUERY_POLICY=2 " - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandStop(startAction,taosdCmdRun) + # startAction = " -c " + taosdCfgPath + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandStop(startAction,taosdCmdRun) - startAction=" -E taosdCaseTmp/.env" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - os.system(" mkdir -p taosdCaseTmp/.env ") - os.system("echo \'TAOS_QUERY_POLICY=3\' > taosdCaseTmp/.env ") - self.taosdCommandStop(startAction,taosdCmdRun) - os.system(" rm -rf taosdCaseTmp/.env ") - startAction = " -V" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandExe(startAction,taosdCmdRun) + # startAction = " -e TAOS_QUERY_POLICY=2 " + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandStop(startAction,taosdCmdRun) - startAction = " -k" - tdLog.printNoPrefix("================================ parameter: %s"%startAction) - self.taosdCommandExe(startAction,taosdCmdRun) + + # startAction=" -E taosdCaseTmp/.env" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # os.system(" mkdir -p taosdCaseTmp/.env ") + # os.system("echo \'TAOS_QUERY_POLICY=3\' > taosdCaseTmp/.env ") + # self.taosdCommandStop(startAction,taosdCmdRun) + # os.system(" rm -rf taosdCaseTmp/.env ") + + # startAction = " -V" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandExe(startAction,taosdCmdRun) + + # startAction = " -k" + # tdLog.printNoPrefix("================================ parameter: %s"%startAction) + # self.taosdCommandExe(startAction,taosdCmdRun) def stop(self): tdSql.close() diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 2c7848d505..92db2700c5 100644 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -13,7 +13,7 @@ python3 ./test.py -f 0-others/udf_restart_taosd.py python3 ./test.py -f 0-others/cachemodel.py python3 ./test.py -f 0-others/udf_cfg1.py python3 ./test.py -f 0-others/udf_cfg2.py - +python3 ./test.py -f 0-others/taosdShell.py -N 5 -M 3 -Q 3 python3 ./test.py -f 0-others/sysinfo.py python3 ./test.py -f 0-others/user_control.py python3 ./test.py -f 0-others/fsync.py @@ -362,7 +362,7 @@ python3 ./test.py -f 2-query/concat.py -Q 2 python3 ./test.py -f 2-query/concat2.py -Q 2 python3 ./test.py -f 2-query/concat_ws.py -Q 2 python3 ./test.py -f 2-query/concat_ws2.py -Q 2 -#python3 ./test.py -f 2-query/check_tsdb.py -Q 2 +python3 ./test.py -f 2-query/check_tsdb.py -Q 2 python3 ./test.py -f 2-query/spread.py -Q 2 python3 ./test.py -f 2-query/hyperloglog.py -Q 2 python3 ./test.py -f 2-query/explain.py -Q 2 @@ -401,13 +401,17 @@ python3 ./test.py -f 2-query/arctan.py -Q 2 python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2 python3 ./test.py -f 2-query/interp.py -Q 2 -# python3 ./test.py -f 2-query/nestedQuery.py -Q 2 -# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 +python3 ./test.py -f 2-query/nestedQuery.py -Q 2 +python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 +python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 +python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 +python3 ./test.py -f 2-query/stablity.py -Q 2 +python3 ./test.py -f 2-query/stablity_1.py -Q 2 python3 ./test.py -f 2-query/avg.py -Q 2 -# python3 ./test.py -f 2-query/elapsed.py -Q 2 +python3 ./test.py -f 2-query/elapsed.py -Q 2 python3 ./test.py -f 2-query/csum.py -Q 2 -#python3 ./test.py -f 2-query/mavg.py -Q 2 +python3 ./test.py -f 2-query/mavg.py -Q 2 python3 ./test.py -f 2-query/sample.py -Q 2 python3 ./test.py -f 2-query/function_diff.py -Q 2 python3 ./test.py -f 2-query/unique.py -Q 2 @@ -431,8 +435,9 @@ python3 ./test.py -f 2-query/count_partition.py -Q 2 python3 ./test.py -f 2-query/max_partition.py -Q 2 python3 ./test.py -f 2-query/last_row.py -Q 2 python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 -#------------querPolicy 3----------- +python3 ./test.py -f 2-query/sml.py -Q 2 +#------------querPolicy 3----------- python3 ./test.py -f 2-query/between.py -Q 3 python3 ./test.py -f 2-query/distinct.py -Q 3 python3 ./test.py -f 2-query/varchar.py -Q 3 @@ -452,7 +457,7 @@ python3 ./test.py -f 2-query/concat.py -Q 3 python3 ./test.py -f 2-query/concat2.py -Q 3 python3 ./test.py -f 2-query/concat_ws.py -Q 3 python3 ./test.py -f 2-query/concat_ws2.py -Q 3 -#python3 ./test.py -f 2-query/check_tsdb.py -Q 3 +python3 ./test.py -f 2-query/check_tsdb.py -Q 3 python3 ./test.py -f 2-query/spread.py -Q 3 python3 ./test.py -f 2-query/hyperloglog.py -Q 3 python3 ./test.py -f 2-query/explain.py -Q 3 @@ -463,7 +468,7 @@ python3 ./test.py -f 2-query/Today.py -Q 3 python3 ./test.py -f 2-query/max.py -Q 3 python3 ./test.py -f 2-query/min.py -Q 3 python3 ./test.py -f 2-query/count.py -Q 3 -#python3 ./test.py -f 2-query/last.py -Q 3 +python3 ./test.py -f 2-query/last.py -Q 3 python3 ./test.py -f 2-query/first.py -Q 3 python3 ./test.py -f 2-query/To_iso8601.py -Q 3 python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 3 @@ -489,12 +494,18 @@ python3 ./test.py -f 2-query/arcsin.py -Q 3 python3 ./test.py -f 2-query/arccos.py -Q 3 python3 ./test.py -f 2-query/arctan.py -Q 3 python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 -# python3 ./test.py -f 2-query/nestedQuery.py -Q 3 -# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 -# python3 ./test.py -f 2-query/avg.py -Q 3 -# python3 ./test.py -f 2-query/elapsed.py -Q 3 + +python3 ./test.py -f 2-query/nestedQuery.py -Q 3 +python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 +python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 +python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 +python3 ./test.py -f 2-query/stablity.py -Q 3 +python3 ./test.py -f 2-query/stablity_1.py -Q 3 + +python3 ./test.py -f 2-query/avg.py -Q 3 +python3 ./test.py -f 2-query/elapsed.py -Q 3 python3 ./test.py -f 2-query/csum.py -Q 3 -#python3 ./test.py -f 2-query/mavg.py -Q 3 +python3 ./test.py -f 2-query/mavg.py -Q 3 python3 ./test.py -f 2-query/sample.py -Q 3 python3 ./test.py -f 2-query/function_diff.py -Q 3 python3 ./test.py -f 2-query/unique.py -Q 3 @@ -543,7 +554,7 @@ python3 ./test.py -f 2-query/concat.py -Q 4 python3 ./test.py -f 2-query/concat2.py -Q 4 python3 ./test.py -f 2-query/concat_ws.py -Q 4 python3 ./test.py -f 2-query/concat_ws2.py -Q 4 -#python3 ./test.py -f 2-query/check_tsdb.py -Q 4 +python3 ./test.py -f 2-query/check_tsdb.py -Q 4 python3 ./test.py -f 2-query/spread.py -Q 4 python3 ./test.py -f 2-query/hyperloglog.py -Q 4 python3 ./test.py -f 2-query/explain.py -Q 4 @@ -554,7 +565,7 @@ python3 ./test.py -f 2-query/Today.py -Q 4 python3 ./test.py -f 2-query/max.py -Q 4 python3 ./test.py -f 2-query/min.py -Q 4 python3 ./test.py -f 2-query/count.py -Q 4 -#python3 ./test.py -f 2-query/last.py -Q 4 +python3 ./test.py -f 2-query/last.py -Q 4 python3 ./test.py -f 2-query/first.py -Q 4 python3 ./test.py -f 2-query/To_iso8601.py -Q 4 python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 4 @@ -580,12 +591,19 @@ python3 ./test.py -f 2-query/arcsin.py -Q 4 python3 ./test.py -f 2-query/arccos.py -Q 4 python3 ./test.py -f 2-query/arctan.py -Q 4 python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 4 -# python3 ./test.py -f 2-query/nestedQuery.py -Q 4 -# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 -# python3 ./test.py -f 2-query/avg.py -Q 4 -# python3 ./test.py -f 2-query/elapsed.py -Q 4 + +#python3 ./test.py -f 2-query/nestedQuery.py -Q 4 +python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 +python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 +python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 +python3 ./test.py -f 2-query/stablity.py -Q 4 +python3 ./test.py -f 2-query/stablity_1.py -Q 4 + + +python3 ./test.py -f 2-query/avg.py -Q 4 +python3 ./test.py -f 2-query/elapsed.py -Q 4 python3 ./test.py -f 2-query/csum.py -Q 4 -#python3 ./test.py -f 2-query/mavg.py -Q 4 +python3 ./test.py -f 2-query/mavg.py -Q 4 python3 ./test.py -f 2-query/sample.py -Q 4 python3 ./test.py -f 2-query/function_diff.py -Q 4 python3 ./test.py -f 2-query/unique.py -Q 4 @@ -609,5 +627,5 @@ python3 ./test.py -f 2-query/count_partition.py -Q 4 python3 ./test.py -f 2-query/max_partition.py -Q 4 python3 ./test.py -f 2-query/last_row.py -Q 4 python3 ./test.py -f 2-query/tsbsQuery.py -Q 4 -#python3 ./test.py -f 2-query/sml.py -Q 4 +python3 ./test.py -f 2-query/sml.py -Q 4 python3 ./test.py -f 2-query/interp.py -Q 4 diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 2f482e4277..dd49f037bd 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -321,7 +321,7 @@ if __name__ == "__main__": for dnode in tdDnodes.dnodes: tdDnodes.starttaosd(dnode.index) tdCases.logSql(logSql) - + if restful: tAdapter.deploy(adapter_cfg_dict) tAdapter.start() @@ -341,6 +341,26 @@ if __name__ == "__main__": print("check dnode ready") except Exception as r: print(r) + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.success(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + if ucase is not None and hasattr(ucase, 'noConn') and ucase.noConn == True: conn = None else: @@ -455,6 +475,26 @@ if __name__ == "__main__": except Exception as r: print(r) + if queryPolicy != 1: + queryPolicy=int(queryPolicy) + if restful: + conn = taosrest.connect(url=f"http://{host}:6041") + else: + conn = taos.connect(host,config=tdDnodes.getSimCfgPath()) + + cursor = conn.cursor() + cursor.execute("create qnode on dnode 1") + cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"') + cursor.execute("show local variables") + res = cursor.fetchall() + for i in range(cursor.rowcount): + if res[i][0] == "queryPolicy" : + if int(res[i][1]) == int(queryPolicy): + tdLog.success(f'alter queryPolicy to {queryPolicy} successfully') + else: + tdLog.debug(res) + tdLog.exit(f"alter queryPolicy to {queryPolicy} failed") + if testCluster: tdLog.info("Procedures for testing cluster")