From ef2e95952447539187e4eb326400774d77b5ed74 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Sat, 11 Jun 2022 10:16:11 +0000 Subject: [PATCH 01/19] update test case for alter table --- tests/system-test/1-insert/alter_stable.py | 6 ++++++ tests/system-test/1-insert/alter_table.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/system-test/1-insert/alter_stable.py b/tests/system-test/1-insert/alter_stable.py index c92efb403c..cd64e3ddfe 100644 --- a/tests/system-test/1-insert/alter_stable.py +++ b/tests/system-test/1-insert/alter_stable.py @@ -77,6 +77,7 @@ class TDTestCase: tdSql.error(f'alter stable {stbname} modify column c9 double') tdSql.error(f'alter stable {stbname} modify column c10 float') tdSql.error(f'alter stable {stbname} modify column c11 int') + tdSql.error(f'alter stable {stbname} drop tag t0') tdSql.execute(f'drop database {dbname}') def alter_stable_tag_check(self,dbname,stbname,tbname): @@ -126,6 +127,11 @@ class TDTestCase: for i in ['int','unsigned int','float','binary(10)','nchar(10)']: tdSql.error(f'alter stable {stbname} modify tag t8 {i}') tdSql.error(f'alter stable {stbname} modify tag t4 int') + tdSql.error(f'alter stable {stbname} drop column t0') + #!bug TD-16410 + # tdSql.error(f'alter stable {tbname} set tag t1=100 ') + # tdSql.execute(f'create table ntb (ts timestamp,c0 int)') + tdSql.error(f'alter stable ntb add column c2 ') tdSql.execute(f'drop database {dbname}') def run(self): diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index 3c0def86e4..ec3e771cbd 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -125,6 +125,22 @@ class TDTestCase: tdSql.execute(f'alter table {dbname}.{tbname} drop column `c15`') tdSql.query(f'describe {dbname}.{tbname}') tdSql.checkRows(14) + #! TD-16422 + # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 binary(10)') + # tdSql.query(f'describe {dbname}.{tbname}') + # tdSql.checkRows(15) + # print(tdSql.queryResult) + # tdSql.checkEqual(tdSql.queryResult[14][2],10) + # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') + + # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 nchar(10)') + # tdSql.query(f'describe {dbname}.{tbname}') + # tdSql.checkRows(15) + # print(tdSql.queryResult) + # tdSql.checkEqual(tdSql.queryResult[14][2],10) + # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') + + tdSql.execute(f'alter table {dbname}.{tbname} modify column c12 binary(30)') tdSql.query(f'describe {dbname}.{tbname}') tdSql.checkData(12,2,30) @@ -164,6 +180,9 @@ class TDTestCase: tdSql.error(f'alter table {dbname}.{tbname} modify column c10 float') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') + + + tdSql.execute(f'drop database {dbname}') def alter_stb_column_check(self): dbname = self.get_long_name(length=10, mode="letters") From 8182cc733df121f11217b5fac8838352de2ffa21 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Tue, 14 Jun 2022 17:47:46 +0800 Subject: [PATCH 02/19] update test case --- tests/system-test/2-query/bottom.py | 100 ++---- tests/system-test/2-query/last.py | 466 +++++----------------------- tests/system-test/2-query/max.py | 222 +++---------- 3 files changed, 164 insertions(+), 624 deletions(-) diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index 008f59aa6a..5620975ef2 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -24,78 +24,42 @@ class TDTestCase: self.rowNum = 10 self.ts = 1537146000000 - - def run(self): + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + def bottom_check_base(self): tdSql.prepare() - - tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + tdSql.execute("create table stb_1 using stb tags('beijing')") + column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] + error_column_list = ['col11','col12','col13'] + error_param_list = [0,101] for i in range(self.rowNum): - tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - - # bottom verifacation - tdSql.error("select bottom(ts, 10) from test") - tdSql.error("select bottom(col1, 0) from test") - tdSql.error("select bottom(col1, 101) from test") - tdSql.error("select bottom(col2, 0) from test") - tdSql.error("select bottom(col2, 101) from test") - tdSql.error("select bottom(col3, 0) from test") - tdSql.error("select bottom(col3, 101) from test") - tdSql.error("select bottom(col4, 0) from test") - tdSql.error("select bottom(col4, 101) from test") - tdSql.error("select bottom(col5, 0) from test") - tdSql.error("select bottom(col5, 101) from test") - tdSql.error("select bottom(col6, 0) from test") - tdSql.error("select bottom(col6, 101) from test") - tdSql.error("select bottom(col7, 10) from test") - tdSql.error("select bottom(col8, 10) from test") - tdSql.error("select bottom(col9, 10) from test") - - tdSql.query("select bottom(col1, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - tdSql.query("select bottom(col2, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col3, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col4, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col11, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col12, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col13, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - - tdSql.query("select bottom(col13,50) from test") - tdSql.checkRows(10) - - tdSql.query("select bottom(col14, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) - tdSql.query("select ts,bottom(col1, 2) from test1") - tdSql.checkRows(2) - tdSql.query("select ts,bottom(col1, 2),ts from test group by tbname") - tdSql.checkRows(2) - - tdSql.query('select bottom(col2,1) from test interval(1y) order by col2') - tdSql.checkData(0,0,1) + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + + for i in column_list: + tdSql.query(f'select bottom({i},2) from stb_1') + tdSql.checkRows(2) + tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)]) + for j in error_param_list: + tdSql.error(f'select bottom({i},{j}) from stb_1') + for i in error_column_list: + tdSql.error(f'select bottom({i},10) from stb_1') + # tdSql.query("select ts,bottom(col1, 2),ts from stb_1 group by tbname") + # tdSql.checkRows(2) + # tdSql.query('select bottom(col2,1) from stb_1 interval(1y) order by col2') + # tdSql.checkData(0,0,1) - tdSql.error('select * from test where bottom(col2,1)=1') + tdSql.error('select * from stb_1 where bottom(col2,1)=1') + tdSql.execute('drop database db') + + + pass + def run(self): + + self.bottom_check_base() def stop(self): diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index 4ef13e9142..2ce528adf6 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -11,415 +11,115 @@ class TDTestCase: self.rowNum = 10 self.ts = 1537146000000 - - def run(self): + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + + def last_check_stb_tb_base(self): tdSql.prepare() - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') tdSql.execute("create table stb_1 using stb tags('beijing')") tdSql.execute("insert into stb_1(ts) values(%d)" % (self.ts - 1)) - - # last verifacation - tdSql.query("select last(*) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, None) - tdSql.query("select last(*) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, None) - tdSql.query("select last(col1) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col1) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col2) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col2) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col3) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col3) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col4) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col4) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col11) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col11) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col12) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col12) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col13) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col13) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col14) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col14) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col5) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col5) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col6) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col6) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col7) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col7) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col8) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col8) from db.stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col9) from stb_1") - tdSql.checkRows(0) - tdSql.query("select last(col9) from db.stb_1") - tdSql.checkRows(0) + # last check for tb + for i in ['stb_1','db.stb_1','stb_1','db.stb_1']: + tdSql.query("select last(*) from stb_1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + for i in range(1, 14): + for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: + tdSql.query(f"select last(col{i}) from {j}") + tdSql.checkRows(0) tdSql.query("select count(col1) from stb_1 group by col7") tdSql.checkRows(1) - for i in range(self.rowNum): - tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - - tdSql.query("select last(*) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, 10) - tdSql.query("select last(*) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, 10) - tdSql.query("select last(col1) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col1) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col5) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col5) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col7) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col7) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col8) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col8) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col9) from stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') - tdSql.query("select last(col9) from db.stb_1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + for i in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + tdSql.query(f"select last(*) from {i}") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + for i in range(1, 14): + for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + tdSql.query(f"select last(col{i}) from {j}") + tdSql.checkRows(1) + # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned + if i >=1 and i<9: + tdSql.checkData(0, 0, 10) + # float,double + elif i>=9 and i<11: + tdSql.checkData(0, 0, 9.1) + # bool + elif i == 11: + tdSql.checkData(0, 0, True) + # binary + elif i == 12: + tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') + # nchar + elif i == 13: + tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') tdSql.query("select last(col1,col2,col3) from stb_1") - tdSql.checkData(0,2,10) + tdSql.checkData(0, 2, 10) - tdSql.query("select last(*) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 1, 10) - tdSql.query("select last(*) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 1, 10) - tdSql.query("select last(col1) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col1) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col5) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col5) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col7) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col7) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col8) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col8) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col9) from stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') - tdSql.query("select last(col9) from db.stb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') - tdSql.query("select last(col1,col2,col3) from stb") - tdSql.checkData(0,2,10) - - - tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') - tdSql.execute("insert into ntb(ts) values(%d)" % (self.ts - 1)) + tdSql.error("select col1 from stb where last(col13)='涛思数据10'") + tdSql.error("select col1 from stb_1 where last(col13)='涛思数据10'") + tdSql.execute('drop database db') + + def last_check_ntb_base(self): + tdSql.prepare() + tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''') + tdSql.execute("insert into ntb(ts) values(%d)" % (self.ts - 1)) tdSql.query("select last(*) from ntb") tdSql.checkRows(1) tdSql.checkData(0, 1, None) tdSql.query("select last(*) from db.ntb") tdSql.checkRows(1) tdSql.checkData(0, 1, None) - tdSql.query("select last(col1) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col1) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col2) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col2) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col3) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col3) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col4) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col4) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col11) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col11) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col12) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col12) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col13) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col13) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col14) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col14) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col5) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col5) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col6) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col6) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col7) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col7) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col8) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col8) from db.ntb") - tdSql.checkRows(0) - tdSql.query("select last(col9) from ntb") - tdSql.checkRows(0) - tdSql.query("select last(col9) from db.ntb") - tdSql.checkRows(0) - + for i in range(1,14): + for j in['ntb','db.ntb']: + tdSql.query(f"select last(col{i}) from {j}") + tdSql.checkRows(0) for i in range(self.rowNum): - tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - + tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) tdSql.query("select last(*) from ntb") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) tdSql.query("select last(*) from db.ntb") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - tdSql.query("select last(col1) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col1) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col2) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col3) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col4) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col11) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col12) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col13) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col14) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 10) - tdSql.query("select last(col5) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col5) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col6) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 9.1) - tdSql.query("select last(col7) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col7) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, True) - tdSql.query("select last(col8) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col8) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata10') - tdSql.query("select last(col9) from ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') - tdSql.query("select last(col9) from db.ntb") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据10') - tdSql.query("select last(col1,col2,col3) from ntb") - tdSql.checkData(0,2,10) + for i in range(1, 9): + for j in ['ntb', 'db.ntb']: + tdSql.query(f"select last(col{i}) from {j}") + tdSql.checkRows(1) + # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned + if i >=1 and i<9: + tdSql.checkData(0, 0, 10) + # float,double + elif i>=9 and i<11: + tdSql.checkData(0, 0, 9.1) + # bool + elif i == 11: + tdSql.checkData(0, 0, True) + # binary + elif i == 12: + tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') + # nchar + elif i == 13: + tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') - tdSql.error("select col1 from stb where last(col9)='涛思数据10'") tdSql.error("select col1 from ntb where last(col9)='涛思数据10'") - tdSql.error("select col1 from stb_1 where last(col9)='涛思数据10'") + + def run(self): + self.last_check_stb_tb_base() + self.last_check_ntb_base() + + 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 +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/max.py b/tests/system-test/2-query/max.py index 5342c7d449..8e520636f8 100644 --- a/tests/system-test/2-query/max.py +++ b/tests/system-test/2-query/max.py @@ -11,192 +11,68 @@ class TDTestCase: self.rowNum = 10 self.ts = 1537146000000 - - def prepare_data(self): - - pass - def run(self): + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + def max_check_stb_and_tb_base(self): tdSql.prepare() - intData = [] floatData = [] - - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') tdSql.execute("create table stb_1 using stb tags('beijing')") - tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''') for i in range(self.rowNum): - tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) - for i in range(self.rowNum): - tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - intData.append(i + 1) - floatData.append(i + 0.1) + for i in ['ts','col11','col12','col13']: + for j in ['db.stb','stb','db.stb_1','stb_1']: + tdSql.error(f'select max({i} from {j} )') - # max verifacation - tdSql.error("select max(ts) from stb_1") - tdSql.error("select max(ts) from db.stb_1") - tdSql.error("select max(col7) from stb_1") - tdSql.error("select max(col7) from db.stb_1") - tdSql.error("select max(col8) from stb_1") - tdSql.error("select max(col8) from db.stb_1") - tdSql.error("select max(col9) from stb_1") - tdSql.error("select max(col9) from db.stb_1") - - tdSql.query("select max(col1) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col1) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from db.stb_1") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col5) from stb_1") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col5) from db.stb_1") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from stb_1") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from db.stb_1") - tdSql.checkData(0, 0, np.max(floatData)) + for i in range(1,11): + for j in ['db.stb','stb','db.stb_1','stb_1']: + tdSql.query(f"select max(col{i}) from {j}") + if i<9: + tdSql.checkData(0, 0, np.max(intData)) + elif i>=9: + tdSql.checkData(0, 0, np.max(floatData)) tdSql.query("select max(col1) from stb_1 where col2<=5") tdSql.checkData(0,0,5) - - - - tdSql.error("select max(ts) from stb") - tdSql.error("select max(ts) from db.stb") - tdSql.error("select max(col7) from stb") - tdSql.error("select max(col7) from db.stb") - tdSql.error("select max(col8) from stb") - tdSql.error("select max(col8) from db.stb") - tdSql.error("select max(col9) from stb") - tdSql.error("select max(col9) from db.stb") - - tdSql.query("select max(col1) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col1) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from db.stb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col5) from stb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col5) from db.stb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from stb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from db.stb") - tdSql.checkData(0, 0, np.max(floatData)) tdSql.query("select max(col1) from stb where col2<=5") tdSql.checkData(0,0,5) - - - - tdSql.error("select max(ts) from ntb") - tdSql.error("select max(ts) from db.ntb") - tdSql.error("select max(col7) from ntb") - tdSql.error("select max(col7) from db.ntb") - tdSql.error("select max(col8) from ntb") - tdSql.error("select max(col8) from db.ntb") - tdSql.error("select max(col9) from ntb") - tdSql.error("select max(col9) from db.ntb") - - tdSql.query("select max(col1) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col1) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col2) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col3) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col4) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col11) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col12) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col13) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col14) from db.ntb") - tdSql.checkData(0, 0, np.max(intData)) - tdSql.query("select max(col5) from ntb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col5) from db.ntb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from ntb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col6) from db.ntb") - tdSql.checkData(0, 0, np.max(floatData)) - tdSql.query("select max(col1) from stb_1 where col2<=5") + tdSql.execute('drop database db') + + def max_check_ntb_base(self): + tdSql.prepare() + intData = [] + floatData = [] + tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''') + for i in range(self.rowNum): + tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + intData.append(i + 1) + floatData.append(i + 0.1) + for i in ['ts','col11','col12','col13']: + for j in ['db.ntb','ntb']: + tdSql.error(f'select max({i} from {j} )') + for i in range(1,11): + for j in ['db.ntb','ntb']: + tdSql.query(f"select max(col{i}) from {j}") + if i<9: + tdSql.checkData(0, 0, np.max(intData)) + elif i>=9: + tdSql.checkData(0, 0, np.max(floatData)) + tdSql.query("select max(col1) from ntb where col2<=5") tdSql.checkData(0,0,5) + tdSql.execute('drop database db') + + def run(self): + self.max_check_stb_and_tb_base() + self.max_check_ntb_base() + + + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From a95baab68f67c103dbd7b64b1e3bc96f3d10abe5 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Tue, 14 Jun 2022 18:34:48 +0800 Subject: [PATCH 03/19] update --- tests/system-test/1-insert/alter_table.py | 10 +++++----- tests/system-test/2-query/bottom.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index ec3e771cbd..3c17d9525e 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -90,13 +90,13 @@ class TDTestCase: tdSql.checkData(0,15,tag_nchar) # bug TD-16211 insert length more than setting binary and nchar - # tag_binary = self.get_long_name(length=21, mode="letters") - # tag_nchar = self.get_long_name(length=21, mode="letters") - # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"') - # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"') + tag_binary = self.get_long_name(length=21, mode="letters") + tag_nchar = self.get_long_name(length=21, mode="letters") + tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"') + tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"') # bug TD-16210 modify binary to nchar - # tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') + tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') tdSql.execute(f"drop database {dbname}") def alter_ntb_column_check(self): ''' diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index 5620975ef2..3c82dd4128 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -46,10 +46,10 @@ class TDTestCase: tdSql.error(f'select bottom({i},{j}) from stb_1') for i in error_column_list: tdSql.error(f'select bottom({i},10) from stb_1') - # tdSql.query("select ts,bottom(col1, 2),ts from stb_1 group by tbname") - # tdSql.checkRows(2) - # tdSql.query('select bottom(col2,1) from stb_1 interval(1y) order by col2') - # tdSql.checkData(0,0,1) + tdSql.query("select ts,bottom(col1, 2),ts from stb_1 group by tbname") + tdSql.checkRows(2) + tdSql.query('select bottom(col2,1) from stb_1 interval(1y) order by col2') + tdSql.checkData(0,0,1) tdSql.error('select * from stb_1 where bottom(col2,1)=1') From 25f04bae59f41c04c70ec992a4e8a747306423d0 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Tue, 14 Jun 2022 19:00:05 +0800 Subject: [PATCH 04/19] update --- tests/system-test/2-query/top.py | 93 +++++++++----------------------- 1 file changed, 24 insertions(+), 69 deletions(-) diff --git a/tests/system-test/2-query/top.py b/tests/system-test/2-query/top.py index 146bb34937..b0dcb9aec2 100644 --- a/tests/system-test/2-query/top.py +++ b/tests/system-test/2-query/top.py @@ -23,81 +23,36 @@ class TDTestCase: self.rowNum = 10 self.ts = 1537146000000 - - def run(self): + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + def top_check_base(self): tdSql.prepare() - - - - tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table test1 using test tags('beijing')") + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + tdSql.execute("create table stb_1 using stb tags('beijing')") for i in range(self.rowNum): - tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - - - # top verifacation - tdSql.error("select top(ts, 10) from test") - tdSql.error("select top(col1, 0) from test") - tdSql.error("select top(col1, 101) from test") - tdSql.error("select top(col2, 0) from test") - tdSql.error("select top(col2, 101) from test") - tdSql.error("select top(col3, 0) from test") - tdSql.error("select top(col3, 101) from test") - tdSql.error("select top(col4, 0) from test") - tdSql.error("select top(col4, 101) from test") - tdSql.error("select top(col5, 0) from test") - tdSql.error("select top(col5, 101) from test") - tdSql.error("select top(col6, 0) from test") - tdSql.error("select top(col6, 101) from test") - tdSql.error("select top(col7, 10) from test") - tdSql.error("select top(col8, 10) from test") - tdSql.error("select top(col9, 10) from test") - tdSql.error("select top(col11, 0) from test") - tdSql.error("select top(col11, 101) from test") - tdSql.error("select top(col12, 0) from test") - tdSql.error("select top(col12, 101) from test") - tdSql.error("select top(col13, 0) from test") - tdSql.error("select top(col13, 101) from test") - tdSql.error("select top(col14, 0) from test") - tdSql.error("select top(col14, 101) from test") - - tdSql.query("select top(col1, 2) from test") + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] + error_column_list = ['col11','col12','col13'] + error_param_list = [0,101] + for i in column_list: + tdSql.query(f'select top({i},2) from stb_1') + tdSql.checkRows(2) + tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) + for j in error_param_list: + tdSql.error(f'select top({i},{j}) from stb_1') + for i in error_column_list: + tdSql.error(f'select top({i},10) from stb_1') + tdSql.query("select ts,top(col1, 2),ts from stb_1 group by tbname") tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col2, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col3, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col4, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col11, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col12, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col13, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select top(col14, 2) from test") - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - tdSql.query("select ts,top(col1, 2),ts from test1") - tdSql.checkRows(2) - tdSql.query("select top(col14, 100) from test") - tdSql.checkRows(10) - tdSql.query("select ts,top(col1, 2),ts from test group by tbname") - tdSql.checkRows(2) - tdSql.query('select top(col2,1) from test interval(1y) order by col2') + tdSql.query('select top(col2,1) from stb_1 interval(1y) order by col2') tdSql.checkData(0,0,10) - tdSql.error("select * from test where bottom(col2,1)=1") tdSql.error("select top(col14, 0) from test;") + + def run(self): + self.top_check_base() def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From d2350019dd25cc65b0de96377a4528ccd886d645 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Wed, 15 Jun 2022 09:15:40 +0800 Subject: [PATCH 05/19] update --- tests/system-test/1-insert/alter_table.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index 3c17d9525e..6ae6febfe4 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -52,8 +52,6 @@ class TDTestCase: tdSql.execute(f'create database if not exists {dbname}') stbname = self.get_long_name(length=3, mode="letters") tbname = self.get_long_name(length=3, mode="letters") - tdLog.info('--------------------------child table tag check--------------------------------------') - tdLog.info(f'-----------------create stable {stbname} and child table {tbname}-------------------') tdSql.execute(f'create stable if not exists {dbname}.{stbname} (col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int, \ t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))') tdSql.execute(f'create table if not exists {dbname}.{tbname} using {dbname}.{stbname} tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")') @@ -90,10 +88,10 @@ class TDTestCase: tdSql.checkData(0,15,tag_nchar) # bug TD-16211 insert length more than setting binary and nchar - tag_binary = self.get_long_name(length=21, mode="letters") - tag_nchar = self.get_long_name(length=21, mode="letters") - tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"') - tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"') + # error_tag_binary = self.get_long_name(length=21, mode="letters") + # error_tag_nchar = self.get_long_name(length=21, mode="letters") + # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') + # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') # bug TD-16210 modify binary to nchar tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') @@ -129,14 +127,12 @@ class TDTestCase: # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 binary(10)') # tdSql.query(f'describe {dbname}.{tbname}') # tdSql.checkRows(15) - # print(tdSql.queryResult) # tdSql.checkEqual(tdSql.queryResult[14][2],10) # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 nchar(10)') # tdSql.query(f'describe {dbname}.{tbname}') # tdSql.checkRows(15) - # print(tdSql.queryResult) # tdSql.checkEqual(tdSql.queryResult[14][2],10) # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') @@ -180,9 +176,6 @@ class TDTestCase: tdSql.error(f'alter table {dbname}.{tbname} modify column c10 float') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') - - - tdSql.execute(f'drop database {dbname}') def alter_stb_column_check(self): dbname = self.get_long_name(length=10, mode="letters") From 612226aa3961a7283fa841c4e86754c867f1d9fc Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Wed, 15 Jun 2022 10:31:21 +0800 Subject: [PATCH 06/19] update --- tests/system-test/1-insert/alter_table.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index 6ae6febfe4..fb5696f343 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -88,10 +88,10 @@ class TDTestCase: tdSql.checkData(0,15,tag_nchar) # bug TD-16211 insert length more than setting binary and nchar - # error_tag_binary = self.get_long_name(length=21, mode="letters") - # error_tag_nchar = self.get_long_name(length=21, mode="letters") - # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') - # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') + error_tag_binary = self.get_long_name(length=21, mode="letters") + error_tag_nchar = self.get_long_name(length=21, mode="letters") + tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') + tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') # bug TD-16210 modify binary to nchar tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') From 1063b155e622ebb510beded7301a78c4717879f7 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Wed, 15 Jun 2022 17:30:17 +0800 Subject: [PATCH 07/19] update test case --- tests/system-test/1-insert/alter_table.py | 9 ++- tests/system-test/2-query/first.py | 29 ++++++++ tests/system-test/2-query/last.py | 90 +++++++++++++++++++++-- 3 files changed, 120 insertions(+), 8 deletions(-) diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index fb5696f343..a4e40d1b0b 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -88,11 +88,14 @@ class TDTestCase: tdSql.checkData(0,15,tag_nchar) # bug TD-16211 insert length more than setting binary and nchar - error_tag_binary = self.get_long_name(length=21, mode="letters") - error_tag_nchar = self.get_long_name(length=21, mode="letters") + # error_tag_binary = self.get_long_name(length=21, mode="letters") + # error_tag_nchar = self.get_long_name(length=21, mode="letters") + # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') + # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') + error_tag_binary = self.get_long_name(length=25, mode="letters") + error_tag_nchar = self.get_long_name(length=25, mode="letters") tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') - # bug TD-16210 modify binary to nchar tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') tdSql.execute(f"drop database {dbname}") diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 7227d1afb5..f0e99f61da 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -26,7 +26,35 @@ class TDTestCase: self.rowNum = 10 self.ts = 1537146000000 + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + def first_check_base(self): + tdSql.prepare() + + tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + tdSql.execute("create table stb_1 using stb tags('beijing')") + tdSql.execute("insert into stb_1(ts) values(%d)" % (self.ts - 1)) + for i in ['stb_1','db.stb_1','stb_1','db.stb_1']: + tdSql.query(f"select first(*) from {i}") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + #!bug TD-16561 + # for i in ['stb','db.stb','stb','db.stb']: + # tdSql.query(f"select first(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) + for i in range(1, 14): + for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: + tdSql.query(f"select first(col{i}) from {j}") + tdSql.checkRows(0) + for i in range(self.rowNum): + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + + + pass def run(self): tdSql.prepare() @@ -40,6 +68,7 @@ class TDTestCase: tdSql.query("select first(*) from test1") tdSql.checkRows(1) tdSql.checkData(0, 1, None) + tdSql.query("select first(col1) from test1") tdSql.checkRows(0) diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index 2ce528adf6..9d5e5269f8 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -1,3 +1,5 @@ +import random +import string from util.log import * from util.cases import * from util.sql import * @@ -14,23 +16,41 @@ class TDTestCase: self.binary_str = 'taosdata' self.nchar_str = '涛思数据' + def get_long_name(self, length, mode="mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) def last_check_stb_tb_base(self): tdSql.prepare() - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') tdSql.execute("create table stb_1 using stb tags('beijing')") tdSql.execute("insert into stb_1(ts) values(%d)" % (self.ts - 1)) - # last check for tb + for i in ['stb_1','db.stb_1','stb_1','db.stb_1']: - tdSql.query("select last(*) from stb_1") + tdSql.query(f"select last(*) from {i}") tdSql.checkRows(1) tdSql.checkData(0, 1, None) + #!bug TD-16561 + # for i in ['stb','db.stb','stb','db.stb']: + # tdSql.query(f"select last(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) for i in range(1, 14): for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: tdSql.query(f"select last(col{i}) from {j}") tdSql.checkRows(0) - tdSql.query("select count(col1) from stb_1 group by col7") + tdSql.query("select last(col1) from stb_1 group by col7") tdSql.checkRows(1) for i in range(self.rowNum): tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" @@ -111,10 +131,70 @@ class TDTestCase: tdSql.error("select col1 from ntb where last(col9)='涛思数据10'") + def last_check_stb_distribute(self): + # prepare data for vgroup 5 + dbname = self.get_long_name(length=10, mode="letters") + stbname = self.get_long_name(length=5, mode="letters") + tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows + tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + for i in range(1,21): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) + # for i in [f'{stbname}', f'{dbname}.{stbname}']: + # tdSql.query(f"select last(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + print(vgroup_list_set) + print(vgroup_list) + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.info('This scene does not meet the requirements!\n') + tdLog.exit(1) + + for i in range(1,21): + for j in range(self.rowNum): + tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) + for i in [f'{stbname}', f'{dbname}.{stbname}']: + tdSql.query(f"select last(*) from {i}") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 10) + for i in range(1, 14): + for j in [f'{stbname}', f'{dbname}.{stbname}']: + tdSql.query(f"select last(col{i}) from {j}") + tdSql.checkRows(1) + # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned + if i >=1 and i<9: + tdSql.checkData(0, 0, 10) + # float,double + elif i>=9 and i<11: + tdSql.checkData(0, 0, 9.1) + # bool + elif i == 11: + tdSql.checkData(0, 0, True) + # binary + elif i == 12: + tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') + # nchar + elif i == 13: + tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') + tdSql.execute(f'drop database {dbname}') def run(self): self.last_check_stb_tb_base() self.last_check_ntb_base() - + self.last_check_stb_distribute() def stop(self): tdSql.close() From 998c9fa981176245135de8ebfffd81d6197863e2 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 16 Jun 2022 09:01:53 +0800 Subject: [PATCH 08/19] update --- tests/system-test/2-query/first.py | 221 ++++++++++++++--------------- tests/system-test/2-query/last.py | 9 +- 2 files changed, 109 insertions(+), 121 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index f0e99f61da..906d8b82b4 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -11,6 +11,8 @@ # -*- coding: utf-8 -*- +import random +import string import sys import taos from util.log import * @@ -28,6 +30,21 @@ class TDTestCase: self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' + + def get_long_name(self, length, mode="mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) def first_check_base(self): tdSql.prepare() @@ -41,7 +58,7 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 1, None) #!bug TD-16561 - # for i in ['stb','db.stb','stb','db.stb']: + # for i in ['stb','db.stb']: # tdSql.query(f"select first(*) from {i}") # tdSql.checkRows(1) # tdSql.checkData(0, 1, None) @@ -52,126 +69,98 @@ class TDTestCase: for i in range(self.rowNum): tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + for i in range(1, 14): + for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + tdSql.query(f"select first(col{i}) from {j}") + tdSql.checkRows(1) + # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned + if i >=1 and i<9: + tdSql.checkData(0, 0, 1) + # float,double + elif i>=9 and i<11: + tdSql.checkData(0, 0, 0.1) + # bool + elif i == 11: + tdSql.checkData(0, 0, False) + # binary + elif i == 12: + tdSql.checkData(0, 0, f'{self.binary_str}1') + # nchar + elif i == 13: + tdSql.checkData(0, 0, f'{self.nchar_str}1') + # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") + # tdSql.checkRows(0) + # tdSql.execute('drop database db') + def first_check_stb_distribute(self): + # prepare data for vgroup 4 + dbname = self.get_long_name(length=10, mode="letters") + stbname = self.get_long_name(length=5, mode="letters") + tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows + tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + for i in range(1,21): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) + # for i in [f'{stbname}', f'{dbname}.{stbname}']: + # tdSql.query(f"select last(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + # print(vgroup_list_set) + # print(vgroup_list) + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + + for i in range(1,21): + for j in range(self.rowNum): + tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) + #!bug TD-16561 + # for i in [f'{stbname}', f'{dbname}.{stbname}']: + # tdSql.query(f"select first(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) + for i in range(1, 14): + for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + tdSql.query(f"select first(col{i}) from {j}") + tdSql.checkRows(1) + # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned + if i >=1 and i<9: + tdSql.checkData(0, 0, 1) + # float,double + elif i>=9 and i<11: + tdSql.checkData(0, 0, 0.1) + # bool + elif i == 11: + tdSql.checkData(0, 0, False) + # binary + elif i == 12: + tdSql.checkData(0, 0, f'{self.binary_str}1') + # nchar + elif i == 13: + tdSql.checkData(0, 0, f'{self.nchar_str}1') + # tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + # tdSql.checkRows(0) + # tdSql.execute('drop database db') + + - pass def run(self): - tdSql.prepare() + self.first_check_base() - tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, - col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''') - tdSql.execute("create table test1 using test tags('beijing')") - tdSql.execute("insert into test1(ts) values(%d)" % (self.ts - 1)) - - # first verifacation - # bug TD-15957 - tdSql.query("select first(*) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, None) - - tdSql.query("select first(col1) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col2) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col3) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col4) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col11) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col12) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col13) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col14) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col5) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col6) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col7) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col8) from test1") - tdSql.checkRows(0) - - tdSql.query("select first(col9) from test1") - tdSql.checkRows(0) - - for i in range(self.rowNum): - tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) - - tdSql.query("select first(*) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 1, 1) - - tdSql.query("select first(col1) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col2) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col3) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col4) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col11) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col12) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col13) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col14) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 1) - - tdSql.query("select first(col5) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 0.1) - - tdSql.query("select first(col6) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 0.1) - - tdSql.query("select first(col7) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, False) - - tdSql.query("select first(col8) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, 'taosdata1') - - tdSql.query("select first(col9) from test1") - tdSql.checkRows(1) - tdSql.checkData(0, 0, '涛思数据1') - - - tdSql.query("select first(*),last(*) from test1 where ts < 23 interval(1s)") - tdSql.checkRows(0) def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index 9d5e5269f8..ace1363fe4 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -132,7 +132,7 @@ class TDTestCase: tdSql.error("select col1 from ntb where last(col9)='涛思数据10'") def last_check_stb_distribute(self): - # prepare data for vgroup 5 + # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") tdSql.execute(f"create database if not exists {dbname} vgroups 4") @@ -152,16 +152,15 @@ class TDTestCase: for i in range(len(tdSql.queryResult)): vgroup_list.append(tdSql.queryResult[i][6]) vgroup_list_set = set(vgroup_list) - print(vgroup_list_set) - print(vgroup_list) + # print(vgroup_list_set) + # print(vgroup_list) for i in vgroup_list_set: vgroups_num = vgroup_list.count(i) if vgroups_num >=2: tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') continue else: - tdLog.info('This scene does not meet the requirements!\n') - tdLog.exit(1) + tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') for i in range(1,21): for j in range(self.rowNum): From 2475e03703d8fac721c29eb9180823626ec4b353 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 16 Jun 2022 09:39:56 +0800 Subject: [PATCH 09/19] update first.py --- tests/system-test/2-query/first.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 906d8b82b4..dcb4f8213e 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -88,9 +88,9 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') - # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") - # tdSql.checkRows(0) - # tdSql.execute('drop database db') + tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") + tdSql.checkRows(0) + tdSql.execute('drop database db') def first_check_stb_distribute(self): # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") @@ -150,16 +150,16 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') - # tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") - # tdSql.checkRows(0) - # tdSql.execute('drop database db') + tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + tdSql.checkRows(0) + tdSql.execute('drop database db') pass def run(self): self.first_check_base() - + self.first_check_stb_distribute() def stop(self): From eecb4cc8c37d9b5e17175415fff83526c8c173ca Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 16 Jun 2022 09:53:11 +0800 Subject: [PATCH 10/19] update --- tests/system-test/2-query/first.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index dcb4f8213e..196023399f 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -88,9 +88,9 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') - tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") - tdSql.checkRows(0) - tdSql.execute('drop database db') + # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") + # tdSql.checkRows(0) + # tdSql.execute('drop database db') def first_check_stb_distribute(self): # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") @@ -159,7 +159,7 @@ class TDTestCase: pass def run(self): self.first_check_base() - self.first_check_stb_distribute() + # self.first_check_stb_distribute() def stop(self): From e3c57c21ca5df7333a01b7e2f30edbc9e026659d Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 16 Jun 2022 10:37:13 +0800 Subject: [PATCH 11/19] update --- tests/system-test/2-query/first.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 196023399f..b1c0d9b4b2 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -88,6 +88,7 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') + #!bug TD-16569 # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") # tdSql.checkRows(0) # tdSql.execute('drop database db') @@ -150,9 +151,10 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') - tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") - tdSql.checkRows(0) - tdSql.execute('drop database db') + #!bug TD-16569 + # tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + # tdSql.checkRows(0) + # tdSql.execute('drop database db') From 3a6e6ee3830d0058f76c0983480f3b88b30cfbee Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 16 Jun 2022 14:47:31 +0800 Subject: [PATCH 12/19] add test case --- tests/system-test/2-query/first.py | 14 +++--- tests/system-test/2-query/last.py | 12 ++--- tests/system-test/2-query/top.py | 72 +++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index b1c0d9b4b2..1c7cc09f87 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -27,6 +27,7 @@ class TDTestCase: tdSql.init(conn.cursor()) self.rowNum = 10 + self.tbnum = 20 self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' @@ -91,7 +92,7 @@ class TDTestCase: #!bug TD-16569 # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") # tdSql.checkRows(0) - # tdSql.execute('drop database db') + tdSql.execute('drop database db') def first_check_stb_distribute(self): # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") @@ -104,10 +105,9 @@ class TDTestCase: for i in range(1,21): tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) - # for i in [f'{stbname}', f'{dbname}.{stbname}']: - # tdSql.query(f"select last(*) from {i}") - # tdSql.checkRows(1) - # tdSql.checkData(0, 1, None) + for i in [f'{stbname}', f'{dbname}.{stbname}']: + tdSql.query(f"select first(*) from {i}") + tdSql.checkRows(0) tdSql.query('show tables') vgroup_list = [] for i in range(len(tdSql.queryResult)): @@ -123,7 +123,7 @@ class TDTestCase: else: tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') - for i in range(1,21): + for i in range(self.tbnum): for j in range(self.rowNum): tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) @@ -154,7 +154,7 @@ class TDTestCase: #!bug TD-16569 # tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") # tdSql.checkRows(0) - # tdSql.execute('drop database db') + tdSql.execute('drop database db') diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index ace1363fe4..99ead9fadc 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -12,6 +12,7 @@ class TDTestCase: tdSql.init(conn.cursor()) self.rowNum = 10 + self.tbnum = 20 self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' @@ -78,8 +79,9 @@ class TDTestCase: # nchar elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') - tdSql.query("select last(col1,col2,col3) from stb_1") - tdSql.checkData(0, 2, 10) + for i in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + tdSql.query("select last(col1,col2,col3) from stb_1") + tdSql.checkData(0, 2, 10) tdSql.error("select col1 from stb where last(col13)='涛思数据10'") tdSql.error("select col1 from stb_1 where last(col13)='涛思数据10'") @@ -140,7 +142,7 @@ class TDTestCase: # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') - for i in range(1,21): + for i in range(self.tbnum): tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) # for i in [f'{stbname}', f'{dbname}.{stbname}']: @@ -152,8 +154,6 @@ class TDTestCase: for i in range(len(tdSql.queryResult)): vgroup_list.append(tdSql.queryResult[i][6]) vgroup_list_set = set(vgroup_list) - # print(vgroup_list_set) - # print(vgroup_list) for i in vgroup_list_set: vgroups_num = vgroup_list.count(i) if vgroups_num >=2: @@ -162,7 +162,7 @@ class TDTestCase: else: tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') - for i in range(1,21): + for i in range(self.tbnum): for j in range(self.rowNum): tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) diff --git a/tests/system-test/2-query/top.py b/tests/system-test/2-query/top.py index b0dcb9aec2..329b4b69e9 100644 --- a/tests/system-test/2-query/top.py +++ b/tests/system-test/2-query/top.py @@ -11,6 +11,8 @@ # -*- coding: utf-8 -*- +import random +import string from util.log import * from util.cases import * from util.sql import * @@ -22,9 +24,24 @@ class TDTestCase: tdSql.init(conn.cursor()) self.rowNum = 10 + self.tbnum = 20 self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' + def get_long_name(self, length, mode="mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) def top_check_base(self): tdSql.prepare() tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, @@ -48,11 +65,62 @@ class TDTestCase: tdSql.checkRows(2) tdSql.query('select top(col2,1) from stb_1 interval(1y) order by col2') tdSql.checkData(0,0,10) - tdSql.error("select * from test where bottom(col2,1)=1") - tdSql.error("select top(col14, 0) from test;") + tdSql.error("select * from stb_1 where top(col2,1)=1") + tdSql.execute('drop database db') + def top_check_stb_distribute(self): + # prepare data for vgroup 4 + dbname = self.get_long_name(length=10, mode="letters") + stbname = self.get_long_name(length=5, mode="letters") + tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows + tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + for i in range(self.tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) + column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] + for i in [f'{stbname}', f'{dbname}.{stbname}']: + for j in column_list: + tdSql.query(f"select top({j},1) from {i}") + tdSql.checkRows(0) + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(self.rowNum): + for j in range(self.tbnum): + tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + error_column_list = ['col11','col12','col13'] + error_param_list = [0,101] + for i in column_list: + tdSql.query(f'select top({i},2) from {stbname}') + tdSql.checkRows(2) + tdSql.checkEqual(tdSql.queryResult,[(10,),(10,)]) + for j in error_param_list: + tdSql.error(f'select top({i},{j}) from {stbname}') + for i in error_column_list: + tdSql.error(f'select top({i},10) from {stbname}') + + tdSql.query(f"select ts,top(col1, 2),ts from {stbname} group by tbname") + tdSql.checkRows(2*self.tbnum) + tdSql.query(f'select top(col2,1) from {stbname} interval(1y) order by col2') + tdSql.checkData(0,0,10) + tdSql.error(f"select * from {stbname} where top(col2,1)=1") def run(self): self.top_check_base() + self.top_check_stb_distribute() def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From 7a9b49fddde39a005ad068c219a486d3aee63dd8 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 08:59:36 +0800 Subject: [PATCH 13/19] update --- tests/system-test/2-query/bottom.py | 37 +++++- tests/system-test/2-query/last.py | 180 +++++++++++++++++++--------- 2 files changed, 158 insertions(+), 59 deletions(-) diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index 3c82dd4128..be47da3c58 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -23,6 +23,7 @@ class TDTestCase: tdSql.init(conn.cursor()) self.rowNum = 10 + self.tbnum = 20 self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' @@ -51,10 +52,42 @@ class TDTestCase: tdSql.query('select bottom(col2,1) from stb_1 interval(1y) order by col2') tdSql.checkData(0,0,1) - tdSql.error('select * from stb_1 where bottom(col2,1)=1') tdSql.execute('drop database db') - + def bottom_check_distribute(self): + # prepare data for vgroup 4 + dbname = self.get_long_name(length=10, mode="letters") + stbname = self.get_long_name(length=5, mode="letters") + tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows + tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + for i in range(self.tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) + column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] + for i in [f'{stbname}', f'{dbname}.{stbname}']: + for j in column_list: + tdSql.query(f"select bottom({j},1) from {i}") + tdSql.checkRows(0) + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(self.rowNum): + for j in range(self.tbnum): + tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) pass def run(self): diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index 99ead9fadc..805a15a005 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -31,14 +31,51 @@ class TDTestCase: else: population = string.ascii_letters.lower() + string.digits return "".join(random.choices(population, k=length)) + + def set_create_normaltable_sql(self, ntbname, column_dict): + column_sql = '' + for k, v in column_dict.items(): + column_sql += f"{k} {v}," + create_ntb_sql = f'create table {ntbname} (ts timestamp,{column_sql[:-1]})' + return create_ntb_sql + + def set_create_stable_sql(self,stbname,column_dict,tag_dict): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}," + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}," + create_stb_sql = f'create table {stbname} (ts timestamp,{column_sql[:-1]}) tags({tag_sql[:-1]})' + return create_stb_sql + def last_check_stb_tb_base(self): tdSql.prepare() - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, - col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') - tdSql.execute("create table stb_1 using stb tags('beijing')") - tdSql.execute("insert into stb_1(ts) values(%d)" % (self.ts - 1)) - - for i in ['stb_1','db.stb_1','stb_1','db.stb_1']: + stbname = self.get_long_name(length=5, mode="letters") + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + tag_dict = { + 'loc':'nchar(20)' + } + tdSql.execute(self.set_create_stable_sql(stbname,column_dict,tag_dict)) + + tdSql.execute(f"create table {stbname}_1 using {stbname} tags('beijing')") + tdSql.execute(f"insert into {stbname}_1(ts) values(%d)" % (self.ts - 1)) + + for i in [f'{stbname}_1', f'db.{stbname}_1']: tdSql.query(f"select last(*) from {i}") tdSql.checkRows(1) tdSql.checkData(0, 1, None) @@ -47,104 +84,131 @@ class TDTestCase: # tdSql.query(f"select last(*) from {i}") # tdSql.checkRows(1) # tdSql.checkData(0, 1, None) - for i in range(1, 14): - for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: - tdSql.query(f"select last(col{i}) from {j}") + for i in column_dict.keys(): + for j in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: + tdSql.query(f"select last({i}) from {j}") tdSql.checkRows(0) - tdSql.query("select last(col1) from stb_1 group by col7") + tdSql.query(f"select last({list(column_dict.keys())[0]}) from {stbname}_1 group by {list(column_dict.keys())[-1]}") tdSql.checkRows(1) for i in range(self.rowNum): tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - for i in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + for i in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: tdSql.query(f"select last(*) from {i}") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - for i in range(1, 14): - for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: - tdSql.query(f"select last(col{i}) from {j}") + for k, v in column_dict.items(): + for j in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: + tdSql.query(f"select last({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >=1 and i<9: + if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ + or v == 'int unsigned' or v == 'bigint unsigned': tdSql.checkData(0, 0, 10) # float,double - elif i>=9 and i<11: + elif v == 'float' or v == 'double': tdSql.checkData(0, 0, 9.1) # bool - elif i == 11: + elif v == 'bool': tdSql.checkData(0, 0, True) # binary - elif i == 12: + elif 'binary' in v: tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') # nchar - elif i == 13: + elif 'nchar' in v: tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') - for i in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: - tdSql.query("select last(col1,col2,col3) from stb_1") + for i in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: + tdSql.query(f"select last({list(column_dict.keys())[0]},{list(column_dict.keys())[1]},{list(column_dict.keys())[2]}) from {stbname}_1") tdSql.checkData(0, 2, 10) - tdSql.error("select col1 from stb where last(col13)='涛思数据10'") - tdSql.error("select col1 from stb_1 where last(col13)='涛思数据10'") + tdSql.error(f"select {list(column_dict.keys())[0]} from {stbname} where last({list(column_dict.keys())[12]})='涛思数据10'") + tdSql.error(f"select {list(column_dict.keys())[0]} from {stbname}_1 where last({list(column_dict.keys())[12]})='涛思数据10'") tdSql.execute('drop database db') - + def last_check_ntb_base(self): tdSql.prepare() - tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, - col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''') - tdSql.execute("insert into ntb(ts) values(%d)" % (self.ts - 1)) - tdSql.query("select last(*) from ntb") + ntbname = self.get_long_name(length=5, mode="letters") + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + create_ntb_sql = self.set_create_normaltable_sql(ntbname, column_dict) + tdSql.execute(create_ntb_sql) + tdSql.execute(f"insert into {ntbname}(ts) values(%d)" % (self.ts - 1)) + tdSql.query(f"select last(*) from {ntbname}") tdSql.checkRows(1) tdSql.checkData(0, 1, None) - tdSql.query("select last(*) from db.ntb") + tdSql.query(f"select last(*) from db.{ntbname}") tdSql.checkRows(1) tdSql.checkData(0, 1, None) - for i in range(1,14): - for j in['ntb','db.ntb']: - tdSql.query(f"select last(col{i}) from {j}") + for i in column_dict.keys(): + for j in [f'{ntbname}', f'db.{ntbname}']: + tdSql.query(f"select last({i}) from {j}") tdSql.checkRows(0) for i in range(self.rowNum): - tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + tdSql.execute(f"insert into {ntbname} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - tdSql.query("select last(*) from ntb") + tdSql.query(f"select last(*) from {ntbname}") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - tdSql.query("select last(*) from db.ntb") + tdSql.query(f"select last(*) from db.{ntbname}") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - for i in range(1, 9): - for j in ['ntb', 'db.ntb']: - tdSql.query(f"select last(col{i}) from {j}") + for k, v in column_dict.items(): + for j in [f'{ntbname}', f'db.{ntbname}']: + tdSql.query(f"select last({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >=1 and i<9: + if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ + or v == 'int unsigned' or v == 'bigint unsigned': tdSql.checkData(0, 0, 10) # float,double - elif i>=9 and i<11: + elif v == 'float' or v == 'double': tdSql.checkData(0, 0, 9.1) # bool - elif i == 11: + elif v == 'bool': tdSql.checkData(0, 0, True) # binary - elif i == 12: + elif 'binary' in v: tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') # nchar - elif i == 13: + elif 'nchar' in v: tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') - tdSql.error("select col1 from ntb where last(col9)='涛思数据10'") + tdSql.error( + f"select {list(column_dict.keys())[0]} from {ntbname} where last({list(column_dict.keys())[9]})='涛思数据10'") def last_check_stb_distribute(self): # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") - tdSql.execute(f"create database if not exists {dbname} vgroups 4") + vgroup_num = 4 + column_list = ['col1', 'col2', 'col3', 'col4', 'col5', 'col6', + 'col7', 'col8', 'col9', 'col10', 'col11', 'col12', 'col13'] + + tdSql.execute( + f"create database if not exists {dbname} vgroups {vgroup_num}") tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') for i in range(self.tbnum): - tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") - tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) + tdSql.execute( + f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.execute( + f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) # for i in [f'{stbname}', f'{dbname}.{stbname}']: # tdSql.query(f"select last(*) from {i}") # tdSql.checkRows(1) @@ -156,29 +220,30 @@ class TDTestCase: vgroup_list_set = set(vgroup_list) for i in vgroup_list_set: vgroups_num = vgroup_list.count(i) - if vgroups_num >=2: + if vgroups_num >= 2: tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') continue else: - tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') - + tdLog.exit( + 'This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(self.tbnum): for j in range(self.rowNum): tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" - % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) + % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) for i in [f'{stbname}', f'{dbname}.{stbname}']: tdSql.query(f"select last(*) from {i}") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - for i in range(1, 14): + for i in column_list: for j in [f'{stbname}', f'{dbname}.{stbname}']: - tdSql.query(f"select last(col{i}) from {j}") + tdSql.query(f"select last({i}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >=1 and i<9: + if i >= 1 and i < 9: tdSql.checkData(0, 0, 10) # float,double - elif i>=9 and i<11: + elif i >= 9 and i < 11: tdSql.checkData(0, 0, 9.1) # bool elif i == 11: @@ -190,10 +255,11 @@ class TDTestCase: elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') tdSql.execute(f'drop database {dbname}') + def run(self): self.last_check_stb_tb_base() - self.last_check_ntb_base() - self.last_check_stb_distribute() + # self.last_check_ntb_base() + # self.last_check_stb_distribute() def stop(self): tdSql.close() From 084f1f699c3d464ba4c6172991d4b5a883b47845 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 10:07:22 +0800 Subject: [PATCH 14/19] update first.py --- tests/system-test/2-query/first.py | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 1c7cc09f87..0fdd683f67 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -90,24 +90,27 @@ class TDTestCase: elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') #!bug TD-16569 - # tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") - # tdSql.checkRows(0) + tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") + tdSql.checkRows(0) tdSql.execute('drop database db') def first_check_stb_distribute(self): # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") + child_table_num = 20 tdSql.execute(f"create database if not exists {dbname} vgroups 4") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') - for i in range(1,21): + for i in range(child_table_num): tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) - for i in [f'{stbname}', f'{dbname}.{stbname}']: - tdSql.query(f"select first(*) from {i}") - tdSql.checkRows(0) + #!bug TD-16561 + # for i in [f'{stbname}', f'{dbname}.{stbname}']: + # tdSql.query(f"select first(*) from {i}") + # tdSql.checkRows(1) + # tdSql.checkData(0, 1, None) tdSql.query('show tables') vgroup_list = [] for i in range(len(tdSql.queryResult)): @@ -123,17 +126,13 @@ class TDTestCase: else: tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') - for i in range(self.tbnum): + for i in range(child_table_num): for j in range(self.rowNum): tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) - #!bug TD-16561 - # for i in [f'{stbname}', f'{dbname}.{stbname}']: - # tdSql.query(f"select first(*) from {i}") - # tdSql.checkRows(1) - # tdSql.checkData(0, 1, None) + for i in range(1, 14): - for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: + for j in [f'{stbname}_{i}', f'{dbname}.{stbname}_{i}', f'{stbname}', f'{dbname}.{stbname}']: tdSql.query(f"select first(col{i}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned @@ -152,16 +151,16 @@ class TDTestCase: elif i == 13: tdSql.checkData(0, 0, f'{self.nchar_str}1') #!bug TD-16569 - # tdSql.query("select first(*),last(*) from {stbname} where ts < 23 interval(1s)") - # tdSql.checkRows(0) - tdSql.execute('drop database db') + tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + tdSql.checkRows(0) + tdSql.execute(f'drop database {dbname}') pass def run(self): self.first_check_base() - # self.first_check_stb_distribute() + self.first_check_stb_distribute() def stop(self): From 78307f91a7faa4d910da57fded0166e51ffdc71d Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 10:14:59 +0800 Subject: [PATCH 15/19] update test case --- tests/system-test/2-query/bottom.py | 39 +++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index be47da3c58..da609a54b2 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -11,6 +11,8 @@ # -*- coding: utf-8 -*- +import random +import string from util.log import * from util.cases import * from util.sql import * @@ -27,6 +29,20 @@ class TDTestCase: self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' + def get_long_name(self, length, mode="mixed"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) def bottom_check_base(self): tdSql.prepare() tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, @@ -58,15 +74,19 @@ class TDTestCase: # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") - tdSql.execute(f"create database if not exists {dbname} vgroups 4") + vgroup_num = 4 + child_table_num = 20 + tdSql.execute(f"create database if not exists {dbname} vgroups {vgroup_num}") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') - for i in range(self.tbnum): + for i in range(child_table_num): tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] + error_column_list = ['col11','col12','col13'] + error_param_list = [0,101] for i in [f'{stbname}', f'{dbname}.{stbname}']: for j in column_list: tdSql.query(f"select bottom({j},1) from {i}") @@ -85,14 +105,23 @@ class TDTestCase: else: tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') for i in range(self.rowNum): - for j in range(self.tbnum): + for j in range(child_table_num): tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - - pass + for i in column_list: + tdSql.query(f'select bottom({i},2) from {stbname}') + tdSql.checkRows(2) + tdSql.checkEqual(tdSql.queryResult,[(1,),(1,)]) + for j in error_param_list: + tdSql.error(f'select bottom({i},{j}) from {stbname}') + for i in error_column_list: + tdSql.error(f'select bottom({i},10) from {stbname}') + + tdSql.execute(f'drop database {dbname}') def run(self): self.bottom_check_base() + self.bottom_check_distribute() def stop(self): From 6297055fb52118bfe25d6ff6098cd0e27d817531 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 15:28:07 +0800 Subject: [PATCH 16/19] update test case --- tests/system-test/2-query/first.py | 71 ++++++++++++++++------ tests/system-test/2-query/hyperloglog.py | 77 ++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 20 deletions(-) diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 0fdd683f67..25d561aa6b 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -48,12 +48,26 @@ class TDTestCase: return "".join(random.choices(population, k=length)) def first_check_base(self): tdSql.prepare() - + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') tdSql.execute("create table stb_1 using stb tags('beijing')") tdSql.execute("insert into stb_1(ts) values(%d)" % (self.ts - 1)) - + column_list = ['col1','col2','col3','col4','col5','col6','col7','col8','col9','col10','col11','col12','col13'] for i in ['stb_1','db.stb_1','stb_1','db.stb_1']: tdSql.query(f"select first(*) from {i}") tdSql.checkRows(1) @@ -63,31 +77,32 @@ class TDTestCase: # tdSql.query(f"select first(*) from {i}") # tdSql.checkRows(1) # tdSql.checkData(0, 1, None) - for i in range(1, 14): + for i in column_list: for j in ['stb_1','db.stb_1','stb_1','db.stb_1']: - tdSql.query(f"select first(col{i}) from {j}") + tdSql.query(f"select first({i}) from {j}") tdSql.checkRows(0) for i in range(self.rowNum): tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - for i in range(1, 14): + for k, v in column_dict.items(): for j in ['stb_1', 'db.stb_1', 'stb', 'db.stb']: - tdSql.query(f"select first(col{i}) from {j}") + tdSql.query(f"select first({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >=1 and i<9: + if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ + or v == 'int unsigned' or v == 'bigint unsigned': tdSql.checkData(0, 0, 1) # float,double - elif i>=9 and i<11: + elif v == 'float' or v == 'double': tdSql.checkData(0, 0, 0.1) # bool - elif i == 11: + elif v == 'bool': tdSql.checkData(0, 0, False) # binary - elif i == 12: + elif 'binary' in v: tdSql.checkData(0, 0, f'{self.binary_str}1') # nchar - elif i == 13: + elif 'nchar' in v: tdSql.checkData(0, 0, f'{self.nchar_str}1') #!bug TD-16569 tdSql.query("select first(*),last(*) from stb where ts < 23 interval(1s)") @@ -98,6 +113,21 @@ class TDTestCase: dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") child_table_num = 20 + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } tdSql.execute(f"create database if not exists {dbname} vgroups 4") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows @@ -131,28 +161,29 @@ class TDTestCase: tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) - for i in range(1, 14): + for k, v in column_dict.items(): for j in [f'{stbname}_{i}', f'{dbname}.{stbname}_{i}', f'{stbname}', f'{dbname}.{stbname}']: - tdSql.query(f"select first(col{i}) from {j}") + tdSql.query(f"select first({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >=1 and i<9: + if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ + or v == 'int unsigned' or v == 'bigint unsigned': tdSql.checkData(0, 0, 1) # float,double - elif i>=9 and i<11: + elif v == 'float' or v == 'double': tdSql.checkData(0, 0, 0.1) # bool - elif i == 11: + elif v == 'bool': tdSql.checkData(0, 0, False) # binary - elif i == 12: + elif 'binary' in v: tdSql.checkData(0, 0, f'{self.binary_str}1') # nchar - elif i == 13: + elif 'nchar' in v: tdSql.checkData(0, 0, f'{self.nchar_str}1') #!bug TD-16569 - tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)") - tdSql.checkRows(0) + # tdSql.query(f"select first(*),last(*) from {stbname} where ts < 23 interval(1s)") + # tdSql.checkRows(0) tdSql.execute(f'drop database {dbname}') diff --git a/tests/system-test/2-query/hyperloglog.py b/tests/system-test/2-query/hyperloglog.py index 337db140a1..920252573b 100644 --- a/tests/system-test/2-query/hyperloglog.py +++ b/tests/system-test/2-query/hyperloglog.py @@ -214,6 +214,79 @@ class TDTestCase: for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2} + def __create_stable(self,stbname='stb',column_dict={'ts':'timestamp','col1': 'tinyint','col2': 'smallint','col3': 'int', + 'col4': 'bigint','col5': 'tinyint unsigned','col6': 'smallint unsigned','col7': 'int unsigned', + 'col8': 'bigint unsigned','col9': 'float','col10': 'double','col11': 'bool','col12': 'binary(20)','col13': 'nchar(20)'}, + tag_dict={'ts_tag':'timestamp','t1': 'tinyint','t2': 'smallint','t3': 'int', + 't4': 'bigint','t5': 'tinyint unsigned','t6': 'smallint unsigned','t7': 'int unsigned', + 't8': 'bigint unsigned','t9': 'float','t10': 'double','t11': 'bool','t12': 'binary(20)','t13': 'nchar(20)'}): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}," + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}," + tdSql.execute(f'create table is not exists {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') + + def __insert_data(self): + + pass + + def __hyperloglog_check_distribute(self): + dbname = "dbtest" + stbname = "stb" + childtable_num = 20 + vgroups_num = 4 + row_num = 10 + ts = 1537146000000 + binary_str = 'taosdata' + nchar_str = '涛思数据' + column_dict = { + 'ts':'timestamp', + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + tag_dict = { + 'loc':'nchar(20)' + } + tdSql.execute(f"create database if not exists {dbname} vgroups {vgroups_num}") + tdSql.execute(f'use {dbname}') + self.__create_stable(stbname,column_dict,tag_dict) + for i in range(childtable_num): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(row_num): + tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{binary_str}%d', '{nchar_str}%d')" + % (ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) + for k in column_dict.keys(): + tdSql.query(f"select hyperloglog({k}) from {stbname}") + tdSql.checkRows(1) + tdSql.query(f"select hyperloglog({k}) from {stbname} group by {k}") + + tdSql.execute(f'drop database {dbname}') + def __insert_data(self, rows): now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -311,6 +384,10 @@ class TDTestCase: tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() + tdLog.printNoPrefix("==========step5: distribute scene check") + self.__hyperloglog_check_distribute() + + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") From 99d7829d03aa0b2a9499cab65749fbd5fd8302f9 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 15:38:45 +0800 Subject: [PATCH 17/19] update cases --- tests/system-test/2-query/hyperloglog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/2-query/hyperloglog.py b/tests/system-test/2-query/hyperloglog.py index 920252573b..8dd6bd2dda 100644 --- a/tests/system-test/2-query/hyperloglog.py +++ b/tests/system-test/2-query/hyperloglog.py @@ -226,7 +226,7 @@ class TDTestCase: column_sql += f"{k} {v}," for k,v in tag_dict.items(): tag_sql += f"{k} {v}," - tdSql.execute(f'create table is not exists {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') + tdSql.execute(f'create table if not exists {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})') def __insert_data(self): From 0c4c7853590b199d83b525ee9c9afbc916a45f6c Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 16:41:13 +0800 Subject: [PATCH 18/19] update --- tests/system-test/2-query/bottom.py | 4 +- tests/system-test/2-query/first.py | 3 +- tests/system-test/2-query/histogram.py | 69 +++++++++++++++++++++++++- tests/system-test/2-query/last.py | 62 ++++++++++++++--------- tests/system-test/2-query/top.py | 4 +- 5 files changed, 111 insertions(+), 31 deletions(-) diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index da609a54b2..6b7e6179c3 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -74,7 +74,7 @@ class TDTestCase: # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") - vgroup_num = 4 + vgroup_num = 2 child_table_num = 20 tdSql.execute(f"create database if not exists {dbname} vgroups {vgroup_num}") tdSql.execute(f'use {dbname}') @@ -103,7 +103,7 @@ class TDTestCase: tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') continue else: - tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + tdLog.exit(f'This scene does not meet the requirements with {vgroups_num} vgroup!\n') for i in range(self.rowNum): for j in range(child_table_num): tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 25d561aa6b..8875bfe748 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -113,6 +113,7 @@ class TDTestCase: dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") child_table_num = 20 + vgroup = 2 column_dict = { 'col1': 'tinyint', 'col2': 'smallint', @@ -128,7 +129,7 @@ class TDTestCase: 'col12': 'binary(20)', 'col13': 'nchar(20)' } - tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f"create database if not exists {dbname} vgroups {vgroup}") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, diff --git a/tests/system-test/2-query/histogram.py b/tests/system-test/2-query/histogram.py index 0448952be8..bc061f8fb7 100644 --- a/tests/system-test/2-query/histogram.py +++ b/tests/system-test/2-query/histogram.py @@ -44,8 +44,7 @@ class TDTestCase: buildPath = root[:len(root) - len("/build/bin")] break return buildPath - - def run(self): + def histogram_check_base(self): print("running {}".format(__file__)) tdSql.execute("drop database if exists db") tdSql.execute("create database if not exists db") @@ -3183,6 +3182,72 @@ class TDTestCase: tdSql.execute('drop database db') + + def histogram_check_distribute(self): + dbname = "db" + stbname = "stb" + row_num = 10 + child_table_num = 20 + vgroups = 2 + user_input_json = "[1,3,5,7]" + ts = 1537146000000 + binary_str = 'taosdata' + nchar_str = '涛思数据' + column_dict = { + 'ts' : 'timestamp', + 'col1' : 'tinyint', + 'col2' : 'smallint', + 'col3' : 'int', + 'col4' : 'bigint', + 'col5' : 'tinyint unsigned', + 'col6' : 'smallint unsigned', + 'col7' : 'int unsigned', + 'col8' : 'bigint unsigned', + 'col9' : 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + tdSql.execute(f"create database if not exists {dbname} vgroups {vgroups}") + tdSql.execute(f'use {dbname}') + # build 20 child tables,every table insert 10 rows + tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, + col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + for i in range(child_table_num): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") + tdSql.query('show tables') + vgroup_list = [] + for i in range(len(tdSql.queryResult)): + vgroup_list.append(tdSql.queryResult[i][6]) + vgroup_list_set = set(vgroup_list) + for i in vgroup_list_set: + vgroups_num = vgroup_list.count(i) + if vgroups_num >=2: + tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') + continue + else: + tdLog.exit(f'This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(child_table_num): + for j in range(row_num): + tdSql.execute(f"insert into {stbname}_{i} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{binary_str}%d', '{nchar_str}%d')" + % (ts + j + i, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1)) + # user_input + for k,v in column_dict.items(): + if v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or v.lower() =='float' or v.lower() =='double'\ + or v.lower() =='tinyint unsigned' or v.lower() =='smallint unsigned' or v.lower() =='int unsigned' or v.lower() =='bigint unsigned': + tdSql.query(f'select histogram({k}, "user_input", "{user_input_json}", 0) from {stbname}') + tdSql.checkRows(len(user_input_json[1:-1].split(','))-1) + elif 'binary' in v.lower() or 'nchar' in v.lower() or 'bool' == v.lower(): + tdSql.error(f'select histogram({k}, "user_input", "{user_input_json}", 0) from {stbname}') + + tdSql.execute(f'drop database {dbname}') + + + def run(self): + self.histogram_check_base() + self.histogram_check_distribute() + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index 805a15a005..d74f88745c 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -91,7 +91,7 @@ class TDTestCase: tdSql.query(f"select last({list(column_dict.keys())[0]}) from {stbname}_1 group by {list(column_dict.keys())[-1]}") tdSql.checkRows(1) for i in range(self.rowNum): - tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" + tdSql.execute(f"insert into {stbname}_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) for i in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: tdSql.query(f"select last(*) from {i}") @@ -102,20 +102,20 @@ class TDTestCase: tdSql.query(f"select last({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ - or v == 'int unsigned' or v == 'bigint unsigned': + if v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or v.lower() == 'tinyint unsigned' or v.lower() == 'smallint unsigned'\ + or v.lower() == 'int unsigned' or v.lower() == 'bigint unsigned': tdSql.checkData(0, 0, 10) # float,double - elif v == 'float' or v == 'double': + elif v.lower() == 'float' or v.lower() == 'double': tdSql.checkData(0, 0, 9.1) # bool - elif v == 'bool': + elif v.lower() == 'bool': tdSql.checkData(0, 0, True) # binary - elif 'binary' in v: + elif 'binary' in v.lower(): tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') # nchar - elif 'nchar' in v: + elif 'nchar' in v.lower(): tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') for i in [f'{stbname}_1', f'db.{stbname}_1', f'{stbname}', f'db.{stbname}']: tdSql.query(f"select last({list(column_dict.keys())[0]},{list(column_dict.keys())[1]},{list(column_dict.keys())[2]}) from {stbname}_1") @@ -170,20 +170,20 @@ class TDTestCase: tdSql.query(f"select last({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if v == 'tinyint' or v == 'smallint' or v == 'int' or v == 'bigint' or v == 'tinyint unsigned' or v == 'smallint unsigned'\ - or v == 'int unsigned' or v == 'bigint unsigned': + if v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or v.lower() == 'tinyint unsigned' or v.lower() == 'smallint unsigned'\ + or v.lower() == 'int unsigned' or v.lower() == 'bigint unsigned': tdSql.checkData(0, 0, 10) # float,double - elif v == 'float' or v == 'double': + elif v.lower() == 'float' or v.lower() == 'double': tdSql.checkData(0, 0, 9.1) # bool - elif v == 'bool': + elif v.lower() == 'bool': tdSql.checkData(0, 0, True) # binary - elif 'binary' in v: + elif 'binary' in v.lower(): tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') # nchar - elif 'nchar' in v: + elif 'nchar' in v.lower(): tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') tdSql.error( @@ -194,8 +194,21 @@ class TDTestCase: dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") vgroup_num = 4 - column_list = ['col1', 'col2', 'col3', 'col4', 'col5', 'col6', - 'col7', 'col8', 'col9', 'col10', 'col11', 'col12', 'col13'] + column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } tdSql.execute( f"create database if not exists {dbname} vgroups {vgroup_num}") @@ -235,31 +248,32 @@ class TDTestCase: tdSql.query(f"select last(*) from {i}") tdSql.checkRows(1) tdSql.checkData(0, 1, 10) - for i in column_list: + for k, v in column_dict.items(): for j in [f'{stbname}', f'{dbname}.{stbname}']: - tdSql.query(f"select last({i}) from {j}") + tdSql.query(f"select last({k}) from {j}") tdSql.checkRows(1) # tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned - if i >= 1 and i < 9: + if v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or v.lower() == 'tinyint unsigned' or v.lower() == 'smallint unsigned'\ + or v.lower() == 'int unsigned' or v.lower() == 'bigint unsigned': tdSql.checkData(0, 0, 10) # float,double - elif i >= 9 and i < 11: + elif v.lower() == 'float' or v.lower() == 'double': tdSql.checkData(0, 0, 9.1) # bool - elif i == 11: + elif v.lower() == 'bool': tdSql.checkData(0, 0, True) # binary - elif i == 12: + elif 'binary' in v.lower(): tdSql.checkData(0, 0, f'{self.binary_str}{self.rowNum}') # nchar - elif i == 13: + elif 'nchar' in v.lower(): tdSql.checkData(0, 0, f'{self.nchar_str}{self.rowNum}') tdSql.execute(f'drop database {dbname}') def run(self): self.last_check_stb_tb_base() - # self.last_check_ntb_base() - # self.last_check_stb_distribute() + self.last_check_ntb_base() + self.last_check_stb_distribute() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/top.py b/tests/system-test/2-query/top.py index 329b4b69e9..acd6bb12e9 100644 --- a/tests/system-test/2-query/top.py +++ b/tests/system-test/2-query/top.py @@ -71,7 +71,7 @@ class TDTestCase: # prepare data for vgroup 4 dbname = self.get_long_name(length=10, mode="letters") stbname = self.get_long_name(length=5, mode="letters") - tdSql.execute(f"create database if not exists {dbname} vgroups 4") + tdSql.execute(f"create database if not exists {dbname} vgroups 2") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, @@ -96,7 +96,7 @@ class TDTestCase: tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') continue else: - tdLog.exit('This scene does not meet the requirements with {vgroups_num} vgroup!\n') + tdLog.exit(f'This scene does not meet the requirements with {vgroups_num} vgroup!\n') for i in range(self.rowNum): for j in range(self.tbnum): tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" From 5e72cacdd3018d4bdf2d7a233eed9996e049e0d9 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Fri, 17 Jun 2022 17:07:18 +0800 Subject: [PATCH 19/19] update test case --- tests/system-test/2-query/bottom.py | 19 +++---------------- tests/system-test/2-query/first.py | 19 +++---------------- tests/system-test/2-query/last.py | 24 +++++------------------- tests/system-test/2-query/top.py | 19 +++---------------- 4 files changed, 14 insertions(+), 67 deletions(-) diff --git a/tests/system-test/2-query/bottom.py b/tests/system-test/2-query/bottom.py index 6b7e6179c3..1037b0a8f3 100644 --- a/tests/system-test/2-query/bottom.py +++ b/tests/system-test/2-query/bottom.py @@ -16,6 +16,7 @@ import string from util.log import * from util.cases import * from util.sql import * +from util.common import * @@ -29,20 +30,6 @@ class TDTestCase: self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) def bottom_check_base(self): tdSql.prepare() tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, @@ -72,8 +59,8 @@ class TDTestCase: tdSql.execute('drop database db') def bottom_check_distribute(self): # prepare data for vgroup 4 - dbname = self.get_long_name(length=10, mode="letters") - stbname = self.get_long_name(length=5, mode="letters") + dbname = tdCom.getLongName(5, "letters") + stbname = tdCom.getLongName(5, "letters") vgroup_num = 2 child_table_num = 20 tdSql.execute(f"create database if not exists {dbname} vgroups {vgroup_num}") diff --git a/tests/system-test/2-query/first.py b/tests/system-test/2-query/first.py index 8875bfe748..e9a8cc950b 100644 --- a/tests/system-test/2-query/first.py +++ b/tests/system-test/2-query/first.py @@ -15,6 +15,7 @@ import random import string import sys import taos +from util.common import * from util.log import * from util.cases import * from util.sql import * @@ -32,20 +33,6 @@ class TDTestCase: self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) def first_check_base(self): tdSql.prepare() column_dict = { @@ -110,8 +97,8 @@ class TDTestCase: tdSql.execute('drop database db') def first_check_stb_distribute(self): # prepare data for vgroup 4 - dbname = self.get_long_name(length=10, mode="letters") - stbname = self.get_long_name(length=5, mode="letters") + dbname = tdCom.getLongName(10, "letters") + stbname = tdCom.getLongName(5, "letters") child_table_num = 20 vgroup = 2 column_dict = { diff --git a/tests/system-test/2-query/last.py b/tests/system-test/2-query/last.py index d74f88745c..ee65d22a22 100644 --- a/tests/system-test/2-query/last.py +++ b/tests/system-test/2-query/last.py @@ -3,6 +3,7 @@ import string from util.log import * from util.cases import * from util.sql import * +from util.common import * import numpy as np @@ -17,21 +18,6 @@ class TDTestCase: self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) - def set_create_normaltable_sql(self, ntbname, column_dict): column_sql = '' for k, v in column_dict.items(): @@ -51,7 +37,7 @@ class TDTestCase: def last_check_stb_tb_base(self): tdSql.prepare() - stbname = self.get_long_name(length=5, mode="letters") + stbname = tdCom.getLongName(5, "letters") column_dict = { 'col1': 'tinyint', 'col2': 'smallint', @@ -127,7 +113,7 @@ class TDTestCase: def last_check_ntb_base(self): tdSql.prepare() - ntbname = self.get_long_name(length=5, mode="letters") + ntbname = tdCom.getLongName(5, "letters") column_dict = { 'col1': 'tinyint', 'col2': 'smallint', @@ -191,8 +177,8 @@ class TDTestCase: def last_check_stb_distribute(self): # prepare data for vgroup 4 - dbname = self.get_long_name(length=10, mode="letters") - stbname = self.get_long_name(length=5, mode="letters") + dbname = tdCom.getLongName(10, "letters") + stbname = tdCom.getLongName(5, "letters") vgroup_num = 4 column_dict = { 'col1': 'tinyint', diff --git a/tests/system-test/2-query/top.py b/tests/system-test/2-query/top.py index acd6bb12e9..83f535856e 100644 --- a/tests/system-test/2-query/top.py +++ b/tests/system-test/2-query/top.py @@ -13,6 +13,7 @@ import random import string +from util.common import * from util.log import * from util.cases import * from util.sql import * @@ -28,20 +29,6 @@ class TDTestCase: self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) def top_check_base(self): tdSql.prepare() tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, @@ -69,8 +56,8 @@ class TDTestCase: tdSql.execute('drop database db') def top_check_stb_distribute(self): # prepare data for vgroup 4 - dbname = self.get_long_name(length=10, mode="letters") - stbname = self.get_long_name(length=5, mode="letters") + dbname = tdCom.getLongName(10, "letters") + stbname = tdCom.getLongName(5, "letters") tdSql.execute(f"create database if not exists {dbname} vgroups 2") tdSql.execute(f'use {dbname}') # build 20 child tables,every table insert 10 rows