openTsdbTelnetLinesInsert.py 75.2 KB
Newer Older
J
jiajingbin 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
###################################################################
#           Copyright (c) 2021 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 traceback
import random
16
from taos.error import SchemalessError
J
jiajingbin 已提交
17 18 19 20 21 22
import time
import numpy as np
from util.log import *
from util.cases import *
from util.sql import *
from util.common import tdCom
J
jiajingbin 已提交
23
from util.types import TDSmlProtocolType, TDSmlTimestampType
J
jiajingbin 已提交
24 25 26 27 28 29 30
import threading

class TDTestCase:
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)
        self._conn = conn 
31
        self.smlChildTableName_value = tdSql.getVariable("smlChildTableName")[0].upper()
J
jiajingbin 已提交
32

33 34 35 36
    def createDb(self, name="test", db_update_tag=0, protocol=None):
        if protocol == "telnet-tcp":
            name = "opentsdb_telnet"
            
J
jiajingbin 已提交
37 38 39 40 41 42 43 44
        if db_update_tag == 0:
            tdSql.execute(f"drop database if exists {name}")
            tdSql.execute(f"create database if not exists {name} precision 'us'")
        else:
            tdSql.execute(f"drop database if exists {name}")
            tdSql.execute(f"create database if not exists {name} precision 'us' update 1")
        tdSql.execute(f'use {name}')

J
jiajingbin 已提交
45 46
    def timeTrans(self, time_value, ts_type):
        if int(time_value) == 0:
J
jiajingbin 已提交
47 48
            ts = time.time()
        else:
J
jiajingbin 已提交
49 50 51 52
            if ts_type == TDSmlTimestampType.MILLI_SECOND.value or ts_type == None:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1000
            elif ts_type == TDSmlTimestampType.SECOND.value:
                ts = int(''.join(list(filter(str.isdigit, time_value))))/1
J
jiajingbin 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
        ulsec = repr(ts).split('.')[1][:6]
        if len(ulsec) < 6 and int(ulsec) != 0:
            ulsec = int(ulsec) * (10 ** (6 - len(ulsec)))
        elif int(ulsec) == 0:
            ulsec *= 6
            # * follow two rows added for tsCheckCase
            td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
            return td_ts
        #td_ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
        td_ts = time.strftime("%Y-%m-%d %H:%M:%S.{}".format(ulsec), time.localtime(ts))
        return td_ts
        #return repr(datetime.datetime.strptime(td_ts, "%Y-%m-%d %H:%M:%S.%f"))
    
    def dateToTs(self, datetime_input):
        return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))

J
jiajingbin 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    def getTdTypeValue(self, value, vtype="col"):
        if vtype == "col":
            if value.lower().endswith("i8"):
                td_type = "TINYINT"
                td_tag_value = ''.join(list(value)[:-2])
            elif value.lower().endswith("i16"):
                td_type = "SMALLINT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("i32"):
                td_type = "INT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("i64"):
                td_type = "BIGINT"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("u64"):
                td_type = "BIGINT UNSIGNED"
                td_tag_value = ''.join(list(value)[:-3])
            elif value.lower().endswith("f32"):
                td_type = "FLOAT"
                td_tag_value = ''.join(list(value)[:-3])
                td_tag_value = '{}'.format(np.float32(td_tag_value))
            elif value.lower().endswith("f64"):
                td_type = "DOUBLE"
                td_tag_value = ''.join(list(value)[:-3])
                if "e" in value.lower():
                    td_tag_value = str(float(td_tag_value))
            elif value.lower().startswith('l"'):
                td_type = "NCHAR"
                td_tag_value = ''.join(list(value)[2:-1])
            elif value.startswith('"') and value.endswith('"'):
                td_type = "BINARY"
                td_tag_value = ''.join(list(value)[1:-1])
            elif value.lower() == "t" or value.lower() == "true":
                td_type = "BOOL"
                td_tag_value = "True"
            elif value.lower() == "f" or value.lower() == "false":
                td_type = "BOOL"
                td_tag_value = "False"
            elif value.isdigit():
                td_type = "DOUBLE"
109 110
                td_tag_value = str(float(value))
            else:
J
jiajingbin 已提交
111 112 113 114 115 116 117 118
                td_type = "DOUBLE"
                if "e" in value.lower():
                    td_tag_value = str(float(value))
                else:
                    td_tag_value = value
        elif vtype == "tag":
            td_type = "NCHAR"
            td_tag_value = str(value)
J
jiajingbin 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
        return td_type, td_tag_value

    def typeTrans(self, type_list):
        type_num_list = []
        for tp in type_list:
            if tp.upper() == "TIMESTAMP":
                type_num_list.append(9)
            elif tp.upper() == "BOOL":
                type_num_list.append(1)
            elif tp.upper() == "TINYINT":
                type_num_list.append(2)
            elif tp.upper() == "SMALLINT":
                type_num_list.append(3)
            elif tp.upper() == "INT":
                type_num_list.append(4)
            elif tp.upper() == "BIGINT":
                type_num_list.append(5)
            elif tp.upper() == "FLOAT":
                type_num_list.append(6)
            elif tp.upper() == "DOUBLE":
                type_num_list.append(7)
            elif tp.upper() == "BINARY":
                type_num_list.append(8)
            elif tp.upper() == "NCHAR":
                type_num_list.append(10)
            elif tp.upper() == "BIGINT UNSIGNED":
                type_num_list.append(14)
        return type_num_list

148
    def inputHandle(self, input_sql, ts_type, protocol=None):
J
jiajingbin 已提交
149
        input_sql_split_list = input_sql.split(" ")
150 151
        if protocol == "telnet-tcp":
            input_sql_split_list.pop(0)
J
jiajingbin 已提交
152
        stb_name = input_sql_split_list[0]
153
        stb_tag_list = input_sql_split_list[3:]
154
        stb_tag_list[-1] = stb_tag_list[-1].strip()
J
jiajingbin 已提交
155
        stb_col_value = input_sql_split_list[2]
J
jiajingbin 已提交
156
        ts_value = self.timeTrans(input_sql_split_list[1], ts_type)
J
jiajingbin 已提交
157 158 159 160 161 162 163 164 165 166 167 168

        tag_name_list = []
        tag_value_list = []
        td_tag_value_list = []
        td_tag_type_list = []

        col_name_list = []
        col_value_list = []
        td_col_value_list = []
        td_col_type_list = []

        for elm in stb_tag_list:
169 170 171 172 173 174 175 176 177
            if self.smlChildTableName_value == "ID":
                if "id=" in elm.lower():
                    tb_name = elm.split('=')[1]
                else:
                    tag_name_list.append(elm.split("=")[0].lower())
                    tag_value_list.append(elm.split("=")[1])
                    tb_name = ""
                    td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
                    td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
J
jiajingbin 已提交
178
            else:
179 180 181 182 183 184 185 186 187 188 189
                if "id" == elm.split("=")[0].lower():
                    tag_name_list.insert(0, elm.split("=")[0])
                    tag_value_list.insert(0, elm.split("=")[1])
                    td_tag_value_list.insert(0, self.getTdTypeValue(elm.split("=")[1], "tag")[1])
                    td_tag_type_list.insert(0, self.getTdTypeValue(elm.split("=")[1], "tag")[0])
                else:
                    tag_name_list.append(elm.split("=")[0])
                    tag_value_list.append(elm.split("=")[1])
                    tb_name = ""
                    td_tag_value_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[1])
                    td_tag_type_list.append(self.getTdTypeValue(elm.split("=")[1], "tag")[0])
J
jiajingbin 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
        
        col_name_list.append('value')
        col_value_list.append(stb_col_value)

        td_col_value_list.append(self.getTdTypeValue(stb_col_value)[1])
        td_col_type_list.append(self.getTdTypeValue(stb_col_value)[0])

        final_field_list = []
        final_field_list.extend(col_name_list)
        final_field_list.extend(tag_name_list)

        final_type_list = []
        final_type_list.append("TIMESTAMP")
        final_type_list.extend(td_col_type_list)
        final_type_list.extend(td_tag_type_list)
        final_type_list = self.typeTrans(final_type_list)

        final_value_list = []
        final_value_list.append(ts_value)
        final_value_list.extend(td_col_value_list)
        final_value_list.extend(td_tag_value_list)
        return final_value_list, final_field_list, final_type_list, stb_name, tb_name

    def genFullTypeSql(self, stb_name="", tb_name="", value="", t0="", t1="127i8", t2="32767i16", t3="2147483647i32",
                        t4="9223372036854775807i64", t5="11.12345f32", t6="22.123456789f64", t7="\"binaryTagValue\"",
J
jiajingbin 已提交
215 216 217
                        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,
                        t_add_tag=None, t_mul_tag=None, c_multi_tag=None, c_blank_tag=None, t_blank_tag=None, 
218
                        chinese_tag=None, multi_field_tag=None, point_trans_tag=None, protocol=None, tcp_keyword_tag=None):
J
jiajingbin 已提交
219 220 221 222 223
        if stb_name == "":
            stb_name = tdCom.getLongName(len=6, mode="letters")
        if tb_name == "":
            tb_name = f'{stb_name}_{random.randint(0, 65535)}_{random.randint(0, 65535)}'
        if t0 == "":
224
            t0 = "t"
J
jiajingbin 已提交
225 226 227 228 229 230
        if value == "":
            value = random.choice(["f", "F", "false", "False", "t", "T", "true", "True", "TRUE", "FALSE"])
        if id_upper_tag is not None:
            id = "ID"
        else:
            id = "id"
J
jiajingbin 已提交
231 232 233 234 235
        if id_mixul_tag is not None:
            id = random.choice(["iD", "Id"])
        else:
            id = "id"
        sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
J
jiajingbin 已提交
236
        if id_noexist_tag is not None:
237
            sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
J
jiajingbin 已提交
238
            if t_add_tag is not None:
239
                sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8} t9={t8}'
J
jiajingbin 已提交
240
        if id_change_tag is not None:
J
jiajingbin 已提交
241
            sql_seq = f'{stb_name} {ts} {value} t0={t0} {id}={tb_name} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
J
jiajingbin 已提交
242
        if id_double_tag is not None:
243
            sql_seq = f'{stb_name} {ts} {value} {id}=\"{tb_name}_1\" t0={t0} t1={t1} {id}=\"{tb_name}_2\" t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
J
jiajingbin 已提交
244
        if t_add_tag is not None:
J
jiajingbin 已提交
245
            sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8} t11={t1} t10={t8}'
J
jiajingbin 已提交
246
        if t_mul_tag is not None:
J
jiajingbin 已提交
247
            sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}'
J
jiajingbin 已提交
248
            if id_noexist_tag is not None:
249
                sql_seq = f'{stb_name} {ts} {value} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}'
J
jiajingbin 已提交
250 251
        if c_multi_tag is not None:
            sql_seq = f'{stb_name} {ts} {value} {value} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6}'
252
        if c_blank_tag is not None:
J
jiajingbin 已提交
253
            sql_seq = f'{stb_name} {ts} {id}={tb_name} t0={t0} t1={t1} t2={t2} t3={t3} t4={t4} t5={t5} t6={t6} t7={t7} t8={t8}'
254
        if t_blank_tag is not None:
255
            sql_seq = f'{stb_name} {ts} {value}'
256
        if chinese_tag is not None:
257
            sql_seq = f'{stb_name} {ts} L"涛思数据" t0={t0} t1=L"涛思数据"'
258
        if multi_field_tag is not None:
J
jiajingbin 已提交
259
            sql_seq = f'{stb_name} {ts} {value} {id}={tb_name} t0={t0} {value}'
260
        if point_trans_tag is not None:
J
jiajingbin 已提交
261
            sql_seq = f'.point.trans.test {ts} {value} t0={t0}'
262 263 264 265
        if tcp_keyword_tag is not None:
            sql_seq = f'put {ts} {value} t0={t0}'
        if protocol == "telnet-tcp":
            sql_seq = 'put ' + sql_seq + '\n'
J
jiajingbin 已提交
266 267 268 269 270 271 272 273 274 275 276
        return sql_seq, stb_name
    
    def genMulTagColStr(self, genType, count=1):
        """
            genType must be tag/col
        """
        tag_str = ""
        col_str = ""
        if genType == "tag":
            for i in range(0, count):
                if i < (count-1):
277
                    tag_str += f't{i}=f '
J
jiajingbin 已提交
278 279 280 281 282 283 284 285 286 287 288
                else:
                    tag_str += f't{i}=f'
            return tag_str
        if genType == "col":
            col_str = "t"
            return col_str

    def genLongSql(self, tag_count):
        stb_name = tdCom.getLongName(7, mode="letters")
        tag_str = self.genMulTagColStr("tag", tag_count)
        col_str = self.genMulTagColStr("col")
J
jiajingbin 已提交
289
        ts = "1626006833641"
290
        long_sql = stb_name + ' ' + ts + ' ' + col_str + ' ' + ' ' + tag_str
J
jiajingbin 已提交
291 292
        return long_sql, stb_name

293
    def getNoIdTbName(self, stb_name, protocol=None):
J
jiajingbin 已提交
294
        query_sql = f"select tbname from {stb_name}"
295
        tb_name = self.resHandle(query_sql, True, protocol)[0][0]
J
jiajingbin 已提交
296 297
        return tb_name

298
    def resHandle(self, query_sql, query_tag, protocol=None):
J
jiajingbin 已提交
299
        tdSql.execute('reset query cache')
300 301
        if protocol == "telnet-tcp":
            time.sleep(0.5)
J
jiajingbin 已提交
302 303 304 305 306 307 308 309 310 311 312 313
        row_info = tdSql.query(query_sql, query_tag)
        col_info = tdSql.getColNameList(query_sql, query_tag)
        res_row_list = []
        sub_list = []
        for row_mem in row_info:
            for i in row_mem:
                sub_list.append(str(i))
            res_row_list.append(sub_list)
        res_field_list_without_ts = col_info[0][1:]
        res_type_list = col_info[1]
        return res_row_list, res_field_list_without_ts, res_type_list

314 315 316 317
    def resCmp(self, input_sql, stb_name, query_sql="select * from", condition="", ts=None, ts_type=None, id=True, none_check_tag=None, precision=None, protocol=None):
        expect_list = self.inputHandle(input_sql, ts_type, protocol)
        if protocol == "telnet-tcp":
            tdCom.tcpClient(input_sql)
J
jiajingbin 已提交
318
        else:
319 320 321 322
            if precision == None:
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, ts_type)
            else:
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, precision)
J
jiajingbin 已提交
323
        query_sql = f"{query_sql} {stb_name} {condition}"
324
        res_row_list, res_field_list_without_ts, res_type_list = self.resHandle(query_sql, True, protocol)
J
jiajingbin 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
        if ts == 0:
            res_ts = self.dateToTs(res_row_list[0][0])
            current_time = time.time()
            if current_time - res_ts < 60:
                tdSql.checkEqual(res_row_list[0][1:], expect_list[0][1:])
            else:
                print("timeout")
                tdSql.checkEqual(res_row_list[0], expect_list[0])
        else:
            if none_check_tag is not None:
                none_index_list = [i for i,x in enumerate(res_row_list[0]) if x=="None"]
                none_index_list.reverse()
                for j in none_index_list:
                    res_row_list[0].pop(j)
                    expect_list[0].pop(j)
            tdSql.checkEqual(res_row_list[0], expect_list[0])
        tdSql.checkEqual(res_field_list_without_ts, expect_list[1])
        for i in range(len(res_type_list)):
            tdSql.checkEqual(res_type_list[i], expect_list[2][i])

345
    def initCheckCase(self, protocol=None):
J
jiajingbin 已提交
346 347 348
        """
            normal tags and cols, one for every elm
        """
J
jiajingbin 已提交
349
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
350
        tdCom.cleanTb()
351 352
        input_sql, stb_name = self.genFullTypeSql(protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
353

354
    def boolTypeCheckCase(self, protocol=None):
J
jiajingbin 已提交
355 356 357
        """
            check all normal type
        """
J
jiajingbin 已提交
358
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
359 360 361
        tdCom.cleanTb()
        full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
        for t_type in full_type_list:
362 363
            input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol)
            self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
364
        
365
    def symbolsCheckCase(self, protocol=None):
J
jiajingbin 已提交
366 367 368 369 370 371 372
        """
            check symbols = `~!@#$%^&*()_-+={[}]\|:;'\",<.>/? 
        """
        '''
            please test :
            binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
        '''
J
jiajingbin 已提交
373
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
374
        tdCom.cleanTb()
375
        binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
J
jiajingbin 已提交
376
        nchar_symbols = f'L{binary_symbols}'
377 378 379 380
        input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol)
        input_sql2, stb_name2 = self.genFullTypeSql(value=nchar_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol)
        self.resCmp(input_sql1, stb_name1, protocol=protocol)
        self.resCmp(input_sql2, stb_name2, protocol=protocol)
J
jiajingbin 已提交
381 382 383

    def tsCheckCase(self):
        """
J
jiajingbin 已提交
384
            test ts list --> ["1626006833640ms", "1626006834s", "1626006822639022"]
J
jiajingbin 已提交
385
        """
J
jiajingbin 已提交
386
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
387
        tdCom.cleanTb()
J
jiajingbin 已提交
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833640)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MILLI_SECOND.value)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006833640)
        self.resCmp(input_sql, stb_name, ts_type=None)
        input_sql, stb_name = self.genFullTypeSql(ts=1626006834)
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.SECOND.value)

        tdSql.execute(f"drop database if exists test_ts")
        tdSql.execute(f"create database if not exists test_ts precision 'ms'")
        tdSql.execute("use test_ts")
        input_sql = ['test_ms 1626006833640 t t0=t', 'test_ms 1626006833641 f t0=t']
        self._conn.schemaless_insert(input_sql, TDSmlProtocolType.TELNET.value, None)
        res = tdSql.query('select * from test_ms', True)
        tdSql.checkEqual(str(res[0][0]), "2021-07-11 20:33:53.640000")
        tdSql.checkEqual(str(res[1][0]), "2021-07-11 20:33:53.641000")

    def openTstbTelnetTsCheckCase(self):
J
jiajingbin 已提交
405
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
        tdCom.cleanTb()
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")} 0 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64'
        stb_name = input_sql.split(" ")[0]
        self.resCmp(input_sql, stb_name, ts=0)
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")} 1626006833640 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64'
        stb_name = input_sql.split(" ")[0]
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MILLI_SECOND.value)
        input_sql = f'{tdCom.getLongName(len=10, mode="letters")} 1626006834 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64'
        stb_name = input_sql.split(" ")[0]
        self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.SECOND.value)
        for ts in [1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 162600683, 16260068341, 162600683412, 16260068336401]:
            try:
                input_sql = f'{tdCom.getLongName(len=10, mode="letters")} {ts} 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64'
                self._conn.schemaless_insert(input_sql, TDSmlProtocolType.TELNET.value, None)
                raise Exception("should not reach here")
            except SchemalessError as err:
                tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
423
    
424
    def idSeqCheckCase(self, protocol=None):
J
jiajingbin 已提交
425 426 427 428
        """
            check id.index in tags
            eg: t0=**,id=**,t1=**
        """
J
jiajingbin 已提交
429
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
430
        tdCom.cleanTb()
431 432
        input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
433
    
434
    def idLetterCheckCase(self, protocol=None):
J
jiajingbin 已提交
435 436 437 438
        """
            check id param
            eg: id and ID
        """
J
jiajingbin 已提交
439
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
440
        tdCom.cleanTb()
441 442 443 444 445 446
        input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True, protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
        input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True, protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
        input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True, protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
447

448
    def noIdCheckCase(self, protocol=None):
J
jiajingbin 已提交
449 450 451
        """
            id not exist
        """
J
jiajingbin 已提交
452
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
453
        tdCom.cleanTb()
454 455
        input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True, protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
456 457 458 459 460 461 462 463 464 465 466
        query_sql = f"select tbname from {stb_name}"
        res_row_list = self.resHandle(query_sql, True)[0]
        if len(res_row_list[0][0]) > 0:
            tdSql.checkColNameList(res_row_list, res_row_list)
        else:
            tdSql.checkColNameList(res_row_list, "please check noIdCheckCase")

    def maxColTagCheckCase(self):
        """
            max tag count is 128
        """
J
jiajingbin 已提交
467
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
468 469
        for input_sql in [self.genLongSql(128)[0]]:
            tdCom.cleanTb()
J
jiajingbin 已提交
470
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
471 472 473
        for input_sql in [self.genLongSql(129)[0]]:
            tdCom.cleanTb()
            try:
J
jiajingbin 已提交
474
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
475
                raise Exception("should not reach here")
476
            except SchemalessError as err:
477 478
                tdSql.checkNotEqual(err.errno, 0)

479
    def stbTbNameCheckCase(self, protocol=None):
J
jiajingbin 已提交
480 481
        """
            test illegal id name
482
            mix "`~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?"
J
jiajingbin 已提交
483
        """
J
jiajingbin 已提交
484
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
485
        tdCom.cleanTb()
486
        rstr = list("~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?")
J
jiajingbin 已提交
487
        for i in rstr:
488 489
            input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"", protocol=protocol)
            self.resCmp(input_sql, f'`{stb_name}`', protocol=protocol)
J
jiajingbin 已提交
490
            tdSql.execute(f'drop table if exists `{stb_name}`')
J
jiajingbin 已提交
491

492
    def idStartWithNumCheckCase(self, protocol=None):
J
jiajingbin 已提交
493 494 495
        """
            id is start with num
        """
J
jiajingbin 已提交
496
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
497
        tdCom.cleanTb()
498 499
        input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb", protocol=protocol)
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
500 501 502 503 504

    def nowTsCheckCase(self):
        """
            check now unsupported
        """
J
jiajingbin 已提交
505
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
506 507 508
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(ts="now")[0]
        try:
J
jiajingbin 已提交
509
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
510
            raise Exception("should not reach here")
511
        except SchemalessError as err:
512
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
513 514 515 516 517

    def dateFormatTsCheckCase(self):
        """
            check date format ts unsupported
        """
J
jiajingbin 已提交
518
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
519 520 521
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0]
        try:
J
jiajingbin 已提交
522
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
523
            raise Exception("should not reach here")
524
        except SchemalessError as err:
525
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
526 527 528 529 530
    
    def illegalTsCheckCase(self):
        """
            check ts format like 16260068336390us19
        """
J
jiajingbin 已提交
531
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
532 533 534
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(ts="16260068336390us19")[0]
        try:
J
jiajingbin 已提交
535
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
536
            raise Exception("should not reach here")
537
        except SchemalessError as err:
538
            tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
539

J
jiajingbin 已提交
540
    def tbnameCheckCase(self):
J
jiajingbin 已提交
541
        """
J
jiajingbin 已提交
542 543 544 545
            check length 192
            check upper tbname
            chech upper tag
            length of stb_name tb_name <= 192
J
jiajingbin 已提交
546
        """
J
jiajingbin 已提交
547
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
548 549
        stb_name_192 = tdCom.getLongName(len=192, mode="letters")
        tb_name_192 = tdCom.getLongName(len=192, mode="letters")
J
jiajingbin 已提交
550
        tdCom.cleanTb()
J
jiajingbin 已提交
551 552 553 554
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name_192, tb_name=tb_name_192)
        self.resCmp(input_sql, stb_name)
        tdSql.query(f'select * from {stb_name}')
        tdSql.checkRows(1)
555 556 557 558 559 560 561 562 563 564
        if self.smlChildTableName_value == "ID":
            for input_sql in [self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0], self.genFullTypeSql(tb_name=tdCom.getLongName(len=193, mode="letters"))[0]]:
                try:
                    self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
                    raise Exception("should not reach here")
                except SchemalessError as err:
                    tdSql.checkNotEqual(err.errno, 0)
            input_sql = 'Abcdffgg 1626006833640 False T1=127i8 id=Abcddd'
        else:
            input_sql = self.genFullTypeSql(stb_name=tdCom.getLongName(len=193, mode="letters"), tb_name=tdCom.getLongName(len=5, mode="letters"))[0]
J
jiajingbin 已提交
565
            try:
J
jiajingbin 已提交
566
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
567
                raise Exception("should not reach here")
568
            except SchemalessError as err:
J
jiajingbin 已提交
569
                tdSql.checkNotEqual(err.errno, 0)
570 571
            input_sql = 'Abcdffgg 1626006833640 False T1=127i8'
        stb_name = f'`{input_sql.split(" ")[0]}`'
J
jiajingbin 已提交
572
        self.resCmp(input_sql, stb_name)
573
        tdSql.execute('drop table `Abcdffgg`')
J
jiajingbin 已提交
574

J
jiajingbin 已提交
575 576
    def tagNameLengthCheckCase(self):
        """
J
jiajingbin 已提交
577
            check tag name limit <= 62
J
jiajingbin 已提交
578
        """
J
jiajingbin 已提交
579
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
580
        tdCom.cleanTb()
J
jiajingbin 已提交
581
        tag_name = tdCom.getLongName(61, "letters")
J
jiajingbin 已提交
582
        tag_name = f'T{tag_name}'
J
jiajingbin 已提交
583
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
584 585 586
        input_sql = f'{stb_name} 1626006833640 L"bcdaaa" {tag_name}=f'
        self.resCmp(input_sql, stb_name)
        input_sql = f'{stb_name} 1626006833640 L"gggcdaaa" {tdCom.getLongName(65, "letters")}=f'
J
jiajingbin 已提交
587
        try:
J
jiajingbin 已提交
588
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
589
            raise Exception("should not reach here")
590
        except SchemalessError as err:
J
jiajingbin 已提交
591 592 593 594 595 596
            tdSql.checkNotEqual(err.errno, 0)   

    def tagValueLengthCheckCase(self):
        """
            check full type tag value limit
        """
J
jiajingbin 已提交
597
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
598
        tdCom.cleanTb()
J
jiajingbin 已提交
599 600 601
        # nchar
        # * legal nchar could not be larger than 16374/4
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
602 603
        input_sql = f'{stb_name} 1626006833640 t t0=t t1={tdCom.getLongName(4093, "letters")}'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
604

J
jiajingbin 已提交
605
        input_sql = f'{stb_name} 1626006833640 t t0=t t1={tdCom.getLongName(4094, "letters")}'
J
jiajingbin 已提交
606
        try:
J
jiajingbin 已提交
607
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
608
            raise Exception("should not reach here")
609
        except SchemalessError as err:
J
jiajingbin 已提交
610 611 612 613 614 615
            tdSql.checkNotEqual(err.errno, 0)

    def colValueLengthCheckCase(self):
        """
            check full type col value limit
        """
J
jiajingbin 已提交
616
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
617 618
        tdCom.cleanTb()
        # i8
619 620
        for value in ["-127i8", "127i8"]:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
621
            self.resCmp(input_sql, stb_name)
622 623 624
        tdCom.cleanTb()
        for value in ["-128i8", "128i8"]:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
625
            try:
J
jiajingbin 已提交
626
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
627
                raise Exception("should not reach here")
628
            except SchemalessError as err:
J
jiajingbin 已提交
629 630
                tdSql.checkNotEqual(err.errno, 0)
        # i16
631 632 633
        tdCom.cleanTb()
        for value in ["-32767i16"]:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
634
            self.resCmp(input_sql, stb_name)
635 636 637
        tdCom.cleanTb()
        for value in ["-32768i16", "32768i16"]:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
638
            try:
J
jiajingbin 已提交
639
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
640
                raise Exception("should not reach here")
641
            except SchemalessError as err:
J
jiajingbin 已提交
642 643 644
                tdSql.checkNotEqual(err.errno, 0)

        # i32
645 646 647
        tdCom.cleanTb()
        for value in ["-2147483647i32"]:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
648
            self.resCmp(input_sql, stb_name)
649 650 651
        tdCom.cleanTb()
        for value in ["-2147483648i32", "2147483648i32"]:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
652
            try:
J
jiajingbin 已提交
653
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
654
                raise Exception("should not reach here")
655
            except SchemalessError as err:
J
jiajingbin 已提交
656 657 658
                tdSql.checkNotEqual(err.errno, 0)

        # i64
659 660 661
        tdCom.cleanTb()
        for value in ["-9223372036854775807i64"]:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
662
            self.resCmp(input_sql, stb_name)
663 664 665
        tdCom.cleanTb()
        for value in ["-9223372036854775808i64", "9223372036854775808i64"]:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
666
            try:
J
jiajingbin 已提交
667
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
668
                raise Exception("should not reach here")
669
            except SchemalessError as err:
J
jiajingbin 已提交
670 671 672
                tdSql.checkNotEqual(err.errno, 0)

        # f32       
673 674 675
        tdCom.cleanTb()
        for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
676 677
            self.resCmp(input_sql, stb_name)
        # * limit set to 4028234664*(10**38)
678 679 680
        tdCom.cleanTb()
        for value in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
681
            try:
J
jiajingbin 已提交
682
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
683
                raise Exception("should not reach here")
684
            except SchemalessError as err:
J
jiajingbin 已提交
685 686 687
                tdSql.checkNotEqual(err.errno, 0)

        # f64
688 689 690
        tdCom.cleanTb()
        for value in [f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64', f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64']:
            input_sql, stb_name = self.genFullTypeSql(value=value)
J
jiajingbin 已提交
691 692
            self.resCmp(input_sql, stb_name)
        # * limit set to 1.797693134862316*(10**308)
693 694 695
        tdCom.cleanTb()
        for value in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']:
            input_sql = self.genFullTypeSql(value=value)[0]
J
jiajingbin 已提交
696
            try:
J
jiajingbin 已提交
697
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
698
                raise Exception("should not reach here")
699
            except SchemalessError as err:
J
jiajingbin 已提交
700 701 702
                tdSql.checkNotEqual(err.errno, 0)

        # # binary 
703
        tdCom.cleanTb()
J
jiajingbin 已提交
704
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
705 706
        input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
707
        
708
        tdCom.cleanTb()
J
jiajingbin 已提交
709
        input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t'
J
jiajingbin 已提交
710
        try:
J
jiajingbin 已提交
711
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
712
            raise Exception("should not reach here")
713
        except SchemalessError as err:
J
jiajingbin 已提交
714 715 716 717
            tdSql.checkNotEqual(err.errno, 0)

        # nchar
        # * legal nchar could not be larger than 16374/4
718
        tdCom.cleanTb()
J
jiajingbin 已提交
719
        stb_name = tdCom.getLongName(7, "letters")
J
jiajingbin 已提交
720 721
        input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4093, "letters")}" t0=t'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
722

723
        tdCom.cleanTb()
J
jiajingbin 已提交
724
        input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4094, "letters")}" t0=t'
J
jiajingbin 已提交
725
        try:
J
jiajingbin 已提交
726
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
727
            raise Exception("should not reach here")
728
        except SchemalessError as err:
J
jiajingbin 已提交
729 730 731 732 733 734 735
            tdSql.checkNotEqual(err.errno, 0)

    def tagColIllegalValueCheckCase(self):

        """
            test illegal tag col value
        """
J
jiajingbin 已提交
736
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
737 738 739
        tdCom.cleanTb()
        # bool
        for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
740 741 742 743
            input_sql1, stb_name = self.genFullTypeSql(t0=i)
            self.resCmp(input_sql1, stb_name)
            input_sql2, stb_name = self.genFullTypeSql(value=i)
            self.resCmp(input_sql2, stb_name)
J
jiajingbin 已提交
744 745 746

        # i8 i16 i32 i64 f32 f64
        for input_sql in [
J
jiajingbin 已提交
747 748 749 750 751 752
                self.genFullTypeSql(value="1s2i8")[0], 
                self.genFullTypeSql(value="1s2i16")[0],
                self.genFullTypeSql(value="1s2i32")[0],
                self.genFullTypeSql(value="1s2i64")[0],
                self.genFullTypeSql(value="11.1s45f32")[0],
                self.genFullTypeSql(value="11.1s45f64")[0], 
J
jiajingbin 已提交
753 754
            ]:
            try:
J
jiajingbin 已提交
755
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
756
                raise Exception("should not reach here")
757
            except SchemalessError as err:
758
                tdSql.checkNotEqual(err.errno, 0)
J
jiajingbin 已提交
759 760 761 762

        # check accepted binary and nchar symbols 
        # # * ~!@#$¥%^&*()-+={}|[]、「」:;
        for symbol in list('~!@#$¥%^&*()-+={}|[]、「」:;'):
J
jiajingbin 已提交
763 764 765 766
            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"'
            self._conn.schemaless_insert([input_sql1], TDSmlProtocolType.TELNET.value, None)
            self._conn.schemaless_insert([input_sql2], TDSmlProtocolType.TELNET.value, None)
767 768 769 770 771
    
    def blankCheckCase(self):
        '''
            check blank case
        '''
J
jiajingbin 已提交
772
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
773
        tdCom.cleanTb()
J
jiajingbin 已提交
774 775 776 777
        input_sql_list = [f'{tdCom.getLongName(7, "letters")}   1626006833640 "abc aaa" t0=t',
                        f'{tdCom.getLongName(7, "letters")} 1626006833640   t t0="abaaa"',
                        f'{tdCom.getLongName(7, "letters")} 1626006833640 t   t0=L"abaaa"',
                        f'{tdCom.getLongName(7, "letters")}  1626006833640   L"aba aa"   t0=L"abcaaa3"   ']
778
        for input_sql in input_sql_list:
J
jiajingbin 已提交
779 780 781 782
            stb_name = input_sql.split(" ")[0]
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
            tdSql.query(f'select * from {stb_name}')
            tdSql.checkRows(1)
J
jiajingbin 已提交
783 784 785 786 787

    def duplicateIdTagColInsertCheckCase(self):
        """
            check duplicate Id Tag Col
        """
J
jiajingbin 已提交
788
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
789 790 791
        tdCom.cleanTb()
        input_sql_id = self.genFullTypeSql(id_double_tag=True)[0]
        try:
J
jiajingbin 已提交
792
            self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
793
            raise Exception("should not reach here")
794
        except SchemalessError as err:
J
jiajingbin 已提交
795 796 797 798 799
            tdSql.checkNotEqual(err.errno, 0)

        input_sql = self.genFullTypeSql()[0]
        input_sql_tag = input_sql.replace("t5", "t6")
        try:
J
jiajingbin 已提交
800
            self._conn.schemaless_insert([input_sql_tag], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
801
            raise Exception("should not reach here")
802
        except SchemalessError as err:
J
jiajingbin 已提交
803 804 805
            tdSql.checkNotEqual(err.errno, 0)

    ##### stb exist #####
806
    @tdCom.smlPass
J
jiajingbin 已提交
807 808 809 810
    def noIdStbExistCheckCase(self):
        """
            case no id when stb exist
        """
J
jiajingbin 已提交
811
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
812 813 814 815 816 817 818 819 820 821 822 823
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", value="f")
        self.resCmp(input_sql, stb_name)
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", value="f")
        self.resCmp(input_sql, stb_name, condition='where tbname like "t_%"')
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)

    def duplicateInsertExistCheckCase(self):
        """
            check duplicate insert when stb exist
        """
J
jiajingbin 已提交
824
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
825 826 827
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql()
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
828
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
829 830
        self.resCmp(input_sql, stb_name)

831
    @tdCom.smlPass
J
jiajingbin 已提交
832 833 834 835
    def tagColBinaryNcharLengthCheckCase(self):
        """
            check length increase
        """
J
jiajingbin 已提交
836
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
837 838 839 840
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql()
        self.resCmp(input_sql, stb_name)
        tb_name = tdCom.getLongName(5, "letters")
841
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name,t7="\"binaryTagValuebinaryTagValue\"", t8="L\"ncharTagValuencharTagValue\"")
J
jiajingbin 已提交
842 843
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"')

844
    @tdCom.smlPass
J
jiajingbin 已提交
845 846
    def tagColAddDupIDCheckCase(self):
        """
847
            check tag count add, stb and tb duplicate
J
jiajingbin 已提交
848 849 850 851 852 853
            * tag: alter table ...
            * col: when update==0 and ts is same, unchange
            * so this case tag&&value will be added, 
            * col is added without value when update==0
            * col is added with value when update==1
        """
J
jiajingbin 已提交
854
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
855 856 857 858 859
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
        for db_update_tag in [0, 1]:
            if db_update_tag == 1 :
                self.createDb("test_update", db_update_tag=db_update_tag)
J
jiajingbin 已提交
860
            input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="t", value="t")
J
jiajingbin 已提交
861
            self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
862
            input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t0="t", value="f", t_add_tag=True)
J
jiajingbin 已提交
863 864
            if db_update_tag == 1 :
                self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)
J
jiajingbin 已提交
865 866 867 868 869 870 871 872 873
                tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
                tdSql.checkData(0, 11, None)  
                tdSql.checkData(0, 12, None)  
            else:
                self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
                tdSql.query(f'select * from {stb_name} where tbname like "{tb_name}"')
                tdSql.checkData(0, 1, True)  
                tdSql.checkData(0, 11, None)  
                tdSql.checkData(0, 12, None)  
874
            self.createDb()
J
jiajingbin 已提交
875

876
    @tdCom.smlPass
J
jiajingbin 已提交
877 878
    def tagColAddCheckCase(self):
        """
879
            check tag count add
J
jiajingbin 已提交
880
        """
J
jiajingbin 已提交
881
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
882 883 884 885 886
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", value="f")
        self.resCmp(input_sql, stb_name)
        tb_name_1 = tdCom.getLongName(7, "letters")
887
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name_1, t0="f", value="f", t_add_tag=True)
J
jiajingbin 已提交
888
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name_1}"')
889 890
        res_row_list = self.resHandle(f"select t10,t11 from {tb_name}", True)[0]
        tdSql.checkEqual(res_row_list[0], ['None', 'None'])
J
jiajingbin 已提交
891 892 893 894 895 896 897
        self.resCmp(input_sql, stb_name, condition=f'where tbname like "{tb_name}"', none_check_tag=True)

    def tagMd5Check(self):
        """
            condition: stb not change
            insert two table, keep tag unchange, change col
        """
J
jiajingbin 已提交
898
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
899 900 901 902 903 904 905 906 907 908
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(t0="f", value="f", id_noexist_tag=True)
        self.resCmp(input_sql, stb_name)
        tb_name1 = self.getNoIdTbName(stb_name)
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", value="f", id_noexist_tag=True)
        self.resCmp(input_sql, stb_name)
        tb_name2 = self.getNoIdTbName(stb_name)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(1)
        tdSql.checkEqual(tb_name1, tb_name2)
909
        input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, t0="f", value="f", id_noexist_tag=True, t_add_tag=True)
J
jiajingbin 已提交
910
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
911 912 913 914 915 916 917 918 919 920
        tb_name3 = self.getNoIdTbName(stb_name)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)
        tdSql.checkNotEqual(tb_name1, tb_name3)

    # * tag nchar max is 16374/4, col+ts nchar max  49151
    def tagColNcharMaxLengthCheckCase(self):
        """
            check nchar length limit
        """
J
jiajingbin 已提交
921
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
922 923
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(7, "letters")
924
        input_sql = f'{stb_name} 1626006833640 f t2={tdCom.getLongName(1, "letters")}'
J
jiajingbin 已提交
925
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
926 927

        # * legal nchar could not be larger than 16374/4
J
jiajingbin 已提交
928 929
        input_sql = f'{stb_name} 1626006833640 f t1={tdCom.getLongName(4093, "letters")} t2={tdCom.getLongName(1, "letters")}'
        self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
930 931
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)
J
jiajingbin 已提交
932
        input_sql = f'{stb_name} 1626006833640 f t1={tdCom.getLongName(4093, "letters")} t2={tdCom.getLongName(2, "letters")}'
J
jiajingbin 已提交
933
        try:
J
jiajingbin 已提交
934
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
935
            raise Exception("should not reach here")
936
        except SchemalessError as err:
J
jiajingbin 已提交
937 938 939 940 941 942 943 944
            tdSql.checkNotEqual(err.errno, 0)
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(2)

    def batchInsertCheckCase(self):
        """
            test batch insert
        """
J
jiajingbin 已提交
945
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
946 947 948
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(8, "letters")
        tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
949
        
J
jiajingbin 已提交
950 951 952 953 954 955 956 957 958
        lines = ["st123456 1626006833640 1i64 t1=3i64 t2=4f64 t3=\"t3\"",
                "st123456 1626006833641 2i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64",
                f'{stb_name} 1626006833642 3i64 t2=5f64 t3=L\"ste\"',
                "stf567890 1626006833643 4i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64",
                "st123456 1626006833644 5i64 t1=4i64 t2=5f64 t3=\"t4\"",
                f'{stb_name} 1626006833645 6i64 t2=5f64 t3=L\"ste2\"',
                f'{stb_name} 1626006833646 7i64 t2=5f64 t3=L\"ste2\"',
                "st123456 1626006833647 8i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64",
                "st123456 1626006833648 9i64 t1=4i64 t3=\"t4\" t2=5f64 t4=5f64"
J
jiajingbin 已提交
959
                ]
J
jiajingbin 已提交
960
        self._conn.schemaless_insert(lines, TDSmlProtocolType.TELNET.value, None)
961 962 963 964 965 966
        tdSql.query('show stables')
        tdSql.checkRows(3)
        tdSql.query('show tables')
        tdSql.checkRows(6)
        tdSql.query('select * from st123456')
        tdSql.checkRows(5)
J
jiajingbin 已提交
967 968
    
    def multiInsertCheckCase(self, count):
J
jiajingbin 已提交
969 970 971
        """
            test multi insert
        """
J
jiajingbin 已提交
972
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
973 974 975 976 977 978 979 980 981 982
        tdCom.cleanTb()
        sql_list = []
        stb_name = tdCom.getLongName(8, "letters")
        tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 nchar(10))')
        for i in range(count):
            input_sql = self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True)[0]
            sql_list.append(input_sql)
        self._conn.schemaless_insert(sql_list, TDSmlProtocolType.TELNET.value, None)
        tdSql.query('show tables')
        tdSql.checkRows(count)
J
jiajingbin 已提交
983 984 985 986 987

    def batchErrorInsertCheckCase(self):
        """
            test batch error insert
        """
J
jiajingbin 已提交
988
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
989 990
        tdCom.cleanTb()
        stb_name = tdCom.getLongName(8, "letters")
J
jiajingbin 已提交
991
        lines = ["st123456 1626006833640 3i 64 t1=3i64 t2=4f64 t3=\"t3\"",
992
                f"{stb_name} 1626056811823316532ns tRue t2=5f64 t3=L\"ste\""]
J
jiajingbin 已提交
993
        try:
J
jiajingbin 已提交
994
            self._conn.schemaless_insert(lines, TDSmlProtocolType.TELNET.value, None)
J
jiajingbin 已提交
995
            raise Exception("should not reach here")
996
        except SchemalessError as err:
J
jiajingbin 已提交
997 998
            tdSql.checkNotEqual(err.errno, 0)

999 1000 1001 1002
    def multiColsInsertCheckCase(self):
        """
            test multi cols insert
        """
J
jiajingbin 已提交
1003
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1004
        tdCom.cleanTb()
J
jiajingbin 已提交
1005
        input_sql = self.genFullTypeSql(c_multi_tag=True)[0]
1006
        try:
J
jiajingbin 已提交
1007
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
1008
            raise Exception("should not reach here")
1009
        except SchemalessError as err:
1010 1011 1012 1013 1014 1015
            tdSql.checkNotEqual(err.errno, 0)
    
    def blankColInsertCheckCase(self):
        """
            test blank col insert
        """
J
jiajingbin 已提交
1016
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1017 1018 1019
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(c_blank_tag=True)[0]
        try:
J
jiajingbin 已提交
1020
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
1021
            raise Exception("should not reach here")
1022
        except SchemalessError as err:
1023 1024 1025 1026 1027 1028
            tdSql.checkNotEqual(err.errno, 0)

    def blankTagInsertCheckCase(self):
        """
            test blank tag insert
        """
J
jiajingbin 已提交
1029
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1030 1031 1032
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(t_blank_tag=True)[0]
        try:
J
jiajingbin 已提交
1033
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
1034
            raise Exception("should not reach here")
1035
        except SchemalessError as err:
1036 1037 1038 1039 1040 1041
            tdSql.checkNotEqual(err.errno, 0)
    
    def chineseCheckCase(self):
        """
            check nchar ---> chinese
        """
J
jiajingbin 已提交
1042
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1043 1044 1045 1046 1047 1048 1049 1050
        tdCom.cleanTb()
        input_sql, stb_name = self.genFullTypeSql(chinese_tag=True)
        self.resCmp(input_sql, stb_name)

    def multiFieldCheckCase(self):
        '''
            multi_field
        '''
J
jiajingbin 已提交
1051
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1052 1053 1054
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(multi_field_tag=True)[0]
        try:
J
jiajingbin 已提交
1055
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
1056
            raise Exception("should not reach here")
1057
        except SchemalessError as err:
1058 1059
            tdSql.checkNotEqual(err.errno, 0)

J
jiajingbin 已提交
1060
    def spellCheckCase(self):
J
jiajingbin 已提交
1061 1062
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
J
jiajingbin 已提交
1063
        stb_name = tdCom.getLongName(8, "letters")
J
jiajingbin 已提交
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
        input_sql_list = [f'{stb_name}_1 1626006833640 127I8 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_2 1626006833640 32767I16 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_3 1626006833640 2147483647I32 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_4 1626006833640 9223372036854775807I64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_5 1626006833640 11.12345027923584F32 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_6 1626006833640 22.123456789F64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_7 1626006833640 22.123456789F64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_8 1626006833640 22.123456789F64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_9 1626006833640 22.123456789F64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
                            f'{stb_name}_10 1626006833640 22.123456789F64 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64']
J
jiajingbin 已提交
1074
        for input_sql in input_sql_list:
J
jiajingbin 已提交
1075
            stb_name = input_sql.split(' ')[0]
1076 1077
            self.resCmp(input_sql, stb_name)

1078
    def pointTransCheckCase(self, protocol=None):
1079 1080 1081
        """
            metric value "." trans to "_"
        """
J
jiajingbin 已提交
1082
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
1083
        tdCom.cleanTb()
1084 1085 1086 1087 1088 1089
        input_sql = self.genFullTypeSql(point_trans_tag=True, protocol=protocol)[0]
        if protocol == 'telnet-tcp':
            stb_name = f'`{input_sql.split(" ")[1]}`'
        else:
            stb_name = f'`{input_sql.split(" ")[0]}`'
        self.resCmp(input_sql, stb_name, protocol=protocol)
J
jiajingbin 已提交
1090
        tdSql.execute("drop table `.point.trans.test`")
1091 1092

    def defaultTypeCheckCase(self):
J
jiajingbin 已提交
1093
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1094
        tdCom.cleanTb()
1095
        stb_name = tdCom.getLongName(8, "letters")
J
jiajingbin 已提交
1096 1097 1098 1099 1100
        input_sql_list = [f'{stb_name}_1 1626006833640 9223372036854775807 t0=f t1=127 t2=32767i16 t3=2147483647i32 t4=9223372036854775807 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \
                        f'{stb_name}_2 1626006833641 22.123456789 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789 t7="vozamcts" t8=L"ncharTagValue"', \
                        f'{stb_name}_3 1626006833642 10e5F32 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=10e5F64 t7="vozamcts" t8=L"ncharTagValue"', \
                        f'{stb_name}_4 1626006833643 10.0e5F64 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=10.0e5F32 t7="vozamcts" t8=L"ncharTagValue"', \
                        f'{stb_name}_5 1626006833644 -10.0e5 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=-10.0e5 t7="vozamcts" t8=L"ncharTagValue"']
1101 1102 1103
        for input_sql in input_sql_list:
            stb_name = input_sql.split(" ")[0]
            self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
1104

J
jiajingbin 已提交
1105
    def tbnameTagsColsNameCheckCase(self):
J
jiajingbin 已提交
1106 1107
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
        if self.smlChildTableName_value == "ID":
            input_sql = 'rFa$sta 1626006834 9223372036854775807 id=rFas$ta_1 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"'
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
            query_sql = 'select * from `rFa$sta`'
            query_res = tdSql.query(query_sql, True)
            tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, 'true', '127Ii8', '32767i16', '2147483647i32', '9223372036854775807i64', '11.12345f32', '22.123456789f64', '"ddzhiksj"', 'L"ncharTagValue"')])
            col_tag_res = tdSql.getColNameList(query_sql)
            tdSql.checkEqual(col_tag_res, ['ts', 'value', 'tt!0', 'tt@1', 't#2', '"t$3"', 't%4', 't^5', 't&6', 't*7', 't!@#$%^&*()_+[];:<>?,9'])
            tdSql.execute('drop table `rFa$sta`')
        else:
            input_sql = 'rFa$sta 1626006834 9223372036854775807 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"'
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
            query_sql = 'select * from `rFa$sta`'
            query_res = tdSql.query(query_sql, True)
            tdSql.checkEqual(query_res, [(datetime.datetime(2021, 7, 11, 20, 33, 54), 9.223372036854776e+18, '2147483647i32', 'L"ncharTagValue"', '32767i16', '9223372036854775807i64', '22.123456789f64', '"ddzhiksj"', '11.12345f32', 'true', '127Ii8')])
            col_tag_res = tdSql.getColNameList(query_sql)
            tdSql.checkEqual(col_tag_res, ['ts', 'value', '"t$3"', 't!@#$%^&*()_+[];:<>?,9', 't#2', 't%4', 't&6', 't*7', 't^5', 'Tt!0', 'tT@1'])
            tdSql.execute('drop table `rFa$sta`')
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136

    def tcpKeywordsCheckCase(self, protocol="telnet-tcp"):
        """
            stb = "put"
        """
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
        tdCom.cleanTb()
        input_sql = self.genFullTypeSql(tcp_keyword_tag=True, protocol=protocol)[0]
        stb_name = f'`{input_sql.split(" ")[1]}`'
        self.resCmp(input_sql, stb_name, protocol=protocol)

J
jiajingbin 已提交
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
    def genSqlList(self, count=5, stb_name="", tb_name=""):
        """
            stb --> supertable
            tb  --> table
            ts  --> timestamp, same default
            col --> column, same default
            tag --> tag, same default
            d   --> different
            s   --> same
            a   --> add
            m   --> minus
        """
        d_stb_d_tb_list = list()
        s_stb_s_tb_list = list()
1151 1152
        s_stb_s_tb_a_tag_list = list()
        s_stb_s_tb_m_tag_list = list()
J
jiajingbin 已提交
1153
        s_stb_d_tb_list = list()
1154 1155
        s_stb_d_tb_m_tag_list = list()
        s_stb_d_tb_a_tag_list = list()
J
jiajingbin 已提交
1156
        s_stb_s_tb_d_ts_list = list()
1157 1158
        s_stb_s_tb_d_ts_m_tag_list = list()
        s_stb_s_tb_d_ts_a_tag_list = list()
J
jiajingbin 已提交
1159
        s_stb_d_tb_d_ts_list = list()
1160 1161
        s_stb_d_tb_d_ts_m_tag_list = list()
        s_stb_d_tb_d_ts_a_tag_list = list()
J
jiajingbin 已提交
1162
        for i in range(count):
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
            d_stb_d_tb_list.append(self.genFullTypeSql(t0="f", value="f"))
            s_stb_s_tb_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"'))
            s_stb_s_tb_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', t_add_tag=True))
            s_stb_s_tb_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', t_mul_tag=True))
            s_stb_d_tb_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True))
            s_stb_d_tb_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, t_mul_tag=True))
            s_stb_d_tb_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, t_add_tag=True))
            s_stb_s_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', ts=0))
            s_stb_s_tb_d_ts_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', ts=0, t_mul_tag=True))
            s_stb_s_tb_d_ts_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, tb_name=tb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', ts=0, t_add_tag=True))
            s_stb_d_tb_d_ts_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0))
            s_stb_d_tb_d_ts_m_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, t_mul_tag=True))
            s_stb_d_tb_d_ts_a_tag_list.append(self.genFullTypeSql(stb_name=stb_name, t7=f'"{tdCom.getLongName(8, "letters")}"', value=f'"{tdCom.getLongName(8, "letters")}"', id_noexist_tag=True, ts=0, t_add_tag=True))

        return d_stb_d_tb_list, s_stb_s_tb_list, s_stb_s_tb_a_tag_list, s_stb_s_tb_m_tag_list, \
            s_stb_d_tb_list, s_stb_d_tb_m_tag_list, s_stb_d_tb_a_tag_list, s_stb_s_tb_d_ts_list, \
            s_stb_s_tb_d_ts_m_tag_list, s_stb_s_tb_d_ts_a_tag_list, s_stb_d_tb_d_ts_list, \
            s_stb_d_tb_d_ts_m_tag_list, s_stb_d_tb_d_ts_a_tag_list
J
jiajingbin 已提交
1181 1182 1183 1184 1185


    def genMultiThreadSeq(self, sql_list):
        tlist = list()
        for insert_sql in sql_list:
J
jiajingbin 已提交
1186
            t = threading.Thread(target=self._conn.schemaless_insert,args=([insert_sql[0]], TDSmlProtocolType.TELNET.value, None))
J
jiajingbin 已提交
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
            tlist.append(t)
        return tlist

    def multiThreadRun(self, tlist):
        for t in tlist:
            t.start()
        for t in tlist:
            t.join()

    def stbInsertMultiThreadCheckCase(self):
        """
            thread input different stb
        """
J
jiajingbin 已提交
1200
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
        tdCom.cleanTb()
        input_sql = self.genSqlList()[0]
        self.multiThreadRun(self.genMultiThreadSeq(input_sql))
        tdSql.query(f"show tables;")
        tdSql.checkRows(5)
    
    def sStbStbDdataInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different data, result keep first data
        """
J
jiajingbin 已提交
1211
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1212 1213
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1214
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1215 1216 1217 1218
        self.resCmp(input_sql, stb_name)
        s_stb_s_tb_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[1]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_list))
        tdSql.query(f"show tables;")
1219 1220 1221 1222
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
        if self.smlChildTableName_value == "ID":
            expected_tb_name = self.getNoIdTbName(stb_name)[0]
            tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1223
        tdSql.query(f"select * from {stb_name};")
1224
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
J
jiajingbin 已提交
1225

1226
    def sStbStbDdataAtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1227 1228 1229
        """
            thread input same stb tb, different data, add columes and tags,  result keep first data
        """
J
jiajingbin 已提交
1230
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1231 1232
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1233
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1234
        self.resCmp(input_sql, stb_name)
1235 1236
        s_stb_s_tb_a_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[2]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_a_tag_list))
J
jiajingbin 已提交
1237
        tdSql.query(f"show tables;")
1238 1239 1240 1241
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
        if self.smlChildTableName_value == "ID":
            expected_tb_name = self.getNoIdTbName(stb_name)[0]
            tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1242
        tdSql.query(f"select * from {stb_name};")
1243
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
J
jiajingbin 已提交
1244
    
1245
    def sStbStbDdataMtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1246 1247 1248
        """
            thread input same stb tb, different data, minus columes and tags,  result keep first data
        """
J
jiajingbin 已提交
1249
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1250 1251
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1252
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1253
        self.resCmp(input_sql, stb_name)
1254 1255
        s_stb_s_tb_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[3]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_m_tag_list))
J
jiajingbin 已提交
1256
        tdSql.query(f"show tables;")
1257 1258 1259 1260
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
        if self.smlChildTableName_value == "ID":
            expected_tb_name = self.getNoIdTbName(stb_name)[0]
            tdSql.checkEqual(tb_name, expected_tb_name)
J
jiajingbin 已提交
1261
        tdSql.query(f"select * from {stb_name};")
1262
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
J
jiajingbin 已提交
1263 1264 1265 1266 1267

    def sStbDtbDdataInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, different data
        """
J
jiajingbin 已提交
1268
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1269
        tdCom.cleanTb()
1270
        input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
J
jiajingbin 已提交
1271 1272 1273 1274 1275 1276
        self.resCmp(input_sql, stb_name)
        s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)

1277
    def sStbDtbDdataMtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1278 1279 1280
        """
            thread input same stb, different tb, different data, add col, mul tag
        """
J
jiajingbin 已提交
1281
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1282
        tdCom.cleanTb()
1283
        input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
J
jiajingbin 已提交
1284
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
1285 1286 1287 1288 1289
        s_stb_d_tb_m_tag_list = [(f'{stb_name} 1626006833640 "omfdhyom" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'),  \
                                (f'{stb_name} 1626006833640 "vqowydbc" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'),  \
                                (f'{stb_name} 1626006833640 "plgkckpv" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'),  \
                                (f'{stb_name} 1626006833640 "cujyqvlj" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'),  \
                                (f'{stb_name} 1626006833640 "twjxisat" t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz')]
1290
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_m_tag_list))
J
jiajingbin 已提交
1291
        tdSql.query(f"show tables;")
1292
        tdSql.checkRows(3)
J
jiajingbin 已提交
1293

1294
    def sStbDtbDdataAtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1295 1296 1297
        """
            thread input same stb, different tb, different data, add tag, mul col
        """
J
jiajingbin 已提交
1298
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1299
        tdCom.cleanTb()
1300
        input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
J
jiajingbin 已提交
1301
        self.resCmp(input_sql, stb_name)
1302 1303
        s_stb_d_tb_a_tag_list = self.genSqlList(stb_name=stb_name)[6]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_a_tag_list))
J
jiajingbin 已提交
1304 1305 1306 1307 1308 1309 1310
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)

    def sStbStbDdataDtsInsertMultiThreadCheckCase(self):
        """
            thread input same stb tb, different ts
        """
J
jiajingbin 已提交
1311
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1312 1313
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1314
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1315
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
1316 1317 1318 1319 1320
        s_stb_s_tb_d_ts_list = [(f'{stb_name} 0 "hkgjiwdj" id={tb_name} t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', 'dwpthv'), \
                                (f'{stb_name} 0 "rljjrrul" id={tb_name} t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="bmcanhbs" t8=L"ncharTagValue"', 'dwpthv'), \
                                (f'{stb_name} 0 "basanglx" id={tb_name} t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enqkyvmb" t8=L"ncharTagValue"', 'dwpthv'), \
                                (f'{stb_name} 0 "clsajzpp" id={tb_name} t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="eivaegjk" t8=L"ncharTagValue"', 'dwpthv'), \
                                (f'{stb_name} 0 "jitwseso" id={tb_name} t0=T t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="yhlwkddq" t8=L"ncharTagValue"', 'dwpthv')]
J
jiajingbin 已提交
1321 1322
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_list))
        tdSql.query(f"show tables;")
1323
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
J
jiajingbin 已提交
1324 1325 1326
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(6)

1327
    def sStbStbDdataDtsMtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1328 1329 1330
        """
            thread input same stb tb, different ts, add col, mul tag
        """
J
jiajingbin 已提交
1331
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1332 1333
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1334
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1335
        self.resCmp(input_sql, stb_name)
1336 1337
        s_stb_s_tb_d_ts_m_tag_list = self.genSqlList(stb_name=stb_name, tb_name=tb_name)[8]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_m_tag_list))
J
jiajingbin 已提交
1338
        tdSql.query(f"show tables;")
1339
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(2)
J
jiajingbin 已提交
1340 1341 1342
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(6)
        tdSql.query(f"select * from {stb_name} where t8 is not NULL")
1343
        tdSql.checkRows(6) if self.smlChildTableName_value == "ID" else tdSql.checkRows(1)
J
jiajingbin 已提交
1344

1345
    def sStbStbDdataDtsAtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1346 1347 1348
        """
            thread input same stb tb, different ts, add tag, mul col
        """
J
jiajingbin 已提交
1349
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1350 1351
        tdCom.cleanTb()
        tb_name = tdCom.getLongName(7, "letters")
1352
        input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
J
jiajingbin 已提交
1353
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
1354 1355 1356 1357 1358
        s_stb_s_tb_d_ts_a_tag_list = [(f'{stb_name} 0 "clummqfy" id={tb_name} t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="hpxzrdiw" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \
                                    (f'{stb_name} 0 "yqeztggb" id={tb_name} t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="gdtblmrc" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \
                                    (f'{stb_name} 0 "gbkinqdk" id={tb_name} t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="iqniuvco" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \
                                    (f'{stb_name} 0 "ldxxejbd" id={tb_name} t0=f t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="vxkipags" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl'), \
                                    (f'{stb_name} 0 "tlvzwjes" id={tb_name} t0=true t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7="enwrlrtj" t8=L"ncharTagValue" t11=127i8 t10=L"ncharTagValue"', 'bokaxl')]
1359
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_s_tb_d_ts_a_tag_list))
J
jiajingbin 已提交
1360
        tdSql.query(f"show tables;")
1361
        tdSql.checkRows(1) if self.smlChildTableName_value == "ID" else tdSql.checkRows(6)
J
jiajingbin 已提交
1362 1363 1364 1365
        tdSql.query(f"select * from {stb_name}")
        tdSql.checkRows(6)
        for t in ["t10", "t11"]:
            tdSql.query(f"select * from {stb_name} where {t} is not NULL;")
1366
            tdSql.checkRows(0) if self.smlChildTableName_value == "ID" else tdSql.checkRows(5)
J
jiajingbin 已提交
1367 1368 1369 1370 1371

    def sStbDtbDdataDtsInsertMultiThreadCheckCase(self):
        """
            thread input same stb, different tb, data, ts
        """
J
jiajingbin 已提交
1372
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1373
        tdCom.cleanTb()
1374
        input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
J
jiajingbin 已提交
1375 1376 1377 1378 1379 1380
        self.resCmp(input_sql, stb_name)
        s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10]
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_list))
        tdSql.query(f"show tables;")
        tdSql.checkRows(6)

1381
    def sStbDtbDdataDtsMtInsertMultiThreadCheckCase(self):
J
jiajingbin 已提交
1382 1383 1384
        """
            thread input same stb, different tb, data, ts, add col, mul tag
        """
J
jiajingbin 已提交
1385
        tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
J
jiajingbin 已提交
1386
        tdCom.cleanTb()
1387
        input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
J
jiajingbin 已提交
1388
        self.resCmp(input_sql, stb_name)
J
jiajingbin 已提交
1389 1390 1391 1392 1393
        s_stb_d_tb_d_ts_m_tag_list = [(f'{stb_name} 0 "mnpmtzul" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \
                                    (f'{stb_name} 0 "zbvwckcd" t0=True t1=126i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \
                                    (f'{stb_name} 0 "vymcjfwc" t0=False t1=125i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \
                                    (f'{stb_name} 0 "laumkwfn" t0=False t1=124i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \
                                    (f'{stb_name} 0 "nyultzxr" t0=false t1=123i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg')]
1394
        self.multiThreadRun(self.genMultiThreadSeq(s_stb_d_tb_d_ts_m_tag_list))
J
jiajingbin 已提交
1395
        tdSql.query(f"show tables;")
J
jiajingbin 已提交
1396
        tdSql.checkRows(6)
J
jiajingbin 已提交
1397 1398 1399

    def test(self):
        try:
1400
            input_sql = f'test_nchar 0 L"涛思数据" t0=f t1=L"涛思数据" t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64'
J
jiajingbin 已提交
1401
            self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
1402
        except SchemalessError as err:
J
jiajingbin 已提交
1403 1404 1405
            print(err.errno)

    def runAll(self):
1406 1407
        self.initCheckCase()
        self.boolTypeCheckCase()
1408
        self.symbolsCheckCase()
1409
        self.tsCheckCase()
J
jiajingbin 已提交
1410
        self.openTstbTelnetTsCheckCase()
1411
        self.idSeqCheckCase()
J
jiajingbin 已提交
1412
        self.idLetterCheckCase()
1413 1414
        self.noIdCheckCase()
        self.maxColTagCheckCase()
J
jiajingbin 已提交
1415
        self.stbTbNameCheckCase()
1416 1417 1418 1419
        self.idStartWithNumCheckCase()
        self.nowTsCheckCase()
        self.dateFormatTsCheckCase()
        self.illegalTsCheckCase()
J
jiajingbin 已提交
1420
        self.tbnameCheckCase()
J
jiajingbin 已提交
1421
        self.tagNameLengthCheckCase()
1422 1423 1424
        self.tagValueLengthCheckCase()
        self.colValueLengthCheckCase()
        self.tagColIllegalValueCheckCase()
1425
        self.blankCheckCase()
1426 1427 1428 1429 1430 1431 1432 1433 1434
        self.duplicateIdTagColInsertCheckCase()
        self.noIdStbExistCheckCase()
        self.duplicateInsertExistCheckCase()
        self.tagColBinaryNcharLengthCheckCase()
        self.tagColAddDupIDCheckCase()
        self.tagColAddCheckCase()
        self.tagMd5Check()
        self.tagColNcharMaxLengthCheckCase()
        self.batchInsertCheckCase()
1435
        self.multiInsertCheckCase(10)
1436 1437 1438 1439 1440 1441
        self.batchErrorInsertCheckCase()
        self.multiColsInsertCheckCase()
        self.blankColInsertCheckCase()
        self.blankTagInsertCheckCase()
        self.chineseCheckCase()
        self.multiFieldCheckCase()
J
jiajingbin 已提交
1442
        self.spellCheckCase()
1443 1444
        self.pointTransCheckCase()
        self.defaultTypeCheckCase()
J
jiajingbin 已提交
1445 1446
        self.tbnameTagsColsNameCheckCase()
        # # # MultiThreads
1447 1448 1449 1450 1451 1452 1453 1454
        self.stbInsertMultiThreadCheckCase()
        self.sStbStbDdataInsertMultiThreadCheckCase()
        self.sStbStbDdataAtInsertMultiThreadCheckCase()
        self.sStbStbDdataMtInsertMultiThreadCheckCase()
        self.sStbDtbDdataInsertMultiThreadCheckCase()
        self.sStbDtbDdataMtInsertMultiThreadCheckCase()
        self.sStbDtbDdataAtInsertMultiThreadCheckCase()
        self.sStbStbDdataDtsInsertMultiThreadCheckCase()
1455
        # self.sStbStbDdataDtsMtInsertMultiThreadCheckCase()
1456 1457 1458
        self.sStbStbDdataDtsAtInsertMultiThreadCheckCase()
        self.sStbDtbDdataDtsInsertMultiThreadCheckCase()
        self.sStbDtbDdataDtsMtInsertMultiThreadCheckCase()
J
jiajingbin 已提交
1459 1460 1461

    def run(self):
        print("running {}".format(__file__))
1462
        
J
jiajingbin 已提交
1463
        try:
1464
            self.createDb()
J
jiajingbin 已提交
1465
            self.runAll()
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476
            # self.createDb(protocol="telnet-tcp")
            # self.initCheckCase('telnet-tcp')
            # self.boolTypeCheckCase('telnet-tcp')
            # self.symbolsCheckCase('telnet-tcp')
            # self.idSeqCheckCase('telnet-tcp')
            # self.idLetterCheckCase('telnet-tcp')
            # self.noIdCheckCase('telnet-tcp')
            # self.stbTbNameCheckCase('telnet-tcp')
            # self.idStartWithNumCheckCase('telnet-tcp')
            # self.pointTransCheckCase('telnet-tcp')
            # self.tcpKeywordsCheckCase()
J
jiajingbin 已提交
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486
        except Exception as err:
            print(''.join(traceback.format_exception(None, err, err.__traceback__)))
            raise err

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())