set.py 33.0 KB
Newer Older
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):
11
        tdLog.debug("start to execute %s" % __file__)
S
Shuduo Sang 已提交
12
        tdSql.init(conn.cursor(), logSql)
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

    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_se_db
        # TSIM: $tbPrefix = ta_se_tb
        tbPrefix = "ta_se_tb"
        # TSIM: $mtPrefix = ta_se_mt
        mtPrefix = "ta_se_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:
        # TSIM: sql create database $db
        # TSIM: sql use $db
        # TSIM:
        # TSIM: print =============== step2
        tdLog.info('=============== step2')
        # TSIM: $i = 2
        i = 2
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM: $tb = $tbPrefix . $i
        tb = "%s%d" % (tbPrefix, i)
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
        # bool, tgcol2 int)
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)' %
            (mt))
        # TSIM: sql create table $tb using $mt tags( 1, 2 )
        tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt))
        tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt))
        # TSIM: sql insert into $tb values(now, 1)
        tdLog.info('insert into %s values(now, 1)' % (tb))
        tdSql.execute('insert into %s values(now, 1)' % (tb))
        # TSIM: sql select * from $mt where tgcol1 = 1
        tdLog.info('select * from %s where tgcol1 = 1' % (mt))
        tdSql.query('select * from %s where tgcol1 = 1' % (mt))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
80
        # TSIM: endi
81 82 83 84
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
85
        # TSIM: endi
86 87 88 89
        # TSIM: if $data02 != 1 then
        tdLog.info('tdSql.checkData(0, 2, 1)')
        tdSql.checkData(0, 2, 1)
        # TSIM: return -1
90
        # TSIM: endi
91 92 93 94
        # TSIM: if $data03 != 2 then
        tdLog.info('tdSql.checkData(0, 3, 2)')
        tdSql.checkData(0, 3, 2)
        # TSIM: return -1
95
        # TSIM: endi
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
        # TSIM:
        # TSIM: sql alter table $tb set tag tagcx 1 -x step21
        tdLog.info('alter table %s set tag tagcx 1 -x step21' % (tb))
        tdSql.error('alter table %s set tag tagcx 11' % (tb))
        # TSIM: return -1
        # TSIM: step21:
        # TSIM: sql alter table $tb set tag tgcol1=false
        tdLog.info('alter table %s set tag tgcol1=false' % (tb))
        tdSql.execute('alter table %s set tag tgcol1=false' % (tb))
        # TSIM: sql alter table $tb set tag tgcol2=4
        tdLog.info('alter table %s set tag tgcol2=4' % (tb))
        tdSql.execute('alter table %s set tag tgcol2=4' % (tb))
        # TSIM:
        # TSIM: sql reset query cache
        tdLog.info('reset query cache')
        tdSql.execute('reset query cache')
        # TSIM:
        # TSIM: sql select * from $mt where tgcol1 = false
        tdLog.info('select * from %s where tgcol1 = false' % (mt))
        tdSql.query('select * from %s where tgcol1 = false' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
122
        # TSIM: endi
123 124 125 126
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
127
        # TSIM: endi
128 129 130 131
        # TSIM: if $data02 != 0 then
        tdLog.info('tdSql.checkData(0, 2, 0)')
        tdSql.checkData(0, 2, 0)
        # TSIM: return -1
132
        # TSIM: endi
133 134 135 136
        # TSIM: if $data03 != 4 then
        tdLog.info('tdSql.checkData(0, 3, 4)')
        tdSql.checkData(0, 3, 4)
        # TSIM: return -1
137
        # TSIM: endi
138 139 140 141 142 143 144 145 146 147
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = 4
        tdLog.info('select * from %s where tgcol2 = 4' % (mt))
        tdSql.query('select * from %s where tgcol2 = 4' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
148
        # TSIM: endi
149 150 151 152
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
153
        # TSIM: endi
154 155 156 157
        # TSIM: if $data02 != 0 then
        tdLog.info('tdSql.checkData(0, 2, 0)')
        tdSql.checkData(0, 2, 0)
        # TSIM: return -1
158
        # TSIM: endi
159 160 161 162
        # TSIM: if $data03 != 4 then
        tdLog.info('tdSql.checkData(0, 3, 4)')
        tdSql.checkData(0, 3, 4)
        # TSIM: return -1
163
        # TSIM: endi
164 165 166 167 168 169 170 171 172 173
        # TSIM:
        # TSIM: sql describe $tb
        tdLog.info('describe %s' % (tb))
        tdSql.query('describe %s' % (tb))
        # TSIM: print $data21 $data23 $data32 $data33
        tdLog.info('$data21 $data23 $data32 $data33')
        # TSIM: if $data21 != BOOL then
        tdLog.info('tdSql.checkDataType(2, 1, "BOOL")')
        tdSql.checkDataType(2, 1, "BOOL")
        # TSIM: return -1
174
        # TSIM: endi
175 176 177 178
        # TSIM: if $data31 != INT then
        tdLog.info('tdSql.checkDataType(3, 1, "INT")')
        tdSql.checkDataType(3, 1, "INT")
        # TSIM: return -1
179
        # TSIM: endi
180
        # TSIM: if $data23 != false then
181 182
        tdLog.info('tdSql.checkData(2, 3, "TAG")')
        tdSql.checkData(2, 3, "TAG")
183
        # TSIM: return -1
184
        # TSIM: endi
185
        # TSIM: if $data33 != 4 then
186 187
        tdLog.info('tdSql.checkData(3, 3, "TAG")')
        tdSql.checkData(3, 3, "TAG")
188
        # TSIM: return -1
189
        # TSIM: endi
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
        # TSIM:
        # TSIM: print =============== step3
        tdLog.info('=============== step3')
        # TSIM: $i = 3
        i = 3
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM: $tb = $tbPrefix . $i
        tb = "%s%d" % (tbPrefix, i)
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
        # smallint, tgcol2 tinyint)
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)' %
            (mt))
        # TSIM: sql create table $tb using $mt tags( 1, 2 )
        tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt))
        tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt))
        # TSIM: sql insert into $tb values(now, 1)
        tdLog.info('insert into %s values(now, 1)' % (tb))
        tdSql.execute('insert into %s values(now, 1)' % (tb))
        # TSIM: sql select * from $mt where tgcol1 = 1
        tdLog.info('select * from %s where tgcol1 = 1' % (mt))
        tdSql.query('select * from %s where tgcol1 = 1' % (mt))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
220
        # TSIM: endi
221 222 223 224
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
225
        # TSIM: endi
226 227 228 229
        # TSIM: if $data02 != 1 then
        tdLog.info('tdSql.checkData(0, 2, 1)')
        tdSql.checkData(0, 2, 1)
        # TSIM: return -1
230
        # TSIM: endi
231 232 233 234
        # TSIM: if $data03 != 2 then
        tdLog.info('tdSql.checkData(0, 3, 2)')
        tdSql.checkData(0, 3, 2)
        # TSIM: return -1
235
        # TSIM: endi
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
        # TSIM:
        # TSIM: sql alter table $tb set tag tgcol1=3
        tdLog.info('alter table %s set tag tgcol1=3' % (tb))
        tdSql.execute('alter table %s set tag tgcol1=3' % (tb))
        # TSIM: sql alter table $tb set tag tgcol2=4
        tdLog.info('alter table %s set tag tgcol2=4' % (tb))
        tdSql.execute('alter table %s set tag tgcol2=4' % (tb))
        # TSIM:
        # TSIM: sql reset query cache
        tdLog.info('reset query cache')
        tdSql.execute('reset query cache')
        # TSIM:
        # TSIM: sql select * from $mt where tgcol1 = 3
        tdLog.info('select * from %s where tgcol1 = 3' % (mt))
        tdSql.query('select * from %s where tgcol1 = 3' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
257
        # TSIM: endi
258 259 260 261
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
262
        # TSIM: endi
263 264 265 266
        # TSIM: if $data02 != 3 then
        tdLog.info('tdSql.checkData(0, 2, 3)')
        tdSql.checkData(0, 2, 3)
        # TSIM: return -1
267
        # TSIM: endi
268 269 270 271
        # TSIM: if $data03 != 4 then
        tdLog.info('tdSql.checkData(0, 3, 4)')
        tdSql.checkData(0, 3, 4)
        # TSIM: return -1
272
        # TSIM: endi
273 274 275 276 277 278 279 280 281 282
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = 4
        tdLog.info('select * from %s where tgcol2 = 4' % (mt))
        tdSql.query('select * from %s where tgcol2 = 4' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
283
        # TSIM: endi
284 285 286 287
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
288
        # TSIM: endi
289 290 291 292
        # TSIM: if $data02 != 3 then
        tdLog.info('tdSql.checkData(0, 2, 3)')
        tdSql.checkData(0, 2, 3)
        # TSIM: return -1
293
        # TSIM: endi
294 295 296 297
        # TSIM: if $data03 != 4 then
        tdLog.info('tdSql.checkData(0, 3, 4)')
        tdSql.checkData(0, 3, 4)
        # TSIM: return -1
298
        # TSIM: endi
299 300 301 302 303 304 305 306
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = 2
        tdLog.info('select * from %s where tgcol2 = 2' % (mt))
        tdSql.query('select * from %s where tgcol2 = 2' % (mt))
        # TSIM: if $rows != 0 then
        tdLog.info('tdSql.checkRow(0)')
        tdSql.checkRows(0)
        # TSIM: return -1
307
        # TSIM: endi
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
        # TSIM:
        # TSIM:
        # TSIM: print =============== step4
        tdLog.info('=============== step4')
        # TSIM: $i = 4
        i = 4
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM: $tb = $tbPrefix . $i
        tb = "%s%d" % (tbPrefix, i)
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
        # bigint, tgcol2 float)
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)' %
            (mt))
        # TSIM: sql create table $tb using $mt tags( 1, 2 )
        tdLog.info('create table %s using %s tags( 1, 2 )' % (tb, mt))
        tdSql.execute('create table %s using %s tags( 1, 2 )' % (tb, mt))
        # TSIM: sql insert into $tb values(now, 1)
        tdLog.info('insert into %s values(now, 1)' % (tb))
        tdSql.execute('insert into %s values(now, 1)' % (tb))
        # TSIM: sql select * from $mt where tgcol1 = 1
        tdLog.info('select * from %s where tgcol1 = 1' % (mt))
        tdSql.query('select * from %s where tgcol1 = 1' % (mt))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
339
        # TSIM: endi
340 341 342 343
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
344
        # TSIM: endi
345 346 347 348
        # TSIM: if $data02 != 1 then
        tdLog.info('tdSql.checkData(0, 2, 1)')
        tdSql.checkData(0, 2, 1)
        # TSIM: return -1
349
        # TSIM: endi
350 351 352 353
        # TSIM: if $data03 != 2.00000 then
        tdLog.info('tdSql.checkData(0, 3, 2.00000)')
        tdSql.checkData(0, 3, 2.00000)
        # TSIM: return -1
354
        # TSIM: endi
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
        # TSIM:
        # TSIM: sql alter table $tb set tag tgcol1=3
        tdLog.info('alter table %s set tag tgcol1=3' % (tb))
        tdSql.execute('alter table %s set tag tgcol1=3' % (tb))
        # TSIM: sql alter table $tb set tag tgcol2=4
        tdLog.info('alter table %s set tag tgcol2=4' % (tb))
        tdSql.execute('alter table %s set tag tgcol2=4' % (tb))
        # TSIM:
        # TSIM: sql reset query cache
        tdLog.info('reset query cache')
        tdSql.execute('reset query cache')
        # TSIM:
        # TSIM: sql select * from $mt where tgcol1 = 3
        tdLog.info('select * from %s where tgcol1 = 3' % (mt))
        tdSql.query('select * from %s where tgcol1 = 3' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
376
        # TSIM: endi
377 378 379 380
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
381
        # TSIM: endi
382 383 384 385
        # TSIM: if $data02 != 3 then
        tdLog.info('tdSql.checkData(0, 2, 3)')
        tdSql.checkData(0, 2, 3)
        # TSIM: return -1
386
        # TSIM: endi
387 388 389 390
        # TSIM: if $data03 != 4.00000 then
        tdLog.info('tdSql.checkData(0, 3, 4.00000)')
        tdSql.checkData(0, 3, 4.00000)
        # TSIM: return -1
391
        # TSIM: endi
392 393 394 395 396 397 398 399 400 401
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = 4
        tdLog.info('select * from %s where tgcol2 = 4' % (mt))
        tdSql.query('select * from %s where tgcol2 = 4' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
402
        # TSIM: endi
403 404 405 406
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
407
        # TSIM: endi
408 409 410 411
        # TSIM: if $data02 != 3 then
        tdLog.info('tdSql.checkData(0, 2, 3)')
        tdSql.checkData(0, 2, 3)
        # TSIM: return -1
412
        # TSIM: endi
413 414 415 416
        # TSIM: if $data03 != 4.00000 then
        tdLog.info('tdSql.checkData(0, 3, 4.00000)')
        tdSql.checkData(0, 3, 4.00000)
        # TSIM: return -1
417
        # TSIM: endi
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
        # TSIM:
        # TSIM:
        # TSIM: print =============== step5
        tdLog.info('=============== step5')
        # TSIM: $i = 5
        i = 5
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM: $tb = $tbPrefix . $i
        tb = "%s%d" % (tbPrefix, i)
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
        # double, tgcol2 binary(10))
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))' %
            (mt))
        # TSIM: sql create table $tb using $mt tags( 1, '2' )
        tdLog.info('create table %s using %s tags( 1, "2" )' % (tb, mt))
        tdSql.execute('create table %s using %s tags( 1, "2" )' % (tb, mt))
        # TSIM: sql insert into $tb values(now, 1)
        tdLog.info('insert into %s values(now, 1)' % (tb))
        tdSql.execute('insert into %s values(now, 1)' % (tb))
        # TSIM: sql select * from $mt where tgcol2 = '2'
        tdLog.info('select * from %s where tgcol2 = "2"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "2"' % (mt))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
449
        # TSIM: endi
450 451 452 453
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
454
        # TSIM: endi
455 456 457 458
        # TSIM: if $data02 != 1.000000000 then
        tdLog.info('tdSql.checkData(0, 2, 1.000000000)')
        tdSql.checkData(0, 2, 1.000000000)
        # TSIM: return -1
459
        # TSIM: endi
460
        # TSIM: if $data03 != 2 then
461 462
        tdLog.info('tdSql.checkData(0, 3, "2")')
        tdSql.checkData(0, 3, "2")
463
        # TSIM: return -1
464
        # TSIM: endi
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
        # TSIM:
        # TSIM: sql alter table $tb set tag tgcol1=3
        tdLog.info('alter table %s set tag tgcol1=3' % (tb))
        tdSql.execute('alter table %s set tag tgcol1=3' % (tb))
        # TSIM: sql alter table $tb set tag tgcol2='4'
        tdLog.info('alter table %s set tag tgcol2="4"' % (tb))
        tdSql.execute('alter table %s set tag tgcol2="4"' % (tb))
        # TSIM:
        # TSIM: sql reset query cache
        tdLog.info('reset query cache')
        tdSql.execute('reset query cache')
        # TSIM:
        # TSIM: sql select * from $mt where tgcol1 = 3
        tdLog.info('select * from %s where tgcol1 = 3' % (mt))
        tdSql.query('select * from %s where tgcol1 = 3' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
486
        # TSIM: endi
487 488 489 490
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
491
        # TSIM: endi
492 493 494 495
        # TSIM: if $data02 != 3.000000000 then
        tdLog.info('tdSql.checkData(0, 2, 3.000000000)')
        tdSql.checkData(0, 2, 3.000000000)
        # TSIM: return -1
496
        # TSIM: endi
497
        # TSIM: if $data03 != 4 then
498 499
        tdLog.info('tdSql.checkData(0, 3, "4")')
        tdSql.checkData(0, 3, "4")
500
        # TSIM: return -1
501
        # TSIM: endi
502 503 504 505 506 507 508 509 510 511
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = '4'
        tdLog.info('select * from %s where tgcol2 = "4"' % (mt))
        tdSql.query('select * from %s where tgcol2 = "4"' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
512
        # TSIM: endi
513 514 515 516
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
517
        # TSIM: endi
518 519 520 521
        # TSIM: if $data02 != 3.000000000 then
        tdLog.info('tdSql.checkData(0, 2, 3.000000000)')
        tdSql.checkData(0, 2, 3.000000000)
        # TSIM: return -1
522
        # TSIM: endi
523
        # TSIM: if $data03 != 4 then
524 525
        tdLog.info('tdSql.checkData(0, 3, "4")')
        tdSql.checkData(0, 3, "4")
526
        # TSIM: return -1
527
        # TSIM: endi
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
        # TSIM:
        # TSIM: print =============== step6
        tdLog.info('=============== step6')
        # TSIM: $i = 6
        i = 6
        # TSIM: $mt = $mtPrefix . $i
        mt = "%s%d" % (mtPrefix, i)
        # TSIM: $tb = $tbPrefix . $i
        tb = "%s%d" % (tbPrefix, i)
        # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
        # binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5
        # double, tgcol6 binary(20))
        tdLog.info(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' %
            (mt))
        tdSql.execute(
            'create table %s (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))' %
            (mt))
        # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' )
        tdLog.info(
            'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' %
            (tb, mt))
        tdSql.execute(
            'create table %s using %s tags( "1", 2, 3, "4", 5, "6" )' %
            (tb, mt))
        # TSIM: sql insert into $tb values(now, 1)
        tdLog.info('insert into %s values(now, 1)' % (tb))
        tdSql.execute('insert into %s values(now, 1)' % (tb))
        # TSIM: sql select * from $mt where tgcol1 = '1'
        tdLog.info('select * from %s where tgcol1 = "1"' % (mt))
        tdSql.query('select * from %s where tgcol1 = "1"' % (mt))
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
563
        # TSIM: endi
564 565 566 567
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
568
        # TSIM: endi
569
        # TSIM: if $data02 != 1 then
570 571
        tdLog.info('tdSql.checkData(0, 2, "1")')
        tdSql.checkData(0, 2, "1")
572
        # TSIM: return -1
573
        # TSIM: endi
574 575 576 577
        # TSIM: if $data03 != 2 then
        tdLog.info('tdSql.checkData(0, 3, 2)')
        tdSql.checkData(0, 3, 2)
        # TSIM: return -1
578
        # TSIM: endi
579 580 581 582
        # TSIM: if $data04 != 3 then
        tdLog.info('tdSql.checkData(0, 4, 3)')
        tdSql.checkData(0, 4, 3)
        # TSIM: return -1
583
        # TSIM: endi
584
        # TSIM: if $data05 != 4 then
585 586
        tdLog.info('tdSql.checkData(0, 5, "4")')
        tdSql.checkData(0, 5, "4")
587
        # TSIM: return -1
588
        # TSIM: endi
589 590 591 592
        # TSIM: if $data06 != 5.000000000 then
        tdLog.info('tdSql.checkData(0, 6, 5.000000000)')
        tdSql.checkData(0, 6, 5.000000000)
        # TSIM: return -1
593
        # TSIM: endi
594
        # TSIM: if $data07 != 6 then
595 596
        tdLog.info('tdSql.checkData(0, 7, "6")')
        tdSql.checkData(0, 7, "6")
597
        # TSIM: return -1
598
        # TSIM: endi
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
        # TSIM:
        # TSIM: sql alter table $mt drop tag tgcol3
        tdLog.info('alter table %s drop tag tgcol3' % (mt))
        tdSql.execute('alter table %s drop tag tgcol3' % (mt))
        # TSIM: sql alter table $tb set tag tgcol1='7'
        tdLog.info('alter table %s set tag tgcol1="7"' % (tb))
        tdSql.execute('alter table %s set tag tgcol1="7"' % (tb))
        # TSIM: sql alter table $tb set tag tgcol2=8
        tdLog.info('alter table %s set tag tgcol2=8' % (tb))
        tdSql.execute('alter table %s set tag tgcol2=8' % (tb))
        # TSIM: sql alter table $tb set tag tgcol4='9'
        tdLog.info('alter table %s set tag tgcol4="9"' % (tb))
        tdSql.execute('alter table %s set tag tgcol4="9"' % (tb))
        # TSIM: sql alter table $tb set tag tgcol5=10
        tdLog.info('alter table %s set tag tgcol5=10' % (tb))
        tdSql.execute('alter table %s set tag tgcol5=10' % (tb))
        # TSIM: sql alter table $tb set tag tgcol6='11'
        tdLog.info('alter table %s set tag tgcol6="11"' % (tb))
        tdSql.execute('alter table %s set tag tgcol6="11"' % (tb))
        # TSIM:
        # TSIM: sql reset query cache
        tdLog.info('reset query cache')
        tdSql.execute('reset query cache')
        # TSIM:
        # TSIM: sql select * from $mt where tgcol1 = '7'
        tdLog.info('select * from %s where tgcol1 = "7"' % (mt))
        tdSql.query('select * from %s where tgcol1 = "7"' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
632
        # TSIM: endi
633 634 635 636
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
637
        # TSIM: endi
638
        # TSIM: if $data02 != 7 then
639 640
        tdLog.info('tdSql.checkData(0, 2, "7")')
        tdSql.checkData(0, 2, "7")
641
        # TSIM: return -1
642
        # TSIM: endi
643 644 645 646
        # TSIM: if $data03 != 8 then
        tdLog.info('tdSql.checkData(0, 3, 8)')
        tdSql.checkData(0, 3, 8)
        # TSIM: return -1
647
        # TSIM: endi
648
        # TSIM: if $data04 != 9 then
649 650
        tdLog.info('tdSql.checkData(0, 4, "9")')
        tdSql.checkData(0, 4, "9")
651
        # TSIM: return -1
652
        # TSIM: endi
653 654 655 656
        # TSIM: if $data05 != 10.000000000 then
        tdLog.info('tdSql.checkData(0, 5, 10.000000000)')
        tdSql.checkData(0, 5, 10.000000000)
        # TSIM: return -1
657
        # TSIM: endi
658
        # TSIM: if $data06 != 11 then
659 660
        tdLog.info('tdSql.checkData(0, 6, "11")')
        tdSql.checkData(0, 6, "11")
661
        # TSIM: return -1
662
        # TSIM: endi
663 664
        # TSIM: if $data07 != NULL then
        tdLog.info('tdSql.checkData(0, 7, NULL)')
665 666 667 668 669
        try:
            tdSql.checkData(0, 7, None)
        except Exception as e:
            tdLog.info(repr(e))
            tdLog.info("out of range")
670
        # TSIM: return -1
671
        # TSIM: endi
672 673 674 675 676 677 678 679 680 681
        # TSIM:
        # TSIM: sql select * from $mt where tgcol2 = 8
        tdLog.info('select * from %s where tgcol2 = 8' % (mt))
        tdSql.query('select * from %s where tgcol2 = 8' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
682
        # TSIM: endi
683 684 685 686
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
687
        # TSIM: endi
688
        # TSIM: if $data02 != 7 then
689 690
        tdLog.info('tdSql.checkData(0, 2, "7")')
        tdSql.checkData(0, 2, "7")
691
        # TSIM: return -1
692
        # TSIM: endi
693 694 695 696
        # TSIM: if $data03 != 8 then
        tdLog.info('tdSql.checkData(0, 3, 8)')
        tdSql.checkData(0, 3, 8)
        # TSIM: return -1
697
        # TSIM: endi
698
        # TSIM: if $data04 != 9 then
699 700
        tdLog.info('tdSql.checkData(0, 4, "9")')
        tdSql.checkData(0, 4, "9")
701
        # TSIM: return -1
702
        # TSIM: endi
703 704 705 706
        # TSIM: if $data05 != 10.000000000 then
        tdLog.info('tdSql.checkData(0, 5, 10.000000000)')
        tdSql.checkData(0, 5, 10.000000000)
        # TSIM: return -1
707
        # TSIM: endi
708
        # TSIM: if $data06 != 11 then
709 710
        tdLog.info('tdSql.checkData(0, 6, "11")')
        tdSql.checkData(0, 6, "11")
711
        # TSIM: return -1
712
        # TSIM: endi
713 714
        # TSIM: if $data07 != NULL then
        tdLog.info('tdSql.checkData(0, 7, NULL)')
715 716 717 718 719
        try:
            tdSql.checkData(0, 7, None)
        except Exception as e:
            tdLog.info(repr(e))
            tdLog.info("out of range")
720
        # TSIM: return -1
721
        # TSIM: endi
722 723 724 725 726 727 728 729 730 731
        # TSIM:
        # TSIM: sql select * from $mt where tgcol4 = '9'
        tdLog.info('select * from %s where tgcol4 = "9"' % (mt))
        tdSql.query('select * from %s where tgcol4 = "9"' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
732
        # TSIM: endi
733 734 735 736
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
737
        # TSIM: endi
738
        # TSIM: if $data02 != 7 then
739 740
        tdLog.info('tdSql.checkData(0, 2, "7")')
        tdSql.checkData(0, 2, "7")
741
        # TSIM: return -1
742
        # TSIM: endi
743 744 745 746
        # TSIM: if $data03 != 8 then
        tdLog.info('tdSql.checkData(0, 3, 8)')
        tdSql.checkData(0, 3, 8)
        # TSIM: return -1
747
        # TSIM: endi
748
        # TSIM: if $data04 != 9 then
749 750
        tdLog.info('tdSql.checkData(0, 4, "9")')
        tdSql.checkData(0, 4, "9")
751
        # TSIM: return -1
752
        # TSIM: endi
753 754 755 756
        # TSIM: if $data05 != 10.000000000 then
        tdLog.info('tdSql.checkData(0, 5, 10.000000000)')
        tdSql.checkData(0, 5, 10.000000000)
        # TSIM: return -1
757
        # TSIM: endi
758
        # TSIM: if $data06 != 11 then
759 760
        tdLog.info('tdSql.checkData(0, 6, "11")')
        tdSql.checkData(0, 6, "11")
761
        # TSIM: return -1
762
        # TSIM: endi
763 764
        # TSIM: if $data07 != NULL then
        tdLog.info('tdSql.checkData(0, 7, NULL)')
765 766 767 768 769
        try:
            tdSql.checkData(0, 7, None)
        except Exception as e:
            tdLog.info(repr(e))
            tdLog.info("out of range")
770
        # TSIM: return -1
771
        # TSIM: endi
772 773 774 775 776 777 778 779 780 781
        # TSIM:
        # TSIM: sql select * from $mt where tgcol5 = 10
        tdLog.info('select * from %s where tgcol5 = 10' % (mt))
        tdSql.query('select * from %s where tgcol5 = 10' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
782
        # TSIM: endi
783 784 785 786
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
787
        # TSIM: endi
788
        # TSIM: if $data02 != 7 then
789 790
        tdLog.info('tdSql.checkData(0, 2, "7")')
        tdSql.checkData(0, 2, "7")
791
        # TSIM: return -1
792
        # TSIM: endi
793 794 795 796
        # TSIM: if $data03 != 8 then
        tdLog.info('tdSql.checkData(0, 3, 8)')
        tdSql.checkData(0, 3, 8)
        # TSIM: return -1
797
        # TSIM: endi
798
        # TSIM: if $data04 != 9 then
799 800
        tdLog.info('tdSql.checkData(0, 4, "9")')
        tdSql.checkData(0, 4, "9")
801
        # TSIM: return -1
802
        # TSIM: endi
803 804 805 806
        # TSIM: if $data05 != 10.000000000 then
        tdLog.info('tdSql.checkData(0, 5, 10.000000000)')
        tdSql.checkData(0, 5, 10.000000000)
        # TSIM: return -1
807
        # TSIM: endi
808
        # TSIM: if $data06 != 11 then
809 810
        tdLog.info('tdSql.checkData(0, 6, "11")')
        tdSql.checkData(0, 6, "11")
811
        # TSIM: return -1
812
        # TSIM: endi
813 814
        # TSIM: if $data07 != NULL then
        tdLog.info('tdSql.checkData(0, 7, NULL)')
815 816 817 818 819
        try:
            tdSql.checkData(0, 7, None)
        except Exception as e:
            tdLog.info(repr(e))
            tdLog.info("out of range")
820
        # TSIM: return -1
821
        # TSIM: endi
822 823 824 825 826 827 828 829 830 831
        # TSIM:
        # TSIM: sql select * from $mt where tgcol6 = '11'
        tdLog.info('select * from %s where tgcol6 = "11"' % (mt))
        tdSql.query('select * from %s where tgcol6 = "11"' % (mt))
        # TSIM: print $data01 $data02 $data03
        tdLog.info('$data01 $data02 $data03')
        # TSIM: if $rows != 1 then
        tdLog.info('tdSql.checkRow(1)')
        tdSql.checkRows(1)
        # TSIM: return -1
832
        # TSIM: endi
833 834 835 836
        # TSIM: if $data01 != 1 then
        tdLog.info('tdSql.checkData(0, 1, 1)')
        tdSql.checkData(0, 1, 1)
        # TSIM: return -1
837
        # TSIM: endi
838
        # TSIM: if $data02 != 7 then
839 840
        tdLog.info('tdSql.checkData(0, 2, "7")')
        tdSql.checkData(0, 2, "7")
841
        # TSIM: return -1
842
        # TSIM: endi
843 844 845 846
        # TSIM: if $data03 != 8 then
        tdLog.info('tdSql.checkData(0, 3, 8)')
        tdSql.checkData(0, 3, 8)
        # TSIM: return -1
847
        # TSIM: endi
848
        # TSIM: if $data04 != 9 then
849 850
        tdLog.info('tdSql.checkData(0, 4, "9")')
        tdSql.checkData(0, 4, "9")
851
        # TSIM: return -1
852
        # TSIM: endi
853 854 855 856
        # TSIM: if $data05 != 10.000000000 then
        tdLog.info('tdSql.checkData(0, 5, 10.000000000)')
        tdSql.checkData(0, 5, 10.000000000)
        # TSIM: return -1
857
        # TSIM: endi
858
        # TSIM: if $data06 != 11 then
859 860
        tdLog.info('tdSql.checkData(0, 6, "11")')
        tdSql.checkData(0, 6, "11")
861
        # TSIM: return -1
862
        # TSIM: endi
863 864
        # TSIM: if $data07 != NULL then
        tdLog.info('tdSql.checkData(0, 7, NULL)')
865 866 867 868 869
        try:
            tdSql.checkData(0, 7, None)
        except Exception as e:
            tdLog.info(repr(e))
            tdLog.info("out of range")
870
        # TSIM: return -1
871
        # TSIM: endi
872 873 874 875
        # TSIM:
        # TSIM: print =============== clear
        tdLog.info('=============== clear')
        # TSIM: sql drop database $db
876 877
        tdLog.info('drop database db')
        tdSql.execute('drop database db')
878 879 880 881 882 883 884
        # 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
885
        # TSIM: endi
886 887 888 889 890 891 892 893 894 895 896
        # 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())