提交 35f5a204 编写于 作者: S Shuduo Sang

read boundary value from taosdef.h

上级 9e031188
# -*- 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())
......@@ -3,6 +3,7 @@
import sys
import string
import random
import subprocess
from util.log import *
from util.cases import *
from util.sql import *
......@@ -16,8 +17,11 @@ class TDTestCase:
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=192))
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)
......
......@@ -12,6 +12,7 @@
# -*- coding: utf-8 -*-
import sys
import subprocess
from util.log import *
from util.cases import *
from util.sql import *
......@@ -25,7 +26,9 @@ class TDTestCase:
def run(self):
tdSql.prepare()
boundary = 32
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
......@@ -40,7 +43,7 @@ class TDTestCase:
tdSql.checkRows(boundary)
stb_name = "stb%d" % (boundary+1)
tagSeq = tagSeq + ", tag%d int" % (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")
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册