smallint.py 23.8 KB
Newer Older
S
Shuduo Sang 已提交
1 2 3 4 5 6 7 8 9
# -*- coding: utf-8 -*-

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


class TDTestCase:
S
Shuduo Sang 已提交
10
    def init(self, conn, logSql):
S
Shuduo Sang 已提交
11
        tdLog.debug("start to execute %s" % __file__)
S
Shuduo Sang 已提交
12
        tdSql.init(conn.cursor(), logSql)
S
Shuduo Sang 已提交
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 75 76 77 78 79 80 81 82 83 84

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

        print("==============step2")    
        tdSql.query("show tables")
        tdSql.checkRows(2)   
S
Shuduo Sang 已提交
594 595 596 597 598 599 600 601

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


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