Merge pull request #1962 from taosdata/feature/add-tag-and-alter-table-cases

add more tag cases.
This commit is contained in:
Shengliang Guan 2020-05-19 22:05:53 +08:00 committed by GitHub
commit e5785734a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 19717 additions and 159 deletions

1332
tests/pytest/tag_lite/3.py Normal file

File diff suppressed because it is too large Load Diff

1877
tests/pytest/tag_lite/4.py Normal file

File diff suppressed because it is too large Load Diff

2306
tests/pytest/tag_lite/5.py Normal file

File diff suppressed because it is too large Load Diff

2754
tests/pytest/tag_lite/6.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,584 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_bi_db
# TSIM: $tbPrefix = ta_bi_tb
tbPrefix = "ta_bi_tb"
# TSIM: $mtPrefix = ta_bi_mt
mtPrefix = "ta_bi_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
# bigint)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bigint)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,588 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_by_db
# TSIM: $tbPrefix = ta_by_tb
tbPrefix = "ta_by_tb"
# TSIM: $mtPrefix = ta_by_mt
mtPrefix = "ta_by_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(10))
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( '0' )
tdLog.info('create table %s using %s tags( "0" )' % (tb, mt))
tdSql.execute('create table %s using %s tags( "0" )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( '1' )
tdLog.info('create table %s using %s tags( "1" )' % (tb, mt))
tdSql.execute('create table %s using %s tags( "1" )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = '0'
tdLog.info('select * from %s where tgcol = "0"' % (mt))
tdSql.query('select * from %s where tgcol = "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '0'
tdLog.info('select * from %s where tgcol = "0"' % (mt))
tdSql.query('select * from %s where tgcol = "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1'
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1'
# group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1" group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,799 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( '1', '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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '1'
tdLog.info('select * from %s where tgcol = "1"' % (mt))
tdSql.query('select * from %s where tgcol = "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '1'
tdLog.info('select * from %s where tgcol <> "1"' % (mt))
tdSql.query('select * from %s where tgcol <> "1"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = '0'
tdLog.info('select * from %s where tgcol = "0"' % (mt))
tdSql.query('select * from %s where tgcol = "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> '0'
tdLog.info('select * from %s where tgcol <> "0"' % (mt))
tdSql.query('select * from %s where tgcol <> "0"' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1'
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = "1"' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,583 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_bo_db
# TSIM: $tbPrefix = ta_bo_tb
tbPrefix = "ta_bo_tb"
# TSIM: $mtPrefix = ta_bo_mt
mtPrefix = "ta_bo_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 bool)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: print expect 100, actual:$rows
tdLog.info('expect 100, actual:$rows')
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = true
tdLog.info('select * from %s where tgcol = true' % (mt))
tdSql.query('select * from %s where tgcol = true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> true
tdLog.info('select * from %s where tgcol <> true' % (mt))
tdSql.query('select * from %s where tgcol <> true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = false
tdLog.info('select * from %s where tgcol = false' % (mt))
tdSql.query('select * from %s where tgcol = false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> false
tdLog.info('select * from %s where tgcol <> false' % (mt))
tdSql.query('select * from %s where tgcol <> false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: sql select * from $mt where ts > now + 4m and tgcol = true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false
# and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
# group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true 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 = true group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print 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 $mt interval(1d) group by tgcol')
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,793 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_bob_db
# TSIM: $tbPrefix = ta_bob_tb
tbPrefix = "ta_bob_tb"
# TSIM: $mtPrefix = ta_bob_mt
mtPrefix = "ta_bob_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 bool,
# tgcol2 binary(5))
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 binary(5))' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = true
tdLog.info('select * from %s where tgcol = true' % (mt))
tdSql.query('select * from %s where tgcol = true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> true
tdLog.info('select * from %s where tgcol <> true' % (mt))
tdSql.query('select * from %s where tgcol <> true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = false
tdLog.info('select * from %s where tgcol = false' % (mt))
tdSql.query('select * from %s where tgcol = false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> false
tdLog.info('select * from %s where tgcol <> false' % (mt))
tdSql.query('select * from %s where tgcol <> false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: sql select * from $mt where ts > now + 4m and tgcol = true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false
# and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select * 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = '1' and
# tgcol = true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 = "1" and tgcol = true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '1' and
# tgcol <> true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 <> "1" and tgcol <> true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = '0' and
# tgcol = false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol2 = "0" and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> '0' and
# tgcol <> false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol2 <> "0" and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = '0' and
# tgcol = false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol2 = "0" and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> '0'
# and tgcol <> false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol2 <> "0" and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol2 <> '0' and tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> "0" and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> '0' and
# ts < now + 5m and ts < now + 5m and tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 <> "0" and ts < now + 5m and ts < now + 5m and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# TSIM:
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and
# tgcol2 = '1'
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true 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 = true 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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 = true
# group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true 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 = true group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# TSIM:
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true 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 = true 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 = true 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,825 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_boi_db
# TSIM: $tbPrefix = ta_boi_tb
tbPrefix = "ta_boi_tb"
# TSIM: $mtPrefix = ta_boi_mt
mtPrefix = "ta_boi_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 bool,
# tgcol2 int)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 int)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = true
tdLog.info('select * from %s where tgcol = true' % (mt))
tdSql.query('select * from %s where tgcol = true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> true
tdLog.info('select * from %s where tgcol <> true' % (mt))
tdSql.query('select * from %s where tgcol <> true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = false
tdLog.info('select * from %s where tgcol = false' % (mt))
tdSql.query('select * from %s where tgcol = false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> false
tdLog.info('select * from %s where tgcol <> false' % (mt))
tdSql.query('select * from %s where tgcol <> false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 = true
tdLog.info('select * from %s where tgcol2 = true' % (mt))
tdSql.query('select * from %s where tgcol2 = true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 <> true
tdLog.info('select * from %s where tgcol2 <> true' % (mt))
tdSql.query('select * from %s where tgcol2 <> true' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 = false
tdLog.info('select * from %s where tgcol2 = false' % (mt))
tdSql.query('select * from %s where tgcol2 = false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 <> false
tdLog.info('select * from %s where tgcol2 <> false' % (mt))
tdSql.query('select * from %s where tgcol2 <> false' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: sql select * from $mt where ts > now + 4m and tgcol = true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol = true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol = false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol <> false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol <> false
# and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol <> false and ts < now + 5m' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select * 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 = 1 and
# tgcol = true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 = 1 and tgcol = true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 1 and
# tgcol <> true
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> true' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 <> 1 and tgcol <> true' %
(mt))
# TSIM: if $rows != 75 then
tdLog.info('tdSql.checkRow(75)')
tdSql.checkRows(75)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol2 = 0 and
# tgcol = false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol2 = 0 and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts < now + 4m and tgcol2 <> 0 and
# tgcol <> false
tdLog.info(
'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts < now + 4m and tgcol2 <> 0 and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 = 0 and
# tgcol = false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol2 = 0 and tgcol = false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts <= now + 4m and tgcol2 <> 0 and
# tgcol <> false
tdLog.info(
'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts <= now + 4m and tgcol2 <> 0 and tgcol <> false' %
(mt))
# TSIM: if $rows != 25 then
tdLog.info('tdSql.checkRow(25)')
tdSql.checkRows(25)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and ts < now + 5m and
# tgcol2 <> 0 and tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m and tgcol2 <> 0 and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where ts > now + 4m and tgcol2 <> 0 and
# ts < now + 5m and ts < now + 5m and tgcol <> false
tdLog.info(
'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false' %
(mt))
tdSql.query(
'select * from %s where ts > now + 4m and tgcol2 <> 0 and ts < now + 5m and ts < now + 5m and tgcol <> false' %
(mt))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# TSIM:
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true and
# tgcol2 = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true 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 = true 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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 = true
# group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = true 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 = true group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# TSIM:
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = true 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 = true 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 = true 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,874 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_ch_db
# TSIM: $tbPrefix = ta_ch_tb
# TSIM: $mtPrefix = ta_ch_mt
# TSIM: $tbNum = 10
# TSIM: $rowNum = 20
# TSIM: $totalNum = 200
# TSIM:
# TSIM: print =============== step1
tdLog.info('=============== step1')
# TSIM: $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
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
# bool, tgcol2 int)
tdLog.info(
"create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)")
tdSql.execute(
'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bool, tgcol2 int)')
# TSIM: sql create table $tb using $mt tags( 1, 2 )
tdLog.info("create table tb2 using $mt tags( 1, 2 )")
tdSql.execute('create table tb2 using $mt tags( 1, 2 )')
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb2 values(now, 1)")
tdSql.execute("insert into tb2 values(now, 1)")
# TSIM: sql select * from $mt where tgcol1 = 1
tdLog.info('select * from $mt where tgcol1 = 1')
tdSql.query('select * from $mt where tgcol1 = 1')
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql alter table $mt change tag tagcx tgcol3 -x step21
# TSIM: return -1
# TSIM: step21:
# TSIM: sql alter table $mt change tag tgcol1 tgcol2 -x step22
# TSIM: return -1
# TSIM: step22:
# TSIM: sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20
# TSIM: return -1
# TSIM: step20:
# TSIM:
# TSIM: sql alter table $mt change tag tgcol1 tgcol3
# TSIM: sql alter table $mt change tag tgcol2 tgcol4
# TSIM: sql alter table $mt change tag tgcol4 tgcol3 -x step23
# TSIM: return -1
# TSIM: step23:
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: $i = 3
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
# smallint, tgcol2 tinyint)
tdLog.info(
"create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)")
tdSql.execute(
'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 smallint, tgcol2 tinyint)')
# TSIM: sql create table $tb using $mt tags( 1, 2 )
tdLog.info("create table tb3 using $mt tags( 1, 2 )")
tdSql.execute('create table tb3 using $mt tags( 1, 2 )')
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb3 values(now, 1)")
tdSql.execute("insert into tb3 values(now, 1)")
# TSIM: sql select * from $mt where tgcol1 = 1
tdLog.info('select * from $mt where tgcol1 = 1')
tdSql.query('select * from $mt where tgcol1 = 1')
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql alter table $mt change tag tgcol1 tgcol3
# TSIM: sql alter table $mt change tag tgcol2 tgcol4
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: $i = 4
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
# bigint, tgcol2 float)
tdLog.info(
"create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)")
tdSql.execute(
'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 bigint, tgcol2 float)')
# TSIM: sql create table $tb using $mt tags( 1, 2 )
tdLog.info("create table tb4 using $mt tags( 1, 2 )")
tdSql.execute('create table tb4 using $mt tags( 1, 2 )')
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb4 values(now, 1)")
tdSql.execute("insert into tb4 values(now, 1)")
# TSIM: sql select * from $mt where tgcol1 = 1
tdLog.info('select * from $mt where tgcol1 = 1')
tdSql.query('select * from $mt where tgcol1 = 1')
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2.00000 then
tdLog.info('tdSql.checkData(0, 3, 2.00000)')
tdSql.checkData(0, 3, 2.00000)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql alter table $mt change tag tgcol1 tgcol3
# TSIM: sql alter table $mt change tag tgcol2 tgcol4
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: $i = 5
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol1
# double, tgcol2 binary(10))
tdLog.info(
"create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))")
tdSql.execute(
'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 double, tgcol2 binary(10))')
# TSIM: sql create table $tb using $mt tags( 1, '2' )
tdLog.info("create table tb5 using $mt tags( 1, '2' )")
tdSql.execute('create table tb5 using $mt tags( 1, '2' )')
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb5 values(now, 1)")
tdSql.execute("insert into tb5 values(now, 1)")
# TSIM: sql select * from $mt where tgcol2 = '2'
tdLog.info('select * from $mt where tgcol2 = '2'')
tdSql.query('select * from $mt where tgcol2 = '2'')
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1.000000000 then
tdLog.info('tdSql.checkData(0, 2, 1.000000000)')
tdSql.checkData(0, 2, 1.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql alter table $mt change tag tgcol1 tgcol3
# TSIM: sql alter table $mt change tag tgcol2 tgcol4
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: $i = 6
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $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 $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))")
tdSql.execute(
'create table $mt (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))')
# TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' )
tdLog.info("create table tb6 using $mt tags( '1', 2, 3, '4', 5, '6' )")
tdSql.execute('create table tb6 using $mt tags( '1', 2, 3, '4', 5, '6' )')
# TSIM: sql insert into $tb values(now, 1)
tdLog.info("insert into tb6 values(now, 1)")
tdSql.execute("insert into tb6 values(now, 1)")
# TSIM: sql select * from $mt where tgcol1 = '1'
tdLog.info('select * from $mt where tgcol1 = '1'')
tdSql.query('select * from $mt where tgcol1 = '1'')
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 3 then
tdLog.info('tdSql.checkData(0, 4, 3)')
tdSql.checkData(0, 4, 3)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 4 then
tdLog.info('tdSql.checkData(0, 5, 4)')
tdSql.checkData(0, 5, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 6, 5.000000000)')
tdSql.checkData(0, 6, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != 6 then
tdLog.info('tdSql.checkData(0, 7, 6)')
tdSql.checkData(0, 7, 6)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql alter table $mt drop tag tgcol3
# TSIM: sql reset query cache
# TSIM: sql alter table $mt change tag tgcol4 tgcol3
# TSIM: sql alter table $mt change tag tgcol1 tgcol7
# TSIM: sql alter table $mt change tag tgcol2 tgcol8
# TSIM: sql reset query cache
# TSIM: sql alter table $mt change tag tgcol3 tgcol9
# TSIM: sql alter table $mt change tag tgcol5 tgcol10
# TSIM: sql alter table $mt change tag tgcol6 tgcol11
# TSIM:
# TSIM: sleep 5000
# TSIM: sql reset query cache
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: $i = 2
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM:
# TSIM: sql select * from $mt where tgcol1 = 1 -x step24
tdLog.info('select * from $mt where tgcol1 = 1 -x step24')
tdSql.error('select * from $mt where tgcol1 = 14')
# TSIM: return -1
# TSIM: step24:
# TSIM: sql select * from $mt where tgcol2 = 1 -x step25
tdLog.info('select * from $mt where tgcol2 = 1 -x step25')
tdSql.error('select * from $mt where tgcol2 = 15')
# TSIM: return -1
# TSIM: step25:
# TSIM:
# TSIM: sql select * from $mt where tgcol3 = 1
tdLog.info('select * from $mt where tgcol3 = 1')
tdSql.query('select * from $mt where tgcol3 = 1')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol4 = 2
tdLog.info('select * from $mt where tgcol4 = 2')
tdSql.query('select * from $mt where tgcol4 = 2')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: $i = 3
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM:
# TSIM: sql select * from $mt where tgcol1 = 1 -x step31
tdLog.info('select * from $mt where tgcol1 = 1 -x step31')
tdSql.error('select * from $mt where tgcol1 = 11')
# TSIM: return -1
# TSIM: step31:
# TSIM: sql select * from $mt where tgcol2 = 1 -x step32
tdLog.info('select * from $mt where tgcol2 = 1 -x step32')
tdSql.error('select * from $mt where tgcol2 = 12')
# TSIM: return -1
# TSIM: step32:
# TSIM:
# TSIM: sql select * from $mt where tgcol3 = 1
tdLog.info('select * from $mt where tgcol3 = 1')
tdSql.query('select * from $mt where tgcol3 = 1')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol4 = 2
tdLog.info('select * from $mt where tgcol4 = 2')
tdSql.query('select * from $mt where tgcol4 = 2')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: $i = 4
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM:
# TSIM: sql select * from $mt where tgcol1 = 1 -x step41
tdLog.info('select * from $mt where tgcol1 = 1 -x step41')
tdSql.error('select * from $mt where tgcol1 = 11')
# TSIM: return -1
# TSIM: step41:
# TSIM: sql select * from $mt where tgcol2 = 1 -x step42
tdLog.info('select * from $mt where tgcol2 = 1 -x step42')
tdSql.error('select * from $mt where tgcol2 = 12')
# TSIM: return -1
# TSIM: step42:
# TSIM:
# TSIM: sql select * from $mt where tgcol3 = 1
tdLog.info('select * from $mt where tgcol3 = 1')
tdSql.query('select * from $mt where tgcol3 = 1')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2.00000 then
tdLog.info('tdSql.checkData(0, 3, 2.00000)')
tdSql.checkData(0, 3, 2.00000)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol4 = 2
tdLog.info('select * from $mt where tgcol4 = 2')
tdSql.query('select * from $mt where tgcol4 = 2')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2.00000 then
tdLog.info('tdSql.checkData(0, 3, 2.00000)')
tdSql.checkData(0, 3, 2.00000)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: $i = 5
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM:
# TSIM: sql select * from $mt where tgcol1 = 1 -x step51
tdLog.info('select * from $mt where tgcol1 = 1 -x step51')
tdSql.error('select * from $mt where tgcol1 = 11')
# TSIM: return -1
# TSIM: step51:
# TSIM: sql select * from $mt where tgcol2 = 1 -x step52
tdLog.info('select * from $mt where tgcol2 = 1 -x step52')
tdSql.error('select * from $mt where tgcol2 = 12')
# TSIM: return -1
# TSIM: step52:
# TSIM:
# TSIM: sql select * from $mt where tgcol3 = 1
tdLog.info('select * from $mt where tgcol3 = 1')
tdSql.query('select * from $mt where tgcol3 = 1')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1.000000000 then
tdLog.info('tdSql.checkData(0, 2, 1.000000000)')
tdSql.checkData(0, 2, 1.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol4 = '2'
tdLog.info('select * from $mt where tgcol4 = '2'')
tdSql.query('select * from $mt where tgcol4 = '2'')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1.000000000 then
tdLog.info('tdSql.checkData(0, 2, 1.000000000)')
tdSql.checkData(0, 2, 1.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: $i = 6
# TSIM: $mt = $mtPrefix . $i
# TSIM: $tb = $tbPrefix . $i
# TSIM:
# TSIM: sql select * from $mt where tgcol1 = 1 -x step61
tdLog.info('select * from $mt where tgcol1 = 1 -x step61')
tdSql.error('select * from $mt where tgcol1 = 11')
# TSIM: return -1
# TSIM: step61:
# TSIM: sql select * from $mt where tgcol2 = 1 -x step62
tdLog.info('select * from $mt where tgcol2 = 1 -x step62')
tdSql.error('select * from $mt where tgcol2 = 12')
# TSIM: return -1
# TSIM: step62:
# TSIM: sql select * from $mt where tgcol3 = 1 -x step63
tdLog.info('select * from $mt where tgcol3 = 1 -x step63')
tdSql.error('select * from $mt where tgcol3 = 13')
# TSIM: return -1
# TSIM: step63:
# TSIM: sql select * from $mt where tgcol4 = 1 -x step64
tdLog.info('select * from $mt where tgcol4 = 1 -x step64')
tdSql.error('select * from $mt where tgcol4 = 14')
# TSIM: return -1
# TSIM: step64:
# TSIM: sql select * from $mt where tgcol5 = 1 -x step65
tdLog.info('select * from $mt where tgcol5 = 1 -x step65')
tdSql.error('select * from $mt where tgcol5 = 15')
# TSIM: return -1
# TSIM: step65:
# TSIM: sql select * from $mt where tgcol6 = 1 -x step66
tdLog.info('select * from $mt where tgcol6 = 1 -x step66')
tdSql.error('select * from $mt where tgcol6 = 16')
# TSIM: return -1
# TSIM: step66:
# TSIM:
# TSIM: sql select * from $mt where tgcol7 = '1'
tdLog.info('select * from $mt where tgcol7 = '1'')
tdSql.query('select * from $mt where tgcol7 = '1'')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 4 then
tdLog.info('tdSql.checkData(0, 4, 4)')
tdSql.checkData(0, 4, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 5, 5.000000000)')
tdSql.checkData(0, 5, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 6 then
tdLog.info('tdSql.checkData(0, 6, 6)')
tdSql.checkData(0, 6, 6)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
tdSql.checkData(0, 7, None)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol8 = 2
tdLog.info('select * from $mt where tgcol8 = 2')
tdSql.query('select * from $mt where tgcol8 = 2')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 4 then
tdLog.info('tdSql.checkData(0, 4, 4)')
tdSql.checkData(0, 4, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 5, 5.000000000)')
tdSql.checkData(0, 5, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 6 then
tdLog.info('tdSql.checkData(0, 6, 6)')
tdSql.checkData(0, 6, 6)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
tdSql.checkData(0, 7, None)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol9 = '4'
tdLog.info('select * from $mt where tgcol9 = '4'')
tdSql.query('select * from $mt where tgcol9 = '4'')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 4 then
tdLog.info('tdSql.checkData(0, 4, 4)')
tdSql.checkData(0, 4, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 5, 5.000000000)')
tdSql.checkData(0, 5, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 6 then
tdLog.info('tdSql.checkData(0, 6, 6)')
tdSql.checkData(0, 6, 6)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
tdSql.checkData(0, 7, None)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol10 = 5
tdLog.info('select * from $mt where tgcol10 = 5')
tdSql.query('select * from $mt where tgcol10 = 5')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 4 then
tdLog.info('tdSql.checkData(0, 4, 4)')
tdSql.checkData(0, 4, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 5, 5.000000000)')
tdSql.checkData(0, 5, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 6 then
tdLog.info('tdSql.checkData(0, 6, 6)')
tdSql.checkData(0, 6, 6)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
tdSql.checkData(0, 7, None)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: sql select * from $mt where tgcol11 = '6'
tdLog.info('select * from $mt where tgcol11 = '6'')
tdSql.query('select * from $mt where tgcol11 = '6'')
# 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
#TSIM: endi
# TSIM: if $data01 != 1 then
tdLog.info('tdSql.checkData(0, 1, 1)')
tdSql.checkData(0, 1, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data02 != 1 then
tdLog.info('tdSql.checkData(0, 2, 1)')
tdSql.checkData(0, 2, 1)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data03 != 2 then
tdLog.info('tdSql.checkData(0, 3, 2)')
tdSql.checkData(0, 3, 2)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data04 != 4 then
tdLog.info('tdSql.checkData(0, 4, 4)')
tdSql.checkData(0, 4, 4)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data05 != 5.000000000 then
tdLog.info('tdSql.checkData(0, 5, 5.000000000)')
tdSql.checkData(0, 5, 5.000000000)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data06 != 6 then
tdLog.info('tdSql.checkData(0, 6, 6)')
tdSql.checkData(0, 6, 6)
# TSIM: return -1
#TSIM: endi
# TSIM: if $data07 != NULL then
tdLog.info('tdSql.checkData(0, 7, NULL)')
tdSql.checkData(0, 7, None)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,197 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_co_db
# TSIM: $tbPrefix = ta_co_tb
tbPrefix = "ta_co_tb"
# TSIM: $mtPrefix = ta_co_mt
mtPrefix = "ta_co_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:
# TSIM: $i = 0
i = 0
# TSIM: sql create table $mt (ts timestamp, tbcol int, tbcol2
# binary(10)) TAGS(tgcol int, tgcol2 binary(10))
tdLog.info(
'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int, tbcol2 binary(10)) TAGS(tgcol int, tgcol2 binary(10))' %
(mt))
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM:
# TSIM: $i = 0
i = 0
# 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:
# TSIM: $i = 1
i = 1
# 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:
# TSIM: $i = 2
i = 2
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( '2', '2' )
tdLog.info('create table %s using %s tags( "2", "2" )' % (tb, mt))
tdSql.execute('create table %s using %s tags( "2", "2" )' % (tb, mt))
# TSIM:
# TSIM: $i = 3
i = 3
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( '3', 3 )
tdLog.info('create table %s using %s tags( "3", 3 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( "3", 3 )' % (tb, mt))
# TSIM:
# TSIM: sql show tables
tdLog.info('show tables')
tdSql.query('show tables')
# TSIM: if $rows != 4 then
tdLog.info('tdSql.checkRow(4)')
tdSql.checkRows(4)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql insert into $tb values(now, 0, '0')
tdLog.info('insert into %s values(now, 0, "0")' % (tb))
tdSql.execute('insert into %s values(now, 0, "0")' % (tb))
# TSIM:
# TSIM: $i = 1
i = 1
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql insert into $tb values(now, 1, 1 )
tdLog.info('insert into %s values(now, 1, 1 )' % (tb))
tdSql.execute('insert into %s values(now, 1, 1 )' % (tb))
# TSIM:
# TSIM: $i = 2
i = 2
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql insert into $tb values(now, '2', '2')
tdLog.info('insert into %s values(now, "2", "2")' % (tb))
tdSql.execute('insert into %s values(now, "2", "2")' % (tb))
# TSIM:
# TSIM: $i = 3
i = 3
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql insert into $tb values(now, '3', 3)
tdLog.info('insert into %s values(now, "3", 3)' % (tb))
tdSql.execute('insert into %s values(now, "3", 3)' % (tb))
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# 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 != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != 4 then
tdLog.info('tdSql.checkRow(4)')
tdSql.checkRows(4)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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 != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,584 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_do_db
# TSIM: $tbPrefix = ta_do_tb
tbPrefix = "ta_do_tb"
# TSIM: $mtPrefix = ta_do_mt
mtPrefix = "ta_do_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
# double)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol double)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -25,35 +25,40 @@ class TDTestCase:
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
#TSIM: system sh/stop_dnodes.sh # TSIM: system sh/stop_dnodes.sh
#TSIM: system sh/deploy.sh -n dnode1 -i 1 # TSIM: system sh/deploy.sh -n dnode1 -i 1
#TSIM: system sh/exec.sh -n dnode1 -s start # TSIM: system sh/exec.sh -n dnode1 -s start
#TSIM: # TSIM:
#TSIM: sleep 3000 # TSIM: sleep 3000
#TSIM: sql connect # TSIM: sql connect
#TSIM: # TSIM:
#TSIM: print ======================== dnode1 start # TSIM: print ======================== dnode1 start
tdLog.info('======================== dnode1 start') tdLog.info('======================== dnode1 start')
#TSIM: # TSIM:
dbPrefix = "ta_fi_db" dbPrefix = "ta_fi_db"
tbPrefix = "ta_fi_tb" tbPrefix = "ta_fi_tb"
mtPrefix = "ta_fi_mt" mtPrefix = "ta_fi_mt"
#TSIM: $tbNum = 10 # TSIM: $tbNum = 10
rowNum = 20 rowNum = 20
#TSIM: $totalNum = 200 # TSIM: $totalNum = 200
#TSIM: # TSIM:
#TSIM: print =============== step1 # TSIM: print =============== step1
tdLog.info('=============== step1') tdLog.info('=============== step1')
i = 0 i = 0
#TSIM: $db = $dbPrefix . $i # TSIM: $db = $dbPrefix . $i
mt = "%s%d" % (mtPrefix, i) mt = "%s%d" % (mtPrefix, i)
#TSIM: # TSIM:
#TSIM: sql create database $db # TSIM: sql create database $db
#TSIM: sql use $db # TSIM: sql use $db
#TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol binary(10)) # TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol
tdLog.info("create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))" % mt) # binary(10))
tdSql.execute('create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' % mt) tdLog.info(
#TSIM: "create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))" %
mt)
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol binary(10))' %
mt)
# TSIM:
i = 0 i = 0
while (i < 5): while (i < 5):
tb = "tbPrefix%d" % i tb = "tbPrefix%d" % i
@ -63,202 +68,299 @@ class TDTestCase:
x = 0 x = 0
while (x < rowNum): while (x < rowNum):
ms = "%dm" % x ms = "%dm" % x
tdLog.info("insert into %s values (now + %s , %d)" % (tb, ms, x)) tdLog.info(
tdSql.execute("insert into %s values (now + %s , %d)" % (tb, ms, x)) "insert into %s values (now + %s , %d)" %
(tb, ms, x))
tdSql.execute(
"insert into %s values (now + %s , %d)" %
(tb, ms, x))
x = x + 1 x = x + 1
i = i + 1 i = i + 1
while (i < 10): while (i < 10):
tb = "%s%d" % (tbPrefix , i) tb = "%s%d" % (tbPrefix, i)
#TSIM: sql create table $tb using $mt tags( '1' ) # TSIM: sql create table $tb using $mt tags( '1' )
tdLog.info("create table %s using %s tags( '1' )" % (tb, mt)) tdLog.info("create table %s using %s tags( '1' )" % (tb, mt))
tdSql.execute("create table %s using %s tags( '1' )" % (tb, mt)) tdSql.execute("create table %s using %s tags( '1' )" % (tb, mt))
x = 0 x = 0
while (x < rowNum): while (x < rowNum):
ms = "%dm" % x ms = "%dm" % x
#TSIM: sql insert into $tb values (now + $ms , $x ) # TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info("insert into %s values (now + %s, %d )" % (tb, ms, x)) tdLog.info(
tdSql.execute("insert into %s values (now + %s, %d )" % (tb, ms, x)) "insert into %s values (now + %s, %d )" %
(tb, ms, x))
tdSql.execute(
"insert into %s values (now + %s, %d )" %
(tb, ms, x))
x = x + 1 x = x + 1
i = i + 1 i = i + 1
#TSIM: # TSIM:
#TSIM: print =============== step2 # TSIM: print =============== step2
tdLog.info('=============== step2') tdLog.info('=============== step2')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1' # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = '1'
tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" % mt) tdLog.info(
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = '1'" %
tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) mt)
#TSIM: if $data00 != 100 then 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(
"%s %s %s %s %s %s %s" %
(tdSql.getData(
0, 0), tdSql.getData(
0, 1), tdSql.getData(
0, 2), tdSql.getData(
0, 3), tdSql.getData(
0, 4), tdSql.getData(
0, 5), tdSql.getData(
0, 6)))
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x step2 # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt where tg = '1' -x
tdSql.error("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'" % mt) # step2
#TSIM: return -1 tdLog.info(
#TSIM: step2: "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1' -x step2" %
#TSIM: mt)
#TSIM: print =============== step3 tdSql.error(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tg = '1'" %
mt)
# TSIM: return -1
# TSIM: step2:
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3') tdLog.info('=============== step3')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x step3 # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt where noexist = '1' -x
tdSql.error("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'" % mt) # step3
#TSIM: return -1 tdLog.info(
#TSIM: step3: "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1' -x step3" %
#TSIM: mt)
#TSIM: print =============== step4 tdSql.error(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where noexist = '1'" %
mt)
# TSIM: return -1
# TSIM: step3:
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4') tdLog.info('=============== step4')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1'
tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" % mt) tdLog.info(
#TSIM: if $rows != 1 then "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" %
mt)
tdSql.query(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tbcol = '1'" %
mt)
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)') tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1) tdSql.checkRows(1)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: if $data00 != 10 then # TSIM: if $data00 != 10 then
tdLog.info('tdSql.checkData(0, 0, 10)') tdLog.info('tdSql.checkData(0, 0, 10)')
tdSql.checkData(0, 0, 10) tdSql.checkData(0, 0, 10)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== step5 # TSIM: print =============== step5
tdLog.info('=============== step5') tdLog.info('=============== step5')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt
tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) tdLog.info(
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" %
tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0,0), tdSql.getData(0,1), tdSql.getData(0,2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0,5 ), tdSql.getData(0, 6))) mt)
#TSIM: if $data00 != 200 then 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(
"%s %s %s %s %s %s %s" %
(tdSql.getData(
0, 0), tdSql.getData(
0, 1), tdSql.getData(
0, 2), tdSql.getData(
0, 3), tdSql.getData(
0, 4), tdSql.getData(
0, 5), tdSql.getData(
0, 6)))
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)') tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200) tdSql.checkData(0, 0, 200)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== step6 # TSIM: print =============== step6
tdLog.info('=============== step6') tdLog.info('=============== step6')
#TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt -x step6 # TSIM: sql select count(tbcol), avg(cc), sum(xx), min(tbcol),
tdLog.info("select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt -x step6
tdSql.error("select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" % mt) tdLog.info(
#TSIM: return -1 "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s -x step6" %
#TSIM: step6: mt)
#TSIM: tdSql.error(
#TSIM: print =============== step7 "select count(tbcol), avg(cc), sum(xx), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s" %
mt)
# TSIM: return -1
# TSIM: step6:
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7') tdLog.info('=============== step7')
#TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from $mt -x step7 # TSIM: sql select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol),
tdLog.info("select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7" % mt) # max(tgcol), first(tgcol), last(tgcol) from $mt -x step7
tdSql.error("select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s" % mt) tdLog.info(
#TSIM: return -1 "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s -x step7" %
#TSIM: step7: mt)
#TSIM: tdSql.error(
#TSIM: print =============== step8 "select count(tgcol), avg(tgcol), sum(tgcol), min(tgcol), max(tgcol), first(tgcol), last(tgcol) from %s" %
mt)
# TSIM: return -1
# TSIM: step7:
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8') tdLog.info('=============== step8')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt group by tbcol
tdSql.query("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol" % mt) tdLog.info(
#TSIM: "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s by tbcol" %
#TSIM: print =============== step9 mt)
tdSql.query(
"select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tbcol" %
mt)
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9') tdLog.info('=============== step9')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x step9 # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info("select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9" % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt group by noexist -x
tdSql.error('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist ' % mt) # step9
#TSIM: return -1 tdLog.info(
#TSIM: step9: "select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist -x step9" %
#TSIM: mt)
#TSIM: print =============== step10 tdSql.error(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by noexist ' %
mt)
# TSIM: return -1
# TSIM: step9:
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10') tdLog.info('=============== step10')
#TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol # TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
tdLog.info('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % mt) # max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdSql.query('select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' % mt) tdLog.info(
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 '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') tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
#TSIM: if $data00 != 100 then # TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== step11 # TSIM: print =============== step11
tdLog.info('=============== step11') tdLog.info('=============== step11')
#TSIM: sql select count(tbcol) as c from $mt group by tbcol # TSIM: sql select count(tbcol) as c from $mt group by tbcol
tdLog.info('select count(tbcol) as c from %s group by tbcol' % mt) tdLog.info('select count(tbcol) as c from %s group by tbcol' % mt)
tdSql.query('select count(tbcol) as c from %s group by tbcol' % mt) tdSql.query('select count(tbcol) as c from %s group by tbcol' % mt)
#TSIM: # TSIM:
#TSIM: print =============== step12 # TSIM: print =============== step12
tdLog.info('=============== step12') tdLog.info('=============== step12')
#TSIM: sql select count(tbcol) as c from $mt group by noexist -x step12 # TSIM: sql select count(tbcol) as c from $mt group by noexist -x
tdLog.info('select count(tbcol) as c from %s group by noexist -x step12' % mt) # step12
tdLog.info(
'select count(tbcol) as c from %s group by noexist -x step12' %
mt)
tdSql.error('select count(tbcol) as c from %s group by noexist2' % mt) tdSql.error('select count(tbcol) as c from %s group by noexist2' % mt)
#TSIM: return -1 # TSIM: return -1
#TSIM: step12: # TSIM: step12:
#TSIM: # TSIM:
#TSIM: print =============== step13 # TSIM: print =============== step13
tdLog.info('=============== step13') tdLog.info('=============== step13')
#TSIM: sql select count(tbcol) as c from $mt group by tgcol # TSIM: sql select count(tbcol) as c from $mt group by tgcol
tdLog.info('select count(tbcol) as c from %s group by tgcol' % mt) tdLog.info('select count(tbcol) as c from %s group by tgcol' % mt)
tdSql.query('select count(tbcol) as c from %s group by tgcol' % mt) tdSql.query('select count(tbcol) as c from %s group by tgcol' % mt)
#TSIM: print $data00 # TSIM: print $data00
tdLog.info('$data00') tdLog.info('$data00')
#TSIM: if $data00 != 100 then # TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== step14 # TSIM: print =============== step14
tdLog.info('=============== step14') tdLog.info('=============== step14')
#TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol # TSIM: sql select count(tbcol) as c from $mt where ts > 1000 group by
tdLog.info('select count(tbcol) as c from %s where ts > 1000 group by tgcol' % mt) # tgcol
tdSql.query('select count(tbcol) as c from %s where ts > 1000 group by tgcol' % mt) tdLog.info(
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 'select count(tbcol) as c from %s where ts > 1000 group by tgcol' %
mt)
tdSql.query(
'select count(tbcol) as c from %s where ts > 1000 group by tgcol' %
mt)
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) # tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6)))
#TSIM: if $data00 != 100 then # TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
#TSIM: print expect 100, actual $data00 # TSIM: print expect 100, actual $data00
tdLog.info('expect 100, actual $data00') tdLog.info('expect 100, actual $data00')
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== step15 # TSIM: print =============== step15
tdLog.info('=============== step15') tdLog.info('=============== step15')
#TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group by tgcol -x step15 # TSIM: sql select count(tbcol) as c from $mt where noexist < 1 group
tdLog.info('select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15' % mt) # by tgcol -x step15
tdSql.error('select count(tbcol) as c from %s where noexist < 1 group by tgcol5' % mt) tdLog.info(
#TSIM: return -1 'select count(tbcol) as c from %s where noexist < 1 group by tgcol -x step15' %
#TSIM: step15: mt)
#TSIM: tdSql.error(
#TSIM: print =============== step16 'select count(tbcol) as c from %s where noexist < 1 group by tgcol5' %
mt)
# TSIM: return -1
# TSIM: step15:
# TSIM:
# TSIM: print =============== step16
tdLog.info('=============== step16') tdLog.info('=============== step16')
#TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group by tgcol # TSIM: sql select count(tbcol) as c from $mt where tgcol = '1' group
tdLog.info("select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % mt) # by tgcol
tdSql.query("select count(tbcol) as c from %s where tgcol = '1' group by tgcol" % mt) tdLog.info(
#TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06 "select count(tbcol) as c from %s where tgcol = '1' group by tgcol" %
mt)
tdSql.query(
"select count(tbcol) as c from %s where tgcol = '1' group by tgcol" %
mt)
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
# tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6))) # tdLog.info("%s %s %s %s %s %s %s" % (tdSql.getData(0, 0), tdSql.getData(0, 1), tdSql.getData(0, 2), tdSql.getData(0, 3), tdSql.getData(0, 4), tdSql.getData(0, 5), tdSql.getData(0, 6)))
#TSIM: if $data00 != 100 then # TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)') tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100) tdSql.checkData(0, 0, 100)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: print =============== clear # TSIM: print =============== clear
tdLog.info('=============== clear') tdLog.info('=============== clear')
#TSIM: sql drop database $db # TSIM: sql drop database $db
tdLog.info('drop database db') tdLog.info('drop database db')
tdSql.execute('drop database db') tdSql.execute('drop database db')
#TSIM: sql show databases # TSIM: sql show databases
tdLog.info('show databases') tdLog.info('show databases')
tdSql.query('show databases') tdSql.query('show databases')
#TSIM: if $rows != 0 then # TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)') tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0) tdSql.checkRows(0)
#TSIM: return -1 # TSIM: return -1
#TSIM: endi #TSIM: endi
#TSIM: # TSIM:
#TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT # TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end # convert end
def stop(self): def stop(self):

View File

@ -0,0 +1,584 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_fl_db
# TSIM: $tbPrefix = ta_fl_tb
tbPrefix = "ta_fl_tb"
# TSIM: $mtPrefix = ta_fl_mt
mtPrefix = "ta_fl_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
# float)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol float)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,583 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_in_db
# TSIM: $tbPrefix = ta_in_tb
tbPrefix = "ta_in_tb"
# TSIM: $mtPrefix = ta_in_mt
mtPrefix = "ta_in_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)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol int)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,791 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1, '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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,827 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_inf_db
# TSIM: $tbPrefix = ta_inf_tb
tbPrefix = "ta_inf_tb"
# TSIM: $mtPrefix = ta_inf_mt
mtPrefix = "ta_inf_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 float)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol int, tgcol2 float)' %
(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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1, 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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol2 > 0.5
tdLog.info('select * from %s where tgcol2 > 0.5' % (mt))
tdSql.query('select * from %s where tgcol2 > 0.5' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 < 0.5
tdLog.info('select * from %s where tgcol2 < 0.5' % (mt))
tdSql.query('select * from %s where tgcol2 < 0.5' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol2 > 0.5 and tgcol2 < 1.5
tdLog.info(
'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' %
(mt))
tdSql.query(
'select * from %s where tgcol2 > 0.5 and tgcol2 < 1.5' %
(mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,584 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
def run(self):
tdSql.prepare()
# TSIM: system sh/stop_dnodes.sh
# TSIM:
# TSIM:
# TSIM: system sh/deploy.sh -n dnode1 -i 1
# TSIM: system sh/cfg.sh -n dnode1 -c walLevel -v 0
# TSIM: system sh/exec.sh -n dnode1 -s start
# TSIM:
# TSIM: sleep 3000
# TSIM: sql connect
# TSIM:
# TSIM: print ======================== dnode1 start
tdLog.info('======================== dnode1 start')
# TSIM:
# TSIM: $dbPrefix = ta_sm_db
# TSIM: $tbPrefix = ta_sm_tb
tbPrefix = "ta_sm_tb"
# TSIM: $mtPrefix = ta_sm_mt
mtPrefix = "ta_sm_mt"
# TSIM: $tbNum = 10
tbNum = 10
# TSIM: $rowNum = 20
rowNum = 20
# TSIM: $totalNum = 200
totalNum = 200
# TSIM:
# TSIM: print =============== step1
tdLog.info('=============== step1')
# TSIM: $i = 0
i = 0
# TSIM: $db = $dbPrefix . $i
# TSIM: $mt = $mtPrefix . $i
mt = "%s%d" % (mtPrefix, i)
# TSIM:
# TSIM: sql create database $db
# TSIM: sql use $db
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol
# smallint)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol smallint)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,584 @@
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
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_ti_db
# TSIM: $tbPrefix = ta_ti_tb
tbPrefix = "ta_ti_tb"
# TSIM: $mtPrefix = ta_ti_mt
mtPrefix = "ta_ti_mt"
# TSIM: $tbNum = 10
tbNum = 10
# TSIM: $rowNum = 20
rowNum = 20
# TSIM: $totalNum = 200
totalNum = 200
# TSIM:
# TSIM: print =============== step1
tdLog.info('=============== step1')
# TSIM: $i = 0
i = 0
# TSIM: $db = $dbPrefix . $i
# TSIM: $mt = $mtPrefix . $i
mt = "%s%d" % (mtPrefix, i)
# TSIM:
# TSIM: sql create database $db
# TSIM: sql use $db
# TSIM: sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol
# tinyint)
tdLog.info(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' %
(mt))
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol tinyint)' %
(mt))
# TSIM:
# TSIM: $i = 0
i = 0
# TSIM: while $i < 5
while (i < 5):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 0 )
tdLog.info('create table %s using %s tags( 0 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 0 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
ms = "%dm" % x
# TSIM: sql insert into $tb values (now + $ms , $x )
tdLog.info(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
tdSql.execute(
'insert into %s values (now + %s , %d )' %
(tb, ms, x))
# TSIM: $x = $x + 1
x = x + 1
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM: while $i < 10
while (i < 10):
# TSIM: $tb = $tbPrefix . $i
tb = "%s%d" % (tbPrefix, i)
# TSIM: sql create table $tb using $mt tags( 1 )
tdLog.info('create table %s using %s tags( 1 )' % (tb, mt))
tdSql.execute('create table %s using %s tags( 1 )' % (tb, mt))
# TSIM: $x = 0
x = 0
# TSIM: while $x < $rowNum
while (x < rowNum):
# TSIM: $ms = $x . m
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
#TSIM: endw
# TSIM: $i = $i + 1
i = i + 1
#TSIM: endw
# TSIM:
# TSIM: print =============== step2
tdLog.info('=============== step2')
# TSIM: sleep 100
# TSIM: sql select * from $tb
tdLog.info('select * from %s' % (tb))
tdSql.query('select * from %s' % (tb))
# TSIM: if $rows != $rowNum then
tdLog.info('tdSql.checkRow($rowNum)')
tdSql.checkRows(rowNum)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m
tdLog.info('select * from %s where ts < now + 4m' % (tb))
tdSql.query('select * from %s where ts < now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts <= now + 4m
tdLog.info('select * from %s where ts <= now + 4m' % (tb))
tdSql.query('select * from %s where ts <= now + 4m' % (tb))
# TSIM: if $rows != 5 then
tdLog.info('tdSql.checkRow(5)')
tdSql.checkRows(5)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m
tdLog.info('select * from %s where ts > now + 4m' % (tb))
tdSql.query('select * from %s where ts > now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts >= now + 4m
tdLog.info('select * from %s where ts >= now + 4m' % (tb))
tdSql.query('select * from %s where ts >= now + 4m' % (tb))
# TSIM: if $rows != 15 then
tdLog.info('tdSql.checkRow(15)')
tdSql.checkRows(15)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 5m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 5m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts < now + 4m and ts > now + 5m
tdLog.info(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
tdSql.query(
'select * from %s where ts < now + 4m and ts > now + 5m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > 100000 and ts < 100000
tdLog.info('select * from %s where ts > 100000 and ts < 100000' % (tb))
tdSql.query(
'select * from %s where ts > 100000 and ts < 100000' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts < now + 3m
tdLog.info(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts < now + 3m' %
(tb))
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $tb where ts > now + 4m and ts > now + 5m and
# ts < now + 6m
tdLog.info(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
tdSql.query(
'select * from %s where ts > now + 4m and ts > now + 5m and ts < now + 6m' %
(tb))
# TSIM: if $rows != 1 then
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step3
tdLog.info('=============== step3')
# TSIM: sql select * from $mt
tdLog.info('select * from %s' % (mt))
tdSql.query('select * from %s' % (mt))
# TSIM: if $rows != $totalNum then
tdLog.info('tdSql.checkRow($totalNum)')
tdSql.checkRows(totalNum)
# TSIM: return -1
#TSIM: endi
# TSIM:
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step4
tdLog.info('=============== step4')
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 1
tdLog.info('select * from %s where tgcol = 1' % (mt))
tdSql.query('select * from %s where tgcol = 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 1
tdLog.info('select * from %s where tgcol <> 1' % (mt))
tdSql.query('select * from %s where tgcol <> 1' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol = 0
tdLog.info('select * from %s where tgcol = 0' % (mt))
tdSql.query('select * from %s where tgcol = 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM: sql select * from $mt where tgcol <> 0
tdLog.info('select * from %s where tgcol <> 0' % (mt))
tdSql.query('select * from %s where tgcol <> 0' % (mt))
# TSIM: if $rows != 100 then
tdLog.info('tdSql.checkRow(100)')
tdSql.checkRows(100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step5
tdLog.info('=============== step5')
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step6
tdLog.info('=============== step6')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 200 then
tdLog.info('tdSql.checkData(0, 0, 200)')
tdSql.checkData(0, 0, 200)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step7
tdLog.info('=============== step7')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step8
tdLog.info('=============== step8')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM: print =============== step9
tdLog.info('=============== step9')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt group by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step10
tdLog.info('=============== step10')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt where tgcol = 1 group
# by tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s where tgcol = 1 group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data00 != 100 then
tdLog.info('tdSql.checkData(0, 0, 100)')
tdSql.checkData(0, 0, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== step11
tdLog.info('=============== step11')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# 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
#TSIM: endi
# TSIM:
# TSIM:
# TSIM: print =============== step12
tdLog.info('=============== step12')
# TSIM: sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol),
# max(tbcol), first(tbcol), last(tbcol) from $mt interval(1d) group by
# tgcol
tdLog.info(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
tdSql.query(
'select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from %s interval(1d) group by tgcol' %
(mt))
# TSIM: print $data00 $data01 $data02 $data03 $data04 $data05 $data06
tdLog.info('$data00 $data01 $data02 $data03 $data04 $data05 $data06')
# TSIM: if $data01 != 100 then
tdLog.info('tdSql.checkData(0, 1, 100)')
tdSql.checkData(0, 1, 100)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: print =============== clear
tdLog.info('=============== clear')
# TSIM: sql drop database $db
tdLog.info('drop database db')
tdSql.execute('drop database db')
# TSIM: sql show databases
tdLog.info('show databases')
tdSql.query('show databases')
# TSIM: if $rows != 0 then
tdLog.info('tdSql.checkRow(0)')
tdSql.checkRows(0)
# TSIM: return -1
#TSIM: endi
# TSIM:
# TSIM: system sh/exec.sh -n dnode1 -s stop -x SIGINT
# convert end
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -234,13 +234,15 @@ class TDDnode:
if self.running != 0: if self.running != 0:
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
while(processID): while(processID):
killCmd = "kill -INT %s" % processID killCmd = "kill -INT %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
self.running = 0 self.running = 0
tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index))
@ -253,13 +255,15 @@ class TDDnode:
if self.running != 0: if self.running != 0:
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
while(processID): while(processID):
killCmd = "kill -KILL %s" % processID killCmd = "kill -KILL %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
self.running = 0 self.running = 0
tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index))
@ -310,7 +314,8 @@ class TDDnodes:
killCmd = "kill -KILL %s" % processID killCmd = "kill -KILL %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
@ -318,7 +323,8 @@ class TDDnodes:
killCmd = "kill -KILL %s" % processID killCmd = "kill -KILL %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
binPath = os.path.dirname(os.path.realpath(__file__)) binPath = os.path.dirname(os.path.realpath(__file__))
binPath = binPath + "/../../../debug/" binPath = binPath + "/../../../debug/"
@ -416,7 +422,8 @@ class TDDnodes:
killCmd = "kill -KILL %s" % processID killCmd = "kill -KILL %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
@ -424,7 +431,8 @@ class TDDnodes:
killCmd = "kill -KILL %s" % processID killCmd = "kill -KILL %s" % processID
os.system(killCmd) os.system(killCmd)
time.sleep(1) time.sleep(1)
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8") processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8")
# if os.system(cmd) != 0 : # if os.system(cmd) != 0 :
# tdLog.exit(cmd) # tdLog.exit(cmd)

View File

@ -157,8 +157,9 @@ class TDSql:
callerModule = inspect.getmodule(frame[0]) callerModule = inspect.getmodule(frame[0])
callerFilename = callerModule.__file__ callerFilename = callerModule.__file__
tdLog.exit("%s failed: sql:%s, affectedRows:%d != expect:%d" % ( tdLog.exit(
callerFilename, self.sql, self.affectedRows, expectAffectedRows)) "%s failed: sql:%s, affectedRows:%d != expect:%d" %
(callerFilename, self.sql, self.affectedRows, expectAffectedRows))
tdLog.info("sql:%s, affectedRows:%d == expect:%d" % tdLog.info("sql:%s, affectedRows:%d == expect:%d" %
(self.sql, self.affectedRows, expectAffectedRows)) (self.sql, self.affectedRows, expectAffectedRows))