sml.py 3.4 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:
wmmhello's avatar
wmmhello 已提交
18 19 20
    updatecfgDict = {'clientCfg': {'smlChildTableName': 'dataModelName', 'fqdn': 'localhost'}, 'fqdn': 'localhost'}
    print("===================: ", updatecfgDict)

21
    def init(self, conn, logSql, replicaVar=1):
22
        self.replicaVar = int(replicaVar)
23
        tdLog.debug(f"start to excute {__file__}")
H
Haojun Liao 已提交
24
        tdSql.init(conn.cursor(), True)
25 26
        #tdSql.init(conn.cursor(), logSql)  # output sql.txt file

C
cpwu 已提交
27
    def checkFileContent(self, dbname="sml_db"):
wmmhello's avatar
wmmhello 已提交
28
        simClientCfg="%s/taos.cfg"%tdDnodes.getSimCfgPath()
29
        buildPath = tdCom.getBuildPath()
wmmhello's avatar
wmmhello 已提交
30 31
        cmdStr = '%s/build/bin/sml_test %s'%(buildPath, simClientCfg)
        print("cmdStr:", cmdStr)
32 33 34
        tdLog.info(cmdStr)
        ret = os.system(cmdStr)
        if ret != 0:
S
Shengliang Guan 已提交
35
            tdLog.info("sml_test ret != 0")
36

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

C
cpwu 已提交
56
        tdSql.query(f"select distinct tbname from {dbname}.readings")
57 58
        tdSql.checkRows(4)

C
cpwu 已提交
59
        tdSql.query(f"select * from {dbname}.t_0799064f5487946e5d22164a822acfc8 order by _ts")
60 61
        tdSql.checkRows(2)
        tdSql.checkData(0, 3, "kk")
wmmhello's avatar
wmmhello 已提交
62
        tdSql.checkData(1, 3, "")
63 64


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

C
cpwu 已提交
68
        tdSql.query(f"select * from {dbname}.t_fc70dec6677d4277c5d9799c4da806da order by _ts")
69 70 71 72
        tdSql.checkRows(2)
        tdSql.checkData(0, 1, 1.300000000)
        tdSql.checkData(1, 1,13.000000000)

C
cpwu 已提交
73
        tdSql.query(f"select * from {dbname}.`sys.procs.running`")
74 75 76 77
        tdSql.checkRows(1)
        tdSql.checkData(0, 1, 42.000000000)
        tdSql.checkData(0, 2, "web01")

C
cpwu 已提交
78
        tdSql.query(f"select distinct tbname from {dbname}.`sys.cpu.nice`")
wmmhello's avatar
wmmhello 已提交
79
        tdSql.checkRows(3)
80

C
cpwu 已提交
81
        tdSql.query(f"select * from {dbname}.`sys.cpu.nice` order by _ts")
wmmhello's avatar
wmmhello 已提交
82 83 84
        tdSql.checkRows(4)
        tdSql.checkData(0, 1, 13.000000000)
        tdSql.checkData(0, 2, "web01")
wmmhello's avatar
wmmhello 已提交
85 86 87
        tdSql.checkData(0, 3, None)
        tdSql.checkData(0, 4, "lga")

wmmhello's avatar
wmmhello 已提交
88 89 90
        tdSql.checkData(1, 1, 9.000000000)
        tdSql.checkData(1, 2, "web02")
        tdSql.checkData(3, 3, "t1")
wmmhello's avatar
wmmhello 已提交
91
        tdSql.checkData(0, 4, "lga")
92

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

wmmhello's avatar
wmmhello 已提交
96 97 98
        tdSql.query(f"select * from {dbname}.qelhxo")
        tdSql.checkRows(5)

C
cpwu 已提交
99
        tdSql.query(f"desc {dbname}.macylr")
wmmhello's avatar
wmmhello 已提交
100
        tdSql.checkRows(25)
101 102 103 104 105 106 107 108 109 110 111 112 113
        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())