int_binary.py 33.5 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

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