sml.py 3.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

import taos
import sys
import time
import socket
import os
import threading

from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
from util.common import *
sys.path.append("./7-tmq")
from tmqCommon import *

class TDTestCase:
    def init(self, conn, logSql):
        tdLog.debug(f"start to excute {__file__}")
        tdSql.init(conn.cursor())
        #tdSql.init(conn.cursor(), logSql)  # output sql.txt file

C
cpwu 已提交
23
    def checkFileContent(self, dbname="sml_db"):
24 25 26 27 28 29 30
        buildPath = tdCom.getBuildPath()
        cmdStr = '%s/build/bin/sml_test'%(buildPath)
        tdLog.info(cmdStr)
        ret = os.system(cmdStr)
        if ret != 0:
            tdLog.exit("sml_test failed")

C
cpwu 已提交
31 32
        # tdSql.execute('use sml_db')
        tdSql.query(f"select * from {dbname}.t_b7d815c9222ca64cdf2614c61de8f211")
33 34 35 36 37 38 39 40 41 42 43 44 45 46
        tdSql.checkRows(1)

        tdSql.checkData(0, 0, '2016-01-01 08:00:07.000')
        tdSql.checkData(0, 1, 2000)
        tdSql.checkData(0, 2, 200)
        tdSql.checkData(0, 3, 15)
        tdSql.checkData(0, 4, 24.5208)
        tdSql.checkData(0, 5, 28.09377)
        tdSql.checkData(0, 6, 428)
        tdSql.checkData(0, 7, 0)
        tdSql.checkData(0, 8, 304)
        tdSql.checkData(0, 9, 0)
        tdSql.checkData(0, 10, 25)

C
cpwu 已提交
47
        tdSql.query(f"select * from {dbname}.readings")
48 49
        tdSql.checkRows(9)

C
cpwu 已提交
50
        tdSql.query(f"select distinct tbname from {dbname}.readings")
51 52
        tdSql.checkRows(4)

C
cpwu 已提交
53
        tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
54 55
        tdSql.checkRows(2)
        tdSql.checkData(0, 3, "kk")
wmmhello's avatar
wmmhello 已提交
56
        tdSql.checkData(1, 3, "")
57 58


C
cpwu 已提交
59
        tdSql.query(f"select distinct tbname from {dbname}.`sys.if.bytes.out`")
60 61
        tdSql.checkRows(2)

C
cpwu 已提交
62
        tdSql.query(f"select * from {dbname}.t_fc70dec6677d4277c5d9799c4da806da order by _ts")
63 64 65 66
        tdSql.checkRows(2)
        tdSql.checkData(0, 1, 1.300000000)
        tdSql.checkData(1, 1,13.000000000)

C
cpwu 已提交
67
        tdSql.query(f"select * from {dbname}.`sys.procs.running`")
68 69 70 71
        tdSql.checkRows(1)
        tdSql.checkData(0, 1, 42.000000000)
        tdSql.checkData(0, 2, "web01")

C
cpwu 已提交
72
        tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`")
73 74
        tdSql.checkRows(2)

C
cpwu 已提交
75
        tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts")
76 77 78 79 80 81 82 83 84 85
        tdSql.checkRows(2)
        tdSql.checkData(0, 1, 9.000000000)
        tdSql.checkData(0, 2, "lga")
        tdSql.checkData(0, 3, "web02")
        tdSql.checkData(0, 4, None)
        tdSql.checkData(1, 1, 18.000000000)
        tdSql.checkData(1, 2, "lga")
        tdSql.checkData(1, 3, "web01")
        tdSql.checkData(1, 4, "t1")

C
cpwu 已提交
86
        tdSql.query(f"select * from {dbname}.macylr")
wmmhello's avatar
wmmhello 已提交
87
        tdSql.checkRows(2)
wmmhello's avatar
wmmhello 已提交
88

C
cpwu 已提交
89
        tdSql.query(f"desc {dbname}.macylr")
wmmhello's avatar
wmmhello 已提交
90
        tdSql.checkRows(25)
91 92 93 94 95 96 97 98 99 100 101 102 103
        return

    def run(self):
        tdSql.prepare()
        self.checkFileContent()

    def stop(self):
        tdSql.close()
        tdLog.success(f"{__file__} successfully executed")


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