未验证 提交 495d2a23 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #1923 from taosdata/feature/add-testcase-to-test-boundary

Feature/add testcase to test boundary
# -*- coding: utf-8 -*-
import sys
import taos
import threading
import traceback
import random
import datetime
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)
tdSql.execute('create dnode 192.168.0.3')
tdDnodes.deploy(3)
tdDnodes.start(3)
time.sleep(3)
self.db = "db"
self.stb = "stb"
self.tbPrefix = "tb"
self.tbNum = 100000
self.count = 0
# self.conn = taos.connect(config=tdDnodes.getSimCfgPath())
self.threadNum = 1
# threadLock = threading.Lock()
# global counter for number of tables created by all threads
self.global_counter = 0
tdSql.init(self.conn.cursor())
def _createTable(self, threadId):
print("Thread%d : createTable" % (threadId))
conn = taos.connect(config=tdDnodes.getSimCfgPath())
cursor = conn.cursor()
i = 0
try:
sql = "use %s" % (self.db)
cursor.execute(sql)
while i < self.tbNum:
if (i % self.threadNum == threadId):
cursor.execute(
"create table tb%d using %s tags(%d)" %
(i + 1, self.stb, i + 1))
with threading.Lock():
self.global_counter += 1
i += 1
except Exception as e:
tdLog.info(
"Failure when creating table tb%d, exception: %s" %
(i + 1, str(e)))
finally:
cursor.close()
conn.close()
def _interfereDnodes(self, threadId, dnodeId):
conn = taos.connect(config=tdDnodes.getSimCfgPath())
cursor = conn.cursor()
# interfere dnode while creating table
print("Thread%d to interfere dnode%d" % (threadId, dnodeId))
while self.global_counter < self.tbNum * 0.05:
time.sleep(0.2)
cursor.execute("drop dnode 192.168.0.%d" % (dnodeId))
while self.global_counter < self.tbNum * 0.15:
time.sleep(0.2)
cursor.execute("create dnode 192.168.0.%d" % (dnodeId))
while self.global_counter < self.tbNum * 0.35:
time.sleep(0.2)
cursor.execute("drop dnode 192.168.0.%d" % (dnodeId))
while self.global_counter < self.tbNum * 0.45:
time.sleep(0.2)
cursor.execute("create dnode 192.168.0.%d" % (dnodeId))
while self.global_counter < self.tbNum * 0.65:
time.sleep(0.2)
cursor.execute("drop dnode 192.168.0.%d" % (dnodeId))
while self.global_counter < self.tbNum * 0.85:
time.sleep(0.2)
cursor.execute("create dnode 192.168.0.%d" % (dnodeId))
def run(self):
tdLog.info("================= creating database with replica 2")
threadId = 0
threads = []
try:
tdSql.execute("drop database if exists %s" % (self.db))
tdSql.execute(
"create database %s replica 2 cache 2048 ablocks 2.0 tblocks 10 tables 2000" %
(self.db))
tdLog.sleep(3)
tdSql.execute("use %s" % (self.db))
tdSql.execute(
"create table %s (ts timestamp, c1 bigint, stime timestamp) tags(tg1 bigint)" %
(self.stb))
tdLog.info("Start to create tables")
while threadId < self.threadNum:
tdLog.info("Thread-%d starts to create tables" % (threadId))
cThread = threading.Thread(
target=self._createTable,
name="thread-%d" %
(threadId),
args=(
threadId,
))
cThread.start()
threads.append(cThread)
threadId += 1
except Exception as e:
tdLog.info("Failed to create tb%d, exception: %s" % (i, str(e)))
# tdDnodes.stopAll()
finally:
time.sleep(1)
threading.Thread(
target=self._interfereDnodes,
name="thread-interfereDnode%d" %
(3),
args=(
1,
3,
)).start()
for t in range(len(threads)):
tdLog.info("Join threads")
# threads[t].start()
threads[t].join()
tdSql.query("show stables")
tdSql.checkData(0, 4, self.tbNum)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addCluster(__file__, TDTestCase())
# -*- coding: utf-8 -*-
import sys
import taos
import threading
import traceback
import random
import datetime
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)
tdSql.execute('create dnode 192.168.0.3')
tdDnodes.deploy(3)
tdDnodes.start(3)
time.sleep(3)
self.db = "db"
self.stb = "stb"
self.tbPrefix = "tb"
self.tbNum = 100000
self.count = 0
# self.conn = taos.connect(config=tdDnodes.getSimCfgPath())
self.threadNum = 1
# threadLock = threading.Lock()
# global counter for number of tables created by all threads
self.global_counter = 0
tdSql.init(self.conn.cursor())
def _createTable(self, threadId):
print("Thread%d : createTable" % (threadId))
conn = taos.connect(config=tdDnodes.getSimCfgPath())
cursor = conn.cursor()
i = 0
try:
sql = "use %s" % (self.db)
cursor.execute(sql)
while i < self.tbNum:
if (i % self.threadNum == threadId):
cursor.execute(
"create table tb%d using %s tags(%d)" %
(i + 1, self.stb, i + 1))
with threading.Lock():
self.global_counter += 1
time.sleep(0.01)
i += 1
except Exception as e:
tdLog.info(
"Failure when creating table tb%d, exception: %s" %
(i + 1, str(e)))
finally:
cursor.close()
conn.close()
def _interfereDnodes(self, threadId, dnodeId):
# interfere dnode while creating table
print("Thread%d to interfere dnode%d" % (threadId, dnodeId))
percent = 0.05
loop = int(1 / (2 * percent))
for t in range(1, loop):
while self.global_counter < self.tbNum * (t * percent):
time.sleep(0.2)
tdDnodes.forcestop(dnodeId)
while self.global_counter < self.tbNum * ((t + 1) * percent):
time.sleep(0.2)
tdDnodes.start(dnodeId)
# while self.global_counter < self.tbNum * 0.05:
# time.sleep(0.2)
# tdDnodes.forcestop(dnodeId)
# while self.global_counter < self.tbNum * 0.10:
# time.sleep(0.2)
# tdDnodes.start(dnodeId)
# while self.global_counter < self.tbNum * 0.15:
# time.sleep(0.2)
# tdDnodes.forcestop(dnodeId)
# while self.global_counter < self.tbNum * 0.20:
# time.sleep(0.2)
# tdDnodes.start(dnodeId)
# while self.global_counter < self.tbNum * 0.25:
# time.sleep(0.2)
# tdDnodes.forcestop(dnodeId)
# while self.global_counter < self.tbNum * 0.30:
# time.sleep(0.2)
# tdDnodes.start(dnodeId)
# while self.global_counter < self.tbNum * 0.35:
# time.sleep(0.2)
# tdDnodes.forcestop(dnodeId)
# while self.global_counter < self.tbNum * 0.40:
# time.sleep(0.2)
# tdDnodes.start(dnodeId)
# while self.global_counter < self.tbNum * 0.45:
# time.sleep(0.2)
# tdDnodes.forcestop(dnodeId)
# while self.global_counter < self.tbNum * 0.50:
# time.sleep(0.2)
# tdDnodes.start(dnodeId)
def run(self):
tdLog.info("================= creating database with replica 2")
threadId = 0
threads = []
try:
tdSql.execute("drop database if exists %s" % (self.db))
tdSql.execute(
"create database %s replica 2 cache 1024 ablocks 2.0 tblocks 4 tables 1000" %
(self.db))
tdLog.sleep(3)
tdSql.execute("use %s" % (self.db))
tdSql.execute(
"create table %s (ts timestamp, c1 bigint, stime timestamp) tags(tg1 bigint)" %
(self.stb))
tdLog.info("Start to create tables")
while threadId < self.threadNum:
tdLog.info("Thread-%d starts to create tables" % (threadId))
cThread = threading.Thread(
target=self._createTable,
name="thread-%d" %
(threadId),
args=(
threadId,
))
cThread.start()
threads.append(cThread)
threadId += 1
except Exception as e:
tdLog.info("Failed to create tb%d, exception: %s" % (i, str(e)))
# tdDnodes.stopAll()
finally:
time.sleep(1)
threading.Thread(
target=self._interfereDnodes,
name="thread-interfereDnode%d" %
(3),
args=(
1,
3,
)).start()
for t in range(len(threads)):
tdLog.info("Join threads")
# threads[t].start()
threads[t].join()
tdSql.query("show stables")
tdSql.checkData(0, 4, self.tbNum)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addCluster(__file__, TDTestCase())
###################################################################
# 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 datetime
import string
import random
import subprocess
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):
chars = string.ascii_uppercase + string.ascii_lowercase
getDbNameLen = "grep -w '#define TSDB_DB_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'"
dbNameMaxLen = int(subprocess.check_output(getDbNameLen, shell=True))
tdLog.notice("DB name max length is %d" % dbNameMaxLen)
tdLog.info("=============== step1")
db_name = ''.join(random.choices(chars, k=(dbNameMaxLen + 1)))
tdLog.info('db_name length %d' % len(db_name))
tdLog.info('create database %s' % db_name)
tdSql.error('create database %s' % db_name)
tdLog.info("=============== step2")
db_name = ''.join(random.choices(chars, k=dbNameMaxLen))
tdLog.info('db_name length %d' % len(db_name))
tdLog.info('create database %s' % db_name)
tdSql.execute('create database %s' % db_name)
tdSql.query('show databases')
tdSql.checkRows(1)
tdSql.checkData(0, 0, db_name.lower())
tdLog.info("=============== step3")
db_name = ''.join(random.choices(chars, k=(dbNameMaxLen - 1)))
tdLog.info('db_name length %d' % len(db_name))
tdLog.info('create database %s' % db_name)
tdSql.execute('create database %s' % db_name)
tdSql.query('show databases')
tdSql.checkRows(2)
tdSql.checkData(0, 0, db_name.lower())
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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()
tbNum = 10000
insertRows = 1
db = "db"
loop = 2
tdSql.execute("drop database if exists %s" % (db))
tdSql.execute("reset query cache")
tdLog.sleep(1)
for k in range(1, loop + 1):
tdLog.info("===========Loop%d starts============" % (k))
tdSql.execute(
"create database %s cache 163840 ablocks 40 maxtables 5000 wal 0" %
(db))
tdSql.execute("use %s" % (db))
tdSql.execute(
"create table stb (ts timestamp, c1 int) tags(t1 bigint, t2 double)")
for j in range(1, tbNum):
tdSql.execute(
"create table tb%d using stb tags(%d, %d)" %
(j, j, j))
for j in range(1, tbNum):
for i in range(0, insertRows):
tdSql.execute(
"insert into tb%d values (now + %dm, %d)" %
(j, i, i))
tdSql.query("select * from tb%d" % (j))
tdSql.checkRows(insertRows)
tdLog.info("insert %d rows into tb%d" % (insertRows, j))
# tdSql.sleep(3)
tdSql.execute("drop database %s" % (db))
tdLog.sleep(2)
tdLog.info("===========Loop%d completed!=============" % (k))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
#tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -10,10 +10,17 @@ python3 ./test.py $1 -f insert/tinyint.py
python3 ./test.py $1 -f insert/date.py
python3 ./test.py $1 -f insert/binary.py
python3 ./test.py $1 -f insert/nchar.py
python3 ./test.py $1 -f insert/nchar-boundary.py
python3 ./test.py $1 -f insert/nchar-unicode.py
python3 ./test.py $1 -f table/column_name.py
python3 ./test.py $1 -f table/column_num.py
python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -f table/tablename-boundary.py
python3 ./test.py $1 -f tag_lite/create-tags-boundary.py
python3 ./test.py $1 -f dbmgmt/database-name-boundary.py
python3 ./test.py $1 -f import_merge/importBlock1HO.py
python3 ./test.py $1 -f import_merge/importBlock1HPO.py
......@@ -87,4 +94,4 @@ python3 ./test.py $1 -f user/user_create.py
python3 ./test.py $1 -f user/pass_len.py
# table
#python3 ./test.py $1 -f table/del_stable.py
\ No newline at end of file
#python3 ./test.py $1 -f table/del_stable.py
# -*- 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()
tdLog.info('=============== step1')
tdLog.info('create table tb (ts timestamp, speed binary(4089))')
tdSql.error('create table tb (ts timestamp, speed binary(4089))')
tdLog.info('create table tb (ts timestamp, speed binary(4088))')
tdSql.error('create table tb (ts timestamp, speed binary(4088))')
tdLog.info('create table tb (ts timestamp, speed binary(4084))')
tdSql.execute('create table tb (ts timestamp, speed binary(4084))')
tdLog.info("insert into tb values (now, ) -x step1")
tdSql.error("insert into tb values (now, )")
with open("../../README.md", "r") as inputFile:
data = inputFile.read(4084).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
tdLog.info("insert %d length data: %s" % (len(data), data))
tdLog.info("insert into tb values (now+2a, data)")
tdSql.execute("insert into tb values (now+2a, '%s')" % data)
tdLog.info('select speed from tb order by ts desc')
tdSql.query('select speed from tb order by ts desc')
tdLog.info('tdSql.checkRow(1)')
tdSql.checkRows(1)
tdLog.info('==> $data01')
tdLog.info("tdSql.checkData(0, 1, '%s')" % data)
tdSql.checkData(0, 1, data)
tdLog.info(
'create table tb2 (ts timestamp, speed binary(2040), temp binary(2044))')
tdSql.execute(
'create table tb2 (ts timestamp, speed binary(2040), temp binary(2044))')
speed = inputFile.read(2044).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
temp = inputFile.read(2040).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
tdLog.info("insert into tb values (now+3a, speed, temp)")
tdSql.error(
"insert into tb values (now+3a, '%s', '%s')" %
(speed, temp))
speed = inputFile.read(2040).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
temp = inputFile.read(2044).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
tdLog.info("insert into tb values (now+4a, speed, temp)")
tdSql.error(
"insert into tb values (now+4a, '%s', '%s')" %
(speed, temp))
tdLog.info('tdSql.checkRow(2)')
tdSql.checkRows(2)
tdLog.info('==> $data11')
tdLog.info("tdSql.checkData(1, 1, '%s')" % speed)
tdSql.checkData(1, 1, speed)
tdLog.info('==> $data12')
tdLog.info("tdSql.checkData(1, 2, '%s')" % temp)
tdSql.checkData(1, 1, temp)
inputFile.close()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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
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.error('create table tb (ts timestamp, col nchar(1022))')
tdSql.execute('create table tb (ts timestamp, col nchar(1021))')
tdSql.execute("insert into tb values (now, 'taosdata')")
tdSql.query("select * from tb")
tdSql.checkRows(1)
tdSql.checkData(0, 1, 'taosdata')
with open("../../README.md", "r") as inputFile:
data = inputFile.read(1021).replace(
"\n",
" ").replace(
"\\",
" ").replace(
"\'",
" ").replace(
"\"",
" ").replace(
"[",
" ").replace(
"]",
" ").replace(
"!",
" ")
tdLog.info("insert %d length data: %s" % (len(data), data))
tdSql.execute("insert into tb values (now, '%s')" % data)
tdSql.query("select * from tb")
tdSql.checkRows(2)
tdSql.checkData(1, 1, data)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
此差异已折叠。
......@@ -37,7 +37,7 @@ class TDTestCase:
print("==============step2")
tdSql.execute(
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
('2020-05-13 10:00:00.001', 1)
dev_002 VALUES('2020-05-13 10:00:00.001', 1)""")
......
......@@ -37,7 +37,7 @@ class TDTestCase:
print("==============step2")
tdSql.execute(
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
"""INSERT INTO dev_001(ts, tagtype) VALUES('2020-05-13 10:00:00.000', 1),
('2020-05-13 10:00:00.001', 1)
dev_002 VALUES('2020-05-13 10:00:00.001', 1)""")
......
# -*- coding: utf-8 -*-
import sys
import string
import random
import subprocess
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()
getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'"
tableNameMaxLen = int(
subprocess.check_output(
getTableNameLen, shell=True))
tdLog.notice("table name max length is %d" % tableNameMaxLen)
chars = string.ascii_uppercase + string.ascii_lowercase
tb_name = ''.join(random.choices(chars, k=tableNameMaxLen))
tdLog.info('tb_name length %d' % len(tb_name))
tdLog.info('create table %s (ts timestamp, value int)' % tb_name)
tdSql.error(
'create table %s (ts timestamp, speed binary(4089))' %
tb_name)
tb_name = ''.join(random.choices(chars, k=191))
tdLog.info('tb_name length %d' % len(tb_name))
tdLog.info('create table %s (ts timestamp, value int)' % tb_name)
tdSql.execute(
'create table %s (ts timestamp, speed binary(4089))' %
tb_name)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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 subprocess
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()
getMaxTagNum = "grep -w TSDB_MAX_TAGS ../../src/inc/taosdef.h|awk '{print $3}'"
boundary = int(subprocess.check_output(getMaxTagNum, shell=True))
tdLog.notice("get max tags number is %d" % boundary)
for x in range(0, boundary):
stb_name = "stb%d" % x
tagSeq = "tag0 int"
for y in range(1, x + 1):
tagSeq = tagSeq + ", tag%d int" % y
tdLog.info(
"create table %s (ts timestamp, value int) tags (%s)" %
(stb_name, tagSeq))
tdSql.execute(
"create table %s (ts timestamp, value int) tags (%s)" %
(stb_name, tagSeq))
tdSql.query("show stables")
tdSql.checkRows(boundary)
stb_name = "stb%d" % (boundary + 1)
tagSeq = tagSeq + ", tag%d int" % (boundary)
tdLog.info(
"create table %s (ts timestamp, value int) tags (%s)" %
(stb_name, tagSeq))
tdSql.error(
"create table %s (ts timestamp, value int) tags (%s)" %
(stb_name, tagSeq))
tdSql.query("show stables")
tdSql.checkRows(boundary)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
###################################################################
# 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("================= 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())
......@@ -70,8 +70,6 @@ if __name__ == "__main__":
toBeKilled = "valgrind.bin"
killCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs kill -HUP " % toBeKilled
# os.system(killCmd)
# time.sleep(1)
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
processID = subprocess.check_output(psCmd, shell=True)
......
......@@ -103,7 +103,8 @@ class TDDnode:
self.logDir = "%s/pysim/dnode%d/log" % (self.path, self.index)
self.dataDir = "%s/pysim/dnode%d/data" % (self.path, self.index)
self.cfgDir = "%s/pysim/dnode%d/cfg" % (self.path, self.index)
self.cfgPath = "%s/pysim/dnode%d/cfg/taos.cfg" % (self.path, self.index)
self.cfgPath = "%s/pysim/dnode%d/cfg/taos.cfg" % (
self.path, self.index)
cmd = "rm -rf " + self.dataDir
if os.system(cmd) != 0:
......@@ -188,7 +189,7 @@ class TDDnode:
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("community" not in rootRealPath):
binPath = os.path.join(root, "taosd")
break;
break
else:
projPath = selfPath + "/../../../"
for root, dirs, files in os.walk(projPath):
......@@ -196,7 +197,7 @@ class TDDnode:
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
binPath = os.path.join(root, "taosd")
break;
break
if (binPath == ""):
tdLog.exit("taosd not found!s")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册