default_json.py 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
###################################################################
#           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
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *


class TDTestCase:
    def caseDescription(self):
22
        """
23
        [TD-11510] taosBenchmark test cases
24
        """
25 26 27 28 29

    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor(), logSql)

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

33 34
        if "community" in selfPath:
            projPath = selfPath[: selfPath.find("community")]
35
        else:
36
            projPath = selfPath[: selfPath.find("tests")]
37 38 39

        paths = []
        for root, dirs, files in os.walk(projPath):
40
            if (tool) in files:
41
                rootRealPath = os.path.dirname(os.path.realpath(root))
42
                if "packaging" not in rootRealPath:
43 44
                    paths.append(os.path.join(root, tool))
                    break
45
        if len(paths) == 0:
46 47 48 49 50 51
            tdLog.exit("taosBenchmark not found!")
            return
        else:
            tdLog.info("taosBenchmark found in %s" % paths[0])
            return paths[0]

52
    def run(self):
53
        binPath = self.getPath()
54
        cmd = "%s -f ./5-taos-tools/taosbenchmark/json/default.json" % binPath
55 56 57 58 59 60
        tdLog.info("%s" % cmd)
        os.system("%s" % cmd)
        tdSql.execute("reset query cache")
        tdSql.query("select count(tbname) from db.stb")
        tdSql.checkData(0, 0, 10)
        tdSql.query("select count(*) from db.stb")
61 62
        if len(tdSql.queryResult):
            tdLog.exit("query result is %d" % len(tdSql.queryResult))
63 64 65 66 67 68 69

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


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