未验证 提交 84a81716 编写于 作者: H Haojun Liao 提交者: GitHub

Merge branch '3.0' into feature/3_liaohj

......@@ -520,6 +520,7 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
pFillInfo->end = endKey;
if (!FILL_IS_ASC_FILL(pFillInfo)) {
pFillInfo->end = taosTimeTruncate(endKey, &pFillInfo->interval, pFillInfo->interval.precision);
pFillInfo->end = taosTimeAdd(pFillInfo->end, pFillInfo->interval.interval, pFillInfo->interval.intervalUnit,pFillInfo->interval.precision);
}
pFillInfo->index = 0;
......
......@@ -303,6 +303,7 @@ int32_t tAppendDataToInputQueue(SStreamTask* pTask, SStreamQueueItem* pItem) {
STREAM_TASK_INPUT_QUEUEU_CAPACITY, STREAM_TASK_INPUT_QUEUEU_CAPACITY_IN_SIZE,
total, size);
streamDataSubmitDestroy(pSubmitBlock);
taosFreeQitem(pSubmitBlock);
return -1;
}
......
......@@ -479,6 +479,11 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3
,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3
,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreMnode.py -N 5 -M 3
,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreQnode.py -N 5 -M 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py
......@@ -495,7 +500,8 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilter.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData1.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
#,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
,,n,system-test,python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAlterSchema.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -N 3 -n 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py -N 3 -n 3
......@@ -583,6 +589,32 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/db_tb_name_check.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/InsertFuturets.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_wide_column.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_benchmark.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_1.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_1.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_1.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_1.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_1.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_2.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_2.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_2.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_2.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_2.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_3.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_3.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_3.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_3.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_3.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_4.py
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_4.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_4.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_4.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_4.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/information_schema.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/abs.py
......
......@@ -68,7 +68,7 @@ docker run \
-v ${REP_REAL_PATH}/community/contrib/libuv/:${REP_DIR}/community/contrib/libuv \
-v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \
-v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10 || exit 1"
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10|| exit 1"
# -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \
if [[ -d ${WORKDIR}/debugNoSan ]] ;then
......@@ -97,7 +97,7 @@ docker run \
-v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \
-v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \
-v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10 || exit 1 "
--rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10|| exit 1 "
mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan
......
......@@ -18,7 +18,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -18,7 +18,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......@@ -39,10 +39,9 @@ class TDTestCase:
tdSql.execute('insert into tb values (now - 5m , NULL)')
tdSql.execute('insert into tb values (now - 6m , 10)')
tdSql.execute('insert into tb values (now - 7m , NULL)')
tdSql.execute('insert into tb values (now - 8m , 254)')
tdSql.error('insert into tb values (now - 9m, -1)')
tdSql.error('insert into tb values (now - 9m, 255)')
tdSql.execute('insert into tb values (now - 9m, 255)')
tdSql.query("select * from tb")
tdSql.checkRows(insertRows + 4)
......
......@@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -10,7 +10,7 @@ import os
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -7,7 +7,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......
......@@ -19,23 +19,24 @@ from util.sql import tdSql
from util.dnodes import tdDnodes
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1538548685000
def bug_6387(self):
tdSql.execute("create database bug6387 ")
tdSql.execute("use bug6387 ")
tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db")
tdSql.execute("use db")
tdSql.execute("create table test(ts timestamp, c1 int) tags(t1 int)")
for i in range(5000):
sql = "insert into t%d using test tags(1) values " % i
for j in range(21):
sql = sql + "(now+%ds,%d)" % (j ,j )
tdSql.execute(sql)
tdSql.query("select count(*) from test interval(1s) group by tbname")
tdSql.checkData(0,1,1)
# tdSql.query("select count(*) from test interval(1s) group by tbname")
# tdSql.checkData(0,1,1)
def run(self):
tdSql.prepare()
......@@ -58,10 +59,10 @@ class TDTestCase:
tdSql.query("select * from db.st where ts='2020-05-13 10:00:00.000'")
tdSql.checkRows(1)
tdSql.query("select tbname, dev from dev_001")
tdSql.checkRows(1)
tdSql.checkData(0, 0, 'dev_001')
tdSql.checkData(0, 1, 'dev_01')
# tdSql.query("select tbname, dev from dev_001")
# tdSql.checkRows(1)
# tdSql.checkData(0, 0, 'dev_001')
# tdSql.checkData(0, 1, 'dev_01')
tdSql.query("select tbname, dev, tagtype from dev_001")
tdSql.checkRows(2)
......@@ -124,10 +125,10 @@ class TDTestCase:
tdSql.checkRows(5)
# For jira: https://jira.taosdata.com:18080/browse/TD-2850
tdSql.execute("create database 'Test' ")
tdSql.execute("use 'Test' ")
tdSql.execute("create table 'TB'(ts timestamp, 'Col1' int) tags('Tag1' int)")
tdSql.execute("insert into 'Tb0' using tb tags(1) values(now, 1)")
tdSql.execute("create database `Test` ")
tdSql.execute("use `Test` ")
tdSql.execute("create table TB(ts timestamp, `Col1` int) tags(`Tag1` int)")
tdSql.execute("insert into Tb0 using tb tags(1) values(now, 1)")
tdSql.query("select * from tb")
tdSql.checkRows(1)
......@@ -135,7 +136,7 @@ class TDTestCase:
tdSql.checkRows(1)
#For jira: https://jira.taosdata.com:18080/browse/TD-6387
self.bug_6387()
#self.bug_6387()
def stop(self):
......
......@@ -19,7 +19,7 @@ from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......@@ -42,10 +42,10 @@ class TDTestCase:
('2020-05-13 10:00:00.005', 3, 'third')""")
# query first .. as ..
tdSql.error("select first(*) as one from st")
tdSql.execute("select first(*) as one from st")
# query last .. as ..
tdSql.error("select last(*) as latest from st")
tdSql.execute("select last(*) as latest from st")
# query last row .. as ..
tdSql.error("select last_row as latest from st")
......@@ -54,7 +54,7 @@ class TDTestCase:
#tdSql.error("select distinct tagtype from st")
# query .. order by non-time field
tdSql.error("select * from st order by name")
tdSql.execute("select * from st order by name")
# TD-2133
tdSql.error("select diff(tagtype),bottom(tagtype,1) from dev_001")
......@@ -66,8 +66,8 @@ class TDTestCase:
tdSql.error("select diff(tagtype),top(tagtype,1) from dev_001")
# TD-6006
tdSql.error("select * from dev_001 where 'name' is not null")
tdSql.error("select * from dev_001 where \"name\" = 'first'")
tdSql.execute("select * from dev_001 where 'name' is not null")
tdSql.execute("select * from dev_001 where \"name\" = 'first'")
def stop(self):
tdSql.close()
......
......@@ -19,7 +19,7 @@ from util.sql import tdSql
class TDTestCase:
def init(self, conn, logSql):
def init(self, conn, logSql, replicaVar = 1):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
......@@ -46,39 +46,39 @@ class TDTestCase:
tdSql.execute(sql)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)")
tdSql.checkRows(139)
tdSql.checkData(0, 1, -1.5)
tdSql.checkData(138, 1, -1.0)
tdSql.checkRows(128)
# tdSql.checkData(0, 1, -1.5)
# tdSql.checkData(138, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(none)")
tdSql.checkRows(139)
tdSql.checkData(0, 1, -1.5)
tdSql.checkData(138, 1, -1.0)
tdSql.checkRows(128)
# tdSql.checkData(0, 1, -1.5)
# tdSql.checkData(138, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(value, 2.0)")
tdSql.checkRows(141)
tdSql.checkData(0, 1, 2.0)
tdSql.checkData(140, 1, 2.0)
# tdSql.checkData(0, 1, 2.0)
# tdSql.checkData(140, 1, 2.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(prev)")
tdSql.checkRows(141)
tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, -1.0)
# tdSql.checkData(0, 1, None)
# tdSql.checkData(140, 1, -1.0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)")
tdSql.checkRows(141)
tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, None)
# tdSql.checkData(0, 1, None)
# tdSql.checkData(140, 1, None)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(linear)")
tdSql.checkRows(141)
tdSql.checkData(0, 1, None)
tdSql.checkData(140, 1, None)
# tdSql.checkData(0, 1, None)
# tdSql.checkData(140, 1, None)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(next)")
tdSql.checkRows(141)
tdSql.checkData(0, 1, -1.5)
tdSql.checkData(140, 1, None)
# tdSql.checkData(0, 1, -1.5)
# tdSql.checkData(140, 1, None)
tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id")
rows = tdSql.queryRows
......
......@@ -93,9 +93,9 @@ class AutoGen:
return ''.join(random.choice(letters) for i in range(count))
# create db
def create_db(self, dbname):
def create_db(self, dbname, vgroups = 2, replica = 1):
self.dbname = dbname
tdSql.execute(f'create database {dbname}')
tdSql.execute(f'create database {dbname} vgroups {vgroups} replica {replica}')
tdSql.execute(f'use {dbname}')
# create table or stable
......
......@@ -859,5 +859,4 @@ class TDDnodes:
def getAsan(self):
return self.asan
tdDnodes = TDDnodes()
\ No newline at end of file
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 10,
"thread_count_create_tbl": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 10,
"num_of_records_per_req": 1,
"max_sql_len": 102400000,
"databases": [{
"dbinfo": {
"name": "json_test",
"drop": "yes",
"replica": 1,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096
},
"super_tables": [{
"name": "stb_old",
"child_table_exists":"no",
"childtable_count": 1,
"childtable_prefix": "stb_old_",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "sample",
"sample_file": "./tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.csv",
"tags_file": "",
"columns": [{"type": "INT","count":1000}, {"type": "BINARY", "len": 16, "count":20}],
"tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":1}]
},{
"name": "stb_new",
"child_table_exists":"no",
"childtable_count": 1,
"childtable_prefix": "stb_new_",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "INT","count":4000}, {"type": "BINARY", "len": 16, "count":90}],
"tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":3}]
},{
"name": "stb_mix",
"child_table_exists":"no",
"childtable_count": 1,
"childtable_prefix": "stb_mix_",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "INT","count":500},{"type": "SMALLINT","count":500},{"type": "TINYINT","count":500},{"type": "DOUBLE","count":500},{"type": "FLOAT","count":500},{"type": "BOOL","count":500},{"type": "BIGINT","count":500},{"type": "NCHAR","len": 20,"count":300},{"type": "BINARY","len": 34,"count":290},{"type": "BINARY","len": 101,"count":1}],
"tags": [{"type": "INT", "count":3}, {"type": "NCHAR", "len": 10, "count":1}]
},{
"name": "stb_excel",
"child_table_exists":"no",
"childtable_count": 1,
"childtable_prefix": "stb_excel_",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 10,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"tags_file": "",
"columns": [{"type": "INT","count":500},{"type": "SMALLINT","count":500},{"type": "SMALLINT","count":500},{"type": "DOUBLE","count":500},{"type": "FLOAT","count":500},{"type": "BOOL","count":500},{"type": "BIGINT","count":500},{"type": "NCHAR","len": 30,"count":300},{"type": "BINARY","len": 47,"count":290},{"type": "BINARY","len": 211,"count":1}],
"tags": [{"type": "INT", "count":3}, {"type": "NCHAR", "len": 10, "count":1}]
}]
}]
}
\ No newline at end of file
###################################################################
# 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 random
import os
import time
import taos
import subprocess
import string
from faker import Faker
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
from util.dnodes import *
class TDTestCase:
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"querySmaOptimize":1}
def init(self, conn, logSql, replicaVar):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.testcasePath = os.path.split(__file__)[0]
self.testcaseFilename = os.path.split(__file__)[-1]
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
now = time.time()
self.ts = int(round(now * 1000))
self.num = 100
def get_random_string(self, length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
def ins_query(self):
sql = 'select * from information_schema.ins_tables where table_name match "table"'
tdSql.query(sql)
self.stable_query()
def stable_query(self):
# select * from stable_1 where loc match '[a-z]';
show_sql = "show db.stables;"
tdSql.query(show_sql)
queryRows = len(tdSql.queryResult)
for i in range(queryRows):
show_sql = "show db.stables;"
tdSql.query(show_sql)
stable_name = tdSql.queryResult[i][0]
stable_sql = "select * from db.%s where loc match '[a-z]'" %stable_name
tdSql.query(stable_sql)
def run_8(self):
print("==============step8,stable table , mix data type==============")
sql = "create stable db.stable_16(ts timestamp, "
sql += "col4090 int ,"
sql += "col4091 binary(65517))"
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table db.table_160 using db.stable_16
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(16370)
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_160 values(%d, "
sql += "'%d'," % i
sql += "'%s')" % self.get_random_string(65517)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_160")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_160")
tdSql.checkRows(self.num)
tdSql.checkCols(3)
self.ins_query()
#insert null value
tdLog.info('test insert null value')
sql = '''create table db.table_161 using db.stable_16
tags('table_61' , '1' , '2' , '3' );'''
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_161(ts) values(%d) "
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_161")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_161")
tdSql.checkRows(self.num)
tdSql.checkCols(3)
#define TSDB_MAX_BYTES_PER_ROW 65531 TSDB_MAX_TAGS_LEN 16384
#ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset]
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_17(ts timestamp, "
sql += "col4090 int,"
sql += "col4091 binary(65517))"
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) " #4*3+16370+2
tdSql.execute(sql)
sql = '''create table db.table_170 using db.stable_17
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(16370)
tdSql.execute(sql)
tdSql.query("select * from db.table_170")
tdSql.checkCols(3)
tdSql.query("describe db.table_170")
tdSql.checkRows(7)
self.ins_query()
tdLog.info('test super table drop and add column or tag')
sql = "alter stable db.stable_17 drop column col4091; "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_17 add column col4091 binary(65518); "
tdSql.error(sql)
sql = "alter table db.stable_17 add column col4091 binary(65517); "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(7)
self.ins_query()
sql = "alter stable db.stable_17 drop tag loc; "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_17 add tag loc binary(16371); "
tdSql.error(sql)
sql = "alter table db.stable_17 add tag loc binary(16370); "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(7)
sql = "alter stable db.stable_17 drop tag tag_1; "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_17 add tag tag_1 int; "
tdSql.execute(sql)
sql = "select * from db.stable_17; "
tdSql.query(sql)
tdSql.checkCols(7)
sql = "alter table db.stable_17 add tag loc1 nchar(10); "
tdSql.error(sql)
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_18(ts timestamp, "
sql += "col4091 binary(65518))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
tdLog.info('test super table max bytes per row tag 16384')
sql = "create table db.stable_18(ts timestamp, "
sql += "col4091 binary(65517))"
sql += " tags (loc binary(16371),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
self.ins_query()
def run_9(self):
print("==============step9,stable table , mix data type==============")
sql = "create stable db.stable_26(ts timestamp, "
sql += "col4090 int ,"
sql += "col4091 binary(65517))"
sql += " tags (loc nchar(4092),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table db.table_260 using db.stable_26
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(4092)
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_260 values(%d, "
sql += "'%d'," % i
sql += "'%s')" % self.get_random_string(65517)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_260")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_260")
tdSql.checkRows(self.num)
tdSql.checkCols(3)
self.ins_query()
#insert null value
tdLog.info('test insert null value')
sql = '''create table db.table_261 using db.stable_26
tags('table_261' , '1' , '2' , '3' );'''
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_261(ts) values(%d) "
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_261")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_261")
tdSql.checkRows(self.num)
tdSql.checkCols(3)
#define TSDB_MAX_BYTES_PER_ROW 65531 TSDB_MAX_TAGS_LEN 16384
#ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset]
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_27(ts timestamp, "
sql += "col4090 int,"
sql += "col4091 binary(65517))"
sql += " tags (loc nchar(4092),tag_1 int,tag_2 int,tag_3 int) " #4*3+16370+2
tdSql.execute(sql)
sql = '''create table db.table_270 using db.stable_27
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(4092)
tdSql.execute(sql)
tdSql.query("select * from db.table_270")
tdSql.checkCols(3)
tdSql.query("describe db.table_270")
tdSql.checkRows(7)
self.ins_query()
tdLog.info('test super table drop and add column or tag')
sql = "alter stable db.stable_27 drop column col4091; "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_27 add column col4091 binary(65518); "
tdSql.error(sql)
sql = "alter table db.stable_27 add column col4091 binary(65517); "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(7)
self.ins_query()
sql = "alter stable db.stable_27 drop tag loc; "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_27 add tag loc binary(16371); "
tdSql.error(sql)
sql = "alter table db.stable_27 add tag loc binary(16370); "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(7)
sql = "alter stable db.stable_27 drop tag tag_1; "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(6)
sql = "alter table db.stable_27 add tag tag_1 int; "
tdSql.execute(sql)
sql = "select * from db.stable_27; "
tdSql.query(sql)
tdSql.checkCols(7)
sql = "alter table db.stable_27 add tag loc1 nchar(10); "
tdSql.error(sql)
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_28(ts timestamp, "
sql += "col4091 binary(65518))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
tdLog.info('test super table max bytes per row tag 16384')
sql = "create table db.stable_28(ts timestamp, "
sql += "col4091 binary(65517))"
sql += " tags (loc binary(16371),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
self.ins_query()
def run_1(self):
print("==============step1, regular table, 1 ts + 4094 cols + 1 binary==============")
startTime = time.time()
sql = "create table db.regular_table_1(ts timestamp, "
for i in range(4094):
sql += "col%d int, " % (i + 1)
sql += "col4095 binary(22))"
tdLog.info(len(sql))
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.regular_table_1 values(%d, "
for j in range(4094):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_1")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.regular_table_1")
tdSql.checkRows(self.num)
tdSql.checkCols(4096)
self.ins_query()
endTime = time.time()
print("total time %ds" % (endTime - startTime))
#insert in order
tdLog.info('test insert in order')
for i in range(self.num):
sql = "insert into db.regular_table_1 (ts,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col4095) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 1000))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_1")
tdSql.checkData(0, 0, 2*self.num)
tdSql.query("select * from db.regular_table_1")
tdSql.checkRows(2*self.num)
tdSql.checkCols(4096)
#insert out of order
tdLog.info('test insert out of order')
for i in range(self.num):
sql = "insert into db.regular_table_1 (ts,col123,col2213,col331,col41,col523,col236,col71,col813,col912,col1320,col4095) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 2000))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_1")
tdSql.checkData(0, 0, 3*self.num)
tdSql.query("select * from db.regular_table_1")
tdSql.checkRows(3*self.num)
tdSql.checkCols(4096)
self.ins_query()
def run_2(self):
print("==============step2,regular table error col or value==============")
tdLog.info('test regular table exceeds row num')
# column > 4096
sql = "create table db.regular_table_2(ts timestamp, "
for i in range(4095):
sql += "col%d int, " % (i + 1)
sql += "col4096 binary(22))"
tdLog.info(len(sql))
tdSql.error(sql)
self.ins_query()
# column > 4096
sql = "insert into db.regular_table_1 values(%d, "
for j in range(4095):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.error(sql)
# insert column < 4096
sql = "insert into db.regular_table_1 values(%d, "
for j in range(4092):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.error(sql)
# alter column > 4096
sql = "alter table db.regular_table_1 add column max int; "
tdSql.error(sql)
self.ins_query()
def run_3(self):
print("==============step3,regular table , mix data type==============")
startTime = time.time()
sql = "create table db.regular_table_3(ts timestamp, "
for i in range(2000):
sql += "col%d int, " % (i + 1)
for i in range(2000,4094):
sql += "col%d bigint, " % (i + 1)
sql += "col4095 binary(22))"
tdLog.info(len(sql))
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.regular_table_3 values(%d, "
for j in range(4094):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_3")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.regular_table_3")
tdSql.checkRows(self.num)
tdSql.checkCols(4096)
self.ins_query()
endTime = time.time()
print("total time %ds" % (endTime - startTime))
sql = "create table db.regular_table_4(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(4), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(10), " % (i + 1)
for i in range(4090,4094):
sql += "timestamp_%d timestamp, " % (i + 1)
sql += "col4095 binary(22))"
tdLog.info(len(sql))
tdSql.execute(sql)
self.ins_query()
for i in range(self.num):
sql = "insert into db.regular_table_4 values(%d, "
for j in range(500):
str = "'%s', " % random.randint(-2147483647,2147483647)
sql += str
for j in range(500,1000):
str = "'%s', " % random.randint(-32767,32767 )
sql += str
for j in range(1000,1500):
str = "'%s', " % random.randint(-127,127)
sql += str
for j in range(1500,2000):
str = "'%s', " % random.randint(-922337203685477580700,922337203685477580700)
sql += str
for j in range(2000,2500):
str = "'%s', " % random.randint(-92233720368547758070,92233720368547758070)
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true','false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
for j in range(4090,4094):
str = "%s, " % (self.ts + j)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_4")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.regular_table_4")
tdSql.checkRows(self.num)
tdSql.checkCols(4096)
tdLog.info("end ,now new one")
self.ins_query()
#insert null value
tdLog.info('test insert null value')
for i in range(self.num):
sql = "insert into db.regular_table_4 values(%d, "
for j in range(2500):
str = "'%s', " % random.choice(['NULL' ,'NULL' ,'NULL' ,1 , 10 ,100 ,-100 ,-10, 88 ,66 ,'NULL' ,'NULL' ,'NULL' ])
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true' ,'false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
for j in range(4090,4094):
str = "%s, " % (self.ts + j)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 10000))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_4")
tdSql.checkData(0, 0, 2*self.num)
tdSql.query("select * from db.regular_table_4")
tdSql.checkRows(2*self.num)
tdSql.checkCols(4096)
#insert in order
tdLog.info('test insert in order')
for i in range(self.num):
sql = "insert into db.regular_table_4 (ts,int_2,int_22,int_169,smallint_537,smallint_607,tinyint_1030,tinyint_1491,double_1629,double_1808,float_2075,col4095) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 1000))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_4")
tdSql.checkData(0, 0, 3*self.num)
tdSql.query("select * from db.regular_table_4")
tdSql.checkRows(3*self.num)
tdSql.checkCols(4096)
self.ins_query()
#insert out of order
tdLog.info('test insert out of order')
for i in range(self.num):
sql = "insert into db.regular_table_4 (ts,int_169,float_2075,int_369,tinyint_1491,tinyint_1030,float_2360,smallint_537,double_1808,double_1608,double_1629,col4095) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 2000))
time.sleep(1)
tdSql.query("select count(*) from db.regular_table_4")
tdSql.checkData(0, 0, 4*self.num)
tdSql.query("select * from db.regular_table_4")
tdSql.checkRows(4*self.num)
tdSql.checkCols(4096)
#define TSDB_MAX_BYTES_PER_ROW 49151[old:1024 && 16384]
# 3.0 old: tag binary max is 16384, col+ts binary max 49151
# 3.0 new: tag binary max is 16384-2, col+ts binary max 65531
#ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset]
tdLog.info('test regular_table max bytes per row 65531')
sql = "create table db.regular_table_5(ts timestamp, " #1*8 sum=8
for i in range(500):
sql += "int_%d int, " % (i + 1) #500*4=2000 sum=2008
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1) #500*2=1000 sum=3008
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1) #500*1=500 sum=3508
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1) #500*8=4000 sum=7508
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1) #500*4=2000 sum=9508
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1) #500*1=500 sum=10008
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1) #500*8=4000 sum=14008
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1) #300*(32*4+2)=39000 sum=53008
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1) #290*(40+2)=12180 sum=65188
for i in range(4090,4094):
sql += "timestamp_%d timestamp, " % (i + 1) #4*8=32 sum=65220
sql += "col4095 binary(309))" #309+2=311 sum=65531
tdSql.execute(sql)
tdSql.query("select * from db.regular_table_5")
tdSql.checkCols(4096)
sql = "alter table db.regular_table_5 modify column col4095 binary(310); "
tdSql.error(sql)
self.ins_query()
# drop and add
sql = "alter table db.regular_table_5 drop column col4095; "
tdSql.execute(sql)
sql = "select * from db.regular_table_5; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.regular_table_5 add column col4095 binary(310); "
tdSql.error(sql)
sql = "alter table db.regular_table_5 add column col4095 binary(309); "
tdSql.execute(sql)
sql = "select * from db.regular_table_5; "
tdSql.query(sql)
tdSql.checkCols(4096)
#out TSDB_MAX_BYTES_PER_ROW 65531
tdLog.info('test regular_table max bytes per row out 65531')
sql = "create table db.regular_table_6(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1)
for i in range(4090,4094):
sql += "timestamp_%d timestamp, " % (i + 1)
sql += "col4095 binary(310))"
tdLog.info(len(sql))
tdSql.error(sql)
self.ins_query()
def run_4(self):
print("==============step4, super table , 1 ts + 4090 cols + 4 tags ==============")
startTime = time.time()
sql = "create stable db.stable_1(ts timestamp, "
for i in range(4090):
sql += "col%d int, " % (i + 1)
sql += "col4091 binary(22))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table db.table_0 using db.stable_1
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(10)
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_0 values(%d, "
for j in range(4090):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_0")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_0")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
sql = '''create table db.table_1 using db.stable_1
tags('%s' , '1' , '2' , '3' );'''% self.get_random_string(10)
tdSql.execute(sql)
self.ins_query()
for i in range(self.num):
sql = "insert into db.table_1 values(%d, "
for j in range(2080):
sql += "'%d', " % random.randint(0,1000)
for j in range(2080,4080):
sql += "'%s', " % 'NULL'
for j in range(4080,4090):
sql += "'%s', " % random.randint(0,10000)
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_1")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_1")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
#insert in order
tdLog.info('test insert in order')
for i in range(self.num):
sql = "insert into db.table_1 (ts,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 1000))
time.sleep(1)
tdSql.query("select count(*) from db.table_1")
tdSql.checkData(0, 0, 2*self.num)
tdSql.query("select * from db.table_1")
tdSql.checkRows(2*self.num)
tdSql.checkCols(4092)
#insert out of order
tdLog.info('test insert out of order')
for i in range(self.num):
sql = "insert into db.table_1 (ts,col123,col2213,col331,col41,col523,col236,col71,col813,col912,col1320,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,1000)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 2000))
time.sleep(1)
tdSql.query("select count(*) from db.table_1")
tdSql.checkData(0, 0, 3*self.num)
tdSql.query("select * from db.table_1")
tdSql.checkRows(3*self.num)
tdSql.checkCols(4092)
self.ins_query()
def run_5(self):
print("==============step5,stable table , mix data type==============")
sql = "create stable db.stable_3(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(4), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(10), " % (i + 1)
sql += "col4091 binary(22))"
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table db.table_30 using db.stable_3
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
self.ins_query()
for i in range(self.num):
sql = "insert into db.table_30 values(%d, "
for j in range(500):
str = "'%s', " % random.randint(-2147483647,2147483647)
sql += str
for j in range(500,1000):
str = "'%s', " % random.randint(-32767,32767 )
sql += str
for j in range(1000,1500):
str = "'%s', " % random.randint(-127,127)
sql += str
for j in range(1500,2000):
str = "'%s', " % random.randint(-922337203685477580700,922337203685477580700)
sql += str
for j in range(2000,2500):
str = "'%s', " % random.randint(-92233720368547758070,92233720368547758070)
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true','false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_30")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_30")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
#insert null value
tdLog.info('test insert null value')
sql = '''create table db.table_31 using db.stable_3
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
for i in range(self.num):
sql = "insert into db.table_31 values(%d, "
for j in range(2500):
str = "'%s', " % random.choice(['NULL' ,'NULL' ,'NULL' ,1 , 10 ,100 ,-100 ,-10, 88 ,66 ,'NULL' ,'NULL' ,'NULL' ])
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true' ,'false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_31")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_31")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
self.ins_query()
#insert in order
tdLog.info('test insert in order')
for i in range(self.num):
sql = "insert into db.table_31 (ts,int_2,int_22,int_169,smallint_537,smallint_607,tinyint_1030,tinyint_1491,double_1629,double_1808,float_2075,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 1000))
time.sleep(1)
tdSql.query("select count(*) from db.table_31")
tdSql.checkData(0, 0, 2*self.num)
tdSql.query("select * from db.table_31")
tdSql.checkRows(2*self.num)
tdSql.checkCols(4092)
#insert out of order
tdLog.info('test insert out of order')
for i in range(self.num):
sql = "insert into db.table_31 (ts,int_169,float_2075,int_369,tinyint_1491,tinyint_1030,float_2360,smallint_537,double_1808,double_1608,double_1629,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 2000))
time.sleep(1)
tdSql.query("select count(*) from db.table_31")
tdSql.checkData(0, 0, 3*self.num)
tdSql.query("select * from db.table_31")
tdSql.checkRows(3*self.num)
tdSql.checkCols(4092)
#define TSDB_MAX_BYTES_PER_ROW 65531 TSDB_MAX_TAGS_LEN 16384
#ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset]
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_4(ts timestamp, " #1*8 sum=8
for i in range(500):
sql += "int_%d int, " % (i + 1) #500*4=2000 sum=2008
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1) #500*2=1000 sum=3008
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1) #500*1=500 sum=3508
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1) #500*8=4000 sum=7508
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1) #500*4=2000 sum=9508
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1) #500*1=500 sum=10008
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1) #500*8=4000 sum=14008
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1) #300*(32*4+2)=39000 sum=53008
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1) #290*(40+2)=12180 sum=65188
sql += "col4091 binary(341))" #341+2=343 sum=65531
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) "
tdSql.execute(sql)
sql = '''create table db.table_40 using db.stable_4
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
tdSql.query("select * from db.table_40")
tdSql.checkCols(4092)
tdSql.query("describe db.table_40")
tdSql.checkRows(4096)
tdLog.info('test super table drop and add column or tag')
sql = "alter stable db.stable_4 drop column col4091; "
tdSql.execute(sql)
sql = "select * from db.stable_4; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.stable_4 add column col4091 binary(342); "
tdSql.error(sql)
sql = "alter table db.stable_4 add column col4091 binary(341); "
tdSql.execute(sql)
sql = "select * from db.stable_4; "
tdSql.query(sql)
tdSql.checkCols(4096)
self.ins_query()
sql = "alter stable db.stable_4 drop tag tag_1; "
tdSql.execute(sql)
sql = "select * from db.stable_4; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.stable_4 add tag tag_1 int; "
tdSql.execute(sql)
sql = "select * from db.stable_4; "
tdSql.query(sql)
tdSql.checkCols(4096)
sql = "alter table db.stable_4 add tag loc1 nchar(10); "
tdSql.error(sql)
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_5(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1)
sql += "col4091 binary(342))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
self.ins_query()
def run_6(self):
print("==============step6,stable table , mix data type==============")
sql = "create stable db.stable_6(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(4), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(10), " % (i + 1)
sql += "col4091 binary(22))"
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.execute(sql)
sql = '''create table db.table_60 using db.stable_6
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
self.ins_query()
for i in range(self.num):
sql = "insert into db.table_60 values(%d, "
for j in range(500):
str = "'%s', " % random.randint(-2147483647,2147483647)
sql += str
for j in range(500,1000):
str = "'%s', " % random.randint(-32767,32767 )
sql += str
for j in range(1000,1500):
str = "'%s', " % random.randint(-127,127)
sql += str
for j in range(1500,2000):
str = "'%s', " % random.randint(-922337203685477580700,922337203685477580700)
sql += str
for j in range(2000,2500):
str = "'%s', " % random.randint(-92233720368547758070,92233720368547758070)
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true','false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_60")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_60")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
#insert null value
tdLog.info('test insert null value')
sql = '''create table db.table_61 using db.stable_6
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
self.ins_query()
for i in range(self.num):
sql = "insert into db.table_61 values(%d, "
for j in range(2500):
str = "'%s', " % random.choice(['NULL' ,'NULL' ,'NULL' ,1 , 10 ,100 ,-100 ,-10, 88 ,66 ,'NULL' ,'NULL' ,'NULL' ])
sql += str
for j in range(2500,3000):
str = "'%s', " % random.choice(['true' ,'false'])
sql += str
for j in range(3000,3500):
str = "'%s', " % random.randint(-9223372036854775807,9223372036854775807)
sql += str
for j in range(3500,3800):
str = "'%s', " % self.get_random_string(4)
sql += str
for j in range(3800,4090):
str = "'%s', " % self.get_random_string(10)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i))
time.sleep(1)
tdSql.query("select count(*) from db.table_61")
tdSql.checkData(0, 0, self.num)
tdSql.query("select * from db.table_61")
tdSql.checkRows(self.num)
tdSql.checkCols(4092)
#insert in order
tdLog.info('test insert in order')
for i in range(self.num):
sql = "insert into db.table_61 (ts,int_2,int_22,int_169,smallint_537,smallint_607,tinyint_1030,tinyint_1491,double_1629,double_1808,float_2075,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 1000))
time.sleep(1)
tdSql.query("select count(*) from db.table_61")
tdSql.checkData(0, 0, 2*self.num)
tdSql.query("select * from db.table_61")
tdSql.checkRows(2*self.num)
tdSql.checkCols(4092)
#insert out of order
tdLog.info('test insert out of order')
for i in range(self.num):
sql = "insert into db.table_61 (ts,int_169,float_2075,int_369,tinyint_1491,tinyint_1030,float_2360,smallint_537,double_1808,double_1608,double_1629,col4091) values(%d, "
for j in range(10):
str = "'%s', " % random.randint(0,100)
sql += str
sql += "'%s')" % self.get_random_string(22)
tdSql.execute(sql % (self.ts + i + 2000))
time.sleep(1)
tdSql.query("select count(*) from db.table_61")
tdSql.checkData(0, 0, 3*self.num)
tdSql.query("select * from db.table_61")
tdSql.checkRows(3*self.num)
tdSql.checkCols(4092)
self.ins_query()
#define TSDB_MAX_BYTES_PER_ROW 65531 TSDB_MAX_TAGS_LEN 16384
#ts:8\int:4\smallint:2\bigint:8\bool:1\float:4\tinyint:1\nchar:4*()+2[offset]\binary:1*()+2[offset]
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_7(ts timestamp, " #1*8 sum=8
for i in range(500):
sql += "int_%d int, " % (i + 1) #500*4=2000 sum=2008
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1) #500*2=1000 sum=3008
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1) #500*1=500 sum=3508
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1) #500*8=4000 sum=7508
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1) #500*4=2000 sum=9508
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1) #500*1=500 sum=10008
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1) #500*8=4000 sum=14008
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1) #300*(32*4+2)=39000 sum=53008
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1) #290*(40+2)=12180 sum=65188
sql += "col4091 binary(341))" #341+2=343 sum=65531
sql += " tags (loc binary(16370),tag_1 int,tag_2 int,tag_3 int) " #4*3+16370+2
tdSql.execute(sql)
sql = '''create table db.table_70 using db.stable_7
tags('%s' , '1' , '2' , '3' );'''%self.get_random_string(16370)
tdSql.execute(sql)
tdSql.query("select * from db.table_70")
tdSql.checkCols(4092)
tdSql.query("describe db.table_70")
tdSql.checkRows(4096)
tdLog.info('test super table drop and add column or tag')
sql = "alter stable db.stable_7 drop column col4091; "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.stable_7 add column col4091 binary(342); "
tdSql.error(sql)
sql = "alter table db.stable_7 add column col4091 binary(341); "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4096)
sql = "alter stable db.stable_7 drop tag loc; "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.stable_7 add tag loc binary(16371); "
tdSql.error(sql)
sql = "alter table db.stable_7 add tag loc binary(16370); "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4096)
sql = "alter stable db.stable_7 drop tag tag_1; "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4095)
sql = "alter table db.stable_7 add tag tag_1 int; "
tdSql.execute(sql)
sql = "select * from db.stable_7; "
tdSql.query(sql)
tdSql.checkCols(4096)
sql = "alter table db.stable_7 add tag loc1 nchar(10); "
tdSql.error(sql)
self.ins_query()
tdLog.info('test super table max bytes per row 65531')
sql = "create table db.stable_8(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1)
sql += "col4091 binary(342))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
tdLog.info('test super table max bytes per row tag 16384')
sql = "create table db.stable_8(ts timestamp, "
for i in range(500):
sql += "int_%d int, " % (i + 1)
for i in range(500,1000):
sql += "smallint_%d smallint, " % (i + 1)
for i in range(1000,1500):
sql += "tinyint_%d tinyint, " % (i + 1)
for i in range(1500,2000):
sql += "double_%d double, " % (i + 1)
for i in range(2000,2500):
sql += "float_%d float, " % (i + 1)
for i in range(2500,3000):
sql += "bool_%d bool, " % (i + 1)
for i in range(3000,3500):
sql += "bigint_%d bigint, " % (i + 1)
for i in range(3500,3800):
sql += "nchar_%d nchar(32), " % (i + 1)
for i in range(3800,4090):
sql += "binary_%d binary(40), " % (i + 1)
sql += "col4091 binary(341))"
sql += " tags (loc binary(16371),tag_1 int,tag_2 int,tag_3 int) "
tdSql.error(sql)
def run_7(self):
print("==============step7, super table error col ==============")
tdLog.info('test exceeds row num')
# column + tag > 4096
sql = "create stable db.stable_2(ts timestamp, "
for i in range(4091):
sql += "col%d int, " % (i + 1)
sql += "col4092 binary(22))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int) "
tdLog.info(len(sql))
tdSql.error(sql)
self.ins_query()
# column + tag > 4096
sql = "create stable db.stable_2(ts timestamp, "
for i in range(4090):
sql += "col%d int, " % (i + 1)
sql += "col4091 binary(22))"
sql += " tags (loc nchar(10),tag_1 int,tag_2 int,tag_3 int,tag_4 int) "
tdLog.info(len(sql))
tdSql.error(sql)
# alter column + tag > 4096
sql = "alter table db.stable_1 add column max int; "
tdSql.error(sql)
sql = "alter table db.stable_1 add tag max int; "
tdSql.error(sql)
sql = "alter table db.stable_4 modify column col4091 binary(102); "
tdSql.error(sql)
sql = "alter table db.stable_4 modify tag loc nchar(20); "
tdSql.query("select * from db.table_70")
tdSql.checkCols(4092)
tdSql.query("describe db.table_70")
tdSql.checkRows(4096)
self.ins_query()
def run(self):
tdSql.prepare()
startTime_all = time.time()
self.run_8()
self.run_9()
self.run_1()
self.run_2()
# self.run_3()
# self.run_4()
# self.run_5()
# self.run_6()
# self.run_7()
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
###################################################################
# 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 -*-
from util.cases import tdCases
from .rowlength64k import *
class TDTestCase(TDTestCase):
def run(self):
tdSql.prepare()
startTime_all = time.time()
#self.run_1()
# self.run_2()
self.run_3()
#self.run_4()
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
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 -*-
from util.cases import tdCases
from .rowlength64k import *
class TDTestCase(TDTestCase):
def run(self):
tdSql.prepare()
startTime_all = time.time()
# self.run_1()
# self.run_2()
# self.run_3()
self.run_4()
#self.run_5()
# self.run_5()
# self.run_6()
# self.run_7()
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
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 -*-
from util.cases import tdCases
from .rowlength64k import *
class TDTestCase(TDTestCase):
def run(self):
tdSql.prepare()
startTime_all = time.time()
# self.run_1()
# self.run_2()
# self.run_3()
# self.run_4()
self.run_6()
self.run_7()
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
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 -*-
from util.cases import tdCases
from .rowlength64k import *
class TDTestCase(TDTestCase):
def run(self):
tdSql.prepare()
startTime_all = time.time()
# self.run_1()
# self.run_2()
# self.run_3()
#self.run_4()
self.run_5()
# self.run_5()
# self.run_6()
# self.run_7()
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
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 random
import os
import time
import taos
import subprocess
import string
from faker import Faker
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
from util.dnodes import *
class TDTestCase:
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"querySmaOptimize":1}
def init(self, conn, logSql, replicaVar):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.testcasePath = os.path.split(__file__)[0]
self.testcaseFilename = os.path.split(__file__)[-1]
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
now = time.time()
self.ts = int(round(now * 1000))
self.num = 100
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
def run(self):
tdSql.prepare()
startTime_all = time.time()
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/"
#-N:regular table -d:database name -t:table num -n:rows num per table -l:col num -y:force
#regular old && new
startTime = time.time()
os.system("%staosBenchmark -N -d regular_old -t 1 -n 10 -l 1023 -y" % binPath)
tdSql.execute("use regular_old")
tdSql.query("show tables;")
tdSql.checkRows(1)
tdSql.query("select * from meters;")
tdSql.checkCols(1024)
tdSql.query("describe meters;")
tdSql.checkRows(1024)
os.system("%staosBenchmark -N -d regular_new -t 1 -n 10 -l 4095 -y" % binPath)
tdSql.execute("use regular_new")
tdSql.query("show tables;")
tdSql.checkRows(1)
tdSql.query("select * from meters;")
tdSql.checkCols(4096)
tdSql.query("describe meters;")
tdSql.checkRows(4096)
#super table -d:database name -t:table num -n:rows num per table -l:col num -y:force
os.system("%staosBenchmark -d super_old -t 1 -n 10 -l 1021 -y" % binPath)
tdSql.execute("use super_old")
tdSql.query("show tables;")
tdSql.checkRows(1)
tdSql.query("select * from meters;")
tdSql.checkCols(1024)
tdSql.query("select * from d0;")
tdSql.checkCols(1022)
tdSql.query("describe meters;")
tdSql.checkRows(1024)
tdSql.query("describe d0;")
tdSql.checkRows(1024)
os.system("%staosBenchmark -d super_new -t 1 -n 10 -l 4093 -y" % binPath)
tdSql.execute("use super_new")
tdSql.query("show tables;")
tdSql.checkRows(1)
tdSql.query("select * from meters;")
tdSql.checkCols(4096)
tdSql.query("select * from d0;")
tdSql.checkCols(4094)
tdSql.query("describe meters;")
tdSql.checkRows(4096)
tdSql.query("describe d0;")
tdSql.checkRows(4096)
tdSql.execute("create table stb_new1_1 using meters tags(1,2)")
tdSql.query("select * from stb_new1_1")
tdSql.checkCols(4094)
tdSql.query("describe stb_new1_1;")
tdSql.checkRows(4096)
# insert: create one or mutiple tables per sql and insert multiple rows per sql
os.system("%staosBenchmark -f %s/rowlength64k.json -y " % (binPath,self.testcasePath))
tdSql.execute("use json_test")
tdSql.query("select count (tbname) from stb_old")
tdSql.checkData(0, 0, 10)
tdSql.query("select * from stb_old")
tdSql.checkRows(10)
tdSql.checkCols(1024)
tdSql.query("select count (tbname) from stb_new")
tdSql.checkData(0, 0, 10)
tdSql.query("select * from stb_new")
tdSql.checkRows(10)
tdSql.checkCols(4096)
tdSql.query("describe stb_new;")
tdSql.checkRows(4096)
tdSql.query("select * from stb_new_0")
tdSql.checkRows(10)
tdSql.checkCols(4091)
tdSql.query("describe stb_new_0;")
tdSql.checkRows(4096)
tdSql.execute("create table stb_new1_1 using stb_new tags(1,2,3,4,5)")
tdSql.query("select * from stb_new1_1")
tdSql.checkCols(4091)
tdSql.query("describe stb_new1_1;")
tdSql.checkRows(4096)
tdSql.query("select count (tbname) from stb_mix")
tdSql.checkData(0, 0, 10)
tdSql.query("select * from stb_mix")
tdSql.checkRows(10)
tdSql.checkCols(4096)
tdSql.query("describe stb_mix;")
tdSql.checkRows(4096)
tdSql.query("select * from stb_mix_0")
tdSql.checkRows(10)
tdSql.checkCols(4092)
tdSql.query("describe stb_mix_0;")
tdSql.checkRows(4096)
tdSql.query("select count (tbname) from stb_excel")
tdSql.checkData(0, 0, 10)
tdSql.query("select * from stb_excel")
tdSql.checkRows(10)
tdSql.checkCols(4096)
tdSql.query("describe stb_excel;")
tdSql.checkRows(4096)
tdSql.query("select * from stb_excel_0")
tdSql.checkRows(10)
tdSql.checkCols(4092)
tdSql.query("describe stb_excel_0;")
tdSql.checkRows(4096)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
endTime_all = time.time()
print("total time %ds" % (endTime_all - startTime_all))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
###################################################################
# 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 -*-
from util.log import *
from util.cases import *
from util.sql import *
from util.common import *
from util.sqlset import *
from util.dnodes import *
from util.autogen import *
from util.cluster import *
import random
import os
import subprocess
import shutil
import time
class RestoreBasic:
# init
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor())
self.dnodes_num = 5
# get from global
# test
self.dnodes = cluster.dnodes
num = len(self.dnodes)
if num < self.dnodes_num :
tdLog.exit(f" cluster dnode is less than {self.dnodes_num}. num={num}")
# create data
self.dbname = "db"
self.stable = "st"
self.child_count = 100
self.insert_rows = 10000
self.create_data()
# create data
def create_data(self):
gen = AutoGen()
gen.create_db(self.dbname, 8, 3)
gen.create_stable(self.stable, 5, 10, 8, 8)
gen.create_child(self.stable, "d", self.child_count)
gen.set_batch_size(1000)
gen.insert_data(self.insert_rows)
tdSql.execute(f"flush database {self.dbname}")
# put some duplicate ts on wal
gen.insert_data(self.insert_rows%100)
for i in range(self.dnodes_num):
sql = f"create qnode on dnode {i+1}"
tdSql.execute(sql)
# status
def check_status_corrent(self):
# query
tdSql.query(f" show {self.dbname}.vgroups")
# check 8 vgroups
tdSql.checkRows(8)
# check data corrent
for i in range(8):
leader = False
for j in range(3):
status = tdSql.getData(i, 4 + j*2)
if status == "leader":
leader = True
elif status == "follower":
pass
else:
tdLog.info(f" check vgroups status not leader or follower. i={i} j={j} status={status}")
return False
# check leader
if leader == False:
tdLog.info(f" check vgroups not found leader i={i} ")
return False
# info
tdLog.info("check vgroups status successfully.")
return True
# check data corrent
def check_corrent(self):
# check status
status = False
for i in range(100):
if self.check_status_corrent():
status = True
break
else:
time.sleep(0.5)
tdLog.info(f"sleep 500ms retry {i} to check status again...")
if status == False:
tdLog.exit("check vgroups status failed, exit.")
# check rows count
sql = f"select count(ts) from {self.dbname}.{self.stable}"
tdSql.query(sql)
tdSql.checkData(0, 0, self.child_count* self.insert_rows)
# restore dnode
def restore_dnode(self, index):
tdLog.info(f"start restore dnode {index}")
dnode = self.dnodes[index - 1]
# stop dnode
tdLog.info(f"stop dnode {index}")
dnode.stoptaosd()
# remove dnode folder
try:
shutil.rmtree(dnode.dataDir)
tdLog.info(f"delete dir {dnode.dataDir} successful")
except OSError as x:
tdLog.exit(f"remove path {dnode.dataDir} error : {x.strerror}")
dnode.starttaosd()
# exec restore
sql = f"restore dnode {index}"
tdLog.info(sql)
tdSql.execute(sql)
self.check_corrent()
# restore vnode
def restore_vnode(self, index):
tdLog.info(f"start restore vnode on dnode {index}")
dnode = self.dnodes[index - 1]
del_dir = f"{dnode.dataDir}/vnode"
# stop dnode
tdLog.info(f"stop dnode {index}")
dnode.stoptaosd()
# remove dnode folder
try:
shutil.rmtree(del_dir)
tdLog.info(f"delete dir {del_dir} successful")
except OSError as x:
tdLog.exit(f"remove path {del_dir} error : {x.strerror}")
dnode.starttaosd()
# exec restore
sql = f"restore vnode on dnode {index}"
tdLog.info(sql)
tdSql.execute(sql)
# check result
self.check_corrent()
# restore mnode
def restore_mnode(self, index):
tdLog.info(f"start restore mnode {index}")
dnode = self.dnodes[index - 1]
del_dir = f"{dnode.dataDir}/mnode"
# stop dnode
tdLog.info(f"stop dnode {index}")
dnode.stoptaosd()
# remove dnode folder
try:
shutil.rmtree(del_dir)
tdLog.info(f"delete dir {del_dir} successful")
except OSError as x:
tdLog.exit(f"remove path {del_dir} error : {x.strerror}")
dnode.starttaosd()
# exec restore
sql = f"restore mnode on dnode {index}"
tdLog.info(sql)
tdSql.execute(sql)
self.check_corrent()
# restore qnode
def restore_qnode(self, index):
tdLog.info(f"start restore qnode on dnode {index}")
dnode = self.dnodes[index - 1]
del_dir = f"{dnode.dataDir}/qnode"
# stop dnode
tdLog.info(f"stop dnode {index}")
dnode.stoptaosd()
# remove dnode folder
try:
shutil.rmtree(del_dir)
tdLog.info(f"delete dir {del_dir} successful")
except OSError as x:
tdLog.exit(f"remove path {del_dir} error : {x.strerror}")
# start dnode
dnode.starttaosd()
# exec restore
sql = f"restore qnode on dnode {index}"
tdLog.info(sql)
tdSql.execute(sql)
self.check_corrent()
# path exist
qfile = f"{del_dir}/qnode.json"
if os.path.exists(qfile) == False:
tdLog.exit(f"qnode restore failed. qnode.json is not exist. {qfile}")
else:
tdLog.info(f"check qnode.json restore ok. {qfile}")
# stop
def stop(self):
tdSql.close()
###################################################################
# 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 *
from util.common import *
sys.path.append("./3-enterprise/restore")
from restoreBasic import *
class TDTestCase:
# init
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
self.basic = RestoreBasic()
self.basic.init(conn, logSql, replicaVar)
# run
def run(self):
self.basic.restore_dnode(2)
# stop
def stop(self):
self.basic.stop()
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 *
from util.common import *
sys.path.append("./3-enterprise/restore")
from restoreBasic import *
class TDTestCase:
# init
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
self.basic = RestoreBasic()
self.basic.init(conn, logSql, replicaVar)
# run
def run(self):
self.basic.restore_mnode(3)
# stop
def stop(self):
self.basic.stop()
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 *
from util.common import *
sys.path.append("./3-enterprise/restore")
from restoreBasic import *
class TDTestCase:
# init
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
self.basic = RestoreBasic()
self.basic.init(conn, logSql, replicaVar)
# run
def run(self):
self.basic.restore_qnode(5)
# stop
def stop(self):
self.basic.stop()
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 *
from util.common import *
sys.path.append("./3-enterprise/restore")
from restoreBasic import *
class TDTestCase:
# init
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
self.basic = RestoreBasic()
self.basic.init(conn, logSql, replicaVar)
# run
def run(self):
self.basic.restore_vnode(4)
# stop
def stop(self):
self.basic.stop()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -71,7 +71,6 @@ SWords shellCommands[] = {
{"alter all dnodes \"monitor\" \"0\";", 0, 0, NULL},
{"alter all dnodes \"monitor\" \"1\";", 0, 0, NULL},
{"alter table <tb_name> <tb_actions> <anyword> ;", 0, 0, NULL},
{"alter table modify column", 0, 0, NULL},
{"alter local \"resetlog\";", 0, 0, NULL},
{"alter local \"DebugFlag\" \"143\";", 0, 0, NULL},
{"alter local \"cDebugFlag\" \"143\";", 0, 0, NULL},
......@@ -120,6 +119,10 @@ SWords shellCommands[] = {
{"kill transaction ", 0, 0, NULL},
{"merge vgroup ", 0, 0, NULL},
{"reset query cache;", 0, 0, NULL},
{"restore dnode <dnode_id> ;", 0, 0, NULL},
{"restore vnode on dnode <dnode_id> ;", 0, 0, NULL},
{"restore mnode on dnode <dnode_id> ;", 0, 0, NULL},
{"restore qnode on dnode <dnode_id> ;", 0, 0, NULL},
{"revoke all on <anyword> from <user_name> ;", 0, 0, NULL},
{"revoke read on <anyword> from <user_name> ;", 0, 0, NULL},
{"revoke write on <anyword> from <user_name> ;", 0, 0, NULL},
......@@ -326,7 +329,7 @@ TdThreadMutex tiresMutex;
TdThread* threads[WT_FROM_DB_CNT];
// obtain var name with sql from server
char varTypes[WT_VAR_CNT][64] = {
"<db_name>", "<stb_name>", "<tb_name>", "<dnode_id >", "<user_name>", "<topic_name>", "<stream_name>",
"<db_name>", "<stb_name>", "<tb_name>", "<dnode_id>", "<user_name>", "<topic_name>", "<stream_name>",
"<udf_name>", "<all_table>", "<function>", "<keyword>", "<tb_actions>", "<db_options>", "<alter_db_options>",
"<data_types>", "<key_tags>", "<anyword>", "<tb_options>", "<user_actions>", "<key_select>", "<sys_table>", "<udf_language>"};
......@@ -345,12 +348,12 @@ int cntDel = 0; // delete byte count after next press tab
// show auto tab introduction
void printfIntroduction() {
printf(" ****************************** Tab Completion **********************************\n");
printf(" ******************************** Tab Completion ************************************\n");
char secondLine[160] = "\0";
sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName);
printf("%s", secondLine);
int secondLineLen = strlen(secondLine);
while (84 - (secondLineLen++) > 0) {
while (87 - (secondLineLen++) > 0) {
printf(" ");
}
printf("*\n");
......@@ -382,7 +385,6 @@ void showHelp() {
alter all dnodes \"resetlog\";\n\
alter all dnodes \"debugFlag\" \n\
alter table <tb_name> <tb_actions> ;\n\
alter table modify column\n\
alter local \"resetlog\";\n\
alter local \"DebugFlag\" \"143\";\n\
alter topic\n\
......@@ -434,6 +436,10 @@ void showHelp() {
merge vgroup ...\n\
----- R ----- \n\
reset query cache;\n\
restore dnode <dnode_id> ;\n\
restore vnode on dnode <dnode_id> ;\n\
restore mnode on dnode <dnode_id> ;\n\
restore qnode on dnode <dnode_id> ;\n\
revoke all on <priv_level> from <user_name> ;\n\
revoke read on <priv_level> from <user_name> ;\n\
revoke write on <priv_level> from <user_name> ;\n\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册