sml.py 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

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:
18
    def init(self, conn, logSql, replicaVar=1):
19
        self.replicaVar = int(replicaVar)
20
        tdLog.debug(f"start to excute {__file__}")
H
Haojun Liao 已提交
21
        tdSql.init(conn.cursor(), True)
22 23
        #tdSql.init(conn.cursor(), logSql)  # output sql.txt file

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

C
cpwu 已提交
32 33
        # tdSql.execute('use sml_db')
        tdSql.query(f"select * from {dbname}.t_b7d815c9222ca64cdf2614c61de8f211")
34 35 36 37 38 39 40 41 42 43 44 45 46 47
        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 已提交
48
        tdSql.query(f"select * from {dbname}.readings")
49 50
        tdSql.checkRows(9)

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

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


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

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

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

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

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

83
        tdSql.checkData(1, 1, 18.000000000)
wmmhello's avatar
wmmhello 已提交
84 85 86
        tdSql.checkData(1, 2, "web01")
        tdSql.checkData(1, 3, "t1")
        tdSql.checkData(0, 4, "lga")
87

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

C
cpwu 已提交
91
        tdSql.query(f"desc {dbname}.macylr")
wmmhello's avatar
wmmhello 已提交
92
        tdSql.checkRows(25)
93 94 95 96 97 98 99 100 101 102 103 104 105
        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())