taosShell.py 19.8 KB
Newer Older
1 2 3 4 5 6

import taos
import sys
import time
import socket
import os
wafwerar's avatar
wafwerar 已提交
7 8 9 10 11
import platform
if platform.system().lower() == 'windows':
    import wexpect as taosExpect
else:
    import pexpect as taosExpect
12 13 14 15 16 17

from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *

P
plum-lihui 已提交
18
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
19 20
    if len(key) == 0:
        tdLog.exit("taos test key is null!")
G
Ganlin Zhao 已提交
21

wafwerar's avatar
wafwerar 已提交
22 23 24 25 26
    if platform.system().lower() == 'windows':
        taosCmd = buildPath + '\\build\\bin\\taos.exe '
        taosCmd = taosCmd.replace('\\','\\\\')
    else:
        taosCmd = buildPath + '/build/bin/taos '
27
    if len(cfgDir) != 0:
P
plum-lihui 已提交
28
        taosCmd = taosCmd + '-c ' + cfgDir
29

P
plum-lihui 已提交
30
    taosCmd = taosCmd + ' -' + key
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    if len(value) != 0:
        if key == 'p':
            taosCmd = taosCmd + value
        else:
            taosCmd = taosCmd + ' ' + value

    if len(key1) != 0:
        taosCmd = taosCmd + ' -' + key1
        if key1 == 'p':
            taosCmd = taosCmd + value1
        else:
            if len(value1) != 0:
                taosCmd = taosCmd + ' ' + value1

    tdLog.info ("taos cmd: %s" % taosCmd)

wafwerar's avatar
wafwerar 已提交
47
    child = taosExpect.spawn(taosCmd, timeout=20)
48 49
    #output = child.readline()
    #print (output.decode())
P
plum-lihui 已提交
50
    if len(expectString) != 0:
wafwerar's avatar
wafwerar 已提交
51
        i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=20)
P
plum-lihui 已提交
52
    else:
wafwerar's avatar
wafwerar 已提交
53
        i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=20)
P
plum-lihui 已提交
54

wafwerar's avatar
wafwerar 已提交
55 56 57 58
    if platform.system().lower() == 'windows':
        retResult = child.before
    else:
        retResult = child.before.decode()
59 60 61 62
    print(retResult)
    #print(child.after.decode())
    if i == 0:
        print ('taos login success! Here can run sql, taos> ')
P
plum-lihui 已提交
63 64
        if len(sqlString) != 0:
            child.sendline (sqlString)
wafwerar's avatar
wafwerar 已提交
65
            w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=10)
66 67 68
            if w == 0:
                return "TAOS_OK"
            else:
wafwerar's avatar
wafwerar 已提交
69 70
                print(1)
                print(retResult)
71 72
                return "TAOS_FAIL"
        else:
73
            if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V':
P
plum-lihui 已提交
74 75 76
                return "TAOS_OK", retResult
            else:
                return  "TAOS_OK"
77
    else:
78
        if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V':
79 80 81 82 83
            return "TAOS_OK", retResult
        else:
            return "TAOS_FAIL"

class TDTestCase:
P
plum-lihui 已提交
84 85 86
    #updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\
    #                 'serverPort': 7080, 'firstEp': 'trd02:7080'}
    hostname = socket.gethostname()
wafwerar's avatar
wafwerar 已提交
87
    if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""):
wafwerar's avatar
wafwerar 已提交
88 89 90 91 92
        try:
            config = eval(tdDnodes.dnodes[0].remoteIP)
            hostname = config["host"]
        except Exception:
            hostname = tdDnodes.dnodes[0].remoteIP
P
plum-lihui 已提交
93
    serverPort = '7080'
94
    rpcDebugFlagVal = '143'
P
plum-lihui 已提交
95
    clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
96 97 98 99
    clientCfgDict["serverPort"]    = serverPort
    clientCfgDict["firstEp"]       = hostname + ':' + serverPort
    clientCfgDict["secondEp"]      = hostname + ':' + serverPort
    clientCfgDict["rpcDebugFlag"]  = rpcDebugFlagVal
P
plum-lihui 已提交
100
    clientCfgDict["fqdn"] = hostname
101

P
plum-lihui 已提交
102
    updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
P
plum-lihui 已提交
103 104 105 106
    updatecfgDict["clientCfg"]  = clientCfgDict
    updatecfgDict["serverPort"] = serverPort
    updatecfgDict["firstEp"]    = hostname + ':' + serverPort
    updatecfgDict["secondEp"]   = hostname + ':' + serverPort
P
plum-lihui 已提交
107 108
    updatecfgDict["fqdn"] = hostname

P
plum-lihui 已提交
109
    print ("===================: ", updatecfgDict)
110

111
    def init(self, conn, logSql, replicaVar=1):
112 113 114 115 116 117 118 119 120 121 122 123
        tdLog.debug(f"start to excute {__file__}")
        tdSql.init(conn.cursor())

    def getBuildPath(self):
        selfPath = os.path.dirname(os.path.realpath(__file__))

        if ("community" in selfPath):
            projPath = selfPath[:selfPath.find("community")]
        else:
            projPath = selfPath[:selfPath.find("tests")]

        for root, dirs, files in os.walk(projPath):
wafwerar's avatar
wafwerar 已提交
124
            if ("taosd" in files or "taosd.exe" in files):
125 126 127 128 129 130 131 132 133 134 135
                rootRealPath = os.path.dirname(os.path.realpath(root))
                if ("packaging" not in rootRealPath):
                    buildPath = root[:len(root) - len("/build/bin")]
                    break
        return buildPath

    def run(self):  # sourcery skip: extract-duplicate-method, remove-redundant-fstring
        tdSql.prepare()
        # time.sleep(2)
        tdSql.query("create user testpy pass 'testpy'")

136 137
        #hostname = socket.gethostname()
        #tdLog.info ("hostname: %s" % hostname)
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

        buildPath = self.getBuildPath()
        if (buildPath == ""):
            tdLog.exit("taosd not found!")
        else:
            tdLog.info("taosd found in %s" % buildPath)
        cfgPath = buildPath + "/../sim/psim/cfg"
        tdLog.info("cfgPath: %s" % cfgPath)

        checkNetworkStatus = ['0: unavailable', '1: network ok', '2: service ok', '3: service degraded', '4: exiting']
        netrole            = ['client', 'server']

        keyDict = {'h':'', 'P':'6030', 'p':'testpy', 'u':'testpy', 'a':'', 'A':'', 'c':'', 'C':'', 's':'', 'r':'', 'f':'', \
                   'k':'', 't':'', 'n':'', 'l':'1024', 'N':'100', 'V':'', 'd':'db', 'w':'30', '-help':'', '-usage':'', '?':''}

153
        keyDict['h'] = self.hostname
154
        keyDict['c'] = cfgPath
155
        keyDict['P'] = self.serverPort
156 157 158

        tdLog.printNoPrefix("================================ parameter: -h")
        newDbName="dbh"
P
plum-lihui 已提交
159
        sqlString = 'create database ' + newDbName + ';'
P
plum-lihui 已提交
160
        retCode = taos_command(buildPath, "h", keyDict['h'], "taos>", keyDict['c'], sqlString)
161 162 163 164
        if retCode != "TAOS_OK":
            tdLog.exit("taos -h %s fail"%keyDict['h'])
        else:
            #dataDbName = ["information_schema", "performance_schema", "db", newDbName]
X
Xiaoyu Wang 已提交
165 166
            tdSql.query("select * from information_schema.ins_databases")
            #tdSql.getResult("select * from information_schema.ins_databases")
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
            for i in range(tdSql.queryRows):
                if tdSql.getData(i, 0) == newDbName:
                    break
            else:
                tdLog.exit("create db fail after taos -h %s fail"%keyDict['h'])

            tdSql.query('drop database %s'%newDbName)

        tdLog.printNoPrefix("================================ parameter: -P")
        #tdDnodes.stop(1)
        #sleep(3)
        #tdDnodes.start(1)
        #sleep(3)
        #keyDict['P'] = 6030
        newDbName = "dbpp"
P
plum-lihui 已提交
182
        sqlString = 'create database ' + newDbName + ';'
P
plum-lihui 已提交
183
        retCode = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], sqlString)
184 185 186
        if retCode != "TAOS_OK":
            tdLog.exit("taos -P %s fail"%keyDict['P'])
        else:
X
Xiaoyu Wang 已提交
187
            tdSql.query("select * from information_schema.ins_databases")
188 189 190 191 192 193 194 195 196 197
            for i in range(tdSql.queryRows):
                if tdSql.getData(i, 0) == newDbName:
                    break
            else:
                tdLog.exit("create db fail after taos -P %s fail"%keyDict['P'])

            tdSql.query('drop database %s'%newDbName)

        tdLog.printNoPrefix("================================ parameter: -u")
        newDbName="dbu"
P
plum-lihui 已提交
198
        sqlString = 'create database ' + newDbName + ';'
P
plum-lihui 已提交
199
        retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, "p", keyDict['p'])
200 201 202
        if retCode != "TAOS_OK":
            tdLog.exit("taos -u %s -p%s fail"%(keyDict['u'], keyDict['p']))
        else:
X
Xiaoyu Wang 已提交
203
            tdSql.query("select * from information_schema.ins_databases")
204 205 206 207 208 209 210 211 212 213
            for i in range(tdSql.queryRows):
                if tdSql.getData(i, 0) == newDbName:
                    break
            else:
                tdLog.exit("create db fail after taos -u %s -p%s fail"%(keyDict['u'], keyDict['p']))

            tdSql.query('drop database %s'%newDbName)

        tdLog.printNoPrefix("================================ parameter: -A")
        newDbName="dbaa"
P
plum-lihui 已提交
214
        retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '')
215 216
        if retCode != "TAOS_OK":
            tdLog.exit("taos -A fail")
G
Ganlin Zhao 已提交
217

P
plum-lihui 已提交
218
        sqlString = 'create database ' + newDbName + ';'
P
plum-lihui 已提交
219
        retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal)
220 221 222
        if retCode != "TAOS_OK":
            tdLog.exit("taos -u %s -a %s"%(keyDict['u'], retVal))

X
Xiaoyu Wang 已提交
223
        tdSql.query("select * from information_schema.ins_databases")
224 225 226 227 228 229 230 231 232 233 234
        for i in range(tdSql.queryRows):
            if tdSql.getData(i, 0) == newDbName:
                break
        else:
            tdLog.exit("create db fail after taos -u %s -a %s fail"%(keyDict['u'], retVal))

        tdSql.query('drop database %s'%newDbName)

        tdLog.printNoPrefix("================================ parameter: -s")
        newDbName="dbss"
        keyDict['s'] = "\"create database " + newDbName + "\""
P
plum-lihui 已提交
235
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
236 237 238 239
        if retCode != "TAOS_OK":
            tdLog.exit("taos -s fail")

        print ("========== check new db ==========")
X
Xiaoyu Wang 已提交
240
        tdSql.query("select * from information_schema.ins_databases")
241 242 243 244 245 246 247
        for i in range(tdSql.queryRows):
            if tdSql.getData(i, 0) == newDbName:
                break
        else:
            tdLog.exit("create db fail after taos -s %s fail"%(keyDict['s']))

        keyDict['s'] = "\"create table " + newDbName + ".stb (ts timestamp, c int) tags (t int)\""
P
plum-lihui 已提交
248
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
249 250 251 252
        if retCode != "TAOS_OK":
            tdLog.exit("taos -s create table fail")

        keyDict['s'] = "\"create table " + newDbName + ".ctb0 using " + newDbName + ".stb tags (0) " + newDbName + ".ctb1 using " + newDbName + ".stb tags (1)\""
P
plum-lihui 已提交
253
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
254 255 256 257
        if retCode != "TAOS_OK":
            tdLog.exit("taos -s create table fail")

        keyDict['s'] = "\"insert into " + newDbName + ".ctb0 values('2021-04-01 08:00:00.000', 10)('2021-04-01 08:00:01.000', 20) " + newDbName + ".ctb1 values('2021-04-01 08:00:00.000', 11)('2021-04-01 08:00:01.000', 21)\""
P
plum-lihui 已提交
258
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
259 260 261
        if retCode != "TAOS_OK":
            tdLog.exit("taos -s insert data fail")

G
Ganlin Zhao 已提交
262
        sqlString = "select * from " + newDbName + ".ctb0"
263 264 265 266 267
        tdSql.query(sqlString)
        tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
        tdSql.checkData(0, 1, 10)
        tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
        tdSql.checkData(1, 1, 20)
G
Ganlin Zhao 已提交
268
        sqlString = "select * from " + newDbName + ".ctb1"
269 270 271 272 273
        tdSql.query(sqlString)
        tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
        tdSql.checkData(0, 1, 11)
        tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
        tdSql.checkData(1, 1, 21)
G
Ganlin Zhao 已提交
274

P
plum-lihui 已提交
275
        keyDict['s'] = "\"select * from " + newDbName + ".ctb0\""
P
plum-lihui 已提交
276
        retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '')
P
plum-lihui 已提交
277 278
        if retCode != "TAOS_OK":
            tdLog.exit("taos -r show fail")
G
Ganlin Zhao 已提交
279

P
plum-lihui 已提交
280 281
        tdLog.printNoPrefix("================================ parameter: -r")
        keyDict['s'] = "\"select * from " + newDbName + ".ctb0\""
P
plum-lihui 已提交
282
        retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '')
P
plum-lihui 已提交
283 284 285 286
        if retCode != "TAOS_OK":
            tdLog.exit("taos -r show fail")

        keyDict['s'] = "\"select * from " + newDbName + ".ctb1\""
P
plum-lihui 已提交
287
        retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '')
P
plum-lihui 已提交
288 289
        if retCode != "TAOS_OK":
            tdLog.exit("taos -r show fail")
G
Ganlin Zhao 已提交
290

P
plum-lihui 已提交
291
        tdSql.query('drop database %s'%newDbName)
G
Ganlin Zhao 已提交
292

P
plum-lihui 已提交
293 294 295 296
        tdLog.printNoPrefix("================================ parameter: -f")
        pwd=os.getcwd()
        newDbName="dbf"
        sqlFile = pwd + "/0-others/sql.txt"
wafwerar's avatar
wafwerar 已提交
297 298
        sql1 = "echo create database " + newDbName + " > " + sqlFile
        sql2 = "echo use " + newDbName + " >> " + sqlFile
wafwerar's avatar
wafwerar 已提交
299 300
        if platform.system().lower() == 'windows':
            sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile
G
Ganlin Zhao 已提交
301
            sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile
wafwerar's avatar
wafwerar 已提交
302
        else:
wafwerar's avatar
wafwerar 已提交
303
            sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile
G
Ganlin Zhao 已提交
304
            sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile
X
Xiaoyu Wang 已提交
305
        sql5 = "echo show databases >> " + sqlFile
G
Ganlin Zhao 已提交
306 307 308 309
        os.system(sql1)
        os.system(sql2)
        os.system(sql3)
        os.system(sql4)
P
plum-lihui 已提交
310 311 312
        os.system(sql5)

        keyDict['f'] = pwd + "/0-others/sql.txt"
P
plum-lihui 已提交
313
        retCode = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '')
P
plum-lihui 已提交
314 315
        print("============ ret code: ", retCode)
        if retCode != "TAOS_OK":
P
plum-lihui 已提交
316
            tdLog.exit("taos -f fail")
P
plum-lihui 已提交
317 318

        print ("========== check new db ==========")
X
Xiaoyu Wang 已提交
319
        tdSql.query("select * from information_schema.ins_databases")
P
plum-lihui 已提交
320 321 322 323 324 325
        for i in range(tdSql.queryRows):
            #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0)))
            if tdSql.getData(i, 0) == newDbName:
                break
        else:
            tdLog.exit("create db fail after taos -f fail")
326

G
Ganlin Zhao 已提交
327
        sqlString = "select * from " + newDbName + ".ntbf"
P
plum-lihui 已提交
328 329 330 331 332
        tdSql.query(sqlString)
        tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
        tdSql.checkData(0, 1, 'test taos -f1')
        tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
        tdSql.checkData(1, 1, 'test taos -f2')
G
Ganlin Zhao 已提交
333

P
plum-lihui 已提交
334 335 336 337 338
        shellCmd = "rm -f " + sqlFile
        os.system(shellCmd)
        tdSql.query('drop database %s'%newDbName)

        tdLog.printNoPrefix("================================ parameter: -C")
339
        #newDbName="dbcc"
P
plum-lihui 已提交
340
        retCode, retVal = taos_command(buildPath, "C", keyDict['C'], "buildinfo", keyDict['c'], '', '', '')
P
plum-lihui 已提交
341 342
        if retCode != "TAOS_OK":
            tdLog.exit("taos -C fail")
343

344

345
        #print ("-C return content:\n ", retVal)
346 347
        totalCfgItem = {"firstEp":['', '', ''], }
        for line in retVal.splitlines():
G
Ganlin Zhao 已提交
348
            strList = line.split()
349
            if (len(strList) > 2):
G
Ganlin Zhao 已提交
350
                totalCfgItem[strList[1]] = strList
351 352 353 354 355 356 357 358

        #print ("dict content:\n ", totalCfgItem)
        firstEp = keyDict["h"] + ':' + keyDict['P']
        if (totalCfgItem["firstEp"][2] != firstEp) and (totalCfgItem["firstEp"][0] != 'cfg_file'):
            tdLog.exit("taos -C return firstEp error!")

        if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'):
            tdLog.exit("taos -C return rpcDebugFlag error!")
G
Ganlin Zhao 已提交
359 360

        count = os.cpu_count()
361 362
        if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'):
            tdLog.exit("taos -C return numOfCores error!")
363

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
        version = totalCfgItem["version"][2]

        tdLog.printNoPrefix("================================ parameter: -V")
        #newDbName="dbvv"
        retCode, retVal = taos_command(buildPath, "V", keyDict['V'], "", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -V fail")

        version = 'version: ' + version
        retVal = retVal.replace("\n", "")
        retVal = retVal.replace("\r", "")
        if retVal != version:
            print ("return version: [%s]"%retVal)
            print ("dict version: [%s]"%version)
            tdLog.exit("taos -V version not match")

        tdLog.printNoPrefix("================================ parameter: -d")
        newDbName="dbd"
        sqlString = 'create database ' + newDbName + ';'
        retCode = taos_command(buildPath, "d", keyDict['d'], "taos>", keyDict['c'], sqlString, '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -d %s fail"%(keyDict['d']))
        else:
X
Xiaoyu Wang 已提交
387
            tdSql.query("select * from information_schema.ins_databases")
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
            for i in range(tdSql.queryRows):
                if tdSql.getData(i, 0) == newDbName:
                    break
            else:
                tdLog.exit("create db fail after taos -d %s fail"%(keyDict['d']))

            tdSql.query('drop database %s'%newDbName)

        retCode = taos_command(buildPath, "d", 'dbno', "taos>", keyDict['c'], sqlString, '', '')
        if retCode != "TAOS_FAIL":
            tdLog.exit("taos -d dbno fail")

        tdLog.printNoPrefix("================================ parameter: -w")
        newDbName="dbw"
        keyDict['s'] = "\"create database " + newDbName + "\""
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w fail")

        keyDict['s'] = "\"create table " + newDbName + ".ntb (ts timestamp, c binary(128))\""
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w create table fail")

        keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.001', 'abcd0123456789')('2021-04-01 08:00:00.002', 'abcd012345678901234567890123456789') \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w insert data fail")

        keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.003', 'aaaaaaaaaaaaaaaaaaaa')('2021-04-01 08:00:01.004', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w insert data fail")

        keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.005', 'cccccccccccccccccccc')('2021-04-01 08:00:01.006', 'dddddddddddddddddddddddddddddddddddddddd') \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w insert data fail")

        keyDict['s'] = "\"select * from " + newDbName + ".ntb \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "aaaaaaaaaaaaaaaaaaaa", keyDict['c'], '', '', '')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w insert data fail")

        keyDict['s'] = "\"select * from " + newDbName + ".ntb \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', '', '')
        if retCode != "TAOS_FAIL":
            tdLog.exit("taos -w insert data fail")

        keyDict['s'] = "\"select * from " + newDbName + ".ntb \""
        retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', 'w', '60')
        if retCode != "TAOS_OK":
            tdLog.exit("taos -w insert data fail")

        tdSql.query('drop database %s'%newDbName)

444 445 446 447 448 449
    def stop(self):
        tdSql.close()
        tdLog.success(f"{__file__} successfully executed")

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