From ba60b4bd1b574861f94b8234e5aef09644f87289 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 16 Jun 2020 16:34:39 +0800 Subject: [PATCH] modify format by autopep8. --- tests/pytest/query/filterAllIntTypes.py | 50 ++-- tests/pytest/query/filterFloatAndDouble.py | 36 +-- tests/pytest/query/filterOtherTypes.py | 141 +++++------ tests/pytest/query/querySort.py | 56 +++-- tests/pytest/random-test/random-test.py | 2 + tests/pytest/table/tablename-boundary.py | 5 +- tests/pytest/tag_lite/change.py | 16 +- tests/pytest/tag_lite/delete.py | 262 ++++++++++++--------- tests/pytest/util/sql.py | 34 +-- 9 files changed, 338 insertions(+), 264 deletions(-) diff --git a/tests/pytest/query/filterAllIntTypes.py b/tests/pytest/query/filterAllIntTypes.py index 32e635d6da..cf65d2b102 100644 --- a/tests/pytest/query/filterAllIntTypes.py +++ b/tests/pytest/query/filterAllIntTypes.py @@ -22,12 +22,12 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) - + self.powers = [7, 15, 31, 63] self.types = ["tinyint", "smallint", "int", "bigint"] self.rowNum = 10 - self.ts = 1537146000000 - + self.ts = 1537146000000 + def run(self): tdSql.prepare() @@ -35,20 +35,30 @@ class TDTestCase: curType = self.types[i] print("======= Verify filter for %s type =========" % (curType)) tdLog.debug( - "create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType)) + "create table st%s(ts timestamp, num %s) tags(id %s)" % + (curType, curType, curType)) tdSql.execute( - "create table st%s(ts timestamp, num %s) tags(id %s)" % (curType, curType, curType)) - - #create 10 tables, insert 10 rows for each table - for j in range(self.rowNum): - tdSql.execute("create table st%s%d using st%s tags(%d)" % (curType, j + 1, curType, j + 1)) - for k in range(self.rowNum): - tdSql.execute("insert into st%s%d values(%d, %d)" % (curType, j + 1, self.ts + k + 1, j * 10 + k + 1)) - - tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 11, pow(2, self.powers[i]))) - tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 12, pow(2, self.powers[i]) - 1)) - tdSql.error("insert into st%s10 values(%d, %d)" % (curType, self.ts + 13, pow(-2, self.powers[i]))) - tdSql.execute("insert into st%s10 values(%d, %d)" % (curType, self.ts + 14, pow(-2, self.powers[i]) + 1)) + "create table st%s(ts timestamp, num %s) tags(id %s)" % + (curType, curType, curType)) + + # create 10 tables, insert 10 rows for each table + for j in range(self.rowNum): + tdSql.execute( + "create table st%s%d using st%s tags(%d)" % + (curType, j + 1, curType, j + 1)) + for k in range(self.rowNum): + tdSql.execute( + "insert into st%s%d values(%d, %d)" % + (curType, j + 1, self.ts + k + 1, j * 10 + k + 1)) + + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 11, pow(2, self.powers[i]))) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 12, pow(2, self.powers[i]) - 1)) + tdSql.error("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 13, pow(-2, self.powers[i]))) + tdSql.execute("insert into st%s10 values(%d, %d)" % + (curType, self.ts + 14, pow(-2, self.powers[i]) + 1)) # > for int type on column tdSql.query("select * from st%s where num > 50" % curType) @@ -104,10 +114,12 @@ class TDTestCase: # != for int type on tag tdSql.query("select * from st%s where id != 5" % curType) - tdSql.checkRows(92) + tdSql.checkRows(92) + + print( + "======= Verify filter for %s type finished =========" % + curType) - print("======= Verify filter for %s type finished =========" % curType) - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/query/filterFloatAndDouble.py b/tests/pytest/query/filterFloatAndDouble.py index bea41be11c..bd349a2a25 100644 --- a/tests/pytest/query/filterFloatAndDouble.py +++ b/tests/pytest/query/filterFloatAndDouble.py @@ -21,28 +21,28 @@ from util.sql import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor()) self.rowNum = 10 self.ts = 1537146000000 - + def run(self): tdSql.prepare() print("======= Verify filter for float and double type =========") tdLog.debug( - "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") + "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") tdSql.execute( - "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") - - for j in range(self.rowNum): - tdSql.execute( - "insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % (self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1))) + "create table st(ts timestamp, num float, speed double) tags(tagcol1 float, tagcol2 double)") + + for j in range(self.rowNum): + tdSql.execute("insert into st1 using st tags(1.1, 2.3) values(%d, %f, %f)" % ( + self.ts + j + 1, 1.1 * (j + 1), 2.3 * (j + 1))) # > for float type on column tdSql.query("select * from st where num > 5.5") tdSql.checkRows(5) - + # >= for float type on column tdSql.query("select * from st where num >= 5.5") tdSql.checkRows(6) @@ -70,11 +70,11 @@ class TDTestCase: # > for float type on tag tdSql.query("select * from st where tagcol1 > 1.1") tdSql.checkRows(0) - + # >= for float type on tag tdSql.query("select * from st where tagcol1 >= 1.1") tdSql.checkRows(10) - + # = for float type on tag tdSql.query("select * from st where tagcol1 = 1.1") tdSql.checkRows(10) @@ -86,7 +86,7 @@ class TDTestCase: # != for float type on tag tdSql.query("select * from st where tagcol1 != 1.1") tdSql.checkRows(0) - + # <= for float type on tag tdSql.query("select * from st where tagcol1 <= 1.1") tdSql.checkRows(10) @@ -94,11 +94,11 @@ class TDTestCase: # < for float type on tag tdSql.query("select * from st where tagcol1 < 1.1") tdSql.checkRows(0) - + # > for double type on column tdSql.query("select * from st where speed > 11.5") tdSql.checkRows(5) - + # >= for double type on column tdSql.query("select * from st where speed >= 11.5") tdSql.checkRows(6) @@ -126,11 +126,11 @@ class TDTestCase: # > for double type on tag tdSql.query("select * from st where tagcol2 > 2.3") tdSql.checkRows(0) - + # >= for double type on tag tdSql.query("select * from st where tagcol2 >= 2.3") tdSql.checkRows(10) - + # = for double type on tag tdSql.query("select * from st where tagcol2 = 2.3") tdSql.checkRows(10) @@ -142,7 +142,7 @@ class TDTestCase: # != for double type on tag tdSql.query("select * from st where tagcol2 != 2.3") tdSql.checkRows(0) - + # <= for double type on tag tdSql.query("select * from st where tagcol2 <= 2.3") tdSql.checkRows(10) @@ -150,7 +150,7 @@ class TDTestCase: # < for double type on tag tdSql.query("select * from st where tagcol2 < 2.3") tdSql.checkRows(0) - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/query/filterOtherTypes.py b/tests/pytest/query/filterOtherTypes.py index f09ac596c7..bc7df18c8d 100644 --- a/tests/pytest/query/filterOtherTypes.py +++ b/tests/pytest/query/filterOtherTypes.py @@ -21,33 +21,39 @@ from util.sql import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) - + tdSql.init(conn.cursor()) + self.ts = 1537146000000 - + def run(self): tdSql.prepare() - + print("======= Verify filter for bool, nchar and binary type =========") tdLog.debug( "create table st(ts timestamp, tbcol1 bool, tbcol2 nchar(10), tbcol3 binary(20)) tags(tagcol1 bool, tagcol2 nchar(10), tagcol3 binary(10))") tdSql.execute( - "create table st(ts timestamp, tbcol1 bool, tbcol2 nchar(10), tbcol3 binary(20)) tags(tagcol1 bool, tagcol2 nchar(10), tagcol3 binary(10))") + "create table st(ts timestamp, tbcol1 bool, tbcol2 nchar(10), tbcol3 binary(20)) tags(tagcol1 bool, tagcol2 nchar(10), tagcol3 binary(10))") tdSql.execute("create table st1 using st tags(true, 'table1', '水表')") - for i in range(1, 6): - tdSql.execute("insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i)) + for i in range(1, 6): + tdSql.execute( + "insert into st1 values(%d, %d, 'taosdata%d', '涛思数据%d')" % + (self.ts + i, i % + 2, i, i)) tdSql.execute("create table st2 using st tags(false, 'table2', '电表')") - for i in range(6, 11): - tdSql.execute("insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" % (self.ts + i, i % 2, i, i)) + for i in range(6, 11): + tdSql.execute( + "insert into st2 values(%d, %d, 'taosdata%d', '涛思数据%d')" % + (self.ts + i, i % + 2, i, i)) # =============Verify stable columns==================== # > for bool type on column tdSql.error("select * from st where tbcol1 > false") # >= for bool type on column - tdSql.error("select * from st where tbcol1 >= false") + tdSql.error("select * from st where tbcol1 >= false") # = for bool type on column tdSql.query("select * from st where tbcol1 = false") @@ -77,18 +83,18 @@ class TDTestCase: tdSql.error("select * from st where tbcol2 > 'taosdata'") # >= for nchar type on column - tdSql.error("select * from st where tbcol2 >= 'taosdata'") + tdSql.error("select * from st where tbcol2 >= 'taosdata'") # = for nchar type on column tdSql.query("select * from st where tbcol2 = 'taosdata1'") tdSql.checkRows(1) # <> for nchar type on column - tdSql.query("select * from st where tbcol2 <> 'taosdata1'") + tdSql.query("select * from st where tbcol2 <> 'taosdata1'") tdSql.checkRows(9) # != for nchar type on column - tdSql.query("select * from st where tbcol2 != 'taosdata1'") + tdSql.query("select * from st where tbcol2 != 'taosdata1'") tdSql.checkRows(9) # > for nchar type on column @@ -98,57 +104,57 @@ class TDTestCase: tdSql.error("select * from st where tbcol2 <= 'taodata'") # % for nchar type on column case 1 - tdSql.query("select * from st where tbcol2 like '%'") + tdSql.query("select * from st where tbcol2 like '%'") tdSql.checkRows(10) # % for nchar type on column case 2 - tdSql.query("select * from st where tbcol2 like 'a%'") + tdSql.query("select * from st where tbcol2 like 'a%'") tdSql.checkRows(0) # % for nchar type on column case 3 - tdSql.query("select * from st where tbcol2 like 't%_'") + tdSql.query("select * from st where tbcol2 like 't%_'") tdSql.checkRows(10) # % for nchar type on column case 4 - tdSql.query("select * from st where tbcol2 like '%1'") + tdSql.query("select * from st where tbcol2 like '%1'") # tdSql.checkRows(2) # _ for nchar type on column case 1 - tdSql.query("select * from st where tbcol2 like '____________'") - tdSql.checkRows(0) + tdSql.query("select * from st where tbcol2 like '____________'") + tdSql.checkRows(0) # _ for nchar type on column case 2 - tdSql.query("select * from st where tbcol2 like '__________'") + tdSql.query("select * from st where tbcol2 like '__________'") tdSql.checkRows(1) # _ for nchar type on column case 3 - tdSql.query("select * from st where tbcol2 like '_________'") + tdSql.query("select * from st where tbcol2 like '_________'") tdSql.checkRows(9) # _ for nchar type on column case 4 - tdSql.query("select * from st where tbcol2 like 't________'") + tdSql.query("select * from st where tbcol2 like 't________'") tdSql.checkRows(9) # _ for nchar type on column case 5 - tdSql.query("select * from st where tbcol2 like '%________'") + tdSql.query("select * from st where tbcol2 like '%________'") tdSql.checkRows(10) # > for binary type on column tdSql.error("select * from st where tbcol3 > '涛思数据'") # >= for binary type on column - tdSql.error("select * from st where tbcol3 >= '涛思数据'") + tdSql.error("select * from st where tbcol3 >= '涛思数据'") # = for binary type on column tdSql.query("select * from st where tbcol3 = '涛思数据1'") tdSql.checkRows(1) # <> for binary type on column - tdSql.query("select * from st where tbcol3 <> '涛思数据1'") + tdSql.query("select * from st where tbcol3 <> '涛思数据1'") tdSql.checkRows(9) # != for binary type on column - tdSql.query("select * from st where tbcol3 != '涛思数据1'") + tdSql.query("select * from st where tbcol3 != '涛思数据1'") tdSql.checkRows(9) # > for binary type on column @@ -158,39 +164,39 @@ class TDTestCase: tdSql.error("select * from st where tbcol3 <= '涛思数据'") # % for binary type on column case 1 - tdSql.query("select * from st where tbcol3 like '%'") + tdSql.query("select * from st where tbcol3 like '%'") tdSql.checkRows(10) # % for binary type on column case 2 - tdSql.query("select * from st where tbcol3 like '陶%'") + tdSql.query("select * from st where tbcol3 like '陶%'") tdSql.checkRows(0) # % for binary type on column case 3 - tdSql.query("select * from st where tbcol3 like '涛%_'") + tdSql.query("select * from st where tbcol3 like '涛%_'") tdSql.checkRows(10) # % for binary type on column case 4 - tdSql.query("select * from st where tbcol3 like '%1'") + tdSql.query("select * from st where tbcol3 like '%1'") tdSql.checkRows(1) # _ for binary type on column case 1 - tdSql.query("select * from st where tbcol3 like '_______'") - tdSql.checkRows(0) + tdSql.query("select * from st where tbcol3 like '_______'") + tdSql.checkRows(0) # _ for binary type on column case 2 - tdSql.query("select * from st where tbcol3 like '______'") + tdSql.query("select * from st where tbcol3 like '______'") tdSql.checkRows(1) # _ for binary type on column case 2 - tdSql.query("select * from st where tbcol3 like '_____'") + tdSql.query("select * from st where tbcol3 like '_____'") tdSql.checkRows(9) # _ for binary type on column case 3 - tdSql.query("select * from st where tbcol3 like '____'") + tdSql.query("select * from st where tbcol3 like '____'") tdSql.checkRows(0) # _ for binary type on column case 4 - tdSql.query("select * from st where tbcol3 like 't____'") + tdSql.query("select * from st where tbcol3 like 't____'") tdSql.checkRows(0) # =============Verify stable tags==================== @@ -198,7 +204,7 @@ class TDTestCase: tdSql.error("select * from st where tagcol1 > false") # >= for bool type on tag - tdSql.error("select * from st where tagcol1 >= false") + tdSql.error("select * from st where tagcol1 >= false") # = for bool type on tag tdSql.query("select * from st where tagcol1 = false") @@ -228,18 +234,18 @@ class TDTestCase: tdSql.error("select * from st where tagcol2 > 'table'") # >= for nchar type on tag - tdSql.error("select * from st where tagcol2 >= 'table'") + tdSql.error("select * from st where tagcol2 >= 'table'") # = for nchar type on tag tdSql.query("select * from st where tagcol2 = 'table1'") tdSql.checkRows(5) # <> for nchar type on tag - tdSql.query("select * from st where tagcol2 <> 'table1'") + tdSql.query("select * from st where tagcol2 <> 'table1'") tdSql.checkRows(5) # != for nchar type on tag - tdSql.query("select * from st where tagcol2 != 'table'") + tdSql.query("select * from st where tagcol2 != 'table'") tdSql.checkRows(10) # > for nchar type on tag @@ -249,57 +255,57 @@ class TDTestCase: tdSql.error("select * from st where tagcol2 <= 'table'") # % for nchar type on tag case 1 - tdSql.query("select * from st where tagcol2 like '%'") + tdSql.query("select * from st where tagcol2 like '%'") tdSql.checkRows(10) # % for nchar type on tag case 2 - tdSql.query("select * from st where tagcol2 like 'a%'") + tdSql.query("select * from st where tagcol2 like 'a%'") tdSql.checkRows(0) # % for nchar type on tag case 3 - tdSql.query("select * from st where tagcol2 like 't%_'") + tdSql.query("select * from st where tagcol2 like 't%_'") tdSql.checkRows(10) # % for nchar type on tag case 4 - tdSql.query("select * from st where tagcol2 like '%1'") + tdSql.query("select * from st where tagcol2 like '%1'") tdSql.checkRows(5) # _ for nchar type on tag case 1 - tdSql.query("select * from st where tagcol2 like '_______'") - tdSql.checkRows(0) + tdSql.query("select * from st where tagcol2 like '_______'") + tdSql.checkRows(0) # _ for nchar type on tag case 2 - tdSql.query("select * from st where tagcol2 like '______'") + tdSql.query("select * from st where tagcol2 like '______'") tdSql.checkRows(10) # _ for nchar type on tag case 3 - tdSql.query("select * from st where tagcol2 like 't_____'") + tdSql.query("select * from st where tagcol2 like 't_____'") tdSql.checkRows(10) # _ for nchar type on tag case 4 - tdSql.query("select * from st where tagcol2 like 's________'") + tdSql.query("select * from st where tagcol2 like 's________'") tdSql.checkRows(0) # _ for nchar type on tag case 5 - tdSql.query("select * from st where tagcol2 like '%__'") + tdSql.query("select * from st where tagcol2 like '%__'") tdSql.checkRows(10) # > for binary type on tag tdSql.error("select * from st where tagcol3 > '表'") # >= for binary type on tag - tdSql.error("select * from st where tagcol3 >= '表'") + tdSql.error("select * from st where tagcol3 >= '表'") # = for binary type on tag tdSql.query("select * from st where tagcol3 = '水表'") tdSql.checkRows(5) # <> for binary type on tag - tdSql.query("select * from st where tagcol3 <> '水表'") + tdSql.query("select * from st where tagcol3 <> '水表'") tdSql.checkRows(5) # != for binary type on tag - tdSql.query("select * from st where tagcol3 != '水表'") + tdSql.query("select * from st where tagcol3 != '水表'") tdSql.checkRows(5) # > for binary type on tag @@ -309,54 +315,53 @@ class TDTestCase: tdSql.error("select * from st where tagcol3 <= '水表'") # % for binary type on tag case 1 - tdSql.query("select * from st where tagcol3 like '%'") + tdSql.query("select * from st where tagcol3 like '%'") tdSql.checkRows(10) # % for binary type on tag case 2 - tdSql.query("select * from st where tagcol3 like '水%'") + tdSql.query("select * from st where tagcol3 like '水%'") tdSql.checkRows(5) # % for binary type on tag case 3 - tdSql.query("select * from st where tagcol3 like '数%_'") + tdSql.query("select * from st where tagcol3 like '数%_'") tdSql.checkRows(0) # % for binary type on tag case 4 - tdSql.query("select * from st where tagcol3 like '%表'") + tdSql.query("select * from st where tagcol3 like '%表'") tdSql.checkRows(10) # % for binary type on tag case 5 - tdSql.query("select * from st where tagcol3 like '%据'") + tdSql.query("select * from st where tagcol3 like '%据'") tdSql.checkRows(0) # _ for binary type on tag case 1 - tdSql.query("select * from st where tagcol3 like '__'") - tdSql.checkRows(10) + tdSql.query("select * from st where tagcol3 like '__'") + tdSql.checkRows(10) # _ for binary type on tag case 2 - tdSql.query("select * from st where tagcol3 like '水_'") + tdSql.query("select * from st where tagcol3 like '水_'") tdSql.checkRows(5) # _ for binary type on tag case 2 - tdSql.query("select * from st where tagcol3 like '_表'") + tdSql.query("select * from st where tagcol3 like '_表'") tdSql.checkRows(10) # _ for binary type on tag case 3 - tdSql.query("select * from st where tagcol3 like '___'") + tdSql.query("select * from st where tagcol3 like '___'") tdSql.checkRows(0) # _ for binary type on tag case 4 - tdSql.query("select * from st where tagcol3 like '数_'") + tdSql.query("select * from st where tagcol3 like '数_'") tdSql.checkRows(0) # _ for binary type on tag case 5 - tdSql.query("select * from st where tagcol3 like '_据'") + tdSql.query("select * from st where tagcol3 like '_据'") tdSql.checkRows(0) - + def stop(self): tdSql.close() - tdLog.success("%s successfully executed" % __file__) + tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) - diff --git a/tests/pytest/query/querySort.py b/tests/pytest/query/querySort.py index bb806c27bc..3858701379 100644 --- a/tests/pytest/query/querySort.py +++ b/tests/pytest/query/querySort.py @@ -21,56 +21,60 @@ from util.sql import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor()) self.rowNum = 10 self.ts = 1537146000000 - + def run(self): tdSql.prepare() print("======= step 1: create table and insert data =========") tdLog.debug( - ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, - tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20)) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, + ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, + tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20)) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, tagcol6 double, tagcol7 bool, tagcol8 nchar(20), tagcol9 binary(20))''') tdSql.execute( - ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, - tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20)) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, + ''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double, + tbcol7 bool, tbcol8 nchar(20), tbcol9 binary(20)) tags(tagcol1 tinyint, tagcol2 smallint, tagcol3 int, tagcol4 bigint, tagcol5 float, tagcol6 double, tagcol7 bool, tagcol8 nchar(20), tagcol9 binary(20))''') - + for i in range(self.rowNum): - tdSql.execute("create table st%d using st tags(%d, %d, %d, %d, %f, %f, %d, 'tag%d', '标签%d')" % (i + 1, i + 1, i + 1, i + 1, i + 1, 1.1 * (i + 1), - 1.23 * (i + 1), (i + 1) % 2, i + 1, i + 1)) + tdSql.execute("create table st%d using st tags(%d, %d, %d, %d, %f, %f, %d, 'tag%d', '标签%d')" % ( + i + 1, i + 1, i + 1, i + 1, i + 1, 1.1 * (i + 1), 1.23 * (i + 1), (i + 1) % 2, i + 1, i + 1)) for j in range(self.rowNum): - tdSql.execute("insert into st%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')" % (i + 1, self.ts + 10 * (i + 1) + j + 1, - j + 1, j + 1, j + 1, j + 1, 1.1 * (j + 1), 1.23 * (j + 1), (j + 1) % 2, j + 1, j + 1)) - + tdSql.execute("insert into st%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')" % ( + i + 1, self.ts + 10 * (i + 1) + j + 1, j + 1, j + 1, j + 1, j + 1, 1.1 * (j + 1), 1.23 * (j + 1), (j + 1) % 2, j + 1, j + 1)) - print("======= step 2: verify order for each column =========") - # sort for timestamp in asc order + print("======= step 2: verify order for each column =========") + # sort for timestamp in asc order tdSql.query("select * from st order by ts asc") tdSql.checkColumnSorted(0, "asc") - # sort for timestamp in desc order + # sort for timestamp in desc order tdSql.query("select * from st order by ts desc") tdSql.checkColumnSorted(0, "desc") + for i in range(1, 10): + tdSql.error("select * from st order by tbcol%d" % i) + tdSql.error("select * from st order by tbcol%d asc" % i) + tdSql.error("select * from st order by tbcol%d desc" % i) - for i in range(1, 10): - tdSql.error("select * from st order by tbcol%d" % i) - tdSql.error("select * from st order by tbcol%d asc" % i) - tdSql.error("select * from st order by tbcol%d desc" % i) - - tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d" % (i, i)) + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d" % + (i, i)) tdSql.checkColumnSorted(1, "") - tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" % (i, i)) + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d asc" % + (i, i)) tdSql.checkColumnSorted(1, "asc") - - tdSql.query("select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" % (i, i)) - tdSql.checkColumnSorted(1, "desc") - + + tdSql.query( + "select avg(tbcol1) from st group by tagcol%d order by tagcol%d desc" % + (i, i)) + tdSql.checkColumnSorted(1, "desc") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/random-test/random-test.py b/tests/pytest/random-test/random-test.py index 5eb356960a..31ce70e90a 100644 --- a/tests/pytest/random-test/random-test.py +++ b/tests/pytest/random-test/random-test.py @@ -97,6 +97,8 @@ class Test: "create table %s using %s tags (1, '表1')" % (current_tb, self.last_stb)) self.last_tb = current_tb + self.written = 0 + tdSql.execute( "insert into %s values (now, 27, '我是nchar字符串')" % self.last_tb) diff --git a/tests/pytest/table/tablename-boundary.py b/tests/pytest/table/tablename-boundary.py index 6ce986c51e..0755e75355 100644 --- a/tests/pytest/table/tablename-boundary.py +++ b/tests/pytest/table/tablename-boundary.py @@ -18,7 +18,10 @@ class TDTestCase: tdSql.prepare() getTableNameLen = "grep -w '#define TSDB_TABLE_NAME_LEN' ../../src/inc/taosdef.h|awk '{print $3}'" - tableNameMaxLen = int( subprocess.check_output(getTableNameLen, shell=True)) - 1 + tableNameMaxLen = int( + subprocess.check_output( + getTableNameLen, + shell=True)) - 1 tdLog.info("table name max length is %d" % tableNameMaxLen) chars = string.ascii_uppercase + string.ascii_lowercase tb_name = ''.join(random.choices(chars, k=tableNameMaxLen)) diff --git a/tests/pytest/tag_lite/change.py b/tests/pytest/tag_lite/change.py index 7cbef188b2..b8ddc3ff87 100644 --- a/tests/pytest/tag_lite/change.py +++ b/tests/pytest/tag_lite/change.py @@ -93,9 +93,13 @@ class TDTestCase: tdSql.error("alter table ta_ch_mt2 change tag tgcol1 tgcol2") # TSIM: return -1 # TSIM: step22: - # TSIM: sql alter table $mt change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20 - tdLog.info("alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") - tdSql.error("alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") + # TSIM: sql alter table $mt change tag tgcol1 + # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x + # step20 + tdLog.info( + "alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") + tdSql.error( + "alter table ta_ch_mt2 change tag tgcol1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -x step20") # TSIM: return -1 # TSIM: step20: # TSIM: @@ -267,8 +271,10 @@ class TDTestCase: tdSql.execute( 'create table ta_ch_mt6 (ts timestamp, tbcol int) TAGS(tgcol1 binary(10), tgcol2 int, tgcol3 smallint, tgcol4 binary(11), tgcol5 double, tgcol6 binary(20))') # TSIM: sql create table $tb using $mt tags( '1', 2, 3, '4', 5, '6' ) - tdLog.info("create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") - tdSql.execute("create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") + tdLog.info( + "create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") + tdSql.execute( + "create table tb6 using ta_ch_mt6 tags( '1', 2, 3, '4', 5, '6' )") # TSIM: sql insert into $tb values(now, 1) tdLog.info("insert into tb6 values(now, 1)") tdSql.execute("insert into tb6 values(now, 1)") diff --git a/tests/pytest/tag_lite/delete.py b/tests/pytest/tag_lite/delete.py index 88615e0406..17b4deb815 100644 --- a/tests/pytest/tag_lite/delete.py +++ b/tests/pytest/tag_lite/delete.py @@ -208,14 +208,14 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data23 != 1 then - tdLog.info('tdSql.checkData(2, 3, 1)') - tdSql.checkData(2, 3, 1) + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql alter table $mt drop tag tgcol1 -x step40 tdLog.info('alter table %s drop tag tgcol1 -x step40' % (mt)) - tdSql.error('alter table %s drop tag tgcol10' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) # TSIM: return -1 # TSIM: step40: # TSIM: sql alter table $mt drop tag tgcol2 @@ -263,14 +263,14 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != 2 then - tdLog.info('tdSql.checkData(0, 3, 2)') - tdSql.checkData(0, 3, 2) + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql alter table $mt drop tag tgcol1 -x step50 tdLog.info('alter table %s drop tag tgcol1 -x step50' % (mt)) - tdSql.error('alter table %s drop tag tgcol10' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) # TSIM: return -1 # TSIM: step50: # TSIM: sql alter table $mt drop tag tgcol2 @@ -381,8 +381,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != 3 then - tdLog.info('tdSql.checkData(0, 4, 3)') - tdSql.checkData(0, 4, 3) + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") # TSIM: return -1 # TSIM: endi # TSIM: @@ -420,18 +420,18 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data23 != 1 then - tdLog.info('tdSql.checkData(2, 3, 1)') - tdSql.checkData(2, 3, 1) + tdLog.info('tdSql.checkData(2, 3, "TAG")') + tdSql.checkData(2, 3, "TAG") # TSIM: return -1 # TSIM: endi # TSIM: if $data33 != 2 then - tdLog.info('tdSql.checkData(3, 3, 2)') - tdSql.checkData(3, 3, 2) + tdLog.info('tdSql.checkData(3, 3, "TAG")') + tdSql.checkData(3, 3, "TAG") # TSIM: return -1 # TSIM: endi # TSIM: if $data43 != 3 then - tdLog.info('tdSql.checkData(4, 3, 3)') - tdSql.checkData(4, 3, 3) + tdLog.info('tdSql.checkData(4, 3, "TAG")') + tdSql.checkData(4, 3, "TAG") # TSIM: return -1 # TSIM: endi # TSIM: @@ -488,8 +488,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != 3 then - tdLog.info('tdSql.checkData(0, 4, 3)') - tdSql.checkData(0, 4, 3) + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") # TSIM: return -1 # TSIM: endi # TSIM: @@ -543,13 +543,13 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != 2 then - tdLog.info('tdSql.checkData(0, 3, 2)') - tdSql.checkData(0, 3, 2) + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != 3 then - tdLog.info('tdSql.checkData(0, 4, 3)') - tdSql.checkData(0, 4, 3) + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") # TSIM: return -1 # TSIM: endi # TSIM: @@ -600,23 +600,23 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data02 != 1 then - tdLog.info('tdSql.checkData(0, 2, 1)') - tdSql.checkData(0, 2, 1) + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != 2 then - tdLog.info('tdSql.checkData(0, 3, 2)') - tdSql.checkData(0, 3, 2) + tdLog.info('tdSql.checkData(0, 3, "2")') + tdSql.checkData(0, 3, "2") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != 3 then - tdLog.info('tdSql.checkData(0, 4, 3)') - tdSql.checkData(0, 4, 3) + tdLog.info('tdSql.checkData(0, 4, "3")') + tdSql.checkData(0, 4, "3") # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != 4 then - tdLog.info('tdSql.checkData(0, 5, 4)') - tdSql.checkData(0, 5, 4) + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") # TSIM: return -1 # TSIM: endi # TSIM: @@ -690,8 +690,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != 5 then - tdLog.info('tdSql.checkData(0, 6, 5)') - tdSql.checkData(0, 6, 5) + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") # TSIM: return -1 # TSIM: endi # TSIM: @@ -766,13 +766,13 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != 5 then - tdLog.info('tdSql.checkData(0, 6, 5)') - tdSql.checkData(0, 6, 5) + tdLog.info('tdSql.checkData(0, 6, "5")') + tdSql.checkData(0, 6, "5") # TSIM: return -1 # TSIM: endi # TSIM: if $data07 != 6 then - tdLog.info('tdSql.checkData(0, 7, 6)') - tdSql.checkData(0, 7, 6) + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") # TSIM: return -1 # TSIM: endi # TSIM: @@ -830,8 +830,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data02 != 1 then - tdLog.info('tdSql.checkData(0, 2, 1)') - tdSql.checkData(0, 2, 1) + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != 2 then @@ -845,8 +845,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != 4 then - tdLog.info('tdSql.checkData(0, 5, 4)') - tdSql.checkData(0, 5, 4) + tdLog.info('tdSql.checkData(0, 5, "4")') + tdSql.checkData(0, 5, "4") # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != 5.000000000 then @@ -855,8 +855,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data07 != 6 then - tdLog.info('tdSql.checkData(0, 7, 6)') - tdSql.checkData(0, 7, 6) + tdLog.info('tdSql.checkData(0, 7, "6")') + tdSql.checkData(0, 7, "6") # TSIM: return -1 # TSIM: endi # TSIM: @@ -903,7 +903,11 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: @@ -944,7 +948,11 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: @@ -985,7 +993,11 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: @@ -1026,7 +1038,11 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: @@ -1067,23 +1083,27 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step51 tdLog.info('select * from %s where tgcol2 = 1 -x step51' % (mt)) - tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step51: # TSIM: sql select * from $mt where tgcol3 = 1 -x step52 tdLog.info('select * from %s where tgcol3 = 1 -x step52' % (mt)) - tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step52: # TSIM: @@ -1118,23 +1138,27 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step71 tdLog.info('select * from %s where tgcol2 = 1 -x step71' % (mt)) - tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step71: # TSIM: sql select * from $mt where tgcol3 = 1 -x step72 tdLog.info('select * from %s where tgcol3 = 1 -x step72' % (mt)) - tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step72: # TSIM: @@ -1169,23 +1193,27 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step81 tdLog.info('select * from %s where tgcol2 = 1 -x step81' % (mt)) - tdSql.error('select * from %s where tgcol2 = 11' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step81: # TSIM: sql select * from $mt where tgcol3 = 1 -x step82 tdLog.info('select * from %s where tgcol3 = 1 -x step82' % (mt)) - tdSql.error('select * from %s where tgcol3 = 12' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step82: # TSIM: @@ -1220,23 +1248,27 @@ class TDTestCase: # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol3 = 1 -x step91 tdLog.info('select * from %s where tgcol3 = 1 -x step91' % (mt)) - tdSql.error('select * from %s where tgcol3 = 11' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step91: # TSIM: sql select * from $mt where tgcol2 = 1 -x step92 tdLog.info('select * from %s where tgcol2 = 1 -x step92' % (mt)) - tdSql.error('select * from %s where tgcol2 = 12' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step92: # TSIM: @@ -1265,39 +1297,43 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data02 != 1 then - tdLog.info('tdSql.checkData(0, 2, 1)') - tdSql.checkData(0, 2, 1) + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != NULL then tdLog.info('tdSql.checkData(0, 3, NULL)') - tdSql.checkData(0, 3, None) + try: + tdSql.checkData(0, 3, None) + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("out of range") # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != NULL then - tdLog.info('tdSql.checkData(0, 5, NULL)') - tdSql.checkData(0, 5, None) + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step101 tdLog.info('select * from %s where tgcol2 = 1 -x step101' % (mt)) - tdSql.error('select * from %s where tgcol2 = 101' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step101: # TSIM: sql select * from $mt where tgcol3 = 1 -x step102 tdLog.info('select * from %s where tgcol3 = 1 -x step102' % (mt)) - tdSql.error('select * from %s where tgcol3 = 102' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step102: # TSIM: sql select * from $mt where tgcol4 = 1 -x step103 tdLog.info('select * from %s where tgcol4 = 1 -x step103' % (mt)) - tdSql.error('select * from %s where tgcol4 = 103' % (mt)) + tdSql.error('select * from %s where tgcol4 = 1' % (mt)) # TSIM: return -1 # TSIM: step103: # TSIM: @@ -1336,34 +1372,34 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != NULL then - tdLog.info('tdSql.checkData(0, 5, NULL)') - tdSql.checkData(0, 5, None) + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != NULL then - tdLog.info('tdSql.checkData(0, 6, NULL)') - tdSql.checkData(0, 6, None) + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step111 tdLog.info('select * from %s where tgcol2 = 1 -x step111' % (mt)) - tdSql.error('select * from %s where tgcol2 = 111' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step111: # TSIM: sql select * from $mt where tgcol3 = 1 -x step112 tdLog.info('select * from %s where tgcol3 = 1 -x step112' % (mt)) - tdSql.error('select * from %s where tgcol3 = 112' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step112: # TSIM: sql select * from $mt where tgcol5 = 1 -x step113 tdLog.info('select * from %s where tgcol5 = 1 -x step113' % (mt)) - tdSql.error('select * from %s where tgcol5 = 113' % (mt)) + tdSql.error('select * from %s where tgcol5 = 1' % (mt)) # TSIM: return -1 # TSIM: step113: # TSIM: @@ -1402,44 +1438,44 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data04 != NULL then - tdLog.info('tdSql.checkData(0, 4, NULL)') - tdSql.checkData(0, 4, None) + tdLog.info('tdSql.checkData(0, 4, NULL) out of range') + # tdSql.checkData(0, 4, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != NULL then - tdLog.info('tdSql.checkData(0, 5, NULL)') - tdSql.checkData(0, 5, None) + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != NULL then - tdLog.info('tdSql.checkData(0, 6, NULL)') - tdSql.checkData(0, 6, None) + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data07 != NULL then - tdLog.info('tdSql.checkData(0, 7, NULL)') - tdSql.checkData(0, 7, None) + tdLog.info('tdSql.checkData(0, 7, NULL) out of range') + # tdSql.checkData(0, 7, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol2 = 1 -x step120 tdLog.info('select * from %s where tgcol2 = 1 -x step120' % (mt)) - tdSql.error('select * from %s where tgcol2 = 120' % (mt)) + tdSql.error('select * from %s where tgcol2 = 1' % (mt)) # TSIM: return -1 # TSIM: step120: # TSIM: sql select * from $mt where tgcol3 = 1 -x step121 tdLog.info('select * from %s where tgcol3 = 1 -x step121' % (mt)) - tdSql.error('select * from %s where tgcol3 = 121' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step121: # TSIM: sql select * from $mt where tgcol5 = 1 -x step122 tdLog.info('select * from %s where tgcol5 = 1 -x step122' % (mt)) - tdSql.error('select * from %s where tgcol5 = 122' % (mt)) + tdSql.error('select * from %s where tgcol5 = 1' % (mt)) # TSIM: return -1 # TSIM: step122: # TSIM: sql select * from $mt where tgcol6 = 1 -x step123 tdLog.info('select * from %s where tgcol6 = 1 -x step123' % (mt)) - tdSql.error('select * from %s where tgcol6 = 123' % (mt)) + tdSql.error('select * from %s where tgcol6 = 1' % (mt)) # TSIM: return -1 # TSIM: step123: # TSIM: @@ -1471,8 +1507,8 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data02 != 1 then - tdLog.info('tdSql.checkData(0, 2, 1)') - tdSql.checkData(0, 2, 1) + tdLog.info('tdSql.checkData(0, 2, "1")') + tdSql.checkData(0, 2, "1") # TSIM: return -1 # TSIM: endi # TSIM: if $data03 != 2 then @@ -1486,34 +1522,34 @@ class TDTestCase: # TSIM: return -1 # TSIM: endi # TSIM: if $data05 != NULL then - tdLog.info('tdSql.checkData(0, 5, NULL)') - tdSql.checkData(0, 5, None) + tdLog.info('tdSql.checkData(0, 5, NULL) out of range') + # tdSql.checkData(0, 5, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data06 != NULL then - tdLog.info('tdSql.checkData(0, 6, NULL)') - tdSql.checkData(0, 6, None) + tdLog.info('tdSql.checkData(0, 6, NULL) out of range') + # tdSql.checkData(0, 6, None) # TSIM: return -1 # TSIM: endi # TSIM: if $data07 != NULL then - tdLog.info('tdSql.checkData(0, 7, NULL)') - tdSql.checkData(0, 7, None) + tdLog.info('tdSql.checkData(0, 7, NULL) out of range') + # tdSql.checkData(0, 7, None) # TSIM: return -1 # TSIM: endi # TSIM: # TSIM: sql select * from $mt where tgcol3 = 1 -x step130 tdLog.info('select * from %s where tgcol3 = 1 -x step130' % (mt)) - tdSql.error('select * from %s where tgcol3 = 130' % (mt)) + tdSql.error('select * from %s where tgcol3 = 1' % (mt)) # TSIM: return -1 # TSIM: step130: # TSIM: sql select * from $mt where tgcol4 = 1 -x step131 tdLog.info('select * from %s where tgcol4 = 1 -x step131' % (mt)) - tdSql.error('select * from %s where tgcol4 = 131' % (mt)) + tdSql.error('select * from %s where tgcol4 = 1' % (mt)) # TSIM: return -1 # TSIM: step131: # TSIM: sql select * from $mt where tgcol6 = 1 -x step133 tdLog.info('select * from %s where tgcol6 = 1 -x step133' % (mt)) - tdSql.error('select * from %s where tgcol6 = 133' % (mt)) + tdSql.error('select * from %s where tgcol6 = 1' % (mt)) # TSIM: return -1 # TSIM: step133: # TSIM: @@ -1542,23 +1578,23 @@ class TDTestCase: # TSIM: # TSIM: sql alter table xxmt drop tag tag1 -x step141 tdLog.info('alter table xxmt drop tag tag1 -x step141') - tdSql.error('alter table xxmt drop tag tag141') + tdSql.error('alter table xxmt drop tag tag1') # TSIM: return -1 # TSIM: step141: # TSIM: sql alter table $tb drop tag tag1 -x step142 tdLog.info('alter table %s drop tag tag1 -x step142' % (tb)) - tdSql.error('alter table %s drop tag tag142' % (tb)) + tdSql.error('alter table %s drop tag tag1' % (tb)) # TSIM: return -1 # TSIM: step142: # TSIM: sql alter table $mt drop tag tag1 -x step143 tdLog.info('alter table %s drop tag tag1 -x step143' % (mt)) - tdSql.error('alter table %s drop tag tag143' % (mt)) + tdSql.error('alter table %s drop tag tag1' % (mt)) # TSIM: return -1 # TSIM: step143: # TSIM: # TSIM: sql alter table $mt drop tag tagcol1 -x step144 tdLog.info('alter table %s drop tag tagcol1 -x step144' % (mt)) - tdSql.error('alter table %s drop tag tagcol144' % (mt)) + tdSql.error('alter table %s drop tag tagcol1' % (mt)) # TSIM: return -1 # TSIM: step144: # TSIM: @@ -1567,15 +1603,15 @@ class TDTestCase: tdSql.execute('alter table %s drop tag tgcol2' % (mt)) # TSIM: sql alter table $mt drop tag tgcol1 -x step145 tdLog.info('alter table %s drop tag tgcol1 -x step145' % (mt)) - tdSql.error('alter table %s drop tag tgcol145' % (mt)) + tdSql.error('alter table %s drop tag tgcol1' % (mt)) # TSIM: return -1 # TSIM: step145: # TSIM: # TSIM: print =============== clear tdLog.info('=============== clear') # TSIM: sql drop database $db - tdLog.info('sql drop database $db') - tdSql.execute('sql drop database $db') + tdLog.info('drop database db') + tdSql.execute('drop database db') # TSIM: sql show databases tdLog.info('show databases') tdSql.query('show databases') diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 367217cd49..f3fd178088 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -205,31 +205,37 @@ class TDSql: if col < 0: tdLog.exit( "%s failed: sql:%s, col:%d is smaller than zero" % - (callerFilename, self.sql, col)) + (callerFilename, self.sql, col)) if col > self.queryCols: tdLog.exit( "%s failed: sql:%s, col:%d is larger than queryCols:%d" % (callerFilename, self.sql, col, self.queryCols)) - + matrix = np.array(self.queryResult) - list = matrix[:, 0] + list = matrix[:, 0] - if order == "" or order.upper() == "ASC": - if all(sorted(list) == list): - tdLog.info("sql:%s, column :%d is sorted in accending order as expected" % + if order == "" or order.upper() == "ASC": + if all(sorted(list) == list): + tdLog.info( + "sql:%s, column :%d is sorted in accending order as expected" % (self.sql, col)) else: - tdLog.exit("%s failed: sql:%s, col:%d is not sorted in accesnind order" % + tdLog.exit( + "%s failed: sql:%s, col:%d is not sorted in accesnind order" % (callerFilename, self.sql, col)) - elif order.upper() == "DESC": - if all(sorted(list, reverse=True) == list): - tdLog.info("sql:%s, column :%d is sorted in decending order as expected" % + elif order.upper() == "DESC": + if all(sorted(list, reverse=True) == list): + tdLog.info( + "sql:%s, column :%d is sorted in decending order as expected" % (self.sql, col)) else: - tdLog.exit("%s failed: sql:%s, col:%d is not sorted in decending order" % - (callerFilename, self.sql, col)) + tdLog.exit( + "%s failed: sql:%s, col:%d is not sorted in decending order" % + (callerFilename, self.sql, col)) else: - tdLog.exit("%s failed: sql:%s, the order provided for col:%d is not correct" % - (callerFilename, self.sql, col)) + tdLog.exit( + "%s failed: sql:%s, the order provided for col:%d is not correct" % + (callerFilename, self.sql, col)) + tdSql = TDSql() -- GitLab