提交 046c9cb7 编写于 作者: C cpwu

fix case

上级 3ae378e0
...@@ -136,23 +136,23 @@ class TDTestCase: ...@@ -136,23 +136,23 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = [ tbname = [
"ct1", f"{dbname}.ct1",
"ct2", f"{dbname}.ct2",
"ct4", f"{dbname}.ct4",
] ]
for tb in tbname: for tb in tbname:
for i in range(2,8): for i in range(2,8):
self.__concat_check(tb,i) self.__concat_check(tb,i)
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = [ tbname = [
"t1", f"{dbname}.t1",
"stb1", f"{dbname}.stb1",
] ]
for tb in tbname: for tb in tbname:
...@@ -163,22 +163,20 @@ class TDTestCase: ...@@ -163,22 +163,20 @@ class TDTestCase:
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
def all_test(self): def all_test(self, dbname="db"):
self.__test_current() self.__test_current(dbname)
self.__test_error() self.__test_error(dbname)
def __create_tb(self, dbname="db"):
def __create_tb(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -188,29 +186,29 @@ class TDTestCase: ...@@ -188,29 +186,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -226,7 +224,7 @@ class TDTestCase: ...@@ -226,7 +224,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -242,13 +240,13 @@ class TDTestCase: ...@@ -242,13 +240,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -268,22 +266,23 @@ class TDTestCase: ...@@ -268,22 +266,23 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
self.__create_tb() self.__create_tb(dbname="db")
tdLog.printNoPrefix("==========step2:insert data") tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10 self.rows = 10
self.__insert_data(self.rows) self.__insert_data(self.rows, dbname="db")
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test(dbname="db")
tdDnodes.stop(1) # tdDnodes.stop(1)
tdDnodes.start(1) # tdDnodes.start(1)
tdSql.execute("flush database db")
tdSql.execute("use db") tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test(dbname="db")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -137,22 +137,22 @@ class TDTestCase: ...@@ -137,22 +137,22 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self, dbname="db"):
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = [ tbname = [
"t1", f"{dbname}.t1",
"stb1", f"{dbname}.stb1",
] ]
for tb in tbname: for tb in tbname:
for i in range(2,8): for i in range(2,8):
self.__concat_check(tb,i) self.__concat_check(tb,i)
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = [ tbname = [
"ct1", f"{dbname}.ct1",
"ct4", f"{dbname}.ct4",
] ]
for tb in tbname: for tb in tbname:
...@@ -163,22 +163,20 @@ class TDTestCase: ...@@ -163,22 +163,20 @@ class TDTestCase:
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
def all_test(self): def all_test(self, dbname="db"):
self.__test_current() self.__test_current(dbname)
self.__test_error() self.__test_error(dbname)
def __create_tb(self, dbname="db"):
def __create_tb(self):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -188,29 +186,29 @@ class TDTestCase: ...@@ -188,29 +186,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -226,7 +224,7 @@ class TDTestCase: ...@@ -226,7 +224,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -242,13 +240,13 @@ class TDTestCase: ...@@ -242,13 +240,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -268,23 +266,23 @@ class TDTestCase: ...@@ -268,23 +266,23 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
self.__create_tb() self.__create_tb(dbname="db")
tdLog.printNoPrefix("==========step2:insert data") tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10 self.rows = 10
self.__insert_data(self.rows) self.__insert_data(self.rows, dbname="db")
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test(dbname="db")
tdDnodes.stop(1) # tdDnodes.stop(1)
tdDnodes.start(1) # tdDnodes.start(1)
tdSql.execute("flush database db")
tdSql.execute("use db") tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test(dbname="db")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -137,23 +137,23 @@ class TDTestCase: ...@@ -137,23 +137,23 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self,dbname="db"): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = [ tbname = [
"t1", f"{dbname}.t1",
"stb1" f"{dbname}.stb1"
] ]
for tb in tbname: for tb in tbname:
for i in range(2,8): for i in range(2,8):
self.__concat_ws_check(tb,i) self.__concat_ws_check(tb,i)
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = [ tbname = [
"ct1", f"{dbname}.ct1",
"ct2", f"{dbname}.ct2",
"ct4", f"{dbname}.ct4",
] ]
for tb in tbname: for tb in tbname:
...@@ -164,22 +164,21 @@ class TDTestCase: ...@@ -164,22 +164,21 @@ class TDTestCase:
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
def all_test(self): def all_test(self,dbname="db"):
self.__test_current() self.__test_current(dbname)
self.__test_error() self.__test_error(dbname)
def __create_tb(self): def __create_tb(self, dbname="db"):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -189,29 +188,29 @@ class TDTestCase: ...@@ -189,29 +188,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -227,7 +226,7 @@ class TDTestCase: ...@@ -227,7 +226,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -243,13 +242,13 @@ class TDTestCase: ...@@ -243,13 +242,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -269,22 +268,23 @@ class TDTestCase: ...@@ -269,22 +268,23 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
self.__create_tb() self.__create_tb(dbname="db")
tdLog.printNoPrefix("==========step2:insert data") tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10 self.rows = 10
self.__insert_data(self.rows) self.__insert_data(self.rows, dbname="db")
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test(dbname="db")
tdDnodes.stop(1) # tdDnodes.stop(1)
tdDnodes.start(1) # tdDnodes.start(1)
tdSql.execute("flush database db")
tdSql.execute("use db") tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test(dbname="db")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -137,23 +137,23 @@ class TDTestCase: ...@@ -137,23 +137,23 @@ class TDTestCase:
return sqls return sqls
def __test_current(self): # sourcery skip: use-itertools-product def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = [ tbname = [
"ct1", f"{dbname}.ct1",
"ct2", f"{dbname}.ct2",
"ct4", f"{dbname}.ct4",
] ]
for tb in tbname: for tb in tbname:
for i in range(2,8): for i in range(2,8):
self.__concat_ws_check(tb,i) self.__concat_ws_check(tb,i)
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========") tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
def __test_error(self): def __test_error(self, dbname="db"):
tdLog.printNoPrefix("==========err sql condition check , must return error==========") tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = [ tbname = [
"t1", f"{dbname}.t1",
"stb1" f"{dbname}.stb1"
] ]
for tb in tbname: for tb in tbname:
...@@ -164,22 +164,21 @@ class TDTestCase: ...@@ -164,22 +164,21 @@ class TDTestCase:
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
def all_test(self): def all_test(self, dbname="db"):
self.__test_current() self.__test_current(dbname="db")
self.__test_error() self.__test_error(dbname="db")
def __create_tb(self): def __create_tb(self, dbname="db"):
tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1( create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int) ) tags (t1 int)
''' '''
create_ntb_sql = f'''create table t1( create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
...@@ -189,29 +188,29 @@ class TDTestCase: ...@@ -189,29 +188,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql) tdSql.execute(create_ntb_sql)
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
def __insert_data(self, rows): def __insert_data(self, rows, dbname="db"):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows): for i in range(rows):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )" f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
) )
tdSql.execute( tdSql.execute(
f'''insert into ct1 values f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } ) ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } ) ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
''' '''
) )
tdSql.execute( tdSql.execute(
f'''insert into ct4 values f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -227,7 +226,7 @@ class TDTestCase: ...@@ -227,7 +226,7 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f'''insert into ct2 values f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -243,13 +242,13 @@ class TDTestCase: ...@@ -243,13 +242,13 @@ class TDTestCase:
) )
for i in range(rows): for i in range(rows):
insert_data = f'''insert into t1 values insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } ) "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
''' '''
tdSql.execute(insert_data) tdSql.execute(insert_data)
tdSql.execute( tdSql.execute(
f'''insert into t1 values f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...@@ -269,22 +268,23 @@ class TDTestCase: ...@@ -269,22 +268,23 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
tdLog.printNoPrefix("==========step1:create table") tdLog.printNoPrefix("==========step1:create table")
self.__create_tb() self.__create_tb(dbname="db")
tdLog.printNoPrefix("==========step2:insert data") tdLog.printNoPrefix("==========step2:insert data")
self.rows = 10 self.rows = 10
self.__insert_data(self.rows) self.__insert_data(self.rows, dbname="db")
tdLog.printNoPrefix("==========step3:all check") tdLog.printNoPrefix("==========step3:all check")
self.all_test() self.all_test(dbname="db")
tdDnodes.stop(1) # tdDnodes.stop(1)
tdDnodes.start(1) # tdDnodes.start(1)
tdSql.execute("flush database db")
tdSql.execute("use db") tdSql.execute("use db")
tdLog.printNoPrefix("==========step4:after wal, all check again ") tdLog.printNoPrefix("==========step4:after wal, all check again ")
self.all_test() self.all_test(dbname="db")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
此差异已折叠。
...@@ -5,13 +5,14 @@ from util.sqlset import * ...@@ -5,13 +5,14 @@ from util.sqlset import *
class TDTestCase: class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(),logSql) tdSql.init(conn.cursor(),False)
self.setsql = TDSetSql() self.setsql = TDSetSql()
self.rowNum = 10 self.rowNum = 10
self.ts = 1537146000000 self.ts = 1537146000000
self.ntbname = 'ntb' dbname = "db"
self.stbname = 'stb' self.ntbname = f'{dbname}.ntb'
self.stbname = f'{dbname}.stb'
self.column_dict = { self.column_dict = {
'ts':'timestamp', 'ts':'timestamp',
'c1':'int', 'c1':'int',
......
...@@ -11,17 +11,17 @@ class TDTestCase: ...@@ -11,17 +11,17 @@ class TDTestCase:
self.row_nums = 10 self.row_nums = 10
self.tb_nums = 10 self.tb_nums = 10
self.ts = 1537146000000 self.ts = 1537146000000
def prepare_datas(self, stb_name , tb_nums , row_nums ): def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ):
tdSql.execute(" use db ") tdSql.execute(f" use {dbname} ")
tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\ tdSql.execute(f" create stable {dbname}.{stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\ uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ") , t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
for i in range(tb_nums): for i in range(tb_nums):
tbname = f"sub_{stb_name}_{i}" tbname = f"{dbname}.sub_{stb_name}_{i}"
ts = self.ts + i*10000 ts = self.ts + i*10000
tdSql.execute(f"create table {tbname} using {stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
for row in range(row_nums): for row in range(row_nums):
ts = self.ts + row*1000 ts = self.ts + row*1000
...@@ -30,143 +30,144 @@ class TDTestCase: ...@@ -30,143 +30,144 @@ class TDTestCase:
for null in range(5): for null in range(5):
ts = self.ts + row_nums*1000 + null*1000 ts = self.ts + row_nums*1000 + null*1000
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )") tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
def basic_query(self): def basic_query(self, dbname="db"):
tdSql.query("select count(*) from stb") tdSql.query(f"select count(*) from {dbname}.stb")
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums) tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
tdSql.query("select count(c1) from stb") tdSql.query(f"select count(c1) from {dbname}.stb")
tdSql.checkData(0,0,(self.row_nums )*self.tb_nums) tdSql.checkData(0,0,(self.row_nums )*self.tb_nums)
tdSql.query(" select tbname , count(*) from stb partition by tbname ") tdSql.query(f"select tbname , count(*) from {dbname}.stb partition by tbname ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.query(" select count(c1) from stb group by t1 order by t1 ") tdSql.query(f"select count(c1) from {dbname}.stb group by t1 order by t1 ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.error(" select count(c1) from stb group by c1 order by t1 ") tdSql.error(f"select count(c1) from {dbname}.stb group by c1 order by t1 ")
tdSql.error(" select count(t1) from stb group by c1 order by t1 ") tdSql.error(f"select count(t1) from {dbname}.stb group by c1 order by t1 ")
tdSql.query(" select count(c1) from stb group by tbname order by tbname ") tdSql.query(f"select count(c1) from {dbname}.stb group by tbname order by tbname ")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
# bug need fix # bug need fix
# tdSql.query(" select count(t1) from stb group by t2 order by t2 ") # tdSql.query(f"select count(t1) from {dbname}.stb group by t2 order by t2 ")
# tdSql.checkRows(self.tb_nums) # tdSql.checkRows(self.tb_nums)
tdSql.query(" select count(c1) from stb group by c1 order by c1 ") tdSql.query(f"select count(c1) from {dbname}.stb group by c1 order by c1 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query(" select c1 , count(c1) from stb group by c1 order by c1 ") tdSql.query(f"select c1 , count(c1) from {dbname}.stb group by c1 order by c1 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1) from stb group by abs(c1) order by abs(c1)") tdSql.query(f"select count(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select abs(c1+c3), count(c1+c3) from stb group by abs(c1+c3) order by abs(c1+c3)") tdSql.query(f"select abs(c1+c3), count(c1+c3) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)") tdSql.query(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from stb group by abs(c1) order by abs(t1)+c2") tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from {dbname}.stb group by abs(c1) order by abs(t1)+c2")
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2") tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2")
tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)") tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from {dbname}.stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1) , count(t2) from stb where abs(c1+t2)=1 partition by tbname") tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(c1) from stb where abs(c1+t2)=1 partition by tbname") tdSql.query(f"select count(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname") tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
tdSql.error("select tbname , count(c1) from stb partition by t1 order by t1") tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t1 order by t1")
tdSql.error("select tbname , count(t1) from stb partition by t1 order by t1") tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t1 order by t1")
tdSql.error("select tbname , count(t1) from stb partition by t2 order by t2") tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t2 order by t2")
# # bug need fix # # bug need fix
# tdSql.query("select t2 , count(t1) from stb partition by t2 order by t2") # tdSql.query(f"select t2 , count(t1) from {dbname}.stb partition by t2 order by t2")
# tdSql.checkRows(self.tb_nums) # tdSql.checkRows(self.tb_nums)
tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname") tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
tdSql.error("select tbname , count(c1) from stb partition by t2 order by t2")
tdSql.query("select c2, count(c1) from stb partition by c2 order by c2 desc") tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t2 order by t2")
tdSql.query(f"select c2, count(c1) from {dbname}.stb partition by c2 order by c2 desc")
tdSql.checkRows(self.tb_nums+1) tdSql.checkRows(self.tb_nums+1)
tdSql.checkData(0,1,self.tb_nums) tdSql.checkData(0,1,self.tb_nums)
tdSql.error("select tbname , count(c1) from stb partition by c1 order by c2") tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by c1 order by c2")
tdSql.query("select tbname , abs(t2) from stb partition by c2 order by t2") tdSql.query(f"select tbname , abs(t2) from {dbname}.stb partition by c2 order by t2")
tdSql.checkRows(self.tb_nums*(self.row_nums+5)) tdSql.checkRows(self.tb_nums*(self.row_nums+5))
tdSql.query("select count(c1) , count(t2) from stb partition by c2 ") tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb partition by c2 ")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
tdSql.query("select count(c1) , count(t2) ,c2 from stb partition by c2 order by c2") tdSql.query(f"select count(c1) , count(t2) ,c2 from {dbname}.stb partition by c2 order by c2")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(c1) , count(t1) ,max(c2) ,tbname from stb partition by tbname order by tbname") tdSql.query(f"select count(c1) , count(t1) ,max(c2) ,tbname from {dbname}.stb partition by tbname order by tbname")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkCols(4) tdSql.checkCols(4)
tdSql.query("select count(c1) , count(t2) ,t1 from stb partition by t1 order by t1") tdSql.query(f"select count(c1) , count(t2) ,t1 from {dbname}.stb partition by t1 order by t1")
tdSql.checkRows(self.tb_nums) tdSql.checkRows(self.tb_nums)
tdSql.checkData(0,0,self.row_nums) tdSql.checkData(0,0,self.row_nums)
# bug need fix # bug need fix
# tdSql.query("select count(c1) , count(t1) ,abs(c1) from stb partition by abs(c1) order by abs(c1)") # tdSql.query(f"select count(c1) , count(t1) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)")
# tdSql.checkRows(self.row_nums+1) # tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
tdSql.query(f"select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
tdSql.query("select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))") tdSql.query(f"select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from {dbname}.stb partition by abs(floor(c1)) order by abs(floor(c1))")
tdSql.checkRows(self.row_nums+1) tdSql.checkRows(self.row_nums+1)
# interval
tdSql.query("select count(c1) from stb interval(2s) sliding(1s)") # interval
tdSql.query(f"select count(c1) from {dbname}.stb interval(2s) sliding(1s)")
# bug need fix # bug need fix
tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)') tdSql.query(f'select max(c1) from {dbname}.stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ") tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s) slimit 5 soffset 1 ")
tdSql.query("select tbname , count(c1) from stb partition by tbname interval(10s)") tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s)")
tdSql.query("select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s)") tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s)")
tdSql.checkData(0,0,'sub_stb_1') tdSql.checkData(0,0,'sub_stb_1')
tdSql.checkData(0,1,self.row_nums) tdSql.checkData(0,1,self.row_nums)
# tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ") # tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ")
# tdSql.checkRows(5)
# tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 1 ")
# tdSql.checkRows(5) # tdSql.checkRows(5)
# tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ") tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
# tdSql.checkRows(5)
tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
tdSql.query(" select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ") tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)')
tdSql.query(f'select tbname , count(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)')
tdSql.query(f'select tbname , count(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
self.prepare_datas("stb",self.tb_nums,self.row_nums) self.prepare_datas("stb",self.tb_nums,self.row_nums)
self.basic_query() self.basic_query()
dbname="db"
# # coverage case for taosd crash about bug fix
tdSql.query(f"select sum(c1) from {dbname}.stb where t2+10 >1 ")
tdSql.query(f"select count(c1),count(t1) from {dbname}.stb where -t2<1 ")
tdSql.query(f"select tbname ,max(ceil(c1)) from {dbname}.stb group by tbname ")
tdSql.query(f"select avg(abs(c1)) , tbname from {dbname}.stb group by tbname ")
tdSql.query(f"select t1,c1 from {dbname}.stb where abs(t2+c1)=1 ")
# # coverage case for taosd crash about bug fix
tdSql.query(" select sum(c1) from stb where t2+10 >1 ")
tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ")
tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ")
tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ")
tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -10,9 +10,6 @@ import random ...@@ -10,9 +10,6 @@ import random
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
"jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
"wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
...@@ -26,22 +23,22 @@ class TDTestCase: ...@@ -26,22 +23,22 @@ class TDTestCase:
tdSql.execute("create table dbms.ntb (ts timestamp, c1 int, c2 bigint)") tdSql.execute("create table dbms.ntb (ts timestamp, c1 int, c2 bigint)")
tdSql.execute("create table dbus.ntb (ts timestamp, c1 int, c2 bigint)") tdSql.execute("create table dbus.ntb (ts timestamp, c1 int, c2 bigint)")
tdSql.execute("create table dbns.ntb (ts timestamp, c1 int, c2 bigint)") tdSql.execute("create table dbns.ntb (ts timestamp, c1 int, c2 bigint)")
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.001', 1, 2)") tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.001', 1, 2)")
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.002', 3, 4)") tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.002', 3, 4)")
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000001', 1, 2)") tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000001', 1, 2)")
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000002', 3, 4)") tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000002', 3, 4)")
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000001', 1, 2)") tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000001', 1, 2)")
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000002', 3, 4)") tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000002', 3, 4)")
tdSql.query("select count(c1) from dbms.ntb interval(1a)") tdSql.query("select count(c1) from dbms.ntb interval(1a)")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(c1) from dbus.ntb interval(1u)") tdSql.query("select count(c1) from dbus.ntb interval(1u)")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.query("select count(c1) from dbns.ntb interval(1b)") tdSql.query("select count(c1) from dbns.ntb interval(1b)")
tdSql.checkRows(2) tdSql.checkRows(2)
......
...@@ -18,116 +18,117 @@ class TDTestCase: ...@@ -18,116 +18,117 @@ class TDTestCase:
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
dbname = "db"
tdSql.execute( tdSql.execute(
"create table ntb(ts timestamp,c1 int,c2 double,c3 float)") f"create table {dbname}.ntb(ts timestamp,c1 int,c2 double,c3 float)")
tdSql.execute( tdSql.execute(
"insert into ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)") f"insert into {dbname}.ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)")
tdSql.query("select diff(c1,0) from ntb") tdSql.query(f"select diff(c1,0) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, 9) tdSql.checkData(0, 0, 9)
tdSql.checkData(1, 0, -11) tdSql.checkData(1, 0, -11)
tdSql.query("select diff(c1,1) from ntb") tdSql.query(f"select diff(c1,1) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, 9) tdSql.checkData(0, 0, 9)
tdSql.checkData(1, 0, None) tdSql.checkData(1, 0, None)
tdSql.query("select diff(c2,0) from ntb") tdSql.query(f"select diff(c2,0) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, -101) tdSql.checkData(0, 0, -101)
tdSql.checkData(1, 0, 115.1) tdSql.checkData(1, 0, 115.1)
tdSql.query("select diff(c2,1) from ntb") tdSql.query(f"select diff(c2,1) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, None) tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, 115.1) tdSql.checkData(1, 0, 115.1)
tdSql.query("select diff(c3,0) from ntb") tdSql.query(f"select diff(c3,0) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, -5.4) tdSql.checkData(0, 0, -5.4)
tdSql.checkData(1, 0, -0.1) tdSql.checkData(1, 0, -0.1)
tdSql.query("select diff(c3,1) from ntb") tdSql.query(f"select diff(c3,1) from {dbname}.ntb")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0, 0, None) tdSql.checkData(0, 0, None)
tdSql.checkData(1, 0, None) tdSql.checkData(1, 0, None)
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, tdSql.execute(f'''create table {dbname}.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))''') 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_1 using stb tags('beijing')") tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
tdSql.execute( tdSql.execute(
"insert into stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1)) f"insert into {dbname}.stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1))
# diff verifacation # diff verifacation
tdSql.query("select diff(col1) from stb_1") tdSql.query(f"select diff(col1) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col2) from stb_1") tdSql.query(f"select diff(col2) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col3) from stb_1") tdSql.query(f"select diff(col3) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col4) from stb_1") tdSql.query(f"select diff(col4) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col5) from stb_1") tdSql.query(f"select diff(col5) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col6) from stb_1") tdSql.query(f"select diff(col6) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select diff(col7) from stb_1") tdSql.query(f"select diff(col7) from {dbname}.stb_1")
tdSql.checkRows(0) tdSql.checkRows(0)
for i in range(self.rowNum): 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)" tdSql.execute(f"insert into {dbname}.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)) % (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.error("select diff(ts) from stb") tdSql.error(f"select diff(ts) from {dbname}.stb")
tdSql.error("select diff(ts) from stb_1") tdSql.error(f"select diff(ts) from {dbname}.stb_1")
# tdSql.error("select diff(col7) from stb") # tdSql.error(f"select diff(col7) from {dbname}.stb")
tdSql.error("select diff(col8) from stb") tdSql.error(f"select diff(col8) from {dbname}.stb")
tdSql.error("select diff(col8) from stb_1") tdSql.error(f"select diff(col8) from {dbname}.stb_1")
tdSql.error("select diff(col9) from stb") tdSql.error(f"select diff(col9) from {dbname}.stb")
tdSql.error("select diff(col9) from stb_1") tdSql.error(f"select diff(col9) from {dbname}.stb_1")
tdSql.error("select diff(col11) from stb_1") tdSql.error(f"select diff(col11) from {dbname}.stb_1")
tdSql.error("select diff(col12) from stb_1") tdSql.error(f"select diff(col12) from {dbname}.stb_1")
tdSql.error("select diff(col13) from stb_1") tdSql.error(f"select diff(col13) from {dbname}.stb_1")
tdSql.error("select diff(col14) from stb_1") tdSql.error(f"select diff(col14) from {dbname}.stb_1")
tdSql.error("select ts,diff(col1),ts from stb_1") tdSql.error(f"select ts,diff(col1),ts from {dbname}.stb_1")
tdSql.query("select diff(col1) from stb_1") tdSql.query(f"select diff(col1) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select diff(col2) from stb_1") tdSql.query(f"select diff(col2) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select diff(col3) from stb_1") tdSql.query(f"select diff(col3) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select diff(col4) from stb_1") tdSql.query(f"select diff(col4) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select diff(col5) from stb_1") tdSql.query(f"select diff(col5) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.query("select diff(col6) from stb_1") tdSql.query(f"select diff(col6) from {dbname}.stb_1")
tdSql.checkRows(10) tdSql.checkRows(10)
tdSql.execute('''create table stb1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, tdSql.execute(f'''create table {dbname}.stb1(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))''') 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 stb1_1 using stb tags('shanghai')") tdSql.execute(f"create table {dbname}.stb1_1 using {dbname}.stb tags('shanghai')")
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" tdSql.execute(f"insert into {dbname}.stb1_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)) % (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))
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" tdSql.execute(f"insert into {dbname}.stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts - i-1, 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)) % (self.ts - i-1, 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 diff(col1,0) from stb1_1") tdSql.query(f"select diff(col1,0) from {dbname}.stb1_1")
tdSql.checkRows(19) tdSql.checkRows(19)
tdSql.query("select diff(col1,1) from stb1_1") tdSql.query(f"select diff(col1,1) from {dbname}.stb1_1")
tdSql.checkRows(19) tdSql.checkRows(19)
tdSql.checkData(0,0,None) tdSql.checkData(0,0,None)
......
...@@ -2,14 +2,10 @@ from util.log import * ...@@ -2,14 +2,10 @@ from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
import numpy as np import numpy as np
import random import random
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
...@@ -17,89 +13,66 @@ class TDTestCase: ...@@ -17,89 +13,66 @@ class TDTestCase:
self.vnode_disbutes = None self.vnode_disbutes = None
self.ts = 1537146000000 self.ts = 1537146000000
def prepare_datas_of_distribute(self): def prepare_datas_of_distribute(self, dbname="testdb"):
# prepate datas for 20 tables distributed at different vgroups # prepate datas for 20 tables distributed at different vgroups
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
tdSql.execute(" use testdb ") tdSql.execute(f" use {dbname} ")
tdSql.execute( tdSql.execute(
'''create table stb1 f'''create table {dbname}.stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
''' '''
) )
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(20): for i in range(20):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
for i in range(9): for i in range(9):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
) )
for i in range(1,21): for i in range(1,21):
if i ==1 or i == 4: if i ==1 or i == 4:
continue continue
else: else:
tbname = "ct"+f'{i}' tbname = f"{dbname}.ct{i}"
for j in range(9): for j in range(9):
tdSql.execute( tdSql.execute(
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
) )
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute(
f'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
tdLog.info(" prepare data for distributed_aggregate done! ") tdLog.info(" prepare data for distributed_aggregate done! ")
def check_distribute_datas(self): def check_distribute_datas(self, dbname="testdb"):
# get vgroup_ids of all # get vgroup_ids of all
tdSql.query("show vgroups ") tdSql.query(f"show {dbname}.vgroups ")
vgroups = tdSql.queryResult vgroups = tdSql.queryResult
vnode_tables={} vnode_tables={}
for vgroup_id in vgroups: for vgroup_id in vgroups:
vnode_tables[vgroup_id[0]]=[] vnode_tables[vgroup_id[0]]=[]
# check sub_table of per vnode ,make sure sub_table has been distributed # check sub_table of per vnode ,make sure sub_table has been distributed
tdSql.query("show tables like 'ct%'") tdSql.query(f"show {dbname}.tables like 'ct%'")
table_names = tdSql.queryResult table_names = tdSql.queryResult
tablenames = [] tablenames = []
for table_name in table_names: for table_name in table_names:
vnode_tables[table_name[6]].append(table_name[0]) vnode_tables[table_name[6]].append(table_name[0])
self.vnode_disbutes = vnode_tables self.vnode_disbutes = vnode_tables
count = 0 count = 0
...@@ -108,74 +81,74 @@ class TDTestCase: ...@@ -108,74 +81,74 @@ class TDTestCase:
count+=1 count+=1
if count < 2: if count < 2:
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
def distribute_agg_query(self): def distribute_agg_query(self, dbname="testdb"):
# basic filter # basic filter
tdSql.query("select apercentile(c1 , 20) from stb1 where c1 is null") tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where c1 is null")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.query("select apercentile(c1 , 20) from stb1 where t1=1") tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where t1=1")
tdSql.checkData(0,0,2.800000000) tdSql.checkData(0,0,2.800000000)
tdSql.query("select apercentile(c1+c2 ,100) from stb1 where c1 =1 ") tdSql.query(f"select apercentile(c1+c2 ,100) from {dbname}.stb1 where c1 =1 ")
tdSql.checkData(0,0,11112.000000000) tdSql.checkData(0,0,11112.000000000)
tdSql.query("select apercentile(c1 ,10 ) from stb1 where tbname=\"ct2\"") tdSql.query(f"select apercentile(c1 ,10 ) from {dbname}.stb1 where tbname=\"ct2\"")
tdSql.checkData(0,0,2.000000000) tdSql.checkData(0,0,2.000000000)
tdSql.query("select apercentile(c1,20) from stb1 partition by tbname") tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 partition by tbname")
tdSql.checkRows(20) tdSql.checkRows(20)
tdSql.query("select apercentile(c1,20) from stb1 where t1> 4 partition by tbname") tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 where t1> 4 partition by tbname")
tdSql.checkRows(15) tdSql.checkRows(15)
# union all # union all
tdSql.query("select apercentile(c1,20) from stb1 union all select apercentile(c1,20) from stb1 ") tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 union all select apercentile(c1,20) from {dbname}.stb1 ")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0,0,7.389181281) tdSql.checkData(0,0,7.389181281)
# join # join
tdSql.execute(" create database if not exists db ") tdSql.execute(" create database if not exists db ")
tdSql.execute(" use db ") tdSql.execute(" use db ")
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table db.tb1 using db.st tags(1) ")
tdSql.execute(" create table tb2 using st tags(2) ") tdSql.execute(" create table db.tb2 using db.st tags(2) ")
for i in range(10): for i in range(10):
ts = i*10 + self.ts ts = i*10 + self.ts
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
tdSql.query("select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from tb1, tb2 where tb1.ts=tb2.ts") tdSql.query(f"select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,0,9.000000000) tdSql.checkData(0,0,9.000000000)
tdSql.checkData(0,0,9.000000000) tdSql.checkData(0,0,9.000000000)
# group by # group by
tdSql.execute(" use testdb ") tdSql.execute(f"use {dbname} ")
tdSql.query(" select max(c1),c1 from stb1 group by t1 ") tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by t1 ")
tdSql.checkRows(20) tdSql.checkRows(20)
tdSql.query(" select max(c1),c1 from stb1 group by c1 ") tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by c1 ")
tdSql.checkRows(30) tdSql.checkRows(30)
tdSql.query(" select max(c1),c2 from stb1 group by c2 ") tdSql.query(f" select max(c1),c2 from {dbname}.stb1 group by c2 ")
tdSql.checkRows(31) tdSql.checkRows(31)
# partition by tbname or partition by tag # partition by tbname or partition by tag
tdSql.query("select apercentile(c1 ,10)from stb1 partition by tbname") tdSql.query(f"select apercentile(c1 ,10)from {dbname}.stb1 partition by tbname")
query_data = tdSql.queryResult query_data = tdSql.queryResult
# nest query for support max # nest query for support max
tdSql.query("select apercentile(c2+2,10)+1 from (select max(c1) c2 from stb1)") tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)")
tdSql.checkData(0,0,31.000000000) tdSql.checkData(0,0,31.000000000)
tdSql.query("select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from stb1)") tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
tdSql.checkData(0,0,7.560701700) tdSql.checkData(0,0,7.560701700)
tdSql.query("select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)") tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
tdSql.checkData(0,0,7.560701700) tdSql.checkData(0,0,7.560701700)
# mixup with other functions # mixup with other functions
tdSql.query("select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from stb1") tdSql.query(f"select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from {dbname}.stb1")
tdSql.checkData(0,0,28) tdSql.checkData(0,0,28)
tdSql.checkData(0,1,184) tdSql.checkData(0,1,184)
tdSql.checkData(0,2,-99999) tdSql.checkData(0,2,-99999)
...@@ -189,7 +162,7 @@ class TDTestCase: ...@@ -189,7 +162,7 @@ class TDTestCase:
self.check_distribute_datas() self.check_distribute_datas()
self.distribute_agg_query() self.distribute_agg_query()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -7,10 +7,6 @@ import platform ...@@ -7,10 +7,6 @@ import platform
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__) tdLog.debug("start to execute %s" % __file__)
...@@ -24,7 +20,7 @@ class TDTestCase: ...@@ -24,7 +20,7 @@ class TDTestCase:
avg_sql = f"select avg({col_name}) from {tbname};" avg_sql = f"select avg({col_name}) from {tbname};"
same_sql = f"select {col_name} from {tbname} where {col_name} is not null " same_sql = f"select {col_name} from {tbname} where {col_name} is not null "
tdSql.query(same_sql) tdSql.query(same_sql)
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'):
...@@ -34,89 +30,66 @@ class TDTestCase: ...@@ -34,89 +30,66 @@ class TDTestCase:
tdSql.query(avg_sql) tdSql.query(avg_sql)
tdSql.checkData(0,0,pre_avg) tdSql.checkData(0,0,pre_avg)
def prepare_datas_of_distribute(self): def prepare_datas_of_distribute(self, dbname="testdb"):
# prepate datas for 20 tables distributed at different vgroups # prepate datas for 20 tables distributed at different vgroups
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
tdSql.execute(" use testdb ") tdSql.execute(f" use {dbname} ")
tdSql.execute( tdSql.execute(
'''create table stb1 f'''create table {dbname}.stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
''' '''
) )
tdSql.execute(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for i in range(20): for i in range(20):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
for i in range(9): for i in range(9):
tdSql.execute( tdSql.execute(
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
) )
tdSql.execute( tdSql.execute(
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
) )
for i in range(1,21): for i in range(1,21):
if i ==1 or i == 4: if i ==1 or i == 4:
continue continue
else: else:
tbname = "ct"+f'{i}' tbname = f"{dbname}.ct{i}"
for j in range(9): for j in range(9):
tdSql.execute( tdSql.execute(
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
) )
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
tdSql.execute( tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
f'''insert into t1 values tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
tdLog.info(" prepare data for distributed_aggregate done! ") tdLog.info(" prepare data for distributed_aggregate done! ")
def check_distribute_datas(self): def check_distribute_datas(self, dbname="testdb"):
# get vgroup_ids of all # get vgroup_ids of all
tdSql.query("show vgroups ") tdSql.query(f"show {dbname}.vgroups ")
vgroups = tdSql.queryResult vgroups = tdSql.queryResult
vnode_tables={} vnode_tables={}
for vgroup_id in vgroups: for vgroup_id in vgroups:
vnode_tables[vgroup_id[0]]=[] vnode_tables[vgroup_id[0]]=[]
# check sub_table of per vnode ,make sure sub_table has been distributed # check sub_table of per vnode ,make sure sub_table has been distributed
tdSql.query("show tables like 'ct%'") tdSql.query(f"show {dbname}.tables like 'ct%'")
table_names = tdSql.queryResult table_names = tdSql.queryResult
tablenames = [] tablenames = []
for table_name in table_names: for table_name in table_names:
vnode_tables[table_name[6]].append(table_name[0]) vnode_tables[table_name[6]].append(table_name[0])
self.vnode_disbutes = vnode_tables self.vnode_disbutes = vnode_tables
count = 0 count = 0
...@@ -126,15 +99,15 @@ class TDTestCase: ...@@ -126,15 +99,15 @@ class TDTestCase:
if count < 2: if count < 2:
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
def check_avg_distribute_diff_vnode(self,col_name): def check_avg_distribute_diff_vnode(self,col_name, dbname="testdb"):
vgroup_ids = [] vgroup_ids = []
for k ,v in self.vnode_disbutes.items(): for k ,v in self.vnode_disbutes.items():
if len(v)>=2: if len(v)>=2:
vgroup_ids.append(k) vgroup_ids.append(k)
distribute_tbnames = [] distribute_tbnames = []
for vgroup_id in vgroup_ids: for vgroup_id in vgroup_ids:
vnode_tables = self.vnode_disbutes[vgroup_id] vnode_tables = self.vnode_disbutes[vgroup_id]
distribute_tbnames.append(random.sample(vnode_tables,1)[0]) distribute_tbnames.append(random.sample(vnode_tables,1)[0])
...@@ -143,10 +116,10 @@ class TDTestCase: ...@@ -143,10 +116,10 @@ class TDTestCase:
tbname_ins += "'%s' ,"%tbname tbname_ins += "'%s' ,"%tbname
tbname_filters = tbname_ins[:-1] tbname_filters = tbname_ins[:-1]
avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});"
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " avg_sql = f"select avg({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});"
same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null "
tdSql.query(same_sql) tdSql.query(same_sql)
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
...@@ -157,105 +130,105 @@ class TDTestCase: ...@@ -157,105 +130,105 @@ class TDTestCase:
tdSql.query(avg_sql) tdSql.query(avg_sql)
tdSql.checkData(0,0,pre_avg) tdSql.checkData(0,0,pre_avg)
def check_avg_status(self): def check_avg_status(self, dbname="testdb"):
# check max function work status # check max function work status
tdSql.query("show tables like 'ct%'") tdSql.query(f"show {dbname}.tables like 'ct%'")
table_names = tdSql.queryResult table_names = tdSql.queryResult
tablenames = [] tablenames = []
for table_name in table_names: for table_name in table_names:
tablenames.append(table_name[0]) tablenames.append(f"{dbname}.{table_name[0]}")
tdSql.query("desc stb1") tdSql.query(f"desc {dbname}.stb1")
col_names = tdSql.queryResult col_names = tdSql.queryResult
colnames = [] colnames = []
for col_name in col_names: for col_name in col_names:
if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]:
colnames.append(col_name[0]) colnames.append(col_name[0])
for tablename in tablenames: for tablename in tablenames:
for colname in colnames: for colname in colnames:
self.check_avg_functions(tablename,colname) self.check_avg_functions(tablename,colname)
# check max function for different vnode # check max function for different vnode
for colname in colnames: for colname in colnames:
if colname.startswith("c"): if colname.startswith("c"):
self.check_avg_distribute_diff_vnode(colname) self.check_avg_distribute_diff_vnode(colname, dbname)
else: else:
# self.check_avg_distribute_diff_vnode(colname) # bug for tag # self.check_avg_distribute_diff_vnode(colname, dbname) # bug for tag
pass pass
def distribute_agg_query(self): def distribute_agg_query(self, dbname="testdb"):
# basic filter # basic filter
tdSql.query(" select avg(c1) from stb1 ") tdSql.query(f"select avg(c1) from {dbname}.stb1 ")
tdSql.checkData(0,0,14.086956522) tdSql.checkData(0,0,14.086956522)
tdSql.query(" select avg(a) from (select avg(c1) a from stb1 partition by tbname) ") tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 partition by tbname) ")
tdSql.checkData(0,0,14.292307692) tdSql.checkData(0,0,14.292307692)
tdSql.query(" select avg(c1) from stb1 where t1=1") tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1=1")
tdSql.checkData(0,0,6.000000000) tdSql.checkData(0,0,6.000000000)
tdSql.query("select avg(c1+c2) from stb1 where c1 =1 ") tdSql.query(f"select avg(c1+c2) from {dbname}.stb1 where c1 =1 ")
tdSql.checkData(0,0,11112.000000000) tdSql.checkData(0,0,11112.000000000)
tdSql.query("select avg(c1) from stb1 where tbname=\"ct2\"") tdSql.query(f"select avg(c1) from {dbname}.stb1 where tbname=\"ct2\"")
tdSql.checkData(0,0,6.000000000) tdSql.checkData(0,0,6.000000000)
tdSql.query("select avg(c1) from stb1 partition by tbname") tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname")
tdSql.checkRows(20) tdSql.checkRows(20)
tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname") tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1> 4 partition by tbname")
tdSql.checkRows(15) tdSql.checkRows(15)
# union all # union all
tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ") tdSql.query(f"select avg(c1) from {dbname}.stb1 union all select avg(c1) from {dbname}.stb1 ")
tdSql.checkRows(2) tdSql.checkRows(2)
tdSql.checkData(0,0,14.086956522) tdSql.checkData(0,0,14.086956522)
tdSql.query("select avg(a) from (select avg(c1) a from stb1 union all select avg(c1) a from stb1)") tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 union all select avg(c1) a from {dbname}.stb1)")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,0,14.086956522) tdSql.checkData(0,0,14.086956522)
# join # join
tdSql.execute(" create database if not exists db ") tdSql.execute(" create database if not exists db ")
tdSql.execute(" use db ") tdSql.execute(" use db ")
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
tdSql.execute(" create table tb1 using st tags(1) ") tdSql.execute(" create table db.tb1 using db.st tags(1) ")
tdSql.execute(" create table tb2 using st tags(2) ") tdSql.execute(" create table db.tb2 using db.st tags(2) ")
for i in range(10): for i in range(10):
ts = i*10 + self.ts ts = i*10 + self.ts
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
tdSql.query("select avg(tb1.c1), avg(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts") tdSql.query(f"select avg(tb1.c1), avg(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,0,4.500000000) tdSql.checkData(0,0,4.500000000)
tdSql.checkData(0,1,4.500000000) tdSql.checkData(0,1,4.500000000)
# group by # group by
tdSql.execute(" use testdb ") tdSql.execute(f" use {dbname} ")
# partition by tbname or partition by tag # partition by tbname or partition by tag
tdSql.query("select avg(c1) from stb1 partition by tbname") tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname")
tdSql.checkRows(20) tdSql.checkRows(20)
# nest query for support max # nest query for support max
tdSql.query("select avg(c2+2)+1 from (select avg(c1) c2 from stb1)") tdSql.query(f"select avg(c2+2)+1 from (select avg(c1) c2 from {dbname}.stb1)")
tdSql.checkData(0,0,17.086956522) tdSql.checkData(0,0,17.086956522)
tdSql.query("select avg(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)") tdSql.query(f"select avg(c1+2) as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
tdSql.checkData(0,0,16.086956522) tdSql.checkData(0,0,16.086956522)
tdSql.query("select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)") tdSql.query(f"select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
tdSql.checkData(0,0,16.086956522) tdSql.checkData(0,0,16.086956522)
# mixup with other functions # mixup with other functions
tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from stb1") tdSql.query(f"select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from {dbname}.stb1")
tdSql.checkData(0,0,28) tdSql.checkData(0,0,28)
tdSql.checkData(0,1,184) tdSql.checkData(0,1,184)
tdSql.checkData(0,2,-99999) tdSql.checkData(0,2,-99999)
...@@ -270,7 +243,7 @@ class TDTestCase: ...@@ -270,7 +243,7 @@ class TDTestCase:
self.check_avg_status() self.check_avg_status()
self.distribute_agg_query() self.distribute_agg_query()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -51,32 +51,32 @@ class TDTestCase: ...@@ -51,32 +51,32 @@ class TDTestCase:
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
# tdLog.info("insert data") # tdLog.info("insert data")
# tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) # tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
tdLog.info("create 4 topics") tdLog.info("create 4 topics")
sqlString = "create topic %s as database %s" %(topicNameList[0], paraDict['dbName']) sqlString = "create topic %s as database %s" %(topicNameList[0], paraDict['dbName'])
tdLog.info("create topic sql: %s"%sqlString) tdLog.info("create topic sql: %s"%sqlString)
tdSql.execute(sqlString) tdSql.execute(sqlString)
sqlString = "create topic %s as stable %s.%s" %(topicNameList[1], paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as stable %s.%s" %(topicNameList[1], paraDict['dbName'], paraDict['stbName'])
tdLog.info("create topic sql: %s"%sqlString) tdLog.info("create topic sql: %s"%sqlString)
tdSql.execute(sqlString) tdSql.execute(sqlString)
queryString = "select * from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) queryString = "select * from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
sqlString = "create topic %s as %s" %(topicNameList[2], queryString) sqlString = "create topic %s as %s" %(topicNameList[2], queryString)
tdLog.info("create topic sql: %s"%sqlString) tdLog.info("create topic sql: %s"%sqlString)
tdSql.execute(sqlString) tdSql.execute(sqlString)
queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
sqlString = "create topic %s as %s " %(topicNameList[3], queryString) sqlString = "create topic %s as %s " %(topicNameList[3], queryString)
tdLog.info("create topic sql: %s"%sqlString) tdLog.info("create topic sql: %s"%sqlString)
tdSql.execute(sqlString) tdSql.execute(sqlString)
tdSql.query("show topics") tdSql.query("show topics")
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
rows = tdSql.getRows() rows = tdSql.getRows()
if rows != len(consumerIdList): if rows != len(consumerIdList):
tdLog.exit("topic rows error") tdLog.exit("topic rows error")
for i in range (rows): for i in range (rows):
topicName = tdSql.getData(i,0) topicName = tdSql.getData(i,0)
matchFlag = 0 matchFlag = 0
...@@ -87,24 +87,24 @@ class TDTestCase: ...@@ -87,24 +87,24 @@ class TDTestCase:
break break
if matchFlag == 0: if matchFlag == 0:
tdLog.exit("topic name: %s is error", topicName) tdLog.exit("topic name: %s is error", topicName)
# init consume info, and start tmq_sim, then check consume result # init consume info, and start tmq_sim, then check consume result
tdLog.info("insert consume info to consume processor") tdLog.info("insert consume info to consume processor")
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
topicList = topicNameList[0] topicList = topicNameList[0]
ifcheckdata = 0 ifcheckdata = 0
ifManualCommit = 0 ifManualCommit = 0
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0]
tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
topicList = topicNameList[1] topicList = topicNameList[1]
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1]
tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
topicList = topicNameList[2] topicList = topicNameList[2]
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2]
tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
topicList = topicNameList[3] topicList = topicNameList[3]
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3] keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3]
tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
...@@ -118,27 +118,27 @@ class TDTestCase: ...@@ -118,27 +118,27 @@ class TDTestCase:
time.sleep(5) time.sleep(5)
tdLog.info("check show consumers") tdLog.info("check show consumers")
tdSql.query("show consumers") tdSql.query("show consumers")
# tdLog.info(tdSql.queryResult) # tdLog.info(tdSql.queryResult)
rows = tdSql.getRows() rows = tdSql.getRows()
tdLog.info("show consumers rows: %d"%rows) tdLog.info("show consumers rows: %d"%rows)
if rows != len(topicNameList): if rows != len(topicNameList):
tdLog.exit("show consumers rows error") tdLog.exit("show consumers rows error")
tdLog.info("check show subscriptions") tdLog.info("check show subscriptions")
tdSql.query("show subscriptions") tdSql.query("show subscriptions")
# tdLog.debug(tdSql.queryResult) # tdLog.debug(tdSql.queryResult)
rows = tdSql.getRows() rows = tdSql.getRows()
tdLog.info("show subscriptions rows: %d"%rows) tdLog.info("show subscriptions rows: %d"%rows)
if rows != paraDict['vgroups'] * len(topicNameList): if rows != paraDict['vgroups'] * len(topicNameList):
tdLog.exit("show subscriptions rows error") tdLog.exit("show subscriptions rows error")
pThread.join() pThread.join()
tdLog.info("insert process end, and start to check consume result") tdLog.info("insert process end, and start to check consume result")
expectRows = len(consumerIdList) expectRows = len(consumerIdList)
_ = tmqCom.selectConsumeResult(expectRows) _ = tmqCom.selectConsumeResult(expectRows)
time.sleep(10) time.sleep(10)
for i in range(len(topicNameList)): for i in range(len(topicNameList)):
tdSql.query("drop topic %s"%topicNameList[i]) tdSql.query("drop topic %s"%topicNameList[i])
......
...@@ -58,14 +58,36 @@ python3 ./test.py -f 2-query/char_length.py ...@@ -58,14 +58,36 @@ python3 ./test.py -f 2-query/char_length.py
python3 ./test.py -f 2-query/char_length.py -R python3 ./test.py -f 2-query/char_length.py -R
python3 ./test.py -f 2-query/check_tsdb.py python3 ./test.py -f 2-query/check_tsdb.py
python3 ./test.py -f 2-query/check_tsdb.py -R python3 ./test.py -f 2-query/check_tsdb.py -R
python3 ./test.py -f 2-query/concat.py
python3 ./test.py -f 2-query/concat.py -R
python3 ./test.py -f 2-query/concat_ws.py
python3 ./test.py -f 2-query/concat_ws.py -R
python3 ./test.py -f 2-query/concat_ws2.py
python3 ./test.py -f 2-query/concat_ws2.py -R
python3 ./test.py -f 2-query/cos.py
python3 ./test.py -f 2-query/cos.py -R
python3 ./test.py -f 2-query/count_partition.py
python3 ./test.py -f 2-query/count_partition.py -R
python3 ./test.py -f 2-query/count.py
python3 ./test.py -f 2-query/count.py -R
python3 ./test.py -f 2-query/db.py
python3 ./test.py -f 2-query/db.py -R
python3 ./test.py -f 2-query/diff.py
python3 ./test.py -f 2-query/diff.py -R
python3 ./test.py -f 2-query/distinct.py
python3 ./test.py -f 2-query/distinct.py -R
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -R
python3 ./test.py -f 2-query/distribute_agg_avg.py
python3 ./test.py -f 2-query/distribute_agg_avg.py -R
python3 ./test.py -f 1-insert/update_data.py python3 ./test.py -f 1-insert/update_data.py
python3 ./test.py -f 1-insert/delete_data.py python3 ./test.py -f 1-insert/delete_data.py
python3 ./test.py -f 2-query/db.py
python3 ./test.py -f 2-query/db.py
python3 ./test.py -f 2-query/distinct.py
python3 ./test.py -f 2-query/varchar.py python3 ./test.py -f 2-query/varchar.py
python3 ./test.py -f 2-query/ltrim.py python3 ./test.py -f 2-query/ltrim.py
python3 ./test.py -f 2-query/rtrim.py python3 ./test.py -f 2-query/rtrim.py
...@@ -77,10 +99,7 @@ python3 ./test.py -f 2-query/join2.py ...@@ -77,10 +99,7 @@ python3 ./test.py -f 2-query/join2.py
python3 ./test.py -f 2-query/substr.py python3 ./test.py -f 2-query/substr.py
python3 ./test.py -f 2-query/union.py python3 ./test.py -f 2-query/union.py
python3 ./test.py -f 2-query/union1.py python3 ./test.py -f 2-query/union1.py
python3 ./test.py -f 2-query/concat.py
python3 ./test.py -f 2-query/concat2.py python3 ./test.py -f 2-query/concat2.py
python3 ./test.py -f 2-query/concat_ws.py
python3 ./test.py -f 2-query/concat_ws2.py
python3 ./test.py -f 2-query/spread.py python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/hyperloglog.py python3 ./test.py -f 2-query/hyperloglog.py
python3 ./test.py -f 2-query/explain.py python3 ./test.py -f 2-query/explain.py
...@@ -93,13 +112,11 @@ python3 ./test.py -f 2-query/Now.py ...@@ -93,13 +112,11 @@ python3 ./test.py -f 2-query/Now.py
python3 ./test.py -f 2-query/Today.py python3 ./test.py -f 2-query/Today.py
python3 ./test.py -f 2-query/max.py python3 ./test.py -f 2-query/max.py
python3 ./test.py -f 2-query/min.py python3 ./test.py -f 2-query/min.py
python3 ./test.py -f 2-query/count.py
python3 ./test.py -f 2-query/last.py python3 ./test.py -f 2-query/last.py
python3 ./test.py -f 2-query/first.py python3 ./test.py -f 2-query/first.py
python3 ./test.py -f 2-query/To_iso8601.py python3 ./test.py -f 2-query/To_iso8601.py
python3 ./test.py -f 2-query/To_unixtimestamp.py python3 ./test.py -f 2-query/To_unixtimestamp.py
python3 ./test.py -f 2-query/timetruncate.py python3 ./test.py -f 2-query/timetruncate.py
python3 ./test.py -f 2-query/diff.py
python3 ./test.py -f 2-query/Timediff.py python3 ./test.py -f 2-query/Timediff.py
python3 ./test.py -f 2-query/json_tag.py python3 ./test.py -f 2-query/json_tag.py
...@@ -111,7 +128,6 @@ python3 ./test.py -f 2-query/log.py ...@@ -111,7 +128,6 @@ python3 ./test.py -f 2-query/log.py
python3 ./test.py -f 2-query/pow.py python3 ./test.py -f 2-query/pow.py
python3 ./test.py -f 2-query/sqrt.py python3 ./test.py -f 2-query/sqrt.py
python3 ./test.py -f 2-query/sin.py python3 ./test.py -f 2-query/sin.py
python3 ./test.py -f 2-query/cos.py
python3 ./test.py -f 2-query/tan.py python3 ./test.py -f 2-query/tan.py
python3 ./test.py -f 2-query/query_cols_tags_and_or.py python3 ./test.py -f 2-query/query_cols_tags_and_or.py
# python3 ./test.py -f 2-query/nestedQuery.py # python3 ./test.py -f 2-query/nestedQuery.py
...@@ -122,7 +138,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py ...@@ -122,7 +138,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/elapsed.py
python3 ./test.py -f 2-query/csum.py python3 ./test.py -f 2-query/csum.py
python3 ./test.py -f 2-query/mavg.py python3 ./test.py -f 2-query/mavg.py
python3 ./test.py -f 2-query/diff.py
python3 ./test.py -f 2-query/sample.py python3 ./test.py -f 2-query/sample.py
python3 ./test.py -f 2-query/function_diff.py python3 ./test.py -f 2-query/function_diff.py
python3 ./test.py -f 2-query/unique.py python3 ./test.py -f 2-query/unique.py
...@@ -136,12 +151,9 @@ python3 ./test.py -f 2-query/distribute_agg_max.py ...@@ -136,12 +151,9 @@ python3 ./test.py -f 2-query/distribute_agg_max.py
python3 ./test.py -f 2-query/distribute_agg_min.py python3 ./test.py -f 2-query/distribute_agg_min.py
python3 ./test.py -f 2-query/distribute_agg_sum.py python3 ./test.py -f 2-query/distribute_agg_sum.py
python3 ./test.py -f 2-query/distribute_agg_spread.py python3 ./test.py -f 2-query/distribute_agg_spread.py
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
python3 ./test.py -f 2-query/distribute_agg_avg.py
python3 ./test.py -f 2-query/distribute_agg_stddev.py python3 ./test.py -f 2-query/distribute_agg_stddev.py
python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 2-query/twa.py
python3 ./test.py -f 2-query/irate.py python3 ./test.py -f 2-query/irate.py
python3 ./test.py -f 2-query/count_partition.py
python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/function_null.py
python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 2-query/queryQnode.py
python3 ./test.py -f 2-query/max_partition.py python3 ./test.py -f 2-query/max_partition.py
...@@ -162,9 +174,9 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 ...@@ -162,9 +174,9 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5
# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3 # python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
# BUG Redict python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 # BUG Redict python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5 python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
python3 ./test.py -f 7-tmq/basic5.py python3 ./test.py -f 7-tmq/basic5.py
python3 ./test.py -f 7-tmq/subscribeDb.py python3 ./test.py -f 7-tmq/subscribeDb.py
python3 ./test.py -f 7-tmq/subscribeDb0.py python3 ./test.py -f 7-tmq/subscribeDb0.py
...@@ -281,7 +293,6 @@ python3 ./test.py -f 2-query/avg.py -Q 2 ...@@ -281,7 +293,6 @@ python3 ./test.py -f 2-query/avg.py -Q 2
# python3 ./test.py -f 2-query/elapsed.py -Q 2 # python3 ./test.py -f 2-query/elapsed.py -Q 2
python3 ./test.py -f 2-query/csum.py -Q 2 python3 ./test.py -f 2-query/csum.py -Q 2
python3 ./test.py -f 2-query/mavg.py -Q 2 python3 ./test.py -f 2-query/mavg.py -Q 2
python3 ./test.py -f 2-query/diff.py -Q 2
python3 ./test.py -f 2-query/sample.py -Q 2 python3 ./test.py -f 2-query/sample.py -Q 2
python3 ./test.py -f 2-query/function_diff.py -Q 2 python3 ./test.py -f 2-query/function_diff.py -Q 2
python3 ./test.py -f 2-query/unique.py -Q 2 python3 ./test.py -f 2-query/unique.py -Q 2
...@@ -369,7 +380,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 ...@@ -369,7 +380,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3
# python3 ./test.py -f 2-query/elapsed.py -Q 3 # python3 ./test.py -f 2-query/elapsed.py -Q 3
python3 ./test.py -f 2-query/csum.py -Q 3 python3 ./test.py -f 2-query/csum.py -Q 3
python3 ./test.py -f 2-query/mavg.py -Q 3 python3 ./test.py -f 2-query/mavg.py -Q 3
python3 ./test.py -f 2-query/diff.py -Q 3
python3 ./test.py -f 2-query/sample.py -Q 3 python3 ./test.py -f 2-query/sample.py -Q 3
python3 ./test.py -f 2-query/function_diff.py -Q 3 python3 ./test.py -f 2-query/function_diff.py -Q 3
python3 ./test.py -f 2-query/unique.py -Q 3 python3 ./test.py -f 2-query/unique.py -Q 3
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册