test.py 21.1 KB
Newer Older
Y
Yang Zhao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/python
###################################################################
#           Copyright (c) 2016 by TAOS Technologies, Inc.
#                     All rights reserved.
#
#  This file is proprietary and confidential to TAOS Technologies.
#  No part of this file may be reproduced, stored, transmitted,
#  disclosed or used in any form or by any means other than as
#  expressly provided by the written permission from Jianhui Tao
#
###################################################################
# install pip
# pip install src/connector/python/

# -*- coding: utf-8 -*-
import sys
import getopt
import subprocess
import time
import base64
import json
import platform
import socket
import threading

import toml
27

Y
Yang Zhao 已提交
28 29 30 31 32 33 34 35 36 37
sys.path.append("../pytest")
from util.log import *
from util.dnodes import *
from util.cases import *
from util.cluster import *
from util.taosadapter import *

import taos
import taosrest

38

Y
Yang Zhao 已提交
39 40
def checkRunTimeError():
    import win32gui
41

Y
Yang Zhao 已提交
42 43 44 45
    timeCount = 0
    while 1:
        time.sleep(1)
        timeCount = timeCount + 1
46 47
        print("checkRunTimeError", timeCount)
        if timeCount > 600:
Y
Yang Zhao 已提交
48 49 50 51 52 53 54 55 56 57 58
            print("stop the test.")
            os.system("TASKKILL /F /IM taosd.exe")
            os.system("TASKKILL /F /IM taos.exe")
            os.system("TASKKILL /F /IM tmq_sim.exe")
            os.system("TASKKILL /F /IM mintty.exe")
            os.system("TASKKILL /F /IM python.exe")
            quit(0)
        hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library")
        if hwnd:
            os.system("TASKKILL /F /IM taosd.exe")

59

Y
Yang Zhao 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
if __name__ == "__main__":

    fileName = "all"
    deployPath = ""
    masterIp = ""
    testCluster = False
    valgrind = 0
    killValgrind = 1
    logSql = True
    stop = 0
    restart = False
    dnodeNums = 1
    mnodeNums = 0
    updateCfgDict = {}
    adapter_cfg_dict = {}
    execCmd = ""
    queryPolicy = 1
    createDnodeNums = 1
    restful = False
79
    replicaVar = 1
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
    opts, args = getopt.gnu_getopt(
        sys.argv[1:],
        "f:p:m:l:scghrd:k:e:N:M:Q:C:RD:n:",
        [
            "file=",
            "path=",
            "master",
            "logSql",
            "stop",
            "cluster",
            "valgrind",
            "help",
            "restart",
            "updateCfgDict",
            "killv",
            "execCmd",
            "dnodeNums",
            "mnodeNums",
            "queryPolicy",
            "createDnodeNums",
            "restful",
            "adaptercfgupdate",
            "replicaVar",
        ],
    )
Y
Yang Zhao 已提交
105
    for key, value in opts:
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
        if key in ["-h", "--help"]:
            tdLog.printNoPrefix("A collection of test cases written using Python")
            tdLog.printNoPrefix("-f Name of test case file written by Python")
            tdLog.printNoPrefix("-p Deploy Path for Simulator")
            tdLog.printNoPrefix("-m Master Ip for Simulator")
            tdLog.printNoPrefix("-l <True:False> logSql Flag")
            tdLog.printNoPrefix("-s stop All dnodes")
            tdLog.printNoPrefix("-c Test Cluster Flag")
            tdLog.printNoPrefix("-g valgrind Test Flag")
            tdLog.printNoPrefix("-r taosd restart test")
            tdLog.printNoPrefix("-d update cfg dict, base64 json str")
            tdLog.printNoPrefix("-k not kill valgrind processer")
            tdLog.printNoPrefix("-e eval str to run")
            tdLog.printNoPrefix("-N start dnodes numbers in clusters")
            tdLog.printNoPrefix("-M create mnode numbers in clusters")
            tdLog.printNoPrefix("-Q set queryPolicy in one dnode")
            tdLog.printNoPrefix("-C create Dnode Numbers in one cluster")
            tdLog.printNoPrefix("-R restful realization form")
            tdLog.printNoPrefix("-D taosadapter update cfg dict ")
            tdLog.printNoPrefix("-n the number of replicas")
Y
Yang Zhao 已提交
126 127
            sys.exit(0)

128
        if key in ["-r", "--restart"]:
Y
Yang Zhao 已提交
129 130
            restart = True

131
        if key in ["-f", "--file"]:
Y
Yang Zhao 已提交
132 133
            fileName = value

134
        if key in ["-p", "--path"]:
Y
Yang Zhao 已提交
135 136
            deployPath = value

137
        if key in ["-m", "--master"]:
Y
Yang Zhao 已提交
138 139
            masterIp = value

140 141
        if key in ["-l", "--logSql"]:
            if value.upper() == "TRUE":
Y
Yang Zhao 已提交
142
                logSql = True
143
            elif value.upper() == "FALSE":
Y
Yang Zhao 已提交
144 145 146 147 148
                logSql = False
            else:
                tdLog.printNoPrefix("logSql value %s is invalid" % logSql)
                sys.exit(0)

149
        if key in ["-c", "--cluster"]:
Y
Yang Zhao 已提交
150 151
            testCluster = True

152
        if key in ["-g", "--valgrind"]:
Y
Yang Zhao 已提交
153 154
            valgrind = 1

155
        if key in ["-s", "--stop"]:
Y
Yang Zhao 已提交
156 157
            stop = 1

158
        if key in ["-d", "--updateCfgDict"]:
Y
Yang Zhao 已提交
159 160 161
            try:
                updateCfgDict = eval(base64.b64decode(value.encode()).decode())
            except:
162
                print("updateCfgDict convert fail.")
Y
Yang Zhao 已提交
163 164
                sys.exit(0)

165
        if key in ["-k", "--killValgrind"]:
Y
Yang Zhao 已提交
166 167
            killValgrind = 0

168
        if key in ["-e", "--execCmd"]:
Y
Yang Zhao 已提交
169 170 171
            try:
                execCmd = base64.b64decode(value.encode()).decode()
            except:
172
                print("execCmd run fail.")
Y
Yang Zhao 已提交
173 174
                sys.exit(0)

175
        if key in ["-N", "--dnodeNums"]:
Y
Yang Zhao 已提交
176 177
            dnodeNums = value

178
        if key in ["-M", "--mnodeNums"]:
Y
Yang Zhao 已提交
179 180
            mnodeNums = value

181
        if key in ["-Q", "--queryPolicy"]:
Y
Yang Zhao 已提交
182 183
            queryPolicy = value

184
        if key in ["-C", "--createDnodeNums"]:
Y
Yang Zhao 已提交
185 186
            createDnodeNums = value

187
        if key in ["-R", "--restful"]:
Y
Yang Zhao 已提交
188 189
            restful = True

190
        if key in ["-D", "--adaptercfgupdate"]:
Y
Yang Zhao 已提交
191 192 193
            try:
                adaptercfgupdate = eval(base64.b64decode(value.encode()).decode())
            except:
194
                print("adapter cfg update convert fail.")
Y
Yang Zhao 已提交
195 196
                sys.exit(0)

197
        if key in ["-n", "--replicaVar"]:
198 199
            replicaVar = value

Y
Yang Zhao 已提交
200 201 202 203 204 205 206 207 208
    if not execCmd == "":
        if restful:
            tAdapter.init(deployPath)
        else:
            tdDnodes.init(deployPath)
        print(execCmd)
        exec(execCmd)
        quit()

209 210
    if stop != 0:
        if valgrind == 0:
Y
Yang Zhao 已提交
211 212 213 214
            toBeKilled = "taosd"
        else:
            toBeKilled = "valgrind.bin"

215 216 217 218
        killCmd = (
            "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1"
            % toBeKilled
        )
Y
Yang Zhao 已提交
219 220 221 222

        psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
        processID = subprocess.check_output(psCmd, shell=True)

223
        while processID:
Y
Yang Zhao 已提交
224 225 226 227 228
            os.system(killCmd)
            time.sleep(1)
            processID = subprocess.check_output(psCmd, shell=True)

        for port in range(6030, 6041):
229
            usePortPID = "lsof -i tcp:%d | grep LISTEN | awk '{print $2}'" % port
Y
Yang Zhao 已提交
230 231 232 233 234 235 236 237 238 239 240
            processID = subprocess.check_output(usePortPID, shell=True)

            if processID:
                killCmd = "kill -TERM %s" % processID
                os.system(killCmd)
            fuserCmd = "fuser -k -n tcp %d" % port
            os.system(fuserCmd)
        if valgrind:
            time.sleep(2)

        if restful:
sangshuduo's avatar
sangshuduo 已提交
241
            toBeKilled = "taosadapter"
Y
Yang Zhao 已提交
242

243 244
            # killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -TERM > /dev/null 2>&1" % toBeKilled
            killCmd = f"pkill {toBeKilled}"
Y
Yang Zhao 已提交
245 246

            psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
247
            # psCmd = f"pgrep {toBeKilled}"
Y
Yang Zhao 已提交
248 249
            processID = subprocess.check_output(psCmd, shell=True)

250
            while processID:
Y
Yang Zhao 已提交
251 252 253 254
                os.system(killCmd)
                time.sleep(1)
                processID = subprocess.check_output(psCmd, shell=True)

255 256 257
            port = 6041
            usePortPID = f"lsof -i tcp:{port} | grep LISTEN | awk '{{print $2}}'"
            processID = subprocess.check_output(usePortPID, shell=True)
Y
Yang Zhao 已提交
258

259 260 261 262 263
            if processID:
                killCmd = f"kill -TERM {processID}"
                os.system(killCmd)
            fuserCmd = f"fuser -k -n tcp {port}"
            os.system(fuserCmd)
Y
Yang Zhao 已提交
264

265
            tdLog.info("stop taosadapter")
Y
Yang Zhao 已提交
266

267
        tdLog.info("stop All dnodes")
Y
Yang Zhao 已提交
268 269 270 271 272 273 274 275 276 277 278

    if masterIp == "":
        host = socket.gethostname()
    else:
        try:
            config = eval(masterIp)
            host = config["host"]
        except Exception as r:
            host = masterIp

    tdLog.info("Procedures for tdengine deployed in %s" % (host))
279
    if platform.system().lower() == "windows":
Y
Yang Zhao 已提交
280
        fileName = fileName.replace("/", os.sep)
281 282
        if masterIp == "" and not fileName == "0-others\\udf_create.py":
            threading.Thread(target=checkRunTimeError, daemon=True).start()
Y
Yang Zhao 已提交
283 284 285 286 287
        tdLog.info("Procedures for testing self-deployment")
        tdDnodes.init(deployPath, masterIp)
        tdDnodes.setTestCluster(testCluster)
        tdDnodes.setValgrind(valgrind)
        tdDnodes.stopAll()
288
        key_word = "tdCases.addWindows"
Y
Yang Zhao 已提交
289 290
        is_test_framework = 0
        try:
291
            if key_word in open(fileName, encoding="UTF-8").read():
Y
Yang Zhao 已提交
292 293 294
                is_test_framework = 1
        except Exception as r:
            print(r)
295
        updateCfgDictStr = ""
Y
Yang Zhao 已提交
296 297 298 299 300 301
        # adapter_cfg_dict_str = ''
        if is_test_framework:
            moduleName = fileName.replace(".py", "").replace(os.sep, ".")
            uModule = importlib.import_module(moduleName)
            try:
                ucase = uModule.TDTestCase()
302 303 304
                if (json.dumps(updateCfgDict) == "{}") and hasattr(
                    ucase, "updatecfgDict"
                ):
Y
Yang Zhao 已提交
305
                    updateCfgDict = ucase.updatecfgDict
306 307 308 309 310 311 312
                    updateCfgDictStr = (
                        "-d %s"
                        % base64.b64encode(json.dumps(updateCfgDict).encode()).decode()
                    )
                if (json.dumps(adapter_cfg_dict) == "{}") and hasattr(
                    ucase, "taosadapter_cfg_dict"
                ):
Y
Yang Zhao 已提交
313 314 315 316 317 318 319 320 321 322
                    adapter_cfg_dict = ucase.taosadapter_cfg_dict
                    # adapter_cfg_dict_str = f"-D {base64.b64encode(toml.dumps(adapter_cfg_dict).encode()).decode()}"
            except Exception as r:
                print(r)
        else:
            pass
        if restful:
            tAdapter.init(deployPath, masterIp)
            tAdapter.stop(force_kill=True)

323 324
        if dnodeNums == 1:
            tdDnodes.deploy(1, updateCfgDict)
Y
Yang Zhao 已提交
325 326 327 328 329 330 331
            tdDnodes.start(1)
            tdCases.logSql(logSql)
            if restful:
                tAdapter.deploy(adapter_cfg_dict)
                tAdapter.start()

            if queryPolicy != 1:
332
                queryPolicy = int(queryPolicy)
Y
Yang Zhao 已提交
333 334 335
                if restful:
                    conn = taosrest.connect(url=f"http://{host}:6041")
                else:
336
                    conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
337 338 339 340 341 342 343

                cursor = conn.cursor()
                cursor.execute("create qnode on dnode 1")
                cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"')
                cursor.execute("show local variables")
                res = cursor.fetchall()
                for i in range(cursor.rowcount):
344
                    if res[i][0] == "queryPolicy":
Y
Yang Zhao 已提交
345
                        if int(res[i][1]) == int(queryPolicy):
H
Haojun Liao 已提交
346
                            tdLog.info(
347 348
                                f"alter queryPolicy to {queryPolicy} successfully"
                            )
Y
Yang Zhao 已提交
349 350 351
                        else:
                            tdLog.debug(res)
                            tdLog.exit(f"alter queryPolicy to  {queryPolicy} failed")
352 353 354 355 356 357 358 359
        else:
            tdLog.debug(
                "create an cluster  with %s nodes and make %s dnode as independent mnode"
                % (dnodeNums, mnodeNums)
            )
            dnodeslist = cluster.configure_cluster(
                dnodeNums=dnodeNums, mnodeNums=mnodeNums
            )
Y
Yang Zhao 已提交
360 361 362 363 364 365
            tdDnodes = ClusterDnodes(dnodeslist)
            tdDnodes.init(deployPath, masterIp)
            tdDnodes.setTestCluster(testCluster)
            tdDnodes.setValgrind(valgrind)
            tdDnodes.stopAll()
            for dnode in tdDnodes.dnodes:
366
                tdDnodes.deploy(dnode.index, {})
Y
Yang Zhao 已提交
367 368 369
            for dnode in tdDnodes.dnodes:
                tdDnodes.starttaosd(dnode.index)
            tdCases.logSql(logSql)
370

Y
Yang Zhao 已提交
371 372 373 374 375
            if restful:
                tAdapter.deploy(adapter_cfg_dict)
                tAdapter.start()

            if not restful:
376
                conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
377 378 379 380
            else:
                conn = taosrest.connect(url=f"http://{host}:6041")
            # tdLog.info(tdDnodes.getSimCfgPath(),host)
            if createDnodeNums == 1:
381
                createDnodeNums = dnodeNums
Y
Yang Zhao 已提交
382
            else:
383 384
                createDnodeNums = createDnodeNums
            cluster.create_dnode(conn, createDnodeNums)
Y
Yang Zhao 已提交
385
            try:
386
                if cluster.check_dnode(conn):
Y
Yang Zhao 已提交
387 388 389
                    print("check dnode ready")
            except Exception as r:
                print(r)
390
            if queryPolicy != 1:
391
                queryPolicy = int(queryPolicy)
392 393 394
                if restful:
                    conn = taosrest.connect(url=f"http://{host}:6041")
                else:
395
                    conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
396 397 398 399 400 401 402

                cursor = conn.cursor()
                cursor.execute("create qnode on dnode 1")
                cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"')
                cursor.execute("show local variables")
                res = cursor.fetchall()
                for i in range(cursor.rowcount):
403
                    if res[i][0] == "queryPolicy":
404
                        if int(res[i][1]) == int(queryPolicy):
H
Haojun Liao 已提交
405
                            tdLog.info(
406 407
                                f"alter queryPolicy to {queryPolicy} successfully"
                            )
408 409 410
                        else:
                            tdLog.debug(res)
                            tdLog.exit(f"alter queryPolicy to  {queryPolicy} failed")
411 412

        if ucase is not None and hasattr(ucase, "noConn") and ucase.noConn == True:
Y
Yang Zhao 已提交
413 414 415
            conn = None
        else:
            if not restful:
416
                conn = taos.connect(host="%s" % (host), config=tdDnodes.sim.getCfgDir())
Y
Yang Zhao 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429
            else:
                conn = taosrest.connect(url=f"http://{host}:6041")
        if is_test_framework:
            tdCases.runOneWindows(conn, fileName)
        else:
            tdCases.runAllWindows(conn)
    else:
        tdDnodes.setKillValgrind(killValgrind)
        tdDnodes.init(deployPath, masterIp)
        tdDnodes.setTestCluster(testCluster)
        tdDnodes.setValgrind(valgrind)
        tdDnodes.stopAll()
        is_test_framework = 0
430
        key_word = "tdCases.addLinux"
Y
Yang Zhao 已提交
431 432 433 434 435 436 437 438 439 440
        try:
            if key_word in open(fileName).read():
                is_test_framework = 1
        except:
            pass
        if is_test_framework:
            moduleName = fileName.replace(".py", "").replace("/", ".")
            uModule = importlib.import_module(moduleName)
            try:
                ucase = uModule.TDTestCase()
441
                if json.dumps(updateCfgDict) == "{}":
Y
Yang Zhao 已提交
442
                    updateCfgDict = ucase.updatecfgDict
443
                if json.dumps(adapter_cfg_dict) == "{}":
Y
Yang Zhao 已提交
444 445 446 447 448 449 450 451
                    adapter_cfg_dict = ucase.taosadapter_cfg_dict
            except:
                pass

        if restful:
            tAdapter.init(deployPath, masterIp)
            tAdapter.stop(force_kill=True)

452 453
        if dnodeNums == 1:
            tdDnodes.deploy(1, updateCfgDict)
Y
Yang Zhao 已提交
454 455 456 457 458 459 460 461
            tdDnodes.start(1)
            tdCases.logSql(logSql)

            if restful:
                tAdapter.deploy(adapter_cfg_dict)
                tAdapter.start()

            if queryPolicy != 1:
462
                queryPolicy = int(queryPolicy)
Y
Yang Zhao 已提交
463
                if not restful:
464
                    conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
465 466 467 468 469 470 471 472 473
                else:
                    conn = taosrest.connect(url=f"http://{host}:6041")
                # tdSql.init(conn.cursor())
                # tdSql.execute("create qnode on dnode 1")
                # tdSql.execute('alter local "queryPolicy" "%d"'%queryPolicy)
                # tdSql.query("show local variables;")
                # for i in range(tdSql.queryRows):
                #     if tdSql.queryResult[i][0] == "queryPolicy" :
                #         if int(tdSql.queryResult[i][1]) == int(queryPolicy):
H
Haojun Liao 已提交
474
                #             tdLog.info('alter queryPolicy to %d successfully'%queryPolicy)
Y
Yang Zhao 已提交
475 476 477 478 479 480 481 482 483 484
                #         else :
                #             tdLog.debug(tdSql.queryResult)
                #             tdLog.exit("alter queryPolicy to  %d failed"%queryPolicy)

                cursor = conn.cursor()
                cursor.execute("create qnode on dnode 1")
                cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"')
                cursor.execute("show local variables")
                res = cursor.fetchall()
                for i in range(cursor.rowcount):
485
                    if res[i][0] == "queryPolicy":
Y
Yang Zhao 已提交
486
                        if int(res[i][1]) == int(queryPolicy):
H
Haojun Liao 已提交
487
                            tdLog.info(
488 489
                                f"alter queryPolicy to {queryPolicy} successfully"
                            )
Y
Yang Zhao 已提交
490 491 492 493
                        else:
                            tdLog.debug(res)
                            tdLog.exit(f"alter queryPolicy to  {queryPolicy} failed")

494 495 496 497 498 499 500 501
        else:
            tdLog.debug(
                "create an cluster  with %s nodes and make %s dnode as independent mnode"
                % (dnodeNums, mnodeNums)
            )
            dnodeslist = cluster.configure_cluster(
                dnodeNums=dnodeNums, mnodeNums=mnodeNums
            )
Y
Yang Zhao 已提交
502 503 504 505 506 507
            tdDnodes = ClusterDnodes(dnodeslist)
            tdDnodes.init(deployPath, masterIp)
            tdDnodes.setTestCluster(testCluster)
            tdDnodes.setValgrind(valgrind)
            tdDnodes.stopAll()
            for dnode in tdDnodes.dnodes:
508
                tdDnodes.deploy(dnode.index, {})
Y
Yang Zhao 已提交
509 510 511 512 513 514 515 516 517
            for dnode in tdDnodes.dnodes:
                tdDnodes.starttaosd(dnode.index)
            tdCases.logSql(logSql)

            if restful:
                tAdapter.deploy(adapter_cfg_dict)
                tAdapter.start()

            if not restful:
518
                conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
519 520
            else:
                conn = taosrest.connect(url=f"http://{host}:6041")
521
            print(tdDnodes.getSimCfgPath(), host)
Y
Yang Zhao 已提交
522
            if createDnodeNums == 1:
523
                createDnodeNums = dnodeNums
Y
Yang Zhao 已提交
524
            else:
525 526
                createDnodeNums = createDnodeNums
            cluster.create_dnode(conn, createDnodeNums)
Y
Yang Zhao 已提交
527
            try:
528
                if cluster.check_dnode(conn):
Y
Yang Zhao 已提交
529 530 531 532
                    print("check dnode ready")
            except Exception as r:
                print(r)

533
            if queryPolicy != 1:
534
                queryPolicy = int(queryPolicy)
535 536 537
                if restful:
                    conn = taosrest.connect(url=f"http://{host}:6041")
                else:
538
                    conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
539 540 541 542 543 544 545

                cursor = conn.cursor()
                cursor.execute("create qnode on dnode 1")
                cursor.execute(f'alter local "queryPolicy" "{queryPolicy}"')
                cursor.execute("show local variables")
                res = cursor.fetchall()
                for i in range(cursor.rowcount):
546
                    if res[i][0] == "queryPolicy":
547
                        if int(res[i][1]) == int(queryPolicy):
H
Haojun Liao 已提交
548
                            tdLog.info(
549 550
                                f"alter queryPolicy to {queryPolicy} successfully"
                            )
551 552 553
                        else:
                            tdLog.debug(res)
                            tdLog.exit(f"alter queryPolicy to  {queryPolicy} failed")
Y
Yang Zhao 已提交
554 555 556 557 558 559 560 561 562 563

        if testCluster:
            tdLog.info("Procedures for testing cluster")
            if fileName == "all":
                tdCases.runAllCluster()
            else:
                tdCases.runOneCluster(fileName)
        else:
            tdLog.info("Procedures for testing self-deployment")
            if not restful:
564
                conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
565 566 567 568 569 570
            else:
                conn = taosrest.connect(url=f"http://{host}:6041")

            if fileName == "all":
                tdCases.runAllLinux(conn)
            else:
571
                tdCases.runOneLinux(conn, fileName, replicaVar)
Y
Yang Zhao 已提交
572 573 574 575 576 577 578 579 580 581 582

        if restart:
            if fileName == "all":
                tdLog.info("not need to query ")
            else:
                sp = fileName.rsplit(".", 1)
                if len(sp) == 2 and sp[1] == "py":
                    tdDnodes.stopAll()
                    tdDnodes.start(1)
                    time.sleep(1)
                    if not restful:
583
                        conn = taos.connect(host, config=tdDnodes.getSimCfgPath())
Y
Yang Zhao 已提交
584 585 586 587
                    else:
                        conn = taosrest.connect(url=f"http://{host}:6041")
                    tdLog.info("Procedures for tdengine deployed in %s" % (host))
                    tdLog.info("query test after taosd restart")
588
                    tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py", replicaVar)
Y
Yang Zhao 已提交
589 590 591 592 593 594
                else:
                    tdLog.info("not need to query")

    if conn is not None:
        conn.close()
    sys.exit(0)