Merge branch '3.0' into merge/mainto3.0

This commit is contained in:
Shengliang Guan 2024-11-28 21:50:18 +08:00
commit a0042719ce
9 changed files with 225 additions and 6 deletions

View File

@ -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"
]
}
]
}
]
}
]
}

View File

@ -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())

View File

@ -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
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

View File

@ -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
return decimal % max
# remove single and doulbe quotation
def removeQuota(origin):
value = ""
for c in origin:
if c != '\'' and c != '"':
value += c
return value

View File

@ -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

View File

@ -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];

View File

@ -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");
}

View File

@ -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;
}

View File

@ -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;
}