parent
bd49f05819
commit
c815a1b20d
|
@ -0,0 +1,129 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdLog.info("prepare cluster")
|
||||
tdDnodes.stopAll()
|
||||
tdDnodes.deploy(1)
|
||||
tdDnodes.start(1)
|
||||
|
||||
self.conn = taos.connect(config=tdDnodes.getSimCfgPath())
|
||||
tdSql.init(self.conn.cursor())
|
||||
tdSql.execute('reset query cache')
|
||||
tdSql.execute('create dnode 192.168.0.2')
|
||||
tdDnodes.deploy(2)
|
||||
tdDnodes.start(2)
|
||||
|
||||
self.conn = taos.connect(config=tdDnodes.getSimCfgPath())
|
||||
tdSql.init(self.conn.cursor())
|
||||
tdSql.execute('reset query cache')
|
||||
tdSql.execute('create dnode 192.168.0.3')
|
||||
tdDnodes.deploy(3)
|
||||
tdDnodes.start(3)
|
||||
|
||||
def run(self):
|
||||
tdSql.execute('create database db replica 3 days 7')
|
||||
tdSql.execute('use db')
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute('create table tb%d(ts timestamp, i int)' % tid)
|
||||
tdLog.sleep(10)
|
||||
|
||||
tdLog.info("================= step1")
|
||||
startTime = 1520000010000
|
||||
for rid in range(1, 11):
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute(
|
||||
'insert into tb%d values(%ld, %d)' %
|
||||
(tid, startTime, rid))
|
||||
startTime += 1
|
||||
tdSql.query('select * from tb1')
|
||||
tdSql.checkRows(10)
|
||||
tdLog.sleep(5)
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdSql.execute('alter database db replica 2')
|
||||
tdLog.sleep(10)
|
||||
|
||||
tdLog.info("================= step3")
|
||||
for rid in range(1, 11):
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute(
|
||||
'insert into tb%d values(%ld, %d)' %
|
||||
(tid, startTime, rid))
|
||||
startTime += 1
|
||||
tdSql.query('select * from tb1')
|
||||
tdSql.checkRows(20)
|
||||
tdLog.sleep(5)
|
||||
|
||||
tdLog.info("================= step4")
|
||||
tdSql.execute('alter database db replica 1')
|
||||
tdLog.sleep(10)
|
||||
|
||||
tdLog.info("================= step5")
|
||||
for rid in range(1, 11):
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute(
|
||||
'insert into tb%d values(%ld, %d)' %
|
||||
(tid, startTime, rid))
|
||||
startTime += 1
|
||||
tdSql.query('select * from tb1')
|
||||
tdSql.checkRows(30)
|
||||
tdLog.sleep(5)
|
||||
|
||||
tdLog.info("================= step6")
|
||||
tdSql.execute('alter database db replica 2')
|
||||
tdLog.sleep(10)
|
||||
|
||||
tdLog.info("================= step7")
|
||||
for rid in range(1, 11):
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute(
|
||||
'insert into tb%d values(%ld, %d)' %
|
||||
(tid, startTime, rid))
|
||||
startTime += 1
|
||||
tdSql.query('select * from tb1')
|
||||
tdSql.checkRows(40)
|
||||
tdLog.sleep(5)
|
||||
|
||||
tdLog.info("================= step8")
|
||||
tdSql.execute('alter database db replica 3')
|
||||
tdLog.sleep(10)
|
||||
|
||||
tdLog.info("================= step9")
|
||||
for rid in range(1, 11):
|
||||
for tid in range(1, 11):
|
||||
tdSql.execute(
|
||||
'insert into tb%d values(%ld, %d)' %
|
||||
(tid, startTime, rid))
|
||||
startTime += 1
|
||||
tdSql.query('select * from tb1')
|
||||
tdSql.checkRows(50)
|
||||
tdLog.sleep(5)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
self.conn.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addCluster(__file__, TDTestCase())
|
|
@ -0,0 +1,138 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
self.types = [
|
||||
"int",
|
||||
"bigint",
|
||||
"float",
|
||||
"double",
|
||||
"smallint",
|
||||
"tinyint",
|
||||
"binary(10)",
|
||||
"nchar(10)",
|
||||
"timestamp"]
|
||||
self.rowNum = 300
|
||||
self.ts = 1537146000000
|
||||
self.step = 1000
|
||||
self.sqlHead = "select count(*), count(c1) "
|
||||
self.sqlTail = " from stb"
|
||||
|
||||
def addColumnAndCount(self):
|
||||
for colIdx in range(len(self.types)):
|
||||
tdSql.execute(
|
||||
"alter table stb add column c%d %s" %
|
||||
(colIdx + 2, self.types[colIdx]))
|
||||
self.sqlHead = self.sqlHead + ",count(c%d) " % (colIdx + 2)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 1))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 1))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check1: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2))
|
||||
|
||||
# insert more rows
|
||||
for k in range(self.rowNum):
|
||||
self.ts += self.step
|
||||
sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2)
|
||||
for j in range(colIdx + 1):
|
||||
sql += ", %d" % (colIdx + 2)
|
||||
sql += ")"
|
||||
tdSql.execute(sql)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 2))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 2))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check2: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3))
|
||||
|
||||
def dropColumnAndCount(self):
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
res = []
|
||||
for i in range(len(self.types)):
|
||||
res.append(tdSql.getData(0, i + 2))
|
||||
|
||||
print(res)
|
||||
|
||||
for colIdx in range(len(self.types), 0, -1):
|
||||
tdSql.execute("alter table stb drop column c%d" % (colIdx + 2))
|
||||
# self.sqlHead = self.sqlHead + ",count(c%d) " %(colIdx + 2)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 1))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 1))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check1: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2))
|
||||
|
||||
# insert more rows
|
||||
for k in range(self.rowNum):
|
||||
self.ts += self.step
|
||||
sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2)
|
||||
for j in range(colIdx + 1):
|
||||
sql += ", %d" % (colIdx + 2)
|
||||
sql += ")"
|
||||
tdSql.execute(sql)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 2))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 2))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check2: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3))
|
||||
|
||||
def run(self):
|
||||
# Setup params
|
||||
db = "db"
|
||||
|
||||
# Create db
|
||||
tdSql.execute("drop database if exists %s" % (db))
|
||||
tdSql.execute("reset query cache")
|
||||
tdSql.execute("create database %s maxrows 200 maxtables 4" % (db))
|
||||
tdSql.execute("use %s" % (db))
|
||||
|
||||
# Create a table with one colunm of int type and insert 300 rows
|
||||
tdLog.info("Create stb and tb")
|
||||
tdSql.execute("create table stb (ts timestamp, c1 int) tags (tg1 int)")
|
||||
tdSql.execute("create table tb using stb tags (0)")
|
||||
tdLog.info("Insert %d rows into tb" % (self.rowNum))
|
||||
for k in range(1, self.rowNum + 1):
|
||||
self.ts += self.step
|
||||
tdSql.execute("insert into tb values (%d, 1)" % (self.ts))
|
||||
|
||||
# Alter tb and add a column of smallint type, then query tb to see if
|
||||
# all added column are NULL
|
||||
self.addColumnAndCount()
|
||||
tdDnodes.stop(1)
|
||||
time.sleep(5)
|
||||
tdDnodes.start(1)
|
||||
time.sleep(5)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
for i in range(2, len(self.types) + 2):
|
||||
tdSql.checkData(0, i, self.rowNum * (len(self.types) + 2 - i))
|
||||
|
||||
self.dropColumnAndCount()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
#tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,138 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
self.types = [
|
||||
"int",
|
||||
"bigint",
|
||||
"float",
|
||||
"double",
|
||||
"smallint",
|
||||
"tinyint",
|
||||
"binary(10)",
|
||||
"nchar(10)",
|
||||
"timestamp"]
|
||||
self.rowNum = 300
|
||||
self.ts = 1537146000000
|
||||
self.step = 1000
|
||||
self.sqlHead = "select count(*), count(c1) "
|
||||
self.sqlTail = " from tb"
|
||||
|
||||
def addColumnAndCount(self):
|
||||
for colIdx in range(len(self.types)):
|
||||
tdSql.execute(
|
||||
"alter table tb add column c%d %s" %
|
||||
(colIdx + 2, self.types[colIdx]))
|
||||
self.sqlHead = self.sqlHead + ",count(c%d) " % (colIdx + 2)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 1))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 1))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check1: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2))
|
||||
|
||||
# insert more rows
|
||||
for k in range(self.rowNum):
|
||||
self.ts += self.step
|
||||
sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2)
|
||||
for j in range(colIdx + 1):
|
||||
sql += ", %d" % (colIdx + 2)
|
||||
sql += ")"
|
||||
tdSql.execute(sql)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 2))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 2))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check2: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3))
|
||||
|
||||
def dropColumnAndCount(self):
|
||||
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
res = []
|
||||
for i in range(len(self.types)):
|
||||
res[i] = tdSql.getData(0, i + 2)
|
||||
|
||||
print(res.join)
|
||||
|
||||
for colIdx in range(len(self.types), 0, -1):
|
||||
tdSql.execute("alter table tb drop column c%d" % (colIdx + 2))
|
||||
# self.sqlHead = self.sqlHead + ",count(c%d) " %(colIdx + 2)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 1))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 1))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check1: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 2))
|
||||
|
||||
# insert more rows
|
||||
for k in range(self.rowNum):
|
||||
self.ts += self.step
|
||||
sql = "insert into tb values (%d, %d" % (self.ts, colIdx + 2)
|
||||
for j in range(colIdx + 1):
|
||||
sql += ", %d" % (colIdx + 2)
|
||||
sql += ")"
|
||||
tdSql.execute(sql)
|
||||
|
||||
# count non-NULL values in each column
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
tdSql.checkData(0, 0, self.rowNum * (colIdx + 2))
|
||||
tdSql.checkData(0, 1, self.rowNum * (colIdx + 2))
|
||||
for i in range(2, colIdx + 2):
|
||||
print("check2: i=%d colIdx=%d" % (i, colIdx))
|
||||
tdSql.checkData(0, i, self.rowNum * (colIdx - i + 3))
|
||||
|
||||
def run(self):
|
||||
# Setup params
|
||||
db = "db"
|
||||
|
||||
# Create db
|
||||
tdSql.execute("drop database if exists %s" % (db))
|
||||
tdSql.execute("reset query cache")
|
||||
tdSql.execute("create database %s maxrows 200 maxtables 4" % (db))
|
||||
tdSql.execute("use %s" % (db))
|
||||
|
||||
# Create a table with one colunm of int type and insert 300 rows
|
||||
tdLog.info("Create table tb")
|
||||
tdSql.execute("create table tb (ts timestamp, c1 int)")
|
||||
tdLog.info("Insert %d rows into tb" % (self.rowNum))
|
||||
for k in range(1, self.rowNum + 1):
|
||||
self.ts += self.step
|
||||
tdSql.execute("insert into tb values (%d, 1)" % (self.ts))
|
||||
|
||||
# Alter tb and add a column of smallint type, then query tb to see if
|
||||
# all added column are NULL
|
||||
self.addColumnAndCount()
|
||||
tdDnodes.stop(1)
|
||||
time.sleep(5)
|
||||
tdDnodes.start(1)
|
||||
time.sleep(5)
|
||||
tdSql.query(self.sqlHead + self.sqlTail)
|
||||
for i in range(2, len(self.types) + 2):
|
||||
tdSql.checkData(0, i, self.rowNum * (len(self.types) + 2 - i))
|
||||
|
||||
self.dropColumnAndCount()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
#tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,77 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
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()
|
||||
tdSql.execute(
|
||||
'create table st (ts timestamp, v1 int, v2 int, v3 int, v4 int, v5 int) tags (t int)')
|
||||
|
||||
totalTables = 100
|
||||
batchSize = 500
|
||||
totalBatch = 60
|
||||
|
||||
tdLog.info(
|
||||
"create %d tables, insert %d rows per table" %
|
||||
(totalTables, batchSize * totalBatch))
|
||||
|
||||
for t in range(0, totalTables):
|
||||
tdSql.execute('create table t%d using st tags(%d)' % (t, t))
|
||||
# 2019-06-10 00:00:00
|
||||
beginTs = 1560096000000
|
||||
interval = 10000
|
||||
for r in range(0, totalBatch):
|
||||
sql = 'insert into t%d values ' % (t)
|
||||
for b in range(0, batchSize):
|
||||
ts = beginTs + (r * batchSize + b) * interval
|
||||
sql += '(%d, 1, 2, 3, 4, 5)' % (ts)
|
||||
tdSql.execute(sql)
|
||||
|
||||
tdLog.info("insert data finished")
|
||||
tdSql.execute('alter table st add column v6 int')
|
||||
tdLog.sleep(5)
|
||||
tdLog.info("alter table finished")
|
||||
|
||||
tdSql.query("select count(*) from t50")
|
||||
tdSql.checkData(0, 0, (int)(batchSize * totalBatch))
|
||||
|
||||
tdLog.info("insert")
|
||||
tdSql.execute(
|
||||
"insert into t50 values ('2019-06-13 07:59:55.000', 1, 2, 3, 4, 5, 6)")
|
||||
|
||||
tdLog.info("import")
|
||||
tdSql.execute(
|
||||
"import into t50 values ('2019-06-13 07:59:55.000', 1, 2, 3, 4, 5, 6)")
|
||||
|
||||
tdLog.info("query")
|
||||
tdSql.query("select count(*) from t50")
|
||||
tdSql.checkData(0, 0, batchSize * totalBatch + 1)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,135 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import taos
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def run(self):
|
||||
self.ntables = 10
|
||||
self.rowsPerTable = 10
|
||||
self.startTime = 1520000010000
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.deploy(1)
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdLog.info("================= step0")
|
||||
tdSql.execute('reset query cache')
|
||||
tdLog.info("drop database db if exits")
|
||||
tdSql.execute('drop database if exists db')
|
||||
tdLog.info("================= step1")
|
||||
tdSql.execute('create database db maxtables 4')
|
||||
tdLog.sleep(5)
|
||||
tdSql.execute('use db')
|
||||
|
||||
tdLog.info("================= step1")
|
||||
tdLog.info("create 1 super table")
|
||||
tdSql.execute('create table stb (ts timestamp, i int) \
|
||||
tags (tin int, tfl float, tbg bigint, tdo double, tbi binary(10), tbl bool)')
|
||||
|
||||
tdLog.info("================= step2")
|
||||
tdLog.info("create %d tables" % self.ntables)
|
||||
for tid in range(1, self.ntables + 1):
|
||||
tdSql.execute(
|
||||
'create table tb%d using stb tags(%d,%f,%ld,%f,\'%s\',%d)' %
|
||||
(tid,
|
||||
tid %
|
||||
3,
|
||||
1.2 *
|
||||
tid,
|
||||
self.startTime +
|
||||
tid,
|
||||
1.22 *
|
||||
tid,
|
||||
't' +
|
||||
str(tid),
|
||||
tid %
|
||||
2))
|
||||
tdLog.sleep(5)
|
||||
|
||||
tdLog.info("================= step3")
|
||||
tdLog.info(
|
||||
"insert %d data in to each %d tables" %
|
||||
(self.rowsPerTable, self.ntables))
|
||||
for rid in range(1, self.rowsPerTable + 1):
|
||||
sqlcmd = ['insert into']
|
||||
for tid in range(1, self.ntables + 1):
|
||||
sqlcmd.append(
|
||||
'tb%d values(%ld,%d)' %
|
||||
(tid, self.startTime + rid, rid))
|
||||
tdSql.execute(" ".join(sqlcmd))
|
||||
tdSql.query('select count(*) from stb')
|
||||
tdSql.checkData(0, 0, self.rowsPerTable * self.ntables)
|
||||
|
||||
tdLog.info("================= step4")
|
||||
tdLog.info("drop one tag")
|
||||
tdSql.execute('alter table stb drop tag tbi')
|
||||
tdLog.info("insert %d data in to each %d tables" % (2, self.ntables))
|
||||
for rid in range(self.rowsPerTable + 1, self.rowsPerTable + 3):
|
||||
sqlcmd = ['insert into']
|
||||
for tid in range(1, self.ntables + 1):
|
||||
sqlcmd.append(
|
||||
'tb%d values(%ld,%d)' %
|
||||
(tid, self.startTime + rid, rid))
|
||||
tdSql.execute(" ".join(sqlcmd))
|
||||
self.rowsPerTable += 2
|
||||
tdSql.query('select count(*) from stb')
|
||||
tdSql.checkData(0, 0, self.rowsPerTable * self.ntables)
|
||||
tdSql.query('describe tb1')
|
||||
tdSql.checkRows(2 + 5)
|
||||
|
||||
tdLog.info("================= step5")
|
||||
tdLog.info("add one tag")
|
||||
tdSql.execute('alter table stb add tag tnc nchar(10)')
|
||||
for tid in range(1, self.ntables + 1):
|
||||
tdSql.execute('alter table tb%d set tag tnc=\"%s\"' %
|
||||
(tid, str(tid * 1.2)))
|
||||
tdLog.info("insert %d data in to each %d tables" % (2, self.ntables))
|
||||
for rid in range(self.rowsPerTable + 1, self.rowsPerTable + 3):
|
||||
sqlcmd = ['insert into']
|
||||
for tid in range(1, self.ntables + 1):
|
||||
sqlcmd.append(
|
||||
'tb%d values(%ld,%d)' %
|
||||
(tid, self.startTime + rid, rid))
|
||||
tdSql.execute(" ".join(sqlcmd))
|
||||
self.rowsPerTable += 2
|
||||
tdSql.query('select count(*) from stb')
|
||||
tdSql.checkData(0, 0, self.rowsPerTable * self.ntables)
|
||||
tdSql.query('describe tb1')
|
||||
tdSql.checkRows(2 + 6)
|
||||
|
||||
tdLog.info("================= step6")
|
||||
tdLog.info("group and filter by tag1 int")
|
||||
tdSql.query('select max(i) from stb where tbl=0 group by tin')
|
||||
tdSql.checkRows(3)
|
||||
tdSql.execute('reset query cache')
|
||||
tdSql.query('select max(i) from stb where tbl=true group by tin')
|
||||
tdSql.checkData(2, 0, self.rowsPerTable)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
Loading…
Reference in New Issue