binary_binary.py 32.4 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 85 86

    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_bib_db
        # TSIM: $tbPrefix = ta_bib_tb
        tbPrefix = "ta_bib_tb"
        # TSIM: $mtPrefix = ta_bib_mt
        mtPrefix = "ta_bib_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
        # binary(5), tgcol2 binary(5))
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(5), tgcol2 binary(5))' %
            (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', '0' )
            tdLog.info('create table %s using %s tags( "0", "0" )' % (tb, mt))
            tdSql.execute(
                'create table %s using %s tags( "0", "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
87
                # TSIM: endw
S
Shuduo Sang 已提交
88 89
            # TSIM: $i = $i + 1
            i = i + 1
90
            # TSIM: endw
S
Shuduo Sang 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
        # 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', '1' )
            tdLog.info('create table %s using %s tags( "1", "1" )' % (tb, mt))
            tdSql.execute(
                'create table %s using %s tags( "1", "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
115
                # TSIM: endw
S
Shuduo Sang 已提交
116 117
            # TSIM: $i = $i + 1
            i = i + 1
118
            # TSIM: endw
S
Shuduo Sang 已提交
119 120 121 122 123 124 125 126 127 128
        # TSIM:
        # TSIM: print =============== step2
        tdLog.info('=============== step2')
        # 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
129
        # TSIM: endi
S
Shuduo Sang 已提交
130 131 132 133 134 135 136 137
        # 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
138
        # TSIM: endi
S
Shuduo Sang 已提交
139 140 141 142 143 144 145
        # 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
146
        # TSIM: endi
S
Shuduo Sang 已提交
147 148 149 150 151 152 153
        # 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
154
        # TSIM: endi
S
Shuduo Sang 已提交
155 156 157 158 159 160 161 162 163 164 165
        # 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
166
        # TSIM: endi
S
Shuduo Sang 已提交
167 168 169 170 171 172 173 174 175 176
        # TSIM:
        # TSIM: print =============== step3
        tdLog.info('=============== step3')
        # 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
177
        # TSIM: endi
S
Shuduo Sang 已提交
178 179 180 181 182 183 184
        # 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
185
        # TSIM: endi
S
Shuduo Sang 已提交
186 187 188 189 190 191 192
        # 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
193
        # TSIM: endi
S
Shuduo Sang 已提交
194 195 196 197 198 199 200
        # 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
201
        # TSIM: endi
S
Shuduo Sang 已提交
202 203 204 205 206 207 208
        # 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
209
        # TSIM: endi
S
Shuduo Sang 已提交
210 211 212 213 214 215 216
        # 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
217
        # TSIM: endi
S
Shuduo Sang 已提交
218 219 220 221 222 223 224
        # 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
225
        # TSIM: endi
S
Shuduo Sang 已提交
226 227 228 229 230 231 232
        # 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
233
        # TSIM: endi
S
Shuduo Sang 已提交
234 235 236 237 238 239 240 241 242 243
        # TSIM:
        # TSIM: print =============== step4
        tdLog.info('=============== step4')
        # TSIM: sql select * from $mt where tgcol2 = '0'
        tdLog.info('select * from %s where tgcol2 = "0"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "0"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
244
        # TSIM: endi
S
Shuduo Sang 已提交
245 246 247 248 249 250 251
        # TSIM: sql select * from $mt where tgcol2 <> '0'
        tdLog.info('select * from %s where tgcol2 <> "0"' % (mt))
        tdSql.query('select * from %s where tgcol2 <> "0"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
252
        # TSIM: endi
S
Shuduo Sang 已提交
253 254 255 256 257 258 259
        # TSIM: sql select * from $mt where tgcol2 = '1'
        tdLog.info('select * from %s where tgcol2 = "1"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "1"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
260
        # TSIM: endi
S
Shuduo Sang 已提交
261 262 263 264 265 266 267
        # TSIM: sql select * from $mt where tgcol2 <> '1'
        tdLog.info('select * from %s where tgcol2 <> "1"' % (mt))
        tdSql.query('select * from %s where tgcol2 <> "1"' % (mt))
        # TSIM: if $rows != 100 then
        tdLog.info('tdSql.checkRow(100)')
        tdSql.checkRows(100)
        # TSIM: return -1
268
        # TSIM: endi
S
Shuduo Sang 已提交
269 270 271 272 273 274 275 276 277 278 279 280 281 282
        # 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
283
        # TSIM: endi
S
Shuduo Sang 已提交
284 285 286 287 288 289 290 291 292 293 294
        # 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
295
        # TSIM: endi
S
Shuduo Sang 已提交
296 297 298 299 300 301 302 303 304 305 306
        # 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
307
        # TSIM: endi
S
Shuduo Sang 已提交
308 309 310 311 312 313 314 315 316 317 318
        # 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
319
        # TSIM: endi
S
Shuduo Sang 已提交
320 321 322 323 324 325 326 327 328 329 330
        # 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
331
        # TSIM: endi
S
Shuduo Sang 已提交
332 333 334 335 336 337 338 339 340 341 342
        # 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
343
        # TSIM: endi
S
Shuduo Sang 已提交
344 345 346 347 348 349 350 351 352 353 354 355
        # 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
356
        # TSIM: endi
S
Shuduo Sang 已提交
357 358 359 360 361 362 363 364 365 366 367 368
        # 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
369
        # TSIM: endi
S
Shuduo Sang 已提交
370 371 372 373 374 375 376 377 378 379 380 381 382 383
        # TSIM:
        # TSIM: print =============== step6
        tdLog.info('=============== step6')
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1'
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 = "1"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 = "1"' %
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
384
        # TSIM: endi
S
Shuduo Sang 已提交
385 386 387 388 389 390 391 392 393 394 395
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1'
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 <> "1"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 <> "1"' %
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
396
        # TSIM: endi
S
Shuduo Sang 已提交
397 398 399 400 401 402 403 404 405 406 407
        # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0'
        tdLog.info(
            'select * from %s where ts < now + 4m and tgcol2 = "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts < now + 4m and tgcol2 = "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
408
        # TSIM: endi
S
Shuduo Sang 已提交
409 410 411 412 413 414 415 416 417 418 419
        # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0'
        tdLog.info(
            'select * from %s where ts < now + 4m and tgcol2 <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts < now + 4m and tgcol2 <> "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
420
        # TSIM: endi
S
Shuduo Sang 已提交
421 422 423 424 425 426 427 428 429 430 431
        # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0'
        tdLog.info(
            'select * from %s where ts <= now + 4m and tgcol2 = "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts <= now + 4m and tgcol2 = "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
432
        # TSIM: endi
S
Shuduo Sang 已提交
433 434 435 436 437 438 439 440 441 442 443
        # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0'
        tdLog.info(
            'select * from %s where ts <= now + 4m and tgcol2 <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts <= now + 4m and tgcol2 <> "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
444
        # TSIM: endi
S
Shuduo Sang 已提交
445 446 447 448 449 450 451 452 453 454 455 456
        # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
        # tgcol2 <> '0'
        tdLog.info(
            'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0"' %
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
457
        # TSIM: endi
S
Shuduo Sang 已提交
458 459 460 461 462 463 464 465 466 467 468 469
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and
        # ts < now + 5m
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m' %
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
470
        # TSIM: endi
S
Shuduo Sang 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
        # TSIM:
        # TSIM: print =============== step7
        tdLog.info('=============== step7')
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' and
        # tgcol = '1'
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = "1"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = "1"' %
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
486
        # TSIM: endi
S
Shuduo Sang 已提交
487 488 489 490 491 492 493 494 495 496 497 498
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and
        # tgcol <> '1'
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> "1"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> "1"' %
            (mt))
        # TSIM: if $rows != 75 then
        tdLog.info('tdSql.checkRow(75)')
        tdSql.checkRows(75)
        # TSIM: return -1
499
        # TSIM: endi
S
Shuduo Sang 已提交
500 501 502 503 504 505 506 507 508 509 510 511
        # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' and
        # tgcol = '0'
        tdLog.info(
            'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
512
        # TSIM: endi
S
Shuduo Sang 已提交
513 514 515 516 517 518 519 520 521 522 523 524
        # TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and
        # tgcol <> '0'
        tdLog.info(
            'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
525
        # TSIM: endi
S
Shuduo Sang 已提交
526 527 528 529 530 531 532 533 534 535 536 537
        # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and
        # tgcol = '0'
        tdLog.info(
            'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
538
        # TSIM: endi
S
Shuduo Sang 已提交
539 540 541 542 543 544 545 546 547 548 549 550
        # TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0'
        # and tgcol <> '0'
        tdLog.info(
            'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        # TSIM: if $rows != 25 then
        tdLog.info('tdSql.checkRow(25)')
        tdSql.checkRows(25)
        # TSIM: return -1
551
        # TSIM: endi
S
Shuduo Sang 已提交
552 553 554 555 556 557 558 559 560 561 562 563
        # TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
        # tgcol2 <> '0' and tgcol <> '0'
        tdLog.info(
            'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> "0"' %
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
564
        # TSIM: endi
S
Shuduo Sang 已提交
565 566 567 568 569 570 571 572 573 574 575 576
        # TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and
        # ts < now + 5m and ts < now + 5m and tgcol <> '0'
        tdLog.info(
            'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> "0"' %
            (mt))
        tdSql.query(
            'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> "0"' %
            (mt))
        # TSIM: if $rows != 5 then
        tdLog.info('tdSql.checkRow(5)')
        tdSql.checkRows(5)
        # TSIM: return -1
577
        # TSIM: endi
S
Shuduo Sang 已提交
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
        # 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
        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
595
        # TSIM: endi
S
Shuduo Sang 已提交
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
        # 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 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
613
        # TSIM: endi
S
Shuduo Sang 已提交
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1'
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "1"' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "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
629
        # TSIM: endi
S
Shuduo Sang 已提交
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and
        # tgcol2 = '1'
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "1"' %
            (mt))
        tdSql.query(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" and tgcol2 = "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
646
        # TSIM: endi
S
Shuduo Sang 已提交
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
        # 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 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
664
        # TSIM: endi
S
Shuduo Sang 已提交
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
        # 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 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
682
        # TSIM: endi
S
Shuduo Sang 已提交
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700
        # 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 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
701
        # TSIM: endi
S
Shuduo Sang 已提交
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol2 = '1'
        # group by tgcol
        tdLog.info(
            'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol2 = "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 tgcol2 = "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
718
        # TSIM: endi
S
Shuduo Sang 已提交
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
        # TSIM:
        # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
        # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' and
        # tgcol2 = '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" and tgcol2 = "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" and tgcol2 = "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
735
        # TSIM: endi
S
Shuduo Sang 已提交
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
        # TSIM:
        # TSIM:
        # TSIM: print =============== step13
        tdLog.info('=============== step13')
        # 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
755
        # TSIM: endi
S
Shuduo Sang 已提交
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
        # TSIM:
        # TSIM: print =============== step14
        tdLog.info('=============== step14')
        # 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
774
        # TSIM: endi
S
Shuduo Sang 已提交
775 776 777 778 779 780 781 782 783 784 785 786 787
        # 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
788
        # TSIM: endi
S
Shuduo Sang 已提交
789 790 791 792 793 794 795 796 797 798 799
        # TSIM:
        # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end

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


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