telnet_tcp.py 3.3 KB
Newer Older
Y
Yang Zhao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
###################################################################
#           Copyright (c) 2016 by TAOS Technologies, Inc.
#                     All rights reserved.
#
#  This file is proprietary and confidential to TAOS Technologies.
#  No part of this file may be reproduced, stored, transmitted,
#  disclosed or used in any form or by any means other than as
#  expressly provided by the written permission from Jianhui Tao
#
###################################################################

# -*- coding: utf-8 -*-
import os
import time
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
sangshuduo's avatar
sangshuduo 已提交
19

Y
Yang Zhao 已提交
20 21 22

class TDTestCase:
    def caseDescription(self):
sangshuduo's avatar
sangshuduo 已提交
23
        """
Y
Yang Zhao 已提交
24
        [TD-11510] taosBenchmark test cases
sangshuduo's avatar
sangshuduo 已提交
25
        """
Y
Yang Zhao 已提交
26

27
    def init(self, conn, logSql, replicaVar=1):
Y
Yang Zhao 已提交
28 29 30 31 32 33
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)

    def getPath(self, tool="taosBenchmark"):
        selfPath = os.path.dirname(os.path.realpath(__file__))

sangshuduo's avatar
sangshuduo 已提交
34 35 36 37 38 39 40 41
        if "community" in selfPath:
            projPath = selfPath[: selfPath.find("community")]
        elif "src" in selfPath:
            projPath = selfPath[: selfPath.find("src")]
        elif "/tools/" in selfPath:
            projPath = selfPath[: selfPath.find("/tools/")]
        elif "/tests/" in selfPath:
            projPath = selfPath[: selfPath.find("/tests/")]
Y
Yang Zhao 已提交
42
        else:
sangshuduo's avatar
sangshuduo 已提交
43
            tdLog.exit("cannot found %s in path: %s, use system's" % (tool, selfPath))
Y
Yang Zhao 已提交
44 45 46

        paths = []
        for root, dirs, files in os.walk(projPath):
sangshuduo's avatar
sangshuduo 已提交
47
            if (tool) in files:
Y
Yang Zhao 已提交
48
                rootRealPath = os.path.dirname(os.path.realpath(root))
sangshuduo's avatar
sangshuduo 已提交
49
                if "packaging" not in rootRealPath:
Y
Yang Zhao 已提交
50 51
                    paths.append(os.path.join(root, tool))
                    break
sangshuduo's avatar
sangshuduo 已提交
52
        if len(paths) == 0:
Y
Yang Zhao 已提交
53 54 55 56 57 58 59 60
            tdLog.exit("taosBenchmark not found!")
            return
        else:
            tdLog.info("taosBenchmark found in %s" % paths[0])
            return paths[0]

    def run(self):
        binPath = self.getPath()
sangshuduo's avatar
sangshuduo 已提交
61
        cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json" % binPath
Y
Yang Zhao 已提交
62 63 64 65
        tdLog.info("%s" % cmd)
        os.system("%s" % cmd)
        time.sleep(5)
        tdSql.execute("reset query cache")
sangshuduo's avatar
sangshuduo 已提交
66 67 68 69 70 71 72 73 74
        tdSql.query("select client_version()")
        client_ver = "".join(tdSql.queryResult[0])
        major_ver = client_ver.split(".")[0]
        if major_ver == "3":
            tdSql.query(
                "select count(*) from (select distinct(tbname) from opentsdb_telnet.stb1)"
            )
        else:
            tdSql.query("select count(tbname) from opentsdb_telnet.stb1")
Y
Yang Zhao 已提交
75 76 77
        tdSql.checkData(0, 0, 8)
        tdSql.query("select count(*) from opentsdb_telnet.stb1")
        tdSql.checkData(0, 0, 160)
sangshuduo's avatar
sangshuduo 已提交
78 79 80 81 82 83
        if major_ver == "3":
            tdSql.query(
                "select count(*) from (select distinct(tbname) from opentsdb_telnet.stb2)"
            )
        else:
            tdSql.query("select count(tbname) from opentsdb_telnet.stb2")
Y
Yang Zhao 已提交
84 85 86 87 88 89 90 91 92 93 94
        tdSql.checkData(0, 0, 8)
        tdSql.query("select count(*) from opentsdb_telnet.stb2")
        tdSql.checkData(0, 0, 160)

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


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