提交 cda7463a 编写于 作者: J jiacy-jcy

update test cases

上级 eeba1cdb
...@@ -122,10 +122,10 @@ class TDTestCase: ...@@ -122,10 +122,10 @@ class TDTestCase:
for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']: for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']:
for j in [1,2,3]: for j in [1,2,3]:
tdSql.error(f'alter table {stbname} modify tag t{j} {i}') tdSql.error(f'alter stable {stbname} modify tag t{j} {i}')
for i in ['int','unsigned int','float','binary(10)','nchar(10)']: for i in ['int','unsigned int','float','binary(10)','nchar(10)']:
tdSql.error(f'alter table {stbname} modify tag t8 {i}') tdSql.error(f'alter stable {stbname} modify tag t8 {i}')
tdSql.error(f'alter table {stbname} modify tag t4 int') tdSql.error(f'alter stable {stbname} modify tag t4 int')
tdSql.execute(f'drop database {dbname}') tdSql.execute(f'drop database {dbname}')
def run(self): def run(self):
......
...@@ -158,9 +158,109 @@ class TDTestCase: ...@@ -158,9 +158,109 @@ class TDTestCase:
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool')
tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)')
tdSql.execute(f'drop database {dbname}') tdSql.execute(f'drop database {dbname}')
def alter_stb_column_check(self):
dbname = self.get_long_name(length=10, mode="letters")
tdSql.execute(f'create database if not exists {dbname}')
stbname = self.get_long_name(length=3, mode="letters")
tbname = self.get_long_name(length=3, mode="letters")
tdSql.execute(f'create database if not exists {dbname}')
tdSql.execute(f'use {dbname}')
tdSql.execute(
f'create table {stbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \
c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) ')
tdSql.execute(f'create table {tbname} using {stbname} tags(1)')
tdSql.execute(f'insert into {tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")')
tdSql.execute(f'alter table {stbname} add column c14 int')
tdSql.query(f'select c14 from {stbname}')
tdSql.checkRows(1)
tdSql.execute(f'alter table {stbname} add column `c15` int')
tdSql.query(f'select c15 from {stbname}')
tdSql.checkRows(1)
tdSql.query(f'describe {stbname}')
tdSql.checkRows(17)
tdSql.execute(f'alter table {stbname} drop column c14')
tdSql.query(f'describe {stbname}')
tdSql.checkRows(16)
tdSql.execute(f'alter table {stbname} drop column `c15`')
tdSql.query(f'describe {stbname}')
tdSql.checkRows(15)
tdSql.execute(f'alter table {stbname} modify column c12 binary(30)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(12,2,30)
tdSql.execute(f'alter table {stbname} modify column `c12` binary(35)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(12,2,35)
tdSql.error(f'alter table {stbname} modify column `c12` binary(34)')
tdSql.execute(f'alter table {stbname} modify column c13 nchar(30)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(13,2,30)
tdSql.error(f'alter table {stbname} modify column c13 nchar(29)')
tdSql.error(f'alter table {stbname} rename column c1 c21')
tdSql.error(f'alter table {stbname} modify column c1 int')
tdSql.error(f'alter table {stbname} modify column c4 int')
tdSql.error(f'alter table {stbname} modify column c8 int')
tdSql.error(f'alter table {stbname} modify column c1 unsigned int')
tdSql.error(f'alter table {stbname} modify column c9 double')
tdSql.error(f'alter table {stbname} modify column c10 float')
tdSql.error(f'alter table {stbname} modify column c11 int')
tdSql.execute(f'drop database {dbname}')
def alter_stb_tag_check(self):
dbname = self.get_long_name(length=10, mode="letters")
tdSql.execute(f'create database if not exists {dbname}')
stbname = self.get_long_name(length=3, mode="letters")
tbname = self.get_long_name(length=3, mode="letters")
tdSql.execute(f'create database if not exists {dbname}')
tdSql.execute(f'use {dbname}')
tdSql.execute(
f'create table {stbname} (ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int, \
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) ')
tdSql.execute(f'create table {tbname} using {stbname} tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")')
tdSql.execute(f'insert into {tbname} values(now,1)')
tdSql.execute(f'alter table {stbname} add tag t14 int')
tdSql.query(f'select t14 from {stbname}')
tdSql.checkRows(1)
tdSql.execute(f'alter table {stbname} add tag `t15` int')
tdSql.query(f'select t14 from {stbname}')
tdSql.checkRows(1)
tdSql.query(f'describe {stbname}')
tdSql.checkRows(18)
tdSql.execute(f'alter table {stbname} drop tag t14')
tdSql.query(f'describe {stbname}')
tdSql.checkRows(17)
tdSql.execute(f'alter table {stbname} drop tag `t15`')
tdSql.query(f'describe {stbname}')
tdSql.checkRows(16)
tdSql.execute(f'alter table {stbname} modify tag t12 binary(30)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(14,2,30)
tdSql.execute(f'alter table {stbname} modify tag `t12` binary(35)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(14,2,35)
tdSql.error(f'alter table {stbname} modify tag `t12` binary(34)')
tdSql.execute(f'alter table {stbname} modify tag t13 nchar(30)')
tdSql.query(f'describe {stbname}')
tdSql.checkData(15,2,30)
tdSql.error(f'alter table {stbname} modify tag t13 nchar(29)')
tdSql.execute(f'alter table {stbname} rename tag t1 t21')
tdSql.query(f'describe {stbname}')
tdSql.checkData(3,0,'t21')
tdSql.execute(f'alter table {stbname} rename tag `t21` t1')
tdSql.query(f'describe {stbname}')
tdSql.checkData(3,0,'t1')
for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']:
for j in [1,2,3]:
tdSql.error(f'alter table {stbname} modify tag t{j} {i}')
for i in ['int','unsigned int','float','binary(10)','nchar(10)']:
tdSql.error(f'alter table {stbname} modify tag t8 {i}')
tdSql.error(f'alter table {stbname} modify tag t4 int')
tdSql.execute(f'drop database {dbname}')
def run(self): def run(self):
self.alter_tb_tag_check() self.alter_tb_tag_check()
self.alter_ntb_column_check() self.alter_ntb_column_check()
self.alter_stb_column_check()
self.alter_stb_tag_check()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -20,39 +20,35 @@ class TDTestCase: ...@@ -20,39 +20,35 @@ class TDTestCase:
# print(today_date) # print(today_date)
time_zone = (os.popen('timedatectl | grep zone').read().strip().split(',')[1].lstrip())[0:5] time_zone = (os.popen('timedatectl | grep zone').read().strip().split(',')[1].lstrip())[0:5]
print(time_zone)
tdSql.execute('create database db1 precision "ms"') tdSql.execute('create database db1 precision "ms"')
tdSql.execute('use db1') tdSql.execute('use db1')
tdSql.execute( tdSql.execute('create table if not exists ntb(ts timestamp, c1 int, c2 timestamp)')
'create table if not exists ntb(ts timestamp, c1 int, c2 timestamp)'
)
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.execute("insert into ntb values(%d, %d, %d)" tdSql.execute("insert into ntb values(%d, %d, %d)"
% (self.ts + i, i + 1, self.ts + i)) % (self.ts + i, i + 1, self.ts + i))
tdSql.query('select to_iso8601(ts) from ntb') tdSql.query('select to_iso8601(ts) from ntb')
print(tdSql.queryResult)
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{time_zone}') tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{time_zone}')
for j in ['z','Z']:
tdSql.query('select to_iso8601(ts,"{j}") from ntb')
print(tdSql.queryResult)
for i in range(self.rowNum):
tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{time_zone}')
timezone_list = ['+0000','+0100','+0200','+0300','+0330','+0400','+0500','+0530','+0600','+0700','+0800','+0900','+1000','+1100','+1200',\ timezone_list = ['+0000','+0100','+0200','+0300','+0330','+0400','+0500','+0530','+0600','+0700','+0800','+0900','+1000','+1100','+1200',\
'+00','+01','+02','+03','+04','+05','+06','+07','+08','+09','+10','+11','+12',\ '+00','+01','+02','+03','+04','+05','+06','+07','+08','+09','+10','+11','+12',\
'+00:00','+01:00','+02:00','+03:00','+03:30','+04:00','+05:00','+05:30','+06:00','+07:00','+08:00','+09:00','+10:00','+11:00','+12:00',\ '+00:00','+01:00','+02:00','+03:00','+03:30','+04:00','+05:00','+05:30','+06:00','+07:00','+08:00','+09:00','+10:00','+11:00','+12:00',\
'-0000','-0100','-0200','-0300','-0400','-0500','-0600','-0700','-0800','-0900','-1000','-1100','-1200',\ '-0000','-0100','-0200','-0300','-0400','-0500','-0600','-0700','-0800','-0900','-1000','-1100','-1200',\
'-00','-01','-02','-03','-04','-05','-06','-07','-08','-09','-10','-11','-12',\ '-00','-01','-02','-03','-04','-05','-06','-07','-08','-09','-10','-11','-12',\
'-00:00','-01:00','-02:00','-03:00','-04:00','-05:00','-06:00','-07:00','-08:00','-09:00','-10:00','-11:00','-12:00'] '-00:00','-01:00','-02:00','-03:00','-04:00','-05:00','-06:00','-07:00','-08:00','-09:00','-10:00','-11:00','-12:00'\
'z','Z']
for j in timezone_list: for j in timezone_list:
tdSql.query(f'select to_iso8601(ts,"{j}") from ntb') tdSql.query(f'select to_iso8601(ts,"{j}") from ntb')
for i in range(self.rowNum): for i in range(self.rowNum):
tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{time_zone}') tdSql.checkEqual(tdSql.queryResult[i][0],f'2022-01-01T00:00:00.00{i}{j}')
error_param_list = [0,100,5,'a','+13','+0101','+00:01','-0001','-13','-00:01'] error_param_list = [0,100.5,'a','!']
for i in error_param_list: for i in error_param_list:
tdSql.error(f'select to_iso8601(ts,"{error_param_list}") from ntb') tdSql.error(f'select to_iso8601(ts,"{i}") from ntb')
# bug TD-16372:对于错误的时区,缺少校验
# error_timezone_param = ['+13','-13','+1300','-1300','+0001','-0001','-0330','+0330']
# for i in error_timezone_param:
# tdSql.error(f'select to_iso8601(ts,"{i}") from ntb')
def check_base_function(self): def check_base_function(self):
tdSql.prepare() tdSql.prepare()
...@@ -74,12 +70,9 @@ class TDTestCase: ...@@ -74,12 +70,9 @@ class TDTestCase:
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select to_iso8601(ts) from ntb where ts=today()") tdSql.query("select to_iso8601(ts) from ntb where ts=today()")
tdSql.checkRows(1) tdSql.checkRows(1)
# tdSql.checkData(0,0,10) for i in range(0,3):
for i in range(1,10):
tdSql.query("select to_iso8601(1) from ntb") tdSql.query("select to_iso8601(1) from ntb")
tdSql.checkData(0,0,"1970-01-01T08:00:01+0800") tdSql.checkData(i,0,"1970-01-01T08:00:01+0800")
i+=1
sleep(0.2)
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select to_iso8601(ts) from ntb") tdSql.query("select to_iso8601(ts) from ntb")
tdSql.checkRows(3) tdSql.checkRows(3)
...@@ -113,12 +106,13 @@ class TDTestCase: ...@@ -113,12 +106,13 @@ class TDTestCase:
for i in err_param: for i in err_param:
tdSql.error(f"select to_iso8601({i}) from ntb") tdSql.error(f"select to_iso8601({i}) from ntb")
tdSql.error(f"select to_iso8601({i}) from db.ntb") tdSql.error(f"select to_iso8601({i}) from db.ntb")
tdSql.query("select to_iso8601(now) from stb") tdSql.query("select to_iso8601(now) from stb")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select to_iso8601(now()) from stb") tdSql.query("select to_iso8601(now()) from stb")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select to_iso8601(1) from stb") tdSql.query("select to_iso8601(1) from stb")
for i in range(1,10): for i in range(0,3):
tdSql.checkData(i,0,"1970-01-01T08:00:01+0800") tdSql.checkData(i,0,"1970-01-01T08:00:01+0800")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query("select to_iso8601(ts) from stb") tdSql.query("select to_iso8601(ts) from stb")
...@@ -128,20 +122,17 @@ class TDTestCase: ...@@ -128,20 +122,17 @@ class TDTestCase:
tdSql.query("select to_iso8601(ts)+'a' from stb ") tdSql.query("select to_iso8601(ts)+'a' from stb ")
tdSql.checkRows(3) tdSql.checkRows(3)
for i in ['+','-','*','/']: for i in ['+','-','*','/']:
tdSql.query("select to_iso8601(today()) {i}null from stb") tdSql.query(f"select to_iso8601(today()) {i}null from stb")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,0,None) tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) {i}null from db.stb") tdSql.query(f"select to_iso8601(today()) {i}null from db.stb")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,0,None) tdSql.checkData(0,0,None)
# bug TD-15207
# tdSql.query("select to_iso8601(-1) from ntb")
# tdSql.checkRows(3)
def run(self): # sourcery skip: extract-duplicate-method def run(self): # sourcery skip: extract-duplicate-method
self.check_base_function() self.check_base_function()
self.check_customize_param_ms() self.check_customize_param_ms()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册