unsignedTinyint.py 25.0 KB
Newer Older
L
liuyq-617 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
# -*- coding: utf-8 -*-

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


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

    def run(self):
        tdSql.prepare()

        # TSIM: system sh/stop_dnodes.sh
        # TSIM:
        # TSIM:
        # TSIM: system sh/deploy.sh -n dnode1 -i 1
        # TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0
        # TSIM: system sh/exec.sh -n dnode1 -s start
        # TSIM:
        # TSIM: sleep 3000
        # TSIM: sql connect
        # TSIM:
        # TSIM: print ======================== dnode1 start
        tdLog.info('======================== dnode1 start')
        # TSIM:
        # TSIM: $dbPrefix = ta_sm_db
        # TSIM: $tbPrefix = ta_sm_tb
        tbPrefix = "ta_sm_tb"
        # TSIM: $mtPrefix = ta_sm_mt
        mtPrefix = "ta_sm_mt"
        # TSIM: $tbNum = 10
        tbNum = 10
        # TSIM: $rowNum = 20
        rowNum = 20
        # TSIM: $totalNum = 200
        totalNum = 200
        # TSIM:
        # TSIM: print =============== step1
        tdLog.info('=============== step1')
        # TSIM: $i = 0
        i = 0
        # TSIM: $db = $dbPrefix . $i
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM:
        # TSIM: sql create database $db
        # TSIM: sql use $db
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol
        # tinyint unsigned)
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint unsigned)' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint unsigned)' %
            (mt))
        # TSIM:
        # TSIM: $i = 0
        i = 0
        # TSIM: while $i < 5
        while (i < 5):
            # TSIM: $tb = $tbPrefix . $i
            tb = "%s%d" % (tbPrefix, i)
            # TSIM: sql create table $tb using $mt tags( 0 )
            tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
            tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
            # TSIM: $x = 0
            x = 0
            # TSIM: while $x < $rowNum
            while (x < rowNum):
                # TSIM: $ms = $x . m
L
liuyq-617 已提交
75
                ms = x * 60000
L
liuyq-617 已提交
76
                tdLog.info(
L
liuyq-617 已提交
77 78
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
L
liuyq-617 已提交
79
                tdSql.execute(
L
liuyq-617 已提交
80 81
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
L
liuyq-617 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
                # TSIM: $x = $x + 1
                x = x + 1
                # TSIM: endw
            # TSIM: $i = $i + 1
            i = i + 1
            # TSIM: endw
        # TSIM: while $i < 10
        while (i < 10):
            # TSIM: $tb = $tbPrefix . $i
            tb = "%s%d" % (tbPrefix, i)
            # TSIM: sql create table $tb using $mt tags( 1 )
            tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
            tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
            # TSIM: $x = 0
            x = 0
            # TSIM: while $x < $rowNum
            while (x < rowNum):
                # TSIM: $ms = $x . m
L
liuyq-617 已提交
100
                ms = x * 60000
L
liuyq-617 已提交
101
                tdLog.info(
L
liuyq-617 已提交
102 103
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
L
liuyq-617 已提交
104
                tdSql.execute(
L
liuyq-617 已提交
105 106
                    "insert into %s values (%d, %d)" %
                    (tb, 1605045600000 + ms, x))
L
liuyq-617 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
                # TSIM: $x = $x + 1
                x = x + 1
                # TSIM: endw
            # TSIM: $i = $i + 1
            i = i + 1
            # TSIM: endw
        # TSIM:
        # TSIM: print =============== step2
        tdLog.info('=============== step2')
        # TSIM: sleep 100
        # TSIM: sql select * from $tb
        tdLog.info('select * from %s' % (tb))
        tdSql.query('select * from %s' % (tb))
        # TSIM: if $rows != $rowNum then
        tdLog.info('tdSql.checkRow($rowNum)')
        tdSql.checkRows(rowNum)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
125 126 127
        # TSIM: sql select * from $tb where ts < 1605045600000 + 240001
        tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (tb))
        tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (tb))
L
liuyq-617 已提交
128 129 130 131 132
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
133 134 135
        # TSIM: sql select * from $tb where ts <= 1605045600000 + 240001
        tdLog.info('select * from %s where ts <= 1605045600000 + 240001' % (tb))
        tdSql.query('select * from %s where ts <= 1605045600000 + 240001' % (tb))
L
liuyq-617 已提交
136 137 138 139 140
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
141 142 143
        # TSIM: sql select * from $tb where ts > 1605045600000 + 240001
        tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (tb))
        tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (tb))
L
liuyq-617 已提交
144 145 146 147 148
        # TSIM: if $rows != 15 then
        tdLog.info('tdSql.checkRow(15)')
        tdSql.checkRows(15)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
149 150 151
        # TSIM: sql select * from $tb where ts >= 1605045600000 + 240001
        tdLog.info('select * from %s where ts >= 1605045600000 + 240001' % (tb))
        tdSql.query('select * from %s where ts >= 1605045600000 + 240001' % (tb))
L
liuyq-617 已提交
152 153 154 155 156
        # TSIM: if $rows != 15 then
        tdLog.info('tdSql.checkRow(15)')
        tdSql.checkRows(15)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
157
        # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001
L
liuyq-617 已提交
158
        tdLog.info(
L
liuyq-617 已提交
159
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
160 161
            (tb))
        tdSql.query(
L
liuyq-617 已提交
162
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
163 164 165 166 167 168
            (tb))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
169
        # TSIM: sql select * from $tb where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001
L
liuyq-617 已提交
170
        tdLog.info(
L
liuyq-617 已提交
171
            'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' %
L
liuyq-617 已提交
172 173
            (tb))
        tdSql.query(
L
liuyq-617 已提交
174
            'select * from %s where ts < 1605045600000 + 240001 and ts > 1605045600000 + 300001' %
L
liuyq-617 已提交
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
            (tb))
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $tb where ts > 100000 and ts < 100000
        tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
        tdSql.query(
            'select * from %s where ts > 100000 and ts < 100000' %
            (tb))
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
191
        # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001
L
liuyq-617 已提交
192
        tdLog.info(
L
liuyq-617 已提交
193
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' %
L
liuyq-617 已提交
194 195
            (tb))
        tdSql.query(
L
liuyq-617 已提交
196
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 180001' %
L
liuyq-617 已提交
197 198 199 200 201 202
            (tb))
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
203 204
        # TSIM: sql select * from $tb where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and
        # ts < 1605045600000 + 360001
L
liuyq-617 已提交
205
        tdLog.info(
L
liuyq-617 已提交
206
            'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' %
L
liuyq-617 已提交
207 208
            (tb))
        tdSql.query(
L
liuyq-617 已提交
209
            'select * from %s where ts > 1605045600000 + 240001 and ts > 1605045600000 + 300001 and ts < 1605045600000 + 360001' %
L
liuyq-617 已提交
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
            (tb))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step3
        tdLog.info('=============== step3')
        # TSIM: sql select * from $mt
        tdLog.info('select * from %s' % (mt))
        tdSql.query('select * from %s' % (mt))
        # TSIM: if $rows != $totalNum then
        tdLog.info('tdSql.checkRow($totalNum)')
        tdSql.checkRows(totalNum)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
L
liuyq-617 已提交
228 229 230
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001
        tdLog.info('select * from %s where ts < 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts < 1605045600000 + 240001' % (mt))
L
liuyq-617 已提交
231 232 233 234 235
        # TSIM: if $rows != 50 then
        tdLog.info('tdSql.checkRow(50)')
        tdSql.checkRows(50)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
236 237 238
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001
        tdLog.info('select * from %s where ts > 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts > 1605045600000 + 240001' % (mt))
L
liuyq-617 已提交
239 240 241 242 243
        # TSIM: if $rows != 150 then
        tdLog.info('tdSql.checkRow(150)')
        tdSql.checkRows(150)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
244 245 246
        # TSIM: sql select * from $mt where ts = 1605045600000 + 240001
        tdLog.info('select * from %s where ts = 1605045600000 + 240001' % (mt))
        tdSql.query('select * from %s where ts = 1605045600000 + 240001' % (mt))
L
liuyq-617 已提交
247 248 249 250 251
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
252
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001
L
liuyq-617 已提交
253
        tdLog.info(
L
liuyq-617 已提交
254
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
255 256
            (mt))
        tdSql.query(
L
liuyq-617 已提交
257
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
            (mt))
        # TSIM: if $rows != 10 then
        tdLog.info('tdSql.checkRow(10)')
        tdSql.checkRows(10)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step4
        tdLog.info('=============== step4')
        # TSIM: sql select * from $mt where tgcol = 0
        tdLog.info('select * from %s where tgcol = 0' % (mt))
        tdSql.query('select * from %s where tgcol = 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol <> 0
        tdLog.info('select * from %s where tgcol <> 0' % (mt))
        tdSql.query('select * from %s where tgcol <> 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol = 1
        tdLog.info('select * from %s where tgcol = 1' % (mt))
        tdSql.query('select * from %s where tgcol = 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol <> 1
        tdLog.info('select * from %s where tgcol <> 1' % (mt))
        tdSql.query('select * from %s where tgcol <> 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol = 1
        tdLog.info('select * from %s where tgcol = 1' % (mt))
        tdSql.query('select * from %s where tgcol = 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol <> 1
        tdLog.info('select * from %s where tgcol <> 1' % (mt))
        tdSql.query('select * from %s where tgcol <> 1' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol = 0
        tdLog.info('select * from %s where tgcol = 0' % (mt))
        tdSql.query('select * from %s where tgcol = 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM: sql select * from $mt where tgcol <> 0
        tdLog.info('select * from %s where tgcol <> 0' % (mt))
        tdSql.query('select * from %s where tgcol <> 0' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step5
        tdLog.info('=============== step5')
L
liuyq-617 已提交
334 335
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol = 1
        tdLog.info('select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' % (mt))
L
liuyq-617 已提交
336
        tdSql.query(
L
liuyq-617 已提交
337
            'select * from %s where ts > 1605045600000 + 240001 and tgcol = 1' %
L
liuyq-617 已提交
338 339 340 341 342 343
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
344
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 1
L
liuyq-617 已提交
345
        tdLog.info(
L
liuyq-617 已提交
346
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' %
L
liuyq-617 已提交
347 348
            (mt))
        tdSql.query(
L
liuyq-617 已提交
349
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 1' %
L
liuyq-617 已提交
350 351 352 353 354 355
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
356 357
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol = 0
        tdLog.info('select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' % (mt))
L
liuyq-617 已提交
358
        tdSql.query(
L
liuyq-617 已提交
359
            'select * from %s where ts < 1605045600000 + 240001 and tgcol = 0' %
L
liuyq-617 已提交
360 361 362 363 364 365
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
366
        # TSIM: sql select * from $mt where ts < 1605045600000 + 240001 and tgcol <> 0
L
liuyq-617 已提交
367
        tdLog.info(
L
liuyq-617 已提交
368
            'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' %
L
liuyq-617 已提交
369 370
            (mt))
        tdSql.query(
L
liuyq-617 已提交
371
            'select * from %s where ts < 1605045600000 + 240001 and tgcol <> 0' %
L
liuyq-617 已提交
372 373 374 375 376 377
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
378
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol = 0
L
liuyq-617 已提交
379
        tdLog.info(
L
liuyq-617 已提交
380
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' %
L
liuyq-617 已提交
381 382
            (mt))
        tdSql.query(
L
liuyq-617 已提交
383
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol = 0' %
L
liuyq-617 已提交
384 385 386 387 388 389
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
390
        # TSIM: sql select * from $mt where ts <= 1605045600000 + 240001 and tgcol <> 0
L
liuyq-617 已提交
391
        tdLog.info(
L
liuyq-617 已提交
392
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' %
L
liuyq-617 已提交
393 394
            (mt))
        tdSql.query(
L
liuyq-617 已提交
395
            'select * from %s where ts <= 1605045600000 + 240001 and tgcol <> 0' %
L
liuyq-617 已提交
396 397 398 399 400 401
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
402
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and
L
liuyq-617 已提交
403 404
        # tgcol <> 0
        tdLog.info(
L
liuyq-617 已提交
405
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' %
L
liuyq-617 已提交
406 407
            (mt))
        tdSql.query(
L
liuyq-617 已提交
408
            'select * from %s where ts > 1605045600000 + 240001 and ts < 1605045600000 + 300001 and tgcol <> 0' %
L
liuyq-617 已提交
409 410 411 412 413 414
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
        # TSIM: endi
L
liuyq-617 已提交
415 416
        # TSIM: sql select * from $mt where ts > 1605045600000 + 240001 and tgcol <> 0 and ts
        # < 1605045600000 + 300001
L
liuyq-617 已提交
417
        tdLog.info(
L
liuyq-617 已提交
418
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
419 420
            (mt))
        tdSql.query(
L
liuyq-617 已提交
421
            'select * from %s where ts > 1605045600000 + 240001 and tgcol <> 0 and ts < 1605045600000 + 300001' %
L
liuyq-617 已提交
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step6
        tdLog.info('=============== step6')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 200 then
        tdLog.info('tdSql.checkData(0, 0, 200)')
        tdSql.checkData(0, 0, 200)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step7
        tdLog.info('=============== step7')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step8
        tdLog.info('=============== step8')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
L
liuyq-617 已提交
468
        # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001
L
liuyq-617 已提交
469
        tdLog.info(
L
liuyq-617 已提交
470
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' %
L
liuyq-617 已提交
471 472
            (mt))
        tdSql.query(
L
liuyq-617 已提交
473
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001' %
L
liuyq-617 已提交
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 50 then
        tdLog.info('tdSql.checkData(0, 0, 50)')
        tdSql.checkData(0, 0, 50)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step9
        tdLog.info('=============== step9')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step10
        tdLog.info('=============== step10')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
        # by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 100 then
        tdLog.info('tdSql.checkData(0, 0, 100)')
        tdSql.checkData(0, 0, 100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== step11
        tdLog.info('=============== step11')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
L
liuyq-617 已提交
523
        # max(tbcol), first(tbcol), last(tbcol) from $mt where ts < 1605045600000 + 240001
L
liuyq-617 已提交
524 525
        # group by tgcol
        tdLog.info(
L
liuyq-617 已提交
526
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' %
L
liuyq-617 已提交
527 528
            (mt))
        tdSql.query(
L
liuyq-617 已提交
529
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where ts < 1605045600000 + 240001 group by tgcol' %
L
liuyq-617 已提交
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data00 != 25 then
        tdLog.info('tdSql.checkData(0, 0, 25)')
        tdSql.checkData(0, 0, 25)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM:
        # TSIM: print =============== step12
        tdLog.info('=============== step12')
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
        # tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
            (mt))
        # TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
        tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
        # TSIM: if $data01 != 100 then
        tdLog.info('tdSql.checkData(0, 1, 100)')
        tdSql.checkData(0, 1, 100)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: print =============== clear
        tdLog.info('=============== clear')
        # TSIM: sql drop database $db
        tdLog.info('drop database db')
        tdSql.execute('drop database db')
        # TSIM: sql show databases
        tdLog.info('show databases')
        tdSql.query('show databases')
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
        # TSIM: endi
        # TSIM:
        # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
        tdSql.execute("create database db")
        tdSql.execute("use db")
        tdSql.execute(
            "create table if not exists st (ts timestamp, tagtype int) tags(dev tinyint unsigned)")
        tdSql.error(
            'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 1))
        tdSql.error(
            'CREATE TABLE if not exists dev_001 using st tags(%d)' % (-1))
        
        tdSql.execute(
            'CREATE TABLE if not exists dev_001 using st tags(%d)' % (pow(2, 8) - 2))
        tdSql.execute(
            'CREATE TABLE if not exists dev_002 using st tags(%d)' % (0))
        tdSql.execute(
            'CREATE TABLE if not exists dev_003 using st tags(%s)' % ('NULL'))
        print("==============step2")    
        tdSql.query("show tables")
        tdSql.checkRows(3)   

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


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