diff --git a/src/connector/grafanaplugin b/src/connector/grafanaplugin index 32e2c97a4cf7bedaa99f5d6dd8cb036e7f4470df..016d8e82a24d72779be0ab0090580a372b4fffca 160000 --- a/src/connector/grafanaplugin +++ b/src/connector/grafanaplugin @@ -1 +1 @@ -Subproject commit 32e2c97a4cf7bedaa99f5d6dd8cb036e7f4470df +Subproject commit 016d8e82a24d72779be0ab0090580a372b4fffca diff --git a/tests/gotest/batchtest.bat b/tests/gotest/batchtest.bat index efd8961bb0be2eb6f20e291114b92b00469b984f..cb7d91047ebeb6b0e62488ed9f5aa232f53d3588 100755 --- a/tests/gotest/batchtest.bat +++ b/tests/gotest/batchtest.bat @@ -8,7 +8,7 @@ if "%severIp%"=="" (set severIp=127.0.0.1) if "%serverPort%"=="" (set serverPort=6030) go env -w GO111MODULE=on -go env -w GOPROXY=https://goproxy.io,direct +go env -w GOPROXY=https://goproxy.cn,direct cd case001 case001.bat %severIp% %serverPort% diff --git a/tests/gotest/batchtest.sh b/tests/gotest/batchtest.sh index 8f5a7fe8f032134e55c9d9675361590ed6d5b19b..4471172c3f925ed635a52f4f5d1621c7f664bdb0 100755 --- a/tests/gotest/batchtest.sh +++ b/tests/gotest/batchtest.sh @@ -14,7 +14,7 @@ if [ ! -n "$serverPort" ]; then fi go env -w GO111MODULE=on -go env -w GOPROXY=https://goproxy.io,direct +go env -w GOPROXY=https://goproxy.cn,direct bash ./case001/case001.sh $severIp $serverPort bash ./case002/case002.sh $severIp $serverPort diff --git a/tests/gotest/case002/case002.bat b/tests/gotest/case002/case002.bat index ebec576e724ccb14319dd380c9783a783ac0db62..385677acae826e248a410472bfc7a022ff3003ab 100644 --- a/tests/gotest/case002/case002.bat +++ b/tests/gotest/case002/case002.bat @@ -1,5 +1,5 @@ @echo off -echo ==== start run cases001.go +echo ==== start run cases002.go del go.* go mod init demotest diff --git a/tests/gotest/case002/case002.go b/tests/gotest/case002/case002.go index c69da04cb271c24e33953ca8fdfea71c67349b4f..6e9ffed2fe2b21bb7c8daaf14936822d72cd77ff 100644 --- a/tests/gotest/case002/case002.go +++ b/tests/gotest/case002/case002.go @@ -43,10 +43,9 @@ func main() { os.Exit(1) } defer db.Close() - db.Exec("drop if exists database test") - db.Exec("create if not exists database test") + db.Exec("drop database if exists test") + db.Exec("create database if not exists test") db.Exec("use test") - db.Exec("drop if exists database test") db.Exec("create table test (ts timestamp ,level int)") for i := 0; i < 10; i++ { sqlcmd := fmt.Sprintf("insert into test values(%d,%d)", ts+i, i) diff --git a/tests/gotest/case002/case002.sh b/tests/gotest/case002/case002.sh index 94e5bb44e03a1f7d2704752fcf9c080abcb4f23f..d98337cce7cfeb51ec9305226b20abdd7b360a46 100644 --- a/tests/gotest/case002/case002.sh +++ b/tests/gotest/case002/case002.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "==== start run cases001.go" +echo "==== start run cases002.go" set +e #set -x diff --git a/tests/pytest/client/taoshellCheckCase.py b/tests/pytest/client/taoshellCheckCase.py new file mode 100644 index 0000000000000000000000000000000000000000..b375cb7b4226392ef03a0ebfae157831ffe20e5f --- /dev/null +++ b/tests/pytest/client/taoshellCheckCase.py @@ -0,0 +1,199 @@ +################################################################### +# Copyright (c) 2016 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 sys, shutil +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def getBuildPath(self) -> str: + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/debug/build/bin")] + break + return buildPath + + def check_coredump(self, res_log): + build_path = self.getBuildPath() + "/debug/build/bin" + cmd = build_path + "/" + "taos -d test -k 1 > res.txt 2>&1" + print(res_log) + out = subprocess.check_output(cmd, shell=True).decode("utf-8") + print(out) + + def execute_cmd(self,cmd): + out = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE).stderr.read().decode("utf-8") + + if out.find("error:") >=0: + print(cmd) + print(out) + + + + def run(self): + tdSql.prepare() + build_path = self.getBuildPath() + "/debug/build/bin" + tdLog.info("====== check tables use taos -d -k ========") + + tdSql.execute("drop database if exists test") + tdSql.execute("drop database if exists dumptest") + tdSql.execute("create database if not exists test") + # self.check_coredump("====== only create database test ==== ") + + tdSql.execute("use test") + tdSql.execute("create stable st (ts timestamp , id int , val double , str binary(20) ) tags (ind int)") + tdSql.execute("create table tb1 using st tags(1)") + self.check_coredump("======= only create one table =======") + + tdSql.execute("create table tb2 using st tags(2)") + tdSql.execute("create table tb3 using st tags(3)") + # self.check_coredump("======= only create three table =======") + + tdSql.execute("create table tb4 using st tags(4)") + tdSql.execute("create table tb5 using st tags(5)") + self.check_coredump("======= only create five table =======") + + start_time = 1604298064000 + rows = 10 + tb_nums = 5 + tdLog.info("====== start insert rows ========") + + for i in range(1, tb_nums + 1): + for j in range(rows): + start_time += 10 + tdSql.execute( + "insert into tb%d values(%d, %d,%f,%s) " % (i, start_time, j, float(j), "'str" + str(j) + "'")) + tdSql.query("select count(*) from st") + tdSql.checkData(0, 0, 50) + + for i in range(1, tb_nums + 1): + tdSql.execute("select * from test.tb%s" % (str(i))) + + tdLog.info("====== check taos -D filedir ========") + + if not os.path.exists("./dumpdata"): + os.mkdir("./dumpdata") + else: + shutil.rmtree("./dumpdata") + os.mkdir("./dumpdata") + + os.system(build_path + "/" + "taosdump -D test -o ./dumpdata") + sleep(2) + os.system("cd ./dumpdata && mv dbs.sql tables.sql") + os.system('sed -i "s/test/dumptest/g" `grep test -rl ./dumpdata`') + os.system(build_path + "/" + "taos -D ./dumpdata") + tdSql.query("select count(*) from dumptest.st") + tdSql.checkData(0, 0, 50) + + tdLog.info("========test other file name about tables.sql========") + os.system("rm -rf ./dumpdata/*") + os.system(build_path + "/" + "taosdump -D test -o ./dumpdata") + sleep(2) + os.system("cd ./dumpdata && mv dbs.sql table.sql") + os.system('sed -i "s/test/tt/g" `grep test -rl ./dumpdata`') + os.system(build_path + "/" + "taos -D ./dumpdata") + + tdLog.info("====== check taos shell params ========") + + tdLog.info("====== step 1 : insert data with some unicode ========") + + sqls = ["drop database if exists dbst", + "create database dbst", + "use dbst", + "create stable dbst.st (ts timestamp , id int , val double , str binary(200) ,char nchar(200) ) tags (ind int)", + "create table dbst.tb1 using dbst.st tags(1)", + "create table dbst.tb2 using dbst.st tags(2)", + "insert into dbst.tb1 values('2021-07-14T10:40:00.006+0800' , 1 , 1.0 , 'binary_1','中文-1') ", + "insert into dbst.tb1 values('2021-07-14T10:40:00.006Z' , 1 , 1.0 , 'binary\\'1','中文?-1')", + "insert into dbst.tb1 values('2021-07-14 10:40:00.000',1,1.0,'!@#¥%……&*', '中文12&%#@!*')", + "insert into dbst.tb1 values(now ,1,1.0,'(){}[];./?&*\n', '中文&%#@!*34')", + "insert into dbst.tb1 values(now ,1,1.0,'\\t\\0', '中文_\\t\\0')", + # "insert into dbst.tb1 values(now ,1,1.0,'\t\"', '中文_\t\\')", + "CREATE STABLE dbst.stb (TS TIMESTAMP , ID INT , VAL DOUBLE , STR BINARY(200) ,CHAR NCHAR(200) ) TAGS (IND INT)", + "CREATE TABLE dbst.tbb1 USING dbst.STB TAGS(1)", + "CREATE TABLE dbst.tbb2 USING dbst.STB TAGS(2)", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14T10:40:00.006+0800' , 1 , 1.0 , 'BINARY_1','中文-1')", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14T10:40:00.006Z' , 1 , 1.0 , 'BINARY1','中文?-1')", + "INSERT INTO dbst.TBB1 VALUES('2021-07-14 10:40:00.000',1,1.0,'!@#¥%……&*', '中文12&%#@!*');"] + for sql in sqls: + cmd = build_path + "/" + "taos -s \""+sql+"\"" + self.execute_cmd(cmd) + + + + basic_code = ['!' ,'#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', + 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M','N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\',']' ,'^', '_', '`', 'a', 'b', 'c', + 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r','s', 't', 'u', + 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'] + for code in basic_code: + if not code=='\\': + cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0,'"+code+"','汉字"+code+"\')\"" + else: + cmd = build_path + "/" + "taos -s \" insert into dbst.tb2 values(now ,2,2.0," +r'"\\"'+",'中文"+r'\\'+ "')\"" + + self.execute_cmd(cmd) + + + + tdLog.info("====== step 2 : query result of results ========") + + querys = ["select count(*) from dbst.tb2", + "show dbst.tables", + "show dbst.tables like tb_", + "show dbst.tables like 't%'", + "select * from dbst.stb", + "select avg(val),max(id),min(id) from dbst.st ", + "select last_row(*) from dbst.st", + "select * from dbst.st where ts >'2021-07-14T10:40:00.006+0800' and ind = 1 ", + "select max(val) from dbst.st where ts >'2021-07-14T10:40:00.006+0800' group by tbname", + "select count(*) from dbst.st interval(1s) group by tbname", + "show queries ", + "show connections", + "show functions", + "select * from dbst.tb2 where str like 'a'", + "select bottom(id, 3) from dbst.st; ", + "select _block_dist() from dbst.st;", + "select 5 from dbst.tb1;", + "select id , val from dbst.st", + "describe dbst.st", + "alter stable dbst.st modify column str binary(205);" ] + + for query in querys: + cmd = build_path + "/" + "taos -s \""+query+"\"" + self.execute_cmd(cmd) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 413f27922eee2b7d35f9890d764585f40ac0c129..3dada72db0bb0c966f55ee9f75c3a239f422a420 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -293,6 +293,7 @@ python3 ./test.py -f client/client.py python3 ./test.py -f client/version.py python3 ./test.py -f client/alterDatabase.py python3 ./test.py -f client/noConnectionErrorTest.py +python3 ./test.py -f client/taoshellCheckCase.py # python3 test.py -f client/change_time_1_1.py # python3 test.py -f client/change_time_1_2.py