提交 9b19420c 编写于 作者: W wenzhouwww@live.cn

Merge remote-tracking branch 'origin/3.0' into test/cluster_case

...@@ -23,7 +23,7 @@ A single line of text is used in OpenTSDB line protocol to represent one row of ...@@ -23,7 +23,7 @@ A single line of text is used in OpenTSDB line protocol to represent one row of
- `metric` will be used as the STable name. - `metric` will be used as the STable name.
- `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported. - `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported.
- `value` is a metric which must be a numeric value, the corresponding column name is "value". - `value` is a metric which must be a numeric value, the corresponding column name is "_value".
- The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically. - The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically.
For example: For example:
...@@ -74,7 +74,7 @@ taos> show STables; ...@@ -74,7 +74,7 @@ taos> show STables;
Query OK, 2 row(s) in set (0.002544s) Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`; taos> select tbname, * from `meters.current`;
tbname | ts | value | groupid | location | tbname | _ts | _value | groupid | location |
================================================================================================================================== ==================================================================================================================================
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles |
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles |
......
...@@ -91,7 +91,7 @@ taos> show STables; ...@@ -91,7 +91,7 @@ taos> show STables;
Query OK, 2 row(s) in set (0.001954s) Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`; taos> select * from `meters.current`;
ts | value | groupid | location | _ts | _value | groupid | location |
=================================================================================================================== ===================================================================================================================
2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco |
2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco |
......
...@@ -23,7 +23,7 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB ...@@ -23,7 +23,7 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB
- metric 将作为超级表名。 - metric 将作为超级表名。
- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 - timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度
- value 度量值,必须为一个数值。对应的列名也是 “value”。 - value 度量值,必须为一个数值。对应的列名是 “_value”。
- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; - 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型;
例如: 例如:
...@@ -74,7 +74,7 @@ taos> show stables; ...@@ -74,7 +74,7 @@ taos> show stables;
Query OK, 2 row(s) in set (0.002544s) Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`; taos> select tbname, * from `meters.current`;
tbname | ts | value | groupid | location | tbname | _ts | _value | groupid | location |
================================================================================================================================== ==================================================================================================================================
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles |
t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles | t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles |
......
...@@ -91,7 +91,7 @@ taos> show stables; ...@@ -91,7 +91,7 @@ taos> show stables;
Query OK, 2 row(s) in set (0.001954s) Query OK, 2 row(s) in set (0.001954s)
taos> select * from `meters.current`; taos> select * from `meters.current`;
ts | value | groupid | location | _ts | _value | groupid | location |
=================================================================================================================== ===================================================================================================================
2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco |
2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco |
......
此差异已折叠。
...@@ -89,7 +89,6 @@ extern uint16_t tsTelemPort; ...@@ -89,7 +89,6 @@ extern uint16_t tsTelemPort;
// query buffer management // query buffer management
extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing
extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node
extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
// query client // query client
extern int32_t tsQueryPolicy; extern int32_t tsQueryPolicy;
......
...@@ -124,9 +124,6 @@ int32_t tsMinIntervalTime = 1; ...@@ -124,9 +124,6 @@ int32_t tsMinIntervalTime = 1;
int32_t tsQueryBufferSize = -1; int32_t tsQueryBufferSize = -1;
int64_t tsQueryBufferSizeBytes = -1; int64_t tsQueryBufferSizeBytes = -1;
// in retrieve blocking model, the retrieve threads will wait for the completion of the query processing.
bool tsRetrieveBlockingModel = false;
// tsdb config // tsdb config
// For backward compatibility // For backward compatibility
bool tsdbForceKeepFile = false; bool tsdbForceKeepFile = false;
...@@ -296,6 +293,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) { ...@@ -296,6 +293,7 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "smaDebugFlag", smaDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "idxDebugFlag", idxDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1; if (cfgAddInt32(pCfg, "tdbDebugFlag", tdbDebugFlag, 0, 255, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "metaDebugFlag", metaDebugFlag, 0, 255, 0) != 0) return -1;
return 0; return 0;
} }
...@@ -362,7 +360,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { ...@@ -362,7 +360,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1; if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, 0) != 0) return -1;
if (cfgAddBool(pCfg, "retrieveBlockingModel", tsRetrieveBlockingModel, 0) != 0) return -1;
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1; if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1; if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
...@@ -476,6 +473,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) { ...@@ -476,6 +473,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32;
idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32;
tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32;
metaDebugFlag = cfgGetItem(pCfg, "metaDebugFlag")->i32;
} }
static int32_t taosSetClientCfg(SConfig *pCfg) { static int32_t taosSetClientCfg(SConfig *pCfg) {
...@@ -547,7 +545,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { ...@@ -547,7 +545,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32; tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32;
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval; tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval; tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
...@@ -832,9 +829,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { ...@@ -832,9 +829,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
break; break;
} }
case 'r': { case 'r': {
if (strcasecmp("retrieveBlockingModel", name) == 0) { if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) {
tsRetrieveBlockingModel = cfgGetItem(pCfg, "retrieveBlockingModel")->bval;
} else if (strcasecmp("rpcQueueMemoryAllowed", name) == 0) {
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
} else if (strcasecmp("rpcDebugFlag", name) == 0) { } else if (strcasecmp("rpcDebugFlag", name) == 0) {
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
...@@ -1100,12 +1095,12 @@ void taosCfgDynamicOptions(const char *option, const char *value) { ...@@ -1100,12 +1095,12 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
const char *options[] = { const char *options[] = {
"dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag",
"tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag",
"tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag",
}; };
int32_t *optionVars[] = { int32_t *optionVars[] = {
&dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag,
&tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag, &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tdbDebugFlag,
&tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &tmrDebugFlag, &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, &metaDebugFlag,
}; };
int32_t optionSize = tListLen(options); int32_t optionSize = tListLen(options);
...@@ -1152,5 +1147,6 @@ void taosSetAllDebugFlag(int32_t flag) { ...@@ -1152,5 +1147,6 @@ void taosSetAllDebugFlag(int32_t flag) {
taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag); taosSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag);
taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag); taosSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag);
taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag); taosSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag);
taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag);
uInfo("all debug flag are set to %d", flag); uInfo("all debug flag are set to %d", flag);
} }
...@@ -788,9 +788,9 @@ _OVER: ...@@ -788,9 +788,9 @@ _OVER:
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node; SMnode *pMnode = pReq->info.node;
const char *options[] = { const char *options[] = {
"debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag",
"tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tdbDebugFlag", "tmrDebugFlag",
"tdbDebugFlag", "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", "metaDebugFlag",
}; };
int32_t optionSize = tListLen(options); int32_t optionSize = tListLen(options);
......
...@@ -2068,7 +2068,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2068,7 +2068,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "apercentile", .name = "apercentile",
.type = FUNCTION_TYPE_APERCENTILE, .type = FUNCTION_TYPE_APERCENTILE,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateApercentile, .translateFunc = translateApercentile,
.getEnvFunc = getApercentileFuncEnv, .getEnvFunc = getApercentileFuncEnv,
.initFunc = apercentileFunctionSetup, .initFunc = apercentileFunctionSetup,
...@@ -2083,7 +2083,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2083,7 +2083,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
}, },
{ {
.name = "_apercentile_partial", .name = "_apercentile_partial",
.type = FUNCTION_TYPE_APERCENTILE_PARTIAL, .type = FUNCTION_TYPE_APERCENTILE_PARTIAL | FUNC_MGT_TIMELINE_FUNC,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateApercentilePartial, .translateFunc = translateApercentilePartial,
.getEnvFunc = getApercentileFuncEnv, .getEnvFunc = getApercentileFuncEnv,
...@@ -2096,7 +2096,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2096,7 +2096,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "_apercentile_merge", .name = "_apercentile_merge",
.type = FUNCTION_TYPE_APERCENTILE_MERGE, .type = FUNCTION_TYPE_APERCENTILE_MERGE,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateApercentileMerge, .translateFunc = translateApercentileMerge,
.getEnvFunc = getApercentileFuncEnv, .getEnvFunc = getApercentileFuncEnv,
.initFunc = apercentileFunctionSetup, .initFunc = apercentileFunctionSetup,
......
...@@ -82,7 +82,7 @@ int64_t tsNumOfTraceLogs = 0; ...@@ -82,7 +82,7 @@ int64_t tsNumOfTraceLogs = 0;
// log // log
int32_t dDebugFlag = 135; int32_t dDebugFlag = 135;
int32_t vDebugFlag = 135; int32_t vDebugFlag = 135;
int32_t mDebugFlag = 131; int32_t mDebugFlag = 135;
int32_t cDebugFlag = 131; int32_t cDebugFlag = 131;
int32_t jniDebugFlag = 131; int32_t jniDebugFlag = 131;
int32_t tmrDebugFlag = 131; int32_t tmrDebugFlag = 131;
......
...@@ -24,14 +24,20 @@ sql alter dnode 1 'fsDebugFlag 131' ...@@ -24,14 +24,20 @@ sql alter dnode 1 'fsDebugFlag 131'
sql alter dnode 1 'udfDebugFlag 131' sql alter dnode 1 'udfDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'idxDebugFlag 131' sql alter dnode 1 'idxDebugFlag 131'
sql alter dnode 1 'tdbDebugFlag 131'
sql alter dnode 1 'tmrDebugFlag 131' sql alter dnode 1 'tmrDebugFlag 131'
sql alter dnode 1 'uDebugFlag 131' sql alter dnode 1 'uDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131' sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'rpcDebugFlag 131' sql alter dnode 1 'rpcDebugFlag 131'
sql alter dnode 1 'qDebugFlag 131' sql alter dnode 1 'qDebugFlag 131'
sql alter dnode 1 'metaDebugFlag 131'
sql_error alter dnode 2 'wDebugFlag 135' sql_error alter dnode 2 'wDebugFlag 135'
sql_error alter dnode 2 'tmrDebugFlag 135' sql_error alter dnode 2 'tmrDebugFlag 135'
sql_error alter dnode 1 'monDebugFlag 131'
sql_error alter dnode 1 'cqDebugFlag 131'
sql_error alter dnode 1 'httpDebugFlag 131'
sql_error alter dnode 1 'mqttDebugFlag 131'
print ======== step3 print ======== step3
sql_error alter $hostname1 debugFlag 135 sql_error alter $hostname1 debugFlag 135
......
...@@ -50,9 +50,9 @@ class TDTestCase: ...@@ -50,9 +50,9 @@ class TDTestCase:
'col11': 'bool', 'col11': 'bool',
'col12': f'binary({self.str_length})', 'col12': f'binary({self.str_length})',
'col13': f'nchar({self.str_length})', 'col13': f'nchar({self.str_length})',
} }
self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX)
self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX)
self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX) self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX)
...@@ -100,15 +100,15 @@ class TDTestCase: ...@@ -100,15 +100,15 @@ class TDTestCase:
elif col_type.lower() == 'bigint unsigned': elif col_type.lower() == 'bigint unsigned':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})')
elif col_type.lower() == 'bool': elif col_type.lower() == 'bool':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})')
elif col_type.lower() == 'float': elif col_type.lower() == 'float':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})')
elif col_type.lower() == 'double': elif col_type.lower() == 'double':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})')
elif 'binary' in col_type.lower(): elif 'binary' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''') tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''')
elif 'nchar' in col_type.lower(): elif 'nchar' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''')
def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1): def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1):
tdSql.execute(f'delete from {tbname}') tdSql.execute(f'delete from {tbname}')
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'flush database {dbname}')
...@@ -164,7 +164,7 @@ class TDTestCase: ...@@ -164,7 +164,7 @@ class TDTestCase:
elif 'nchar' in column_type.lower(): elif 'nchar' in column_type.lower():
tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar']) tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar'])
else: else:
tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type])
def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1): def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1):
for i in range(row_num): for i in range(row_num):
tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}') tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}')
...@@ -189,7 +189,7 @@ class TDTestCase: ...@@ -189,7 +189,7 @@ class TDTestCase:
elif tb_type == 'stb': elif tb_type == 'stb':
tdSql.checkRows(i*tb_num) tdSql.checkRows(i*tb_num)
for j in range(tb_num): for j in range(tb_num):
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
for i in range(row_num): for i in range(row_num):
tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}') tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}')
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'flush database {dbname}')
...@@ -240,7 +240,7 @@ class TDTestCase: ...@@ -240,7 +240,7 @@ class TDTestCase:
tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''') tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''')
else: else:
tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}') tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}')
def delete_data_ntb(self): def delete_data_ntb(self):
tdSql.execute(f'create database if not exists {self.dbname}') tdSql.execute(f'create database if not exists {self.dbname}')
tdSql.execute(f'use {self.dbname}') tdSql.execute(f'use {self.dbname}')
...@@ -295,4 +295,4 @@ class TDTestCase: ...@@ -295,4 +295,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -26,13 +26,13 @@ from util.common import tdCom ...@@ -26,13 +26,13 @@ from util.common import tdCom
import platform import platform
import io import io
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
self._conn = conn self._conn = conn
def createDb(self, name="test", db_update_tag=0): def createDb(self, name="test", db_update_tag=0):
if db_update_tag == 0: if db_update_tag == 0:
...@@ -67,7 +67,7 @@ class TDTestCase: ...@@ -67,7 +67,7 @@ class TDTestCase:
td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
return td_ts return td_ts
#return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
def dateToTs(self, datetime_input): def dateToTs(self, datetime_input):
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
...@@ -274,7 +274,7 @@ class TDTestCase: ...@@ -274,7 +274,7 @@ class TDTestCase:
input_sql = self.gen_influxdb_line(stb_name, tb_name, id, t0, t1, t2, t3, t4, t5, t6, t7, t8, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, ts, input_sql = self.gen_influxdb_line(stb_name, tb_name, id, t0, t1, t2, t3, t4, t5, t6, t7, t8, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, ts,
id_noexist_tag, id_change_tag, id_double_tag, ct_add_tag, ct_am_tag, ct_ma_tag, ct_min_tag, c_multi_tag, t_multi_tag, c_blank_tag, t_blank_tag, chinese_tag) id_noexist_tag, id_change_tag, id_double_tag, ct_add_tag, ct_am_tag, ct_ma_tag, ct_min_tag, c_multi_tag, t_multi_tag, c_blank_tag, t_blank_tag, chinese_tag)
return input_sql, stb_name return input_sql, stb_name
def genMulTagColStr(self, gen_type, count): def genMulTagColStr(self, gen_type, count):
""" """
gen_type must be "tag"/"col" gen_type must be "tag"/"col"
...@@ -370,10 +370,10 @@ class TDTestCase: ...@@ -370,10 +370,10 @@ class TDTestCase:
for t_type in full_type_list: for t_type in full_type_list:
input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type) input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
def symbolsCheckCase(self): def symbolsCheckCase(self):
""" """
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
""" """
''' '''
please test : please test :
...@@ -395,7 +395,7 @@ class TDTestCase: ...@@ -395,7 +395,7 @@ class TDTestCase:
for ts in ts_list: for ts in ts_list:
input_sql, stb_name = self.genFullTypeSql(ts=ts) input_sql, stb_name = self.genFullTypeSql(ts=ts)
self.resCmp(input_sql, stb_name, ts=ts) self.resCmp(input_sql, stb_name, ts=ts)
def idSeqCheckCase(self): def idSeqCheckCase(self):
""" """
check id.index in tags check id.index in tags
...@@ -404,7 +404,7 @@ class TDTestCase: ...@@ -404,7 +404,7 @@ class TDTestCase:
tdCom.cleanTb() tdCom.cleanTb()
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True) input_sql, stb_name = self.genFullTypeSql(id_change_tag=True)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
def idUpperCheckCase(self): def idUpperCheckCase(self):
""" """
check id param check id param
...@@ -444,7 +444,7 @@ class TDTestCase: ...@@ -444,7 +444,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def idIllegalNameCheckCase(self): def idIllegalNameCheckCase(self):
""" """
test illegal id name test illegal id name
...@@ -490,7 +490,7 @@ class TDTestCase: ...@@ -490,7 +490,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def illegalTsCheckCase(self): def illegalTsCheckCase(self):
""" """
check ts format like 16260068336390us19 check ts format like 16260068336390us19
...@@ -575,11 +575,11 @@ class TDTestCase: ...@@ -575,11 +575,11 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# binary # binary
stb_name = tdCom.getLongName(7, "letters") stb_name = tdCom.getLongName(7, "letters")
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}" c0=f 1626006833639000000' input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16375, "letters")}" c0=f 1626006833639000000' input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16375, "letters")}" c0=f 1626006833639000000'
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -647,7 +647,7 @@ class TDTestCase: ...@@ -647,7 +647,7 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# f32 # f32
for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: for c5 in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
input_sql, stb_name = self.genFullTypeSql(c5=c5) input_sql, stb_name = self.genFullTypeSql(c5=c5)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
...@@ -671,11 +671,11 @@ class TDTestCase: ...@@ -671,11 +671,11 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# # # binary # # # binary
# stb_name = tdCom.getLongName(7, "letters") # stb_name = tdCom.getLongName(7, "letters")
# input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000' # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16374, "letters")}" 1626006833639000000'
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
# input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000' # input_sql = f'{stb_name},t0=t c0=f,c1="{tdCom.getLongName(16375, "letters")}" 1626006833639000000'
# try: # try:
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
...@@ -715,13 +715,13 @@ class TDTestCase: ...@@ -715,13 +715,13 @@ class TDTestCase:
# i8 i16 i32 i64 f32 f64 # i8 i16 i32 i64 f32 f64
for input_sql in [ for input_sql in [
self.genFullTypeSql(t1="1s2i8")[0], self.genFullTypeSql(t1="1s2i8")[0],
self.genFullTypeSql(t2="1s2i16")[0], self.genFullTypeSql(t2="1s2i16")[0],
self.genFullTypeSql(t3="1s2i32")[0], self.genFullTypeSql(t3="1s2i32")[0],
self.genFullTypeSql(t4="1s2i64")[0], self.genFullTypeSql(t4="1s2i64")[0],
self.genFullTypeSql(t5="11.1s45f32")[0], self.genFullTypeSql(t5="11.1s45f32")[0],
self.genFullTypeSql(t6="11.1s45f64")[0], self.genFullTypeSql(t6="11.1s45f64")[0],
self.genFullTypeSql(c1="1s2i8")[0], self.genFullTypeSql(c1="1s2i8")[0],
self.genFullTypeSql(c2="1s2i16")[0], self.genFullTypeSql(c2="1s2i16")[0],
self.genFullTypeSql(c3="1s2i32")[0], self.genFullTypeSql(c3="1s2i32")[0],
self.genFullTypeSql(c4="1s2i64")[0], self.genFullTypeSql(c4="1s2i64")[0],
...@@ -746,14 +746,14 @@ class TDTestCase: ...@@ -746,14 +746,14 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# check accepted binary and nchar symbols # check accepted binary and nchar symbols
# # * ~!@#$¥%^&*()-+={}|[]、「」:; # # * ~!@#$¥%^&*()-+={}|[]、「」:;
for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000' input_sql1 = f'{stb_name},t0=t c0=f,c1="abc{symbol}aaa" 1626006833639000000'
input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000' input_sql2 = f'{stb_name},t0=t,t1="abc{symbol}aaa" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
# self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
def duplicateIdTagColInsertCheckCase(self): def duplicateIdTagColInsertCheckCase(self):
""" """
check duplicate Id Tag Col check duplicate Id Tag Col
...@@ -810,7 +810,7 @@ class TDTestCase: ...@@ -810,7 +810,7 @@ class TDTestCase:
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
self.resCmp(input_sql, stb_name) self.resCmp(input_sql, stb_name)
@tdCom.smlPass @tdCom.smlPass
def tagColBinaryNcharLengthCheckCase(self): def tagColBinaryNcharLengthCheckCase(self):
""" """
...@@ -829,7 +829,7 @@ class TDTestCase: ...@@ -829,7 +829,7 @@ class TDTestCase:
check column and tag count add, stb and tb duplicate check column and tag count add, stb and tb duplicate
* tag: alter table ... * tag: alter table ...
* col: when update==0 and ts is same, unchange * col: when update==0 and ts is same, unchange
* so this case tag&&value will be added, * so this case tag&&value will be added,
* col is added without value when update==0 * col is added without value when update==0
* col is added with value when update==1 * col is added with value when update==1
""" """
...@@ -897,7 +897,7 @@ class TDTestCase: ...@@ -897,7 +897,7 @@ class TDTestCase:
# * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2 # * every binary and nchar must be length+2, so here is two tag, max length could not larger than 16384-2*2
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}" c0=f 1626006833639000000' input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(5, "letters")}" c0=f 1626006833639000000'
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
tdSql.query(f"select * from {stb_name}") tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(2) tdSql.checkRows(2)
input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}" c0=f 1626006833639000000' input_sql = f'{stb_name},t0=t,t1="{tdCom.getLongName(16374, "letters")}",t2="{tdCom.getLongName(6, "letters")}" c0=f 1626006833639000000'
...@@ -922,7 +922,7 @@ class TDTestCase: ...@@ -922,7 +922,7 @@ class TDTestCase:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
tdSql.query(f"select * from {stb_name}") tdSql.query(f"select * from {stb_name}")
tdSql.checkRows(3) tdSql.checkRows(3)
# * tag nchar max is 16374/4, col+ts nchar max 49151 # * tag nchar max is 16374/4, col+ts nchar max 49151
def tagColNcharMaxLengthCheckCase(self): def tagColNcharMaxLengthCheckCase(self):
""" """
...@@ -977,7 +977,7 @@ class TDTestCase: ...@@ -977,7 +977,7 @@ class TDTestCase:
"st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" "st123456,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000"
] ]
self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value) self._conn.schemaless_insert(lines, TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
def multiInsertCheckCase(self, count): def multiInsertCheckCase(self, count):
""" """
test multi insert test multi insert
...@@ -1073,7 +1073,7 @@ class TDTestCase: ...@@ -1073,7 +1073,7 @@ class TDTestCase:
self.multiThreadRun(self.genMultiThreadSeq(input_sql)) self.multiThreadRun(self.genMultiThreadSeq(input_sql))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(5) tdSql.checkRows(5)
def sStbStbDdataInsertMultiThreadCheckCase(self): def sStbStbDdataInsertMultiThreadCheckCase(self):
""" """
thread input same stb tb, different data, result keep first data thread input same stb tb, different data, result keep first data
...@@ -1107,7 +1107,7 @@ class TDTestCase: ...@@ -1107,7 +1107,7 @@ class TDTestCase:
tdSql.checkEqual(tb_name, expected_tb_name) tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};") tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) tdSql.checkRows(1)
def sStbStbDdataMtcInsertMultiThreadCheckCase(self): def sStbStbDdataMtcInsertMultiThreadCheckCase(self):
""" """
thread input same stb tb, different data, minus columes and tags, result keep first data thread input same stb tb, different data, minus columes and tags, result keep first data
...@@ -1217,7 +1217,7 @@ class TDTestCase: ...@@ -1217,7 +1217,7 @@ class TDTestCase:
tdSql.checkRows(6) tdSql.checkRows(6)
for c in ["c7", "c8", "c9"]: for c in ["c7", "c8", "c9"]:
tdSql.query(f"select * from {stb_name} where {c} is NULL") tdSql.query(f"select * from {stb_name} where {c} is NULL")
tdSql.checkRows(5) tdSql.checkRows(5)
for t in ["t10", "t11"]: for t in ["t10", "t11"]:
tdSql.query(f"select * from {stb_name} where {t} is not NULL;") tdSql.query(f"select * from {stb_name} where {t} is not NULL;")
tdSql.checkRows(6) tdSql.checkRows(6)
......
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
case1: limit offset base function test case1: limit offset base function test
case2: offset return valid case2: offset return valid
''' '''
return return
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
# self.create_tables(); # self.create_tables();
self.ts = 1500000000000 self.ts = 1500000000000
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -80,7 +80,7 @@ class TDTestCase: ...@@ -80,7 +80,7 @@ class TDTestCase:
def newcur(self,host,cfg): def newcur(self,host,cfg):
user = "root" user = "root"
password = "taosdata" password = "taosdata"
port =6030 port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
cur=con.cursor() cur=con.cursor()
print(cur) print(cur)
...@@ -90,7 +90,7 @@ class TDTestCase: ...@@ -90,7 +90,7 @@ class TDTestCase:
def create_tables(self,host,dbname,stbname,count): def create_tables(self,host,dbname,stbname,count):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tsql.execute("use %s" %dbname) tsql.execute("use %s" %dbname)
...@@ -109,7 +109,7 @@ class TDTestCase: ...@@ -109,7 +109,7 @@ class TDTestCase:
tsql.execute(sql) tsql.execute(sql)
sql = pre_create sql = pre_create
# print(time.time()) # print(time.time())
# end sql # end sql
if sql != pre_create: if sql != pre_create:
# print(sql) # print(sql)
tsql.execute(sql) tsql.execute(sql)
...@@ -122,7 +122,7 @@ class TDTestCase: ...@@ -122,7 +122,7 @@ class TDTestCase:
def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount): def mutiThread_create_tables(self,host,dbname,stbname,vgroups,threadNumbers,childcount):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tdLog.debug("create database %s"%dbname) tdLog.debug("create database %s"%dbname)
tsql.execute("drop database if exists %s"%dbname) tsql.execute("drop database if exists %s"%dbname)
...@@ -132,7 +132,7 @@ class TDTestCase: ...@@ -132,7 +132,7 @@ class TDTestCase:
threads = [] threads = []
for i in range(threadNumbers): for i in range(threadNumbers):
tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,))) threads.append(thd.Thread(target=self.create_tables, args=(host, dbname, stbname+"%d"%i, count,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
spendTime=end_time-start_time spendTime=end_time-start_time
speedCreate=threadNumbers*count/spendTime speedCreate=threadNumbers*count/spendTime
tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate)) tdLog.debug("spent %.2fs to create %d stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,threadNumbers,threadNumbers*count,speedCreate))
return return
# def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop): # def create_tables(self,host,dbname,stbname,vgroups,tcountStart,tcountStop):
...@@ -169,7 +169,7 @@ class TDTestCase: ...@@ -169,7 +169,7 @@ class TDTestCase:
# print(sql) # print(sql)
tsql.execute(sql) tsql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i) sql = "insert into %s_%d values " %(stbname,i)
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
# print(sql) # print(sql)
print(len(sql)) print(len(sql))
...@@ -184,7 +184,7 @@ class TDTestCase: ...@@ -184,7 +184,7 @@ class TDTestCase:
def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount): def mutiThread_insert_data(self, host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tdLog.debug("ready to inser data") tdLog.debug("ready to inser data")
...@@ -193,7 +193,7 @@ class TDTestCase: ...@@ -193,7 +193,7 @@ class TDTestCase:
threads = [] threads = []
for i in range(threadNumbers): for i in range(threadNumbers):
# tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i)) # tsql.execute("create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"%(stbname,i))
threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,))) threads.append(thd.Thread(target=self.insert_data, args=(host, dbname, stbname+"%d"%i, chilCount, ts_start, childrowcount,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -224,10 +224,10 @@ class TDTestCase: ...@@ -224,10 +224,10 @@ class TDTestCase:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
taosBenchbin = buildPath+ "/build/bin/taosBenchmark" taosBenchbin = buildPath+ "/build/bin/taosBenchmark"
os.system("%s -f %s -y " %(taosBenchbin,jsonFile)) os.system("%s -f %s -y " %(taosBenchbin,jsonFile))
return return
def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count): def taosBenchCreate(self,host,dropdb,dbname,stbname,vgroups,processNumbers,count):
# count=50000 # count=50000
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
...@@ -241,7 +241,7 @@ class TDTestCase: ...@@ -241,7 +241,7 @@ class TDTestCase:
# tsql.getResult("show databases") # tsql.getResult("show databases")
# print(tdSql.queryResult) # print(tdSql.queryResult)
tsql.execute("use %s" %dbname) tsql.execute("use %s" %dbname)
threads = [] threads = []
for i in range(processNumbers): for i in range(processNumbers):
jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i) jsonfile="1-insert/Vgroups%d%d.json"%(vgroups,i)
...@@ -252,7 +252,7 @@ class TDTestCase: ...@@ -252,7 +252,7 @@ class TDTestCase:
os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile)) os.system("sed -i 's/\"childtable_count\": 10000,/\"childtable_count\": %d,/g' %s "%(count,jsonfile))
os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"name\": \"stb1\",/\"name\": \"%s%d\",/g' %s "%(stbname,i,jsonfile))
os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile)) os.system("sed -i 's/\"childtable_prefix\": \"stb1_\",/\"childtable_prefix\": \"%s%d_\",/g' %s "%(stbname,i,jsonfile))
threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,))) threads.append(mp.Process(target=self.taosBench, args=("%s"%jsonfile,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -274,10 +274,10 @@ class TDTestCase: ...@@ -274,10 +274,10 @@ class TDTestCase:
for i in range(stableCount): for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
# test case1 base # test case1 base
def test_case1(self): def test_case1(self):
#stableCount=threadNumbersCtb #stableCount=threadNumbersCtb
parameterDict = {'vgroups': 1, \ parameterDict = {'vgroups': 1, \
...@@ -290,22 +290,22 @@ class TDTestCase: ...@@ -290,22 +290,22 @@ class TDTestCase:
'stbname': 'stb', \ 'stbname': 'stb', \
'host': 'localhost', \ 'host': 'localhost', \
'startTs': 1640966400000} # 2022-01-01 00:00:00.000 'startTs': 1640966400000} # 2022-01-01 00:00:00.000
tdLog.debug("-----create database and muti-thread create tables test------- ") tdLog.debug("-----create database and muti-thread create tables test------- ")
#host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop #host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop
#host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount #host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount
self.mutiThread_create_tables( self.mutiThread_create_tables(
host=parameterDict['host'], host=parameterDict['host'],
dbname=parameterDict['dbname'], dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'], stbname=parameterDict['stbname'],
vgroups=parameterDict['vgroups'], vgroups=parameterDict['vgroups'],
threadNumbers=parameterDict['threadNumbersCtb'], threadNumbers=parameterDict['threadNumbersCtb'],
childcount=parameterDict['tablesPerStb']) childcount=parameterDict['tablesPerStb'])
self.mutiThread_insert_data( self.mutiThread_insert_data(
host=parameterDict['host'], host=parameterDict['host'],
dbname=parameterDict['dbname'], dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'], stbname=parameterDict['stbname'],
threadNumbers=parameterDict['threadNumbersIda'], threadNumbers=parameterDict['threadNumbersIda'],
chilCount=parameterDict['tablesPerStb'], chilCount=parameterDict['tablesPerStb'],
ts_start=parameterDict['startTs'], ts_start=parameterDict['startTs'],
...@@ -315,7 +315,7 @@ class TDTestCase: ...@@ -315,7 +315,7 @@ class TDTestCase:
rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb']
self.checkData(dbname=parameterDict['dbname'],stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'],CtableCount=tableCount,rowsPerSTable=rowsPerStable) self.checkData(dbname=parameterDict['dbname'],stbname=parameterDict['stbname'], stableCount=parameterDict['threadNumbersCtb'],CtableCount=tableCount,rowsPerSTable=rowsPerStable)
def test_case3(self): def test_case3(self):
#stableCount=threadNumbersCtb #stableCount=threadNumbersCtb
parameterDict = {'vgroups': 1, \ parameterDict = {'vgroups': 1, \
...@@ -327,21 +327,21 @@ class TDTestCase: ...@@ -327,21 +327,21 @@ class TDTestCase:
'stbname': 'stb1', \ 'stbname': 'stb1', \
'host': 'localhost', \ 'host': 'localhost', \
'startTs': 1640966400000} # 2022-01-01 00:00:00.000 'startTs': 1640966400000} # 2022-01-01 00:00:00.000
self.taosBenchCreate( self.taosBenchCreate(
parameterDict['host'], parameterDict['host'],
"no", "no",
parameterDict['dbname'], parameterDict['dbname'],
parameterDict['stbname'], parameterDict['stbname'],
parameterDict['vgroups'], parameterDict['vgroups'],
parameterDict['threadNumbersCtb'], parameterDict['threadNumbersCtb'],
parameterDict['tablesPerStb']) parameterDict['tablesPerStb'])
tableCount=parameterDict['threadNumbersCtb']*parameterDict['tablesPerStb'] tableCount=parameterDict['threadNumbersCtb']*parameterDict['tablesPerStb']
rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb'] rowsPerStable=parameterDict['rowsPerTable']*parameterDict['tablesPerStb']
self.checkData( self.checkData(
dbname=parameterDict['dbname'], dbname=parameterDict['dbname'],
stbname=parameterDict['stbname'], stbname=parameterDict['stbname'],
stableCount=parameterDict['threadNumbersCtb'], stableCount=parameterDict['threadNumbersCtb'],
CtableCount=tableCount, CtableCount=tableCount,
rowsPerSTable=rowsPerStable) rowsPerSTable=rowsPerStable)
...@@ -353,9 +353,9 @@ class TDTestCase: ...@@ -353,9 +353,9 @@ class TDTestCase:
# self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000) # self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000)
# self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000) # self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000)
return return
# run case # run case
def run(self): def run(self):
# create database and tables。 # create database and tables。
...@@ -368,7 +368,7 @@ class TDTestCase: ...@@ -368,7 +368,7 @@ class TDTestCase:
return return
# #
# add case with filename # add case with filename
# #
......
...@@ -38,7 +38,7 @@ class TDTestCase: ...@@ -38,7 +38,7 @@ class TDTestCase:
tlist = self.genMultiThreadSeq(sql_list) tlist = self.genMultiThreadSeq(sql_list)
self.multiThreadRun(tlist) self.multiThreadRun(tlist)
tdSql.query(f'show databases') tdSql.query(f'show databases')
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -34,14 +34,14 @@ class TDTestCase: ...@@ -34,14 +34,14 @@ class TDTestCase:
# #
# --------------- main frame ------------------- # --------------- main frame -------------------
# #
def caseDescription(self): def caseDescription(self):
''' '''
limit and offset keyword function test cases; limit and offset keyword function test cases;
case1: limit offset base function test case1: limit offset base function test
case2: offset return valid case2: offset return valid
''' '''
return return
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
self.ts = 1500000000000 self.ts = 1500000000000
# run case # run case
def run(self): def run(self):
# test base case # test base case
...@@ -79,7 +79,7 @@ class TDTestCase: ...@@ -79,7 +79,7 @@ class TDTestCase:
# self.test_case2() # self.test_case2()
# tdLog.debug(" LIMIT test_case2 ............ [OK]") # tdLog.debug(" LIMIT test_case2 ............ [OK]")
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -101,7 +101,7 @@ class TDTestCase: ...@@ -101,7 +101,7 @@ class TDTestCase:
tdSql.execute(sql) tdSql.execute(sql)
sql = pre_create sql = pre_create
# print(time.time()) # print(time.time())
# end sql # end sql
if sql != pre_create: if sql != pre_create:
tdSql.execute(sql) tdSql.execute(sql)
exeEndTime=time.time() exeEndTime=time.time()
...@@ -113,7 +113,7 @@ class TDTestCase: ...@@ -113,7 +113,7 @@ class TDTestCase:
def newcur(self,host,cfg): def newcur(self,host,cfg):
user = "root" user = "root"
password = "taosdata" password = "taosdata"
port =6030 port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
cur=con.cursor() cur=con.cursor()
print(cur) print(cur)
...@@ -123,7 +123,7 @@ class TDTestCase: ...@@ -123,7 +123,7 @@ class TDTestCase:
host = "127.0.0.1" host = "127.0.0.1"
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
config = buildPath+ "../sim/dnode1/cfg/" config = buildPath+ "../sim/dnode1/cfg/"
tsql=self.newcur(host,config) tsql=self.newcur(host,config)
tsql.execute("drop database if exists %s" %(dbname)) tsql.execute("drop database if exists %s" %(dbname))
tsql.execute("create database if not exists %s vgroups %d"%(dbname,vgroups)) tsql.execute("create database if not exists %s vgroups %d"%(dbname,vgroups))
...@@ -147,7 +147,7 @@ class TDTestCase: ...@@ -147,7 +147,7 @@ class TDTestCase:
tsql.execute(sql) tsql.execute(sql)
sql = pre_create sql = pre_create
# print(time.time()) # print(time.time())
# end sql # end sql
if sql != pre_create: if sql != pre_create:
# print(sql) # print(sql)
tsql.execute(sql) tsql.execute(sql)
...@@ -176,7 +176,7 @@ class TDTestCase: ...@@ -176,7 +176,7 @@ class TDTestCase:
# print(sql) # print(sql)
tdSql.execute(sql) tdSql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i) sql = "insert into %s_%d values " %(stbname,i)
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
# print(sql) # print(sql)
tdSql.execute(sql) tdSql.execute(sql)
...@@ -189,7 +189,7 @@ class TDTestCase: ...@@ -189,7 +189,7 @@ class TDTestCase:
return return
# test case1 base # test case1 base
def test_case1(self): def test_case1(self):
tdLog.debug("-----create database and tables test------- ") tdLog.debug("-----create database and tables test------- ")
# tdSql.execute("drop database if exists db1") # tdSql.execute("drop database if exists db1")
...@@ -220,7 +220,7 @@ class TDTestCase: ...@@ -220,7 +220,7 @@ class TDTestCase:
threads = [] threads = []
threadNumbers=2 threadNumbers=2
for i in range(threadNumbers): for i in range(threadNumbers):
threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,))) threads.append(mp.Process(target=self.new_create_tables, args=("db1%d"%i, vgroups, "stb1", 0,count,)))
start_time = time.time() start_time = time.time()
for tr in threads: for tr in threads:
tr.start() tr.start()
...@@ -247,7 +247,7 @@ class TDTestCase: ...@@ -247,7 +247,7 @@ class TDTestCase:
# tdSql.execute("create database db16 vgroups 16") # tdSql.execute("create database db16 vgroups 16")
# self.create_tables("db16", "stb16", 30*10000) # self.create_tables("db16", "stb16", 30*10000)
return return
# test case2 base:insert data # test case2 base:insert data
def test_case2(self): def test_case2(self):
...@@ -266,7 +266,7 @@ class TDTestCase: ...@@ -266,7 +266,7 @@ class TDTestCase:
tdSql.execute("create database db1 vgroups 1") tdSql.execute("create database db1 vgroups 1")
self.create_tables("db1", "stb1", 1*100) self.create_tables("db1", "stb1", 1*100)
self.insert_data("db1", "stb1", self.ts, 1*50,1*10000) self.insert_data("db1", "stb1", self.ts, 1*50,1*10000)
tdSql.execute("create database db4 vgroups 4") tdSql.execute("create database db4 vgroups 4")
self.create_tables("db4", "stb4", 1*100) self.create_tables("db4", "stb4", 1*100)
...@@ -287,7 +287,7 @@ class TDTestCase: ...@@ -287,7 +287,7 @@ class TDTestCase:
tdSql.execute("create database db16 vgroups 16") tdSql.execute("create database db16 vgroups 16")
self.create_tables("db16", "stb16", 1*100) self.create_tables("db16", "stb16", 1*100)
self.insert_data("db16", "stb16", self.ts, 1*100,1*10000) self.insert_data("db16", "stb16", self.ts, 1*100,1*10000)
return return
# #
...@@ -296,4 +296,4 @@ class TDTestCase: ...@@ -296,4 +296,4 @@ class TDTestCase:
# tdCases.addWindows(__file__, TDTestCase()) # tdCases.addWindows(__file__, TDTestCase())
# tdCases.addLinux(__file__, TDTestCase()) # tdCases.addLinux(__file__, TDTestCase())
case=TDTestCase() case=TDTestCase()
case.test_case1() case.test_case1()
\ No newline at end of file
...@@ -25,19 +25,19 @@ import threading ...@@ -25,19 +25,19 @@ import threading
import platform import platform
import io import io
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
self._conn = conn self._conn = conn
self.smlChildTableName_value = "id" self.smlChildTableName_value = "id"
def createDb(self, name="test", db_update_tag=0, protocol=None): def createDb(self, name="test", db_update_tag=0, protocol=None):
if protocol == "telnet-tcp": if protocol == "telnet-tcp":
name = "opentsdb_telnet" name = "opentsdb_telnet"
if db_update_tag == 0: if db_update_tag == 0:
tdSql.execute(f"drop database if exists {name}") tdSql.execute(f"drop database if exists {name}")
tdSql.execute(f"create database if not exists {name} precision 'us' schemaless 1") tdSql.execute(f"create database if not exists {name} precision 'us' schemaless 1")
...@@ -66,7 +66,7 @@ class TDTestCase: ...@@ -66,7 +66,7 @@ class TDTestCase:
td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts)) td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
return td_ts return td_ts
#return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f")) #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
def dateToTs(self, datetime_input): def dateToTs(self, datetime_input):
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
...@@ -191,7 +191,7 @@ class TDTestCase: ...@@ -191,7 +191,7 @@ class TDTestCase:
tb_name = "" tb_name = ""
td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1]) td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0]) td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
col_name_list.append('_value') col_name_list.append('_value')
col_value_list.append(stb_col_value) col_value_list.append(stb_col_value)
...@@ -218,7 +218,7 @@ class TDTestCase: ...@@ -218,7 +218,7 @@ class TDTestCase:
t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"", t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"",
t8="L\"ncharTagValue\"", ts="1626006833641", t8="L\"ncharTagValue\"", ts="1626006833641",
id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None, id_noexist_tag=None, id_change_tag=None, id_upper_tag=None, id_mixul_tag=None, id_double_tag=None,
t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None,
chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None): chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None):
if stb_name == "": if stb_name == "":
stb_name = tdCom.getLongName(len=6, mode="letters") stb_name = tdCom.getLongName(len=6, mode="letters")
...@@ -268,7 +268,7 @@ class TDTestCase: ...@@ -268,7 +268,7 @@ class TDTestCase:
if protocol == "telnet-tcp": if protocol == "telnet-tcp":
sql_seq = 'put ' + sql_seq + '\n' sql_seq = 'put ' + sql_seq + '\n'
return sql_seq, stb_name return sql_seq, stb_name
def genMulTagColStr(self, genType, count=1): def genMulTagColStr(self, genType, count=1):
""" """
genType must be tag/col genType must be tag/col
...@@ -365,10 +365,10 @@ class TDTestCase: ...@@ -365,10 +365,10 @@ class TDTestCase:
for t_type in full_type_list: for t_type in full_type_list:
input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol) input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol)
self.resCmp(input_sql, stb_name, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol)
def symbolsCheckCase(self, protocol=None): def symbolsCheckCase(self, protocol=None):
""" """
check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/?
""" """
''' '''
please test : please test :
...@@ -424,7 +424,7 @@ class TDTestCase: ...@@ -424,7 +424,7 @@ class TDTestCase:
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def idSeqCheckCase(self, protocol=None): def idSeqCheckCase(self, protocol=None):
""" """
check id.index in tags check id.index in tags
...@@ -434,7 +434,7 @@ class TDTestCase: ...@@ -434,7 +434,7 @@ class TDTestCase:
tdCom.cleanTb() tdCom.cleanTb()
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol) input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol)
self.resCmp(input_sql, stb_name, protocol=protocol) self.resCmp(input_sql, stb_name, protocol=protocol)
def idLetterCheckCase(self, protocol=None): def idLetterCheckCase(self, protocol=None):
""" """
check id param check id param
...@@ -527,7 +527,7 @@ class TDTestCase: ...@@ -527,7 +527,7 @@ class TDTestCase:
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def illegalTsCheckCase(self): def illegalTsCheckCase(self):
""" """
check ts format like 16260068336390us19 check ts format like 16260068336390us19
...@@ -592,7 +592,7 @@ class TDTestCase: ...@@ -592,7 +592,7 @@ class TDTestCase:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def tagValueLengthCheckCase(self): def tagValueLengthCheckCase(self):
""" """
...@@ -673,7 +673,7 @@ class TDTestCase: ...@@ -673,7 +673,7 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# f32 # f32
tdCom.cleanTb() tdCom.cleanTb()
for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]: for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
input_sql, stb_name = self.genFullTypeSql(value=value) input_sql, stb_name = self.genFullTypeSql(value=value)
...@@ -703,12 +703,12 @@ class TDTestCase: ...@@ -703,12 +703,12 @@ class TDTestCase:
# except SchemalessError as err: # except SchemalessError as err:
# tdSql.checkNotEqual(err.errno, 0) # tdSql.checkNotEqual(err.errno, 0)
# # # binary # # # binary
# tdCom.cleanTb() # tdCom.cleanTb()
# stb_name = tdCom.getLongName(7, "letters") # stb_name = tdCom.getLongName(7, "letters")
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t' # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t'
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) # self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
# tdCom.cleanTb() # tdCom.cleanTb()
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t' # input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t'
# try: # try:
...@@ -748,12 +748,12 @@ class TDTestCase: ...@@ -748,12 +748,12 @@ class TDTestCase:
# i8 i16 i32 i64 f32 f64 # i8 i16 i32 i64 f32 f64
for input_sql in [ for input_sql in [
self.genFullTypeSql(value="1s2i8")[0], self.genFullTypeSql(value="1s2i8")[0],
self.genFullTypeSql(value="1s2i16")[0], self.genFullTypeSql(value="1s2i16")[0],
self.genFullTypeSql(value="1s2i32")[0], self.genFullTypeSql(value="1s2i32")[0],
self.genFullTypeSql(value="1s2i64")[0], self.genFullTypeSql(value="1s2i64")[0],
self.genFullTypeSql(value="11.1s45f32")[0], self.genFullTypeSql(value="11.1s45f32")[0],
self.genFullTypeSql(value="11.1s45f64")[0], self.genFullTypeSql(value="11.1s45f64")[0],
]: ]:
try: try:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
...@@ -761,14 +761,14 @@ class TDTestCase: ...@@ -761,14 +761,14 @@ class TDTestCase:
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
# check accepted binary and nchar symbols # check accepted binary and nchar symbols
# # * ~!@#$¥%^&*()-+={}|[]、「」:; # # * ~!@#$¥%^&*()-+={}|[]、「」:;
for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'): for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc{symbol}aaa" t0=t' input_sql1 = f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc{symbol}aaa" t0=t'
input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=t t1="abc{symbol}aaa"' input_sql2 = f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=t t1="abc{symbol}aaa"'
self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None)
# self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None) # self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None)
def blankCheckCase(self): def blankCheckCase(self):
''' '''
check blank case check blank case
...@@ -853,7 +853,7 @@ class TDTestCase: ...@@ -853,7 +853,7 @@ class TDTestCase:
check tag count add, stb and tb duplicate check tag count add, stb and tb duplicate
* tag: alter table ... * tag: alter table ...
* col: when update==0 and ts is same, unchange * col: when update==0 and ts is same, unchange
* so this case tag&&value will be added, * so this case tag&&value will be added,
* col is added without value when update==0 * col is added without value when update==0
* col is added with value when update==1 * col is added with value when update==1
""" """
...@@ -869,14 +869,14 @@ class TDTestCase: ...@@ -869,14 +869,14 @@ class TDTestCase:
if db_update_tag == 1 : if db_update_tag == 1 :
self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True) self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 11, None) tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None) tdSql.checkData(0, 12, None)
else: else:
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None) self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"') tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
tdSql.checkData(0, 1, True) tdSql.checkData(0, 1, True)
tdSql.checkData(0, 11, None) tdSql.checkData(0, 11, None)
tdSql.checkData(0, 12, None) tdSql.checkData(0, 12, None)
self.createDb() self.createDb()
@tdCom.smlPass @tdCom.smlPass
...@@ -952,7 +952,7 @@ class TDTestCase: ...@@ -952,7 +952,7 @@ class TDTestCase:
tdCom.cleanTb() tdCom.cleanTb()
stb_name = tdCom.getLongName(8, "letters") stb_name = tdCom.getLongName(8, "letters")
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)') tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"", lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"",
"st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64", "st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64",
f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"', f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"',
...@@ -970,7 +970,7 @@ class TDTestCase: ...@@ -970,7 +970,7 @@ class TDTestCase:
tdSql.checkRows(6) tdSql.checkRows(6)
tdSql.query('select * from st123456') tdSql.query('select * from st123456')
tdSql.checkRows(5) tdSql.checkRows(5)
def multiInsertCheckCase(self, count): def multiInsertCheckCase(self, count):
""" """
test multi insert test multi insert
...@@ -1014,7 +1014,7 @@ class TDTestCase: ...@@ -1014,7 +1014,7 @@ class TDTestCase:
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def blankColInsertCheckCase(self): def blankColInsertCheckCase(self):
""" """
test blank col insert test blank col insert
...@@ -1040,7 +1040,7 @@ class TDTestCase: ...@@ -1040,7 +1040,7 @@ class TDTestCase:
raise Exception("should not reach here") raise Exception("should not reach here")
except SchemalessError as err: except SchemalessError as err:
tdSql.checkNotEqual(err.errno, 0) tdSql.checkNotEqual(err.errno, 0)
def chineseCheckCase(self): def chineseCheckCase(self):
""" """
check nchar ---> chinese check nchar ---> chinese
...@@ -1210,7 +1210,7 @@ class TDTestCase: ...@@ -1210,7 +1210,7 @@ class TDTestCase:
self.multiThreadRun(self.genMultiThreadSeq(input_sql)) self.multiThreadRun(self.genMultiThreadSeq(input_sql))
tdSql.query(f"show tables;") tdSql.query(f"show tables;")
tdSql.checkRows(5) tdSql.checkRows(5)
def sStbStbDdataInsertMultiThreadCheckCase(self): def sStbStbDdataInsertMultiThreadCheckCase(self):
""" """
thread input same stb tb, different data, result keep first data thread input same stb tb, different data, result keep first data
...@@ -1248,7 +1248,7 @@ class TDTestCase: ...@@ -1248,7 +1248,7 @@ class TDTestCase:
tdSql.checkEqual(tb_name, expected_tb_name) tdSql.checkEqual(tb_name, expected_tb_name)
tdSql.query(f"select * from {stb_name};") tdSql.query(f"select * from {stb_name};")
tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6) tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
def sStbStbDdataMtInsertMultiThreadCheckCase(self): def sStbStbDdataMtInsertMultiThreadCheckCase(self):
""" """
thread input same stb tb, different data, minus columes and tags, result keep first data thread input same stb tb, different data, minus columes and tags, result keep first data
...@@ -1466,7 +1466,7 @@ class TDTestCase: ...@@ -1466,7 +1466,7 @@ class TDTestCase:
def run(self): def run(self):
print("running {}".format(__file__)) print("running {}".format(__file__))
try: try:
self.createDb() self.createDb()
self.runAll() self.runAll()
......
...@@ -42,7 +42,7 @@ class TDTestCase: ...@@ -42,7 +42,7 @@ class TDTestCase:
self.comment_flag_list = [True,False] self.comment_flag_list = [True,False]
def __set_and_alter_comment(self,tb_type='',comment_flag= False): def __set_and_alter_comment(self,tb_type='',comment_flag= False):
column_sql = '' column_sql = ''
tag_sql = '' tag_sql = ''
for k,v in self.column_dict.items(): for k,v in self.column_dict.items():
...@@ -78,7 +78,7 @@ class TDTestCase: ...@@ -78,7 +78,7 @@ class TDTestCase:
tdSql.execute(f'create {operation} {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]}) comment "{comment_info}"') tdSql.execute(f'create {operation} {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]}) comment "{comment_info}"')
self.check_comment_info(comment_info,'stable') self.check_comment_info(comment_info,'stable')
self.alter_comment(self.stbname,'stable') self.alter_comment(self.stbname,'stable')
tdSql.execute(f'drop table {self.stbname}') tdSql.execute(f'drop table {self.stbname}')
elif tb_type == 'child_table': elif tb_type == 'child_table':
tdSql.execute(f'create table if not exists {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') tdSql.execute(f'create table if not exists {self.stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})')
if comment_flag == False: if comment_flag == False:
...@@ -122,7 +122,7 @@ class TDTestCase: ...@@ -122,7 +122,7 @@ class TDTestCase:
for flag in comment_flag: for flag in comment_flag:
self.__set_and_alter_comment(tb,flag) self.__set_and_alter_comment(tb,flag)
tdSql.execute('drop database db') tdSql.execute('drop database db')
def run(self): def run(self):
self.comment_check_case(self.table_type_list,self.comment_flag_list) self.comment_check_case(self.table_type_list,self.comment_flag_list)
...@@ -131,4 +131,4 @@ class TDTestCase: ...@@ -131,4 +131,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -20,7 +20,7 @@ class TDTestCase: ...@@ -20,7 +20,7 @@ class TDTestCase:
updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3} updatecfgDict = {'ttlUnit':5,'ttlPushInterval':3}
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
self.ntbname = 'ntb' self.ntbname = 'ntb'
self.stbname = 'stb' self.stbname = 'stb'
self.tbnum = 10 self.tbnum = 10
......
...@@ -38,7 +38,7 @@ class TDTestCase: ...@@ -38,7 +38,7 @@ class TDTestCase:
case1: limit offset base function test case1: limit offset base function test
case2: offset return valid case2: offset return valid
''' '''
return return
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -64,7 +64,7 @@ class TDTestCase: ...@@ -64,7 +64,7 @@ class TDTestCase:
# self.create_tables(); # self.create_tables();
self.ts = 1500000000000 self.ts = 1500000000000
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -76,7 +76,7 @@ class TDTestCase: ...@@ -76,7 +76,7 @@ class TDTestCase:
def newcon(self,host,cfg): def newcon(self,host,cfg):
user = "root" user = "root"
password = "taosdata" password = "taosdata"
port =6030 port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
print(con) print(con)
return con return con
...@@ -126,14 +126,14 @@ class TDTestCase: ...@@ -126,14 +126,14 @@ class TDTestCase:
end = datetime.now() end = datetime.now()
print("elapsed time: ", end - start) print("elapsed time: ", end - start)
assert stmt.affected_rows == 3 assert stmt.affected_rows == 3
#query 1 #query 1
querystmt=conn.statement("select ?,bu from stb1") querystmt=conn.statement("select ?,bu from stb1")
queryparam=new_bind_params(1) queryparam=new_bind_params(1)
print(type(queryparam)) print(type(queryparam))
queryparam[0].binary("ts") queryparam[0].binary("ts")
querystmt.bind_param(queryparam) querystmt.bind_param(queryparam)
querystmt.execute() querystmt.execute()
result=querystmt.use_result() result=querystmt.use_result()
# rows=result.fetch_all() # rows=result.fetch_all()
# print( querystmt.use_result()) # print( querystmt.use_result())
...@@ -152,7 +152,7 @@ class TDTestCase: ...@@ -152,7 +152,7 @@ class TDTestCase:
print(type(queryparam1)) print(type(queryparam1))
queryparam1[0].int(4) queryparam1[0].int(4)
querystmt1.bind_param(queryparam1) querystmt1.bind_param(queryparam1)
querystmt1.execute() querystmt1.execute()
result1=querystmt1.use_result() result1=querystmt1.use_result()
rows1=result1.fetch_all() rows1=result1.fetch_all()
print(rows1) print(rows1)
...@@ -176,10 +176,10 @@ class TDTestCase: ...@@ -176,10 +176,10 @@ class TDTestCase:
host="localhost" host="localhost"
connectstmt=self.newcon(host,config) connectstmt=self.newcon(host,config)
self.test_stmt_insert_multi(connectstmt) self.test_stmt_insert_multi(connectstmt)
return return
# add case with filename # add case with filename
# #
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -38,7 +38,7 @@ class TDTestCase: ...@@ -38,7 +38,7 @@ class TDTestCase:
case1: limit offset base function test case1: limit offset base function test
case2: offset return valid case2: offset return valid
''' '''
return return
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -64,7 +64,7 @@ class TDTestCase: ...@@ -64,7 +64,7 @@ class TDTestCase:
# self.create_tables(); # self.create_tables();
self.ts = 1500000000000 self.ts = 1500000000000
# stop # stop
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
...@@ -76,7 +76,7 @@ class TDTestCase: ...@@ -76,7 +76,7 @@ class TDTestCase:
def newcon(self,host,cfg): def newcon(self,host,cfg):
user = "root" user = "root"
password = "taosdata" password = "taosdata"
port =6030 port =6030
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
tdLog.debug(con) tdLog.debug(con)
return con return con
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
def stmtExe(self,conn,sql,bindStat): def stmtExe(self,conn,sql,bindStat):
queryStat=conn.statement("%s"%sql) queryStat=conn.statement("%s"%sql)
queryStat.bind_param(bindStat) queryStat.bind_param(bindStat)
queryStat.execute() queryStat.execute()
result=queryStat.use_result() result=queryStat.use_result()
rows=result.fetch_all() rows=result.fetch_all()
return rows return rows
...@@ -101,7 +101,7 @@ class TDTestCase: ...@@ -101,7 +101,7 @@ class TDTestCase:
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\ ff float, dd double, bb binary(100), nn nchar(100), tt timestamp , vc varchar(100)) tags (t1 timestamp, t2 bool,\
t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \ t3 tinyint, t4 tinyint, t5 smallint, t6 int, t7 bigint, t8 tinyint unsigned, t9 smallint unsigned, \
t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"%stablename) t10 int unsigned, t11 bigint unsigned, t12 float, t13 double, t14 binary(100), t15 nchar(100), t16 timestamp)"%stablename)
stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \ stmt = conn.statement("insert into ? using log tags (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
tags = new_bind_params(16) tags = new_bind_params(16)
...@@ -140,13 +140,13 @@ class TDTestCase: ...@@ -140,13 +140,13 @@ class TDTestCase:
params[14].nchar(["涛思数据", None, "a long string with 中文?字符"]) params[14].nchar(["涛思数据", None, "a long string with 中文?字符"])
params[15].timestamp([None, None, 1626861392591]) params[15].timestamp([None, None, 1626861392591])
params[16].binary(["涛思数据16", None, None]) params[16].binary(["涛思数据16", None, None])
stmt.bind_param_batch(params) stmt.bind_param_batch(params)
stmt.execute() stmt.execute()
assert stmt.affected_rows == 3 assert stmt.affected_rows == 3
#query all #query all
queryparam=new_bind_params(1) queryparam=new_bind_params(1)
queryparam[0].int(10) queryparam[0].int(10)
rows=self.stmtExe(conn,"select * from log where bu < ?",queryparam) rows=self.stmtExe(conn,"select * from log where bu < ?",queryparam)
...@@ -189,7 +189,7 @@ class TDTestCase: ...@@ -189,7 +189,7 @@ class TDTestCase:
#query: conversion Functions #query: conversion Functions
queryparam=new_bind_params(1) queryparam=new_bind_params(1)
queryparam[0].binary('1232a') queryparam[0].binary('1232a')
rows=self.stmtExe(conn,"select cast( ? as bigint) from log",queryparam) rows=self.stmtExe(conn,"select cast( ? as bigint) from log",queryparam)
tdLog.debug("assert 5th case %s"%rows) tdLog.debug("assert 5th case %s"%rows)
assert rows[0][0] == 1232, '5th.1 case is failed' assert rows[0][0] == 1232, '5th.1 case is failed'
...@@ -210,7 +210,7 @@ class TDTestCase: ...@@ -210,7 +210,7 @@ class TDTestCase:
tdLog.debug("assert 7th case %s"%rows) tdLog.debug("assert 7th case %s"%rows)
assert rows[0][0] == 1, '7th case is failed' assert rows[0][0] == 1, '7th case is failed'
assert rows[1][0] == 1, '7th case is failed' assert rows[1][0] == 1, '7th case is failed'
#query: aggregate Functions #query: aggregate Functions
queryparam=new_bind_params(1) queryparam=new_bind_params(1)
queryparam[0].int(123) queryparam[0].int(123)
...@@ -238,7 +238,7 @@ class TDTestCase: ...@@ -238,7 +238,7 @@ class TDTestCase:
# conn.execute("drop database if exists %s" % dbname) # conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
except Exception as err: except Exception as err:
# conn.execute("drop database if exists %s" % dbname) # conn.execute("drop database if exists %s" % dbname)
conn.close() conn.close()
...@@ -251,10 +251,10 @@ class TDTestCase: ...@@ -251,10 +251,10 @@ class TDTestCase:
connectstmt=self.newcon(host,config) connectstmt=self.newcon(host,config)
self.test_stmt_set_tbname_tag(connectstmt) self.test_stmt_set_tbname_tag(connectstmt)
return return
# add case with filename # add case with filename
# #
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -47,7 +47,7 @@ class TDTestCase: ...@@ -47,7 +47,7 @@ class TDTestCase:
'col13': f'nchar({self.str_length})', 'col13': f'nchar({self.str_length})',
'col_ts' : 'timestamp' 'col_ts' : 'timestamp'
} }
def data_check(self,tbname,col_name,col_type,value): def data_check(self,tbname,col_name,col_type,value):
tdSql.query(f'select {col_name} from {tbname}') tdSql.query(f'select {col_name} from {tbname}')
if col_type.lower() == 'float' or col_type.lower() == 'double': if col_type.lower() == 'float' or col_type.lower() == 'double':
...@@ -121,9 +121,9 @@ class TDTestCase: ...@@ -121,9 +121,9 @@ class TDTestCase:
tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.error(f'insert into {stbname} values({self.ts},{error_value})')
elif col_type.lower() == 'tinyint unsigned': elif col_type.lower() == 'tinyint unsigned':
for error_value in [constant.TINYINT_UN_MIN-1,constant.TINYINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: for error_value in [constant.TINYINT_UN_MIN-1,constant.TINYINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]:
tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') tdSql.error(f'insert into {tbname} values({self.ts},{error_value})')
if tb_type == 'ctb': if tb_type == 'ctb':
tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.error(f'insert into {stbname} values({self.ts},{error_value})')
elif col_type.lower() == 'smallint unsigned': elif col_type.lower() == 'smallint unsigned':
for error_value in [constant.SMALLINT_UN_MIN-1,constant.SMALLINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: for error_value in [constant.SMALLINT_UN_MIN-1,constant.SMALLINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]:
tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') tdSql.error(f'insert into {tbname} values({self.ts},{error_value})')
...@@ -136,9 +136,9 @@ class TDTestCase: ...@@ -136,9 +136,9 @@ class TDTestCase:
tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.error(f'insert into {stbname} values({self.ts},{error_value})')
elif col_type.lower() == 'bigint unsigned': elif col_type.lower() == 'bigint unsigned':
for error_value in [constant.BIGINT_UN_MIN-1,constant.BIGINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: for error_value in [constant.BIGINT_UN_MIN-1,constant.BIGINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]:
tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') tdSql.error(f'insert into {tbname} values({self.ts},{error_value})')
if tb_type == 'ctb': if tb_type == 'ctb':
tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.error(f'insert into {stbname} values({self.ts},{error_value})')
tdSql.execute(f'drop table {tbname}') tdSql.execute(f'drop table {tbname}')
if tb_type == 'ctb': if tb_type == 'ctb':
tdSql.execute(f'drop table {stbname}') tdSql.execute(f'drop table {stbname}')
...@@ -182,9 +182,9 @@ class TDTestCase: ...@@ -182,9 +182,9 @@ class TDTestCase:
elif col_type.lower() == 'bigint unsigned': elif col_type.lower() == 'bigint unsigned':
self.update_and_check_data(tbname,col_name,col_type,up_unbigint,dbname) self.update_and_check_data(tbname,col_name,col_type,up_unbigint,dbname)
elif col_type.lower() == 'bool': elif col_type.lower() == 'bool':
self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname) self.update_and_check_data(tbname,col_name,col_type,up_bool,dbname)
elif col_type.lower() == 'float': elif col_type.lower() == 'float':
self.update_and_check_data(tbname,col_name,col_type,up_float,dbname) self.update_and_check_data(tbname,col_name,col_type,up_float,dbname)
elif col_type.lower() == 'double': elif col_type.lower() == 'double':
self.update_and_check_data(tbname,col_name,col_type,up_double,dbname) self.update_and_check_data(tbname,col_name,col_type,up_double,dbname)
elif 'binary' in col_type.lower(): elif 'binary' in col_type.lower():
...@@ -248,10 +248,10 @@ class TDTestCase: ...@@ -248,10 +248,10 @@ class TDTestCase:
self.update_check() self.update_check()
self.update_check_error() self.update_check_error()
# i+=1 # i+=1
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -87,7 +87,7 @@ class TDTestCase: ...@@ -87,7 +87,7 @@ class TDTestCase:
sql += f'({self.ts+i},{values})' sql += f'({self.ts+i},{values})'
sql += ' ' sql += ' '
tdSql.execute(sql) tdSql.execute(sql)
def insert_data(self,col_type,tbname,rows,data): def insert_data(self,col_type,tbname,rows,data):
for i in range(rows): for i in range(rows):
if col_type.lower() == 'tinyint': if col_type.lower() == 'tinyint':
...@@ -107,16 +107,16 @@ class TDTestCase: ...@@ -107,16 +107,16 @@ class TDTestCase:
elif col_type.lower() == 'bigint unsigned': elif col_type.lower() == 'bigint unsigned':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint unsigned"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint unsigned"]})')
elif col_type.lower() == 'bool': elif col_type.lower() == 'bool':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})')
elif col_type.lower() == 'float': elif col_type.lower() == 'float':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})')
elif col_type.lower() == 'double': elif col_type.lower() == 'double':
tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["double"]})') tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["double"]})')
elif 'binary' in col_type.lower(): elif 'binary' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['binary']}")''') tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['binary']}")''')
elif 'nchar' in col_type.lower(): elif 'nchar' in col_type.lower():
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''')
def data_check(self,dbname,tbname,tbnum,rownum,data,col_name,col_type): def data_check(self,dbname,tbname,tbnum,rownum,data,col_name,col_type):
if 'binary' in col_type.lower(): if 'binary' in col_type.lower():
self.update_data(dbname,f'{tbname}',tbnum,rownum,data['binary'],col_type) self.update_data(dbname,f'{tbname}',tbnum,rownum,data['binary'],col_type)
...@@ -170,10 +170,10 @@ class TDTestCase: ...@@ -170,10 +170,10 @@ class TDTestCase:
self.update_data_ntb() self.update_data_ntb()
self.update_data_ctb() self.update_data_ctb()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -141,8 +141,8 @@ class TDTestCase: ...@@ -141,8 +141,8 @@ class TDTestCase:
query_data = tdSql.queryResult query_data = tdSql.queryResult
# nest query for support max # nest query for support max
tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)") #tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)")
tdSql.checkData(0,0,31.000000000) #tdSql.checkData(0,0,31.000000000)
tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)") tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
tdSql.checkData(0,0,7.560701700) tdSql.checkData(0,0,7.560701700)
tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)") tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册