diff --git a/tests/army/cmdline/json/taosCli.json b/tests/army/cmdline/json/taosCli.json new file mode 100644 index 0000000000..2dcd28afdb --- /dev/null +++ b/tests/army/cmdline/json/taosCli.json @@ -0,0 +1,57 @@ +{ + "filetype":"insert", + "cfgdir":"/etc/taos", + "host":"127.0.0.1", + "port":6030, + "user":"root", + "password":"taosdata", + "thread_count":1, + "create_table_thread_count":1, + "confirm_parameter_prompt":"no", + "prepare_rand":100, + "num_of_records_per_req":100, + "databases": [ + { + "dbinfo":{ + "name":"test", + "drop":"yes" + }, + "super_tables":[ + { + "name":"meters", + "child_table_exists":"no", + "childtable_prefix":"d", + "data_source":"rand", + "insert_mode":"taosc", + "childtable_count": 1, + "insert_rows":10, + "timestamp_step":1000, + "start_timestamp":"2022-10-01 00:00:00.000", + "columns":[ + { "type": "int", "count": 1000, "max": 2000, "min": 0 } + ], + "tags":[ + { + "type":"binary", + "name":"location", + "max":64, + "min":1, + "values":[ + "San Francisco", + "Los Angles", + "San Diego", + "San Jose", + "Palo Alto", + "Campbell", + "Mountain View", + "Sunnyvale", + "Santa Clara", + "Cupertino" + ] + } + ] + } + ] + } + ] +} diff --git a/tests/army/cmdline/taosCli.py b/tests/army/cmdline/taosCli.py new file mode 100644 index 0000000000..d446a25c86 --- /dev/null +++ b/tests/army/cmdline/taosCli.py @@ -0,0 +1,67 @@ +################################################################### +# 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 +import time +import random + +import frame.eos +import frame.etime +import frame.etool +import frame.etool +import frame.etool +import frame.etool +import taos +import frame.etool +import frame + +from frame.log import * +from frame.sql import * +from frame.cases import * +from frame.caseBase import * +from frame.srvCtl import * +from frame import * + + +class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"query" + } + + def checkDescribe(self): + tdLog.info(f"check describe show full.") + + # insert + json = "cmdline/json/taosCli.json" + db, stb, childCount, insertRows = self.insertBenchJson(json) + # describe + sql = f"describe {db}.{stb};" + tdSql.query(sql) + tdSql.checkRows(2 + 1000) + # desc + sql = f"desc {db}.{stb};" + tdSql.query(sql) + tdSql.checkRows(2 + 1000) + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + + # check show whole + self.checkDescribe() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/frame/caseBase.py b/tests/army/frame/caseBase.py index c2b3411e77..3cb33e8fbc 100644 --- a/tests/army/frame/caseBase.py +++ b/tests/army/frame/caseBase.py @@ -17,9 +17,13 @@ import time import datetime import random import copy +import json +import frame.eutil from frame.log import * from frame.sql import * +from frame import * +import frame # test case base class TBase: @@ -317,4 +321,77 @@ class TBase: if strs != "": strs += sepa strs += f"'{ls}'" - return strs \ No newline at end of file + return strs + +# +# taosBenchmark +# + + # run taosBenchmark and check insert Result + def insertBenchJson(self, jsonFile, options="", checkStep=False): + # exe insert + cmd = f"{options} -f {jsonFile}" + frame.etool.benchMark(command = cmd) + + # + # check insert result + # + with open(jsonFile, "r") as file: + data = json.load(file) + + db = data["databases"][0]["dbinfo"]["name"] + stb = data["databases"][0]["super_tables"][0]["name"] + child_count = data["databases"][0]["super_tables"][0]["childtable_count"] + insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"] + timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"] + + # drop + try: + drop = data["databases"][0]["dbinfo"]["drop"] + except: + drop = "yes" + + # command is first + if options.find("-Q") != -1: + drop = "no" + + # cachemodel + try: + cachemode = data["databases"][0]["dbinfo"]["cachemodel"] + except: + cachemode = None + + # vgropus + try: + vgroups = data["databases"][0]["dbinfo"]["vgroups"] + except: + vgroups = None + + tdLog.info(f"get json info: db={db} stb={stb} child_count={child_count} insert_rows={insert_rows} \n") + + # all count insert_rows * child_table_count + sql = f"select * from {db}.{stb}" + tdSql.query(sql) + tdSql.checkRows(child_count * insert_rows) + + # timestamp step + if checkStep: + sql = f"select * from (select diff(ts) as dif from {db}.{stb} partition by tbname) where dif != {timestamp_step};" + tdSql.query(sql) + tdSql.checkRows(0) + + if drop.lower() == "yes": + # check database optins + sql = f"select `vgroups`,`cachemodel` from information_schema.ins_databases where name='{db}';" + tdSql.query(sql) + + if cachemode != None: + + value = frame.eutil.removeQuota(cachemode) + tdLog.info(f" deal both origin={cachemode} after={value}") + tdSql.checkData(0, 1, value) + + if vgroups != None: + tdSql.checkData(0, 0, vgroups) + + return db, stb,child_count, insert_rows \ No newline at end of file diff --git a/tests/army/frame/eutil.py b/tests/army/frame/eutil.py index a32e6e9a38..459a45b0b0 100644 --- a/tests/army/frame/eutil.py +++ b/tests/army/frame/eutil.py @@ -25,4 +25,13 @@ import psutil # cpu frequent as random def cpuRand(max): decimal = int(str(psutil.cpu_freq().current).split(".")[1]) - return decimal % max \ No newline at end of file + return decimal % max + +# remove single and doulbe quotation +def removeQuota(origin): + value = "" + for c in origin: + if c != '\'' and c != '"': + value += c + + return value \ No newline at end of file diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index cb307fe9eb..0cc84ad0ec 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -52,6 +52,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f query/sys/tb_perf_queries_exist_test.py -N 3 ,,y,army,./pytest.sh python3 ./test.py -f query/test_having.py ,,n,army,python3 ./test.py -f tmq/drop_lost_comsumers.py +,,y,army,./pytest.sh python3 ./test.py -f cmdline/taosCli.py # # system test diff --git a/tools/shell/inc/shellInt.h b/tools/shell/inc/shellInt.h index ba3dadc646..b1f09d5161 100644 --- a/tools/shell/inc/shellInt.h +++ b/tools/shell/inc/shellInt.h @@ -48,6 +48,7 @@ #define SHELL_FLOAT_WIDTH 20 #define SHELL_DOUBLE_WIDTH 25 +#define ERROR_CODE_DETAIL "\r\n\r\nTo view possible causes and suggested actions for error codes, see \r\n\"Error Code Reference\" in the TDengine online documentation.\r\n" typedef struct { char* hist[SHELL_MAX_HISTORY_SIZE]; char file[TSDB_FILENAME_LEN]; diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 959e2d6d62..9fc929a595 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -662,6 +662,7 @@ void showHelp() { now - current time \n\ Example : \n\ select * from t1 where ts > now - 2w + 3d and ts <= now - 1w -2h ;\n"); + printf(ERROR_CODE_DETAIL); printf("\n"); } diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 6d56aa7fe2..6fcebd667d 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -730,6 +730,10 @@ bool shellIsShowWhole(const char *sql) { if (taosStrCaseStr(sql, "describe ") != NULL) { return true; } + // desc + if (taosStrCaseStr(sql, "desc ") != NULL) { + return true; + } // show if (taosStrCaseStr(sql, "show ") != NULL) { return true; @@ -1091,7 +1095,7 @@ void shellCleanupHistory() { void shellPrintError(TAOS_RES *tres, int64_t st) { int64_t et = taosGetTimestampUs(); - fprintf(stderr, "\r\nDB error: %s (%.6fs)\r\n", taos_errstr(tres), (et - st) / 1E6); + fprintf(stderr, "\r\nDB error: %s[0x%08X] (%.6fs)\r\n", taos_errstr(tres), taos_errno(tres), (et - st) / 1E6); taos_free_result(tres); } @@ -1303,6 +1307,8 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (shell.args.restful || shell.args.cloud) { if (shell_conn_ws_server(1)) { + printf("failed to connect to server, reason: %s[0x%08X]\n%s", ws_errstr(NULL), ws_errno(NULL), ERROR_CODE_DETAIL); + fflush(stdout); return -1; } } else { @@ -1314,7 +1320,7 @@ int32_t shellExecute() { } if (shell.conn == NULL) { - printf("failed to connect to server, reason: %s\n", taos_errstr(NULL)); + printf("failed to connect to server, reason: %s[0x%08X]\n%s", taos_errstr(NULL), taos_errno(NULL), ERROR_CODE_DETAIL); fflush(stdout); return -1; } diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index 1ec1697c3a..61074102be 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -286,8 +286,8 @@ void shellRunSingleCommandWebsocketImp(char *command) { // if it's not a ws connection error if (TSDB_CODE_WS_DSN_ERROR != (code&TSDB_CODE_WS_DSN_ERROR)) { et = taosGetTimestampUs(); - fprintf(stderr, "\nDB: error: %s (%.6fs)\n", - ws_errstr(res), (et - st)/1E6); + fprintf(stderr, "\nDB: error:0x%08X %s (%.6fs)\n", + ws_errno(res), ws_errstr(res), (et - st)/1E6); ws_free_result(res); return; }