tsbsQuery.py 17.3 KB
Newer Older
haoranc's avatar
haoranc 已提交
1
# from asyncio.windows_events import NULL
haoranc's avatar
haoranc 已提交
2 3 4 5
import taos
import sys
import datetime
import inspect
haoranc's avatar
haoranc 已提交
6
import random
haoranc's avatar
haoranc 已提交
7 8
from util.dnodes import TDDnode
from util.dnodes import tdDnodes
haoranc's avatar
haoranc 已提交
9 10 11 12 13 14

from util.log import *
from util.sql import *
from util.cases import *

class TDTestCase:
haoranc's avatar
haoranc 已提交
15 16

    clientCfgDict = {'queryproxy': '1','debugFlag': 135}
haoranc's avatar
haoranc 已提交
17
    clientCfgDict["debugFlag"] = 131
haoranc's avatar
haoranc 已提交
18
    updatecfgDict = {'clientCfg': {}}
haoranc's avatar
haoranc 已提交
19
    updatecfgDict = {'debugFlag': 131}
haoranc's avatar
haoranc 已提交
20
    updatecfgDict = {'keepColumnName': 1}
haoranc's avatar
haoranc 已提交
21 22
    updatecfgDict["clientCfg"]  = clientCfgDict

haoranc's avatar
haoranc 已提交
23 24 25 26
    def init(self, conn, logSql):
        tdLog.debug(f"start to excute {__file__}")
        tdSql.init(conn.cursor(), True)

haoranc's avatar
haoranc 已提交
27
    def create_ctable(self,tsql=None, dbName='db',stbName='stb',ctbPrefix='ctb',ctbNum=1):
haoranc's avatar
haoranc 已提交
28 29 30 31 32 33 34
            tsql.execute("use %s" %dbName)
            pre_create = "create table"
            sql = pre_create
            #tdLog.debug("doing create one  stable %s and %d  child table in %s  ..." %(stbname, count ,dbname))
            for i in range(ctbNum):
                tagValue = 'beijing'
                if (i % 10 == 0):
haoranc's avatar
haoranc 已提交
35
                    sql += " %s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption)  tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i))
haoranc's avatar
haoranc 已提交
36 37
                else:
                    model = 'H-%d'%i
haoranc's avatar
haoranc 已提交
38
                    sql += " %s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i))
haoranc's avatar
haoranc 已提交
39 40 41 42 43 44 45 46 47
                if (i > 0) and (i%1000 == 0):
                    tsql.execute(sql)
                    sql = pre_create
            if sql != pre_create:
                tsql.execute(sql)
            
            tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
            return

haoranc's avatar
haoranc 已提交
48 49 50 51 52 53 54 55 56 57 58 59
    def insertData(self,startTs,tsql=None, dbName='db',stbName='stb',ctbPrefix='ctb',ctbNum=1,rowsPerTbl=100,batchNum=1000):
            tsql.execute("use %s" %dbName)
            pre_insert = "insert into "
            sql = pre_insert
            if startTs is None:
                t = time.time()
                startTs = int(round(t * 1000))

            for i in range(ctbNum):
                sql += " %s%d values "%(ctbPrefix,i)
                for j in range(rowsPerTbl):
                    if(ctbPrefix=="rct"):
haoranc's avatar
haoranc 已提交
60
                        sql += f"({startTs+j*60000}, {80+j}, {90+j}, {85+j}, {30+j*10}, {1.2*j}, {221+j*2}, {20+j*0.2}) "
haoranc's avatar
haoranc 已提交
61 62
                    elif ( ctbPrefix=="dct"):
                        status= random.randint(0,1)
haoranc's avatar
haoranc 已提交
63
                        sql += f"( {startTs+j*60000}, {1+j*0.1},{1400+j*15},  {status} ) "   
haoranc's avatar
haoranc 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77
                    # tdLog.debug("1insert sql:%s"%sql)
                    if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
                        # tdLog.debug("2insert sql:%s"%sql)
                        tsql.execute(sql)
                        if j < rowsPerTbl - 1:
                            sql = "insert into %s%d values " %(ctbPrefix,i)
                        else:
                            sql = "insert into "
            if sql != pre_insert:
                # tdLog.debug("3insert sql:%s"%sql)
                tsql.execute(sql) 
            tdLog.debug("insert data ............ [OK]")
            return

haoranc's avatar
haoranc 已提交
78
    def prepareData(self):
haoranc's avatar
haoranc 已提交
79 80 81 82 83
        dbname="db_tsbs"
        stabname1="readings"
        stabname2="diagnostics"
        ctbnamePre1="rct"        
        ctbnamePre2="dct"
haoranc's avatar
haoranc 已提交
84
        ctbNums=50
haoranc's avatar
haoranc 已提交
85
        self.ctbNums=ctbNums
haoranc's avatar
haoranc 已提交
86
        rowNUms=5000
haoranc's avatar
haoranc 已提交
87
        ts=1451606400000
haoranc's avatar
haoranc 已提交
88 89 90
        tdSql.execute(f"create database {dbname};")
        tdSql.execute(f"use {dbname} ")
        tdSql.execute(f'''
haoranc's avatar
haoranc 已提交
91
        create table {stabname1} (ts timestamp,latitude double,longitude double,elevation double,velocity double,heading double,grade double,fuel_consumption double) tags (name binary(30),fleet binary(30),driver binary(30),model binary(30),device_version binary(30),load_capacity double,fuel_capacity double,nominal_fuel_consumption double);
haoranc's avatar
haoranc 已提交
92
        ''')
haoranc's avatar
haoranc 已提交
93
        tdSql.execute(f'''
haoranc's avatar
haoranc 已提交
94
        create table {stabname2} (ts timestamp,fuel_state double,current_load double,status bigint) tags (name binary(30),fleet binary(30),driver binary(30),model binary(30),device_version binary(30),load_capacity double,fuel_capacity double,nominal_fuel_consumption double) ;
haoranc's avatar
haoranc 已提交
95
        ''')
haoranc's avatar
haoranc 已提交
96 97
        self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname1,ctbPrefix=ctbnamePre1,ctbNum=ctbNums)
        self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums)
haoranc's avatar
haoranc 已提交
98 99
        self.insertData(tsql=tdSql,dbName=dbname,stbName=stabname1,ctbPrefix=ctbnamePre1,ctbNum=ctbNums,rowsPerTbl=rowNUms,startTs=ts,batchNum=10000)
        self.insertData(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums,rowsPerTbl=rowNUms,startTs=ts,batchNum=10000)
haoranc's avatar
haoranc 已提交
100 101 102 103 104 105 106 107 108 109
        # for i in range(ctbNum):
        #     if i %10 == 0 :
        #         # tdLog.debug(f"create table rct{i} using readings (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}', NULL,'v2.3')")
        #         tdSql.execute(f"create table rct{i} using readings (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}', NULL,'v2.3')")
        #     else :
        #         tdSql.execute(f"create table rct{i} using readings (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}','H-{i}','v2.3')")
        #     if i %10 == 0 :
        #         tdSql.execute(f"create table dct{i} using diagnostics (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}',NULL ,'v2.3')")
        #     else:
        #         tdSql.execute(f"create table dct{i} using diagnostics (name,fleet,driver,model,device_version) tags ('truck_{i}','South{i}','Trish{i}','H-{i}','v2.3')")
haoranc's avatar
haoranc 已提交
110 111 112 113 114 115 116 117 118 119
        # for j in range(ctbNums): 
        #     for i in range(rowNUms):
        #         tdSql.execute(
        #             f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )"
        #         )
        #         status= random.randint(0,1)
        #         tdSql.execute(
        #             f"insert into dct{j} values ( {ts+i*60000}, {1+i*0.1},{1400+i*15},  {status},{1500+i*20}, {150+i*2},{5+i} )"
        #         )
        # tdSql.execute("insert into dct9 (ts,fuel_state) values('2021-07-13 14:06:33.123Z',1.2) ;")
haoranc's avatar
haoranc 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    # def check_avg(self ,origin_query , check_query):
    #     avg_result = tdSql.getResult(origin_query)
    #     origin_result = tdSql.getResult(check_query)

    #     check_status = True
    #     for row_index , row in enumerate(avg_result):
    #         for col_index , elem in enumerate(row):
    #             if avg_result[row_index][col_index] != origin_result[row_index][col_index]:
    #                 check_status = False
    #     if not check_status:
    #         tdLog.notice("avg function value has not as expected , sql is \"%s\" "%origin_query )
    #         sys.exit(1)
    #     else:
    #         tdLog.info("avg value check pass , it work as expected ,sql is \"%s\"   "%check_query )


haoranc's avatar
haoranc 已提交
136
    def tsbsIotQuery(self,insertinto=True):
haoranc's avatar
haoranc 已提交
137
        
haoranc's avatar
haoranc 已提交
138
        tdSql.execute("use db_tsbs")
haoranc's avatar
haoranc 已提交
139 140
        
        # test interval and partition
haoranc's avatar
haoranc 已提交
141
        tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ")
haoranc's avatar
haoranc 已提交
142
        parRows=tdSql.queryRows
haoranc's avatar
haoranc 已提交
143
        tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ")
haoranc's avatar
haoranc 已提交
144
        tdSql.checkRows(parRows)
haoranc's avatar
haoranc 已提交
145 146
        
        
haoranc's avatar
haoranc 已提交
147
        # test insert into 
haoranc's avatar
haoranc 已提交
148 149 150 151 152
        if insertinto == True :
            tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;")
            tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
            
            tdSql.query("insert into testsnode(ts,c1,c2,c3,c4)  SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
haoranc's avatar
haoranc 已提交
153 154


haoranc's avatar
haoranc 已提交
155
        # test paitition interval fill
haoranc's avatar
haoranc 已提交
156
        tdSql.query("SELECT name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings   WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition by name interval(10m) fill(value,0) ;")
haoranc's avatar
haoranc 已提交
157

haoranc's avatar
haoranc 已提交
158

haoranc's avatar
haoranc 已提交
159
        # test partition interval limit  (PRcore-TD-17410)
haoranc's avatar
haoranc 已提交
160
        tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings partition BY name,driver,fleet interval (10m) limit 1);")
haoranc's avatar
haoranc 已提交
161
        tdSql.checkRows(self.ctbNums)
haoranc's avatar
haoranc 已提交
162 163

        # test partition interval Pseudo time-column
haoranc's avatar
haoranc 已提交
164
        tdSql.query("SELECT count(ms1)/144  FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'  partition by model, fleet interval(10m)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
haoranc's avatar
haoranc 已提交
165

haoranc's avatar
haoranc 已提交
166
        # 1 high-load:
haoranc's avatar
haoranc 已提交
167
        tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics  WHERE fleet = 'South'   partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name desc, ts DESC;")
haoranc's avatar
haoranc 已提交
168

haoranc's avatar
haoranc 已提交
169
        tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics  WHERE fleet = 'South'   partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;")
haoranc's avatar
haoranc 已提交
170 171 172 173 174 175

        # 2 stationary-trucks 
        tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z'    partition BY name,driver,fleet interval(10m) LIMIT 1)")
        tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z'    partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name")

        # 3 long-driving-sessions
haoranc's avatar
haoranc 已提交
176
        tdSql.query("SELECT name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT _wstart as ts,name,driver,avg(velocity) as mean_velocity FROM readings  where ts > '2016-01-01T00:00:34Z' AND ts <= '2016-01-01T04:00:34Z'     partition BY name,driver interval(10m)) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 22 ;")
haoranc's avatar
haoranc 已提交
177 178 179 180 181 182 183 184 185


        #4 long-daily-sessions
        tdSql.query("SELECT name,driver FROM(SELECT name,driver,count(*) AS ten_min FROM(SELECT name,driver,avg(velocity) as mean_velocity FROM readings WHERE fleet ='West' AND ts > '2016-01-01T12:31:37Z' AND ts <= '2016-01-05T12:31:37Z' partition BY name,driver  interval(10m) ) WHERE mean_velocity > 1 GROUP BY name,driver) WHERE ten_min > 60")

        # 5. avg-daily-driving-duration
        tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z'     and ts < '2016-01-05T00:00:01Z'    partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z'  and ts < '2016-01-05T00:00:01Z'    partition by fleet,name,driver interval(1d) ;")


haoranc's avatar
haoranc 已提交
186 187
        # # 6. avg-daily-driving-session        
        # #taosc core dumped
haoranc's avatar
haoranc 已提交
188
        tdSql.query(" SELECT _wstart as ts,name,floor(avg(velocity)/5) AS mv FROM readings   WHERE name is not null  AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition by name interval(10m) fill(value,0);")
haoranc's avatar
haoranc 已提交
189 190
        # tdSql.query("select name,diff(mv) AS difka  FROM (SELECT  ts,name,mv  FROM (SELECT _wstart as ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings   WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition by name interval(10m) fill(value,0)))  group  BY name ;")
        # tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings   WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition by name interval(10m) fill(value,0)")
haoranc's avatar
haoranc 已提交
191 192 193

        # 7. avg-load
        tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by  fleet ;")
haoranc's avatar
haoranc 已提交
194

haoranc's avatar
haoranc 已提交
195 196
        # 8. daily-activity   
        tdSql.query(" SELECT model,ms1  FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'  partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z'  AND ms1<1;")
haoranc's avatar
haoranc 已提交
197 198 199

        tdSql.query(" SELECT model,ms1  FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'  partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z'  AND ms1<1;")

haoranc's avatar
haoranc 已提交
200
        tdSql.query("SELECT _wstart,model,fleet,count(ms1)/144  FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'  partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z'  AND ms1<1 partition by model, fleet interval(1d) ;")
haoranc's avatar
haoranc 已提交
201

haoranc's avatar
haoranc 已提交
202
        tdSql.query("SELECT _wstart as ts,model,fleet,count(ms1)/144  FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'  partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z'  AND ms1<1 partition by model, fleet interval(1d) ;")
haoranc's avatar
haoranc 已提交
203 204


haoranc's avatar
haoranc 已提交
205 206
        # 9. breakdown-frequency
        # NULL ---count(NULL)=0 expect count(NULL)= 100
haoranc's avatar
haoranc 已提交
207
        tdSql.query("SELECT model,state_changed,count(state_changed)  FROM (SELECT model,diff(broken_down) AS state_changed   FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE  ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition BY model interval(10m)) partition BY model) where model is null  partition BY model,state_changed ")
haoranc's avatar
haoranc 已提交
208
        parRows=tdSql.queryRows
haoranc's avatar
haoranc 已提交
209
        assert parRows != 0 , "query result is wrong, query rows %d but expect > 0 " %parRows
haoranc's avatar
haoranc 已提交
210

haoranc's avatar
haoranc 已提交
211 212

        tdSql.query(" SELECT model,state_changed,count(state_changed)  FROM (SELECT model,diff(broken_down) AS state_changed   FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE  ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z'   partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;")
haoranc's avatar
haoranc 已提交
213 214
        sql="select  model,ctc from (SELECT model,count(state_changed) as ctc FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= 1451606400000 AND ts < 1451952001000 ) WHERE ts >= 1451606400000 AND ts < 1451952001000 partition BY model interval(10m)) partition BY model) WHERE state_changed = 1 partition BY model )where model is null;"

haoranc's avatar
haoranc 已提交
215 216 217 218 219 220 221
        # for i in range(2):
        #     tdSql.query("%s"%sql)
        #     quertR1=tdSql.queryResult  
        #     for j in  range(50):
        #         tdSql.query("%s"%sql)
        #         quertR2=tdSql.queryResult
        #         assert quertR1 == quertR2 , "%s != %s ,The results of multiple queries are different" %(quertR1,quertR2)            
haoranc's avatar
haoranc 已提交
222

haoranc's avatar
haoranc 已提交
223
        
haoranc's avatar
haoranc 已提交
224 225
        #it's already supported:
        # last-loc
haoranc's avatar
haoranc 已提交
226
        tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;")
haoranc's avatar
haoranc 已提交
227

haoranc's avatar
haoranc 已提交
228 229 230 231 232 233 234 235

        #2. low-fuel
        tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;")
        
        # 3. avg-vs-projected-fuel-consumption
        tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet")
        
    def run(self):  
haoranc's avatar
haoranc 已提交
236
        tdLog.printNoPrefix("==========step1:create database and table,insert data  ==============")
haoranc's avatar
haoranc 已提交
237
        self.prepareData()
haoranc's avatar
haoranc 已提交
238
        self.tsbsIotQuery()
haoranc's avatar
haoranc 已提交
239 240 241
        tdDnodes.stop(1)
        tdDnodes.start(1)
        self.tsbsIotQuery(False)
haoranc's avatar
haoranc 已提交
242 243 244 245 246 247 248

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

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