[TD-5923]<test>finish test--->where tbname in UPPER/lower/mIXed
add query/queryTbnameUpperLower.py add util/common.py for adding common function in case of duplicate use
This commit is contained in:
parent
fbf76a3705
commit
52848c4de5
|
@ -381,6 +381,7 @@ python3 test.py -f alter/alter_create_exception.py
|
|||
python3 ./test.py -f insert/flushwhiledrop.py
|
||||
python3 ./test.py -f insert/schemalessInsert.py
|
||||
python3 ./test.py -f alter/alterColMultiTimes.py
|
||||
python3 ./test.py -f query/queryTbnameUpperLower.py
|
||||
|
||||
#======================p4-end===============
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from util.log import tdLog
|
||||
from util.cases import tdCases
|
||||
from util.sql import tdSql
|
||||
from util.common import tdCom
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def checkStbWhereIn(self):
|
||||
'''
|
||||
where in ---> upper lower mixed
|
||||
'''
|
||||
tdCom.cleanTb()
|
||||
table_name = tdCom.getLongName(8, "letters_mixed")
|
||||
table_name_sub = f'{table_name}_sub'
|
||||
tb_name_lower = table_name_sub.lower()
|
||||
tb_name_upper = table_name_sub.upper()
|
||||
|
||||
## create stb and tb
|
||||
tdSql.execute(f'CREATE TABLE {table_name} (ts timestamp, id int, bi1 binary(20)) tags (si1 binary(20))')
|
||||
tdSql.execute(f'create table {table_name_sub}1 using {table_name} tags ("{table_name_sub}1")')
|
||||
tdSql.execute(f'create table {tb_name_lower}2 using {table_name} tags ("{tb_name_lower}2")')
|
||||
tdSql.execute(f'create table {tb_name_upper}3 using {table_name} tags ("{tb_name_upper}3")')
|
||||
|
||||
## insert values
|
||||
tdSql.execute(f'insert into {table_name_sub}1 values (now-1s, 1, "{table_name_sub}1")')
|
||||
tdSql.execute(f'insert into {tb_name_lower}2 values (now-2s, 2, "{tb_name_lower}21")')
|
||||
tdSql.execute(f'insert into {tb_name_lower}2 values (now-3s, 3, "{tb_name_lower}22")')
|
||||
tdSql.execute(f'insert into {tb_name_upper}3 values (now-4s, 4, "{tb_name_upper}31")')
|
||||
tdSql.execute(f'insert into {tb_name_upper}3 values (now-5s, 5, "{tb_name_upper}32")')
|
||||
tdSql.execute(f'insert into {tb_name_upper}3 values (now-6s, 6, "{tb_name_upper}33")')
|
||||
|
||||
## query where tbname in single
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1")')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.upper()}1")')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub.lower()}1")')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower}2")')
|
||||
tdSql.checkRows(2)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_lower.upper()}2")')
|
||||
tdSql.checkRows(2)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper}3")')
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{tb_name_upper.lower()}3")')
|
||||
tdSql.checkRows(3)
|
||||
|
||||
## query where tbname in multi
|
||||
tdSql.query(f'select * from {table_name} where id=5 and tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query(f'select * from {table_name} where tbname in ("{table_name_sub}1", "{tb_name_lower.upper()}2", "{tb_name_upper.lower()}3")')
|
||||
tdSql.checkRows(6)
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
self.checkStbWhereIn()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -0,0 +1,53 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import random
|
||||
import string
|
||||
from util.sql import tdSql
|
||||
|
||||
class TDCom:
|
||||
def init(self, conn, logSql):
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def cleanTb(self):
|
||||
query_sql = "show stables"
|
||||
res_row_list = tdSql.query(query_sql, True)
|
||||
stb_list = map(lambda x: x[0], res_row_list)
|
||||
for stb in stb_list:
|
||||
tdSql.execute(f'drop table if exists {stb}')
|
||||
|
||||
query_sql = "show tables"
|
||||
res_row_list = tdSql.query(query_sql, True)
|
||||
tb_list = map(lambda x: x[0], res_row_list)
|
||||
for tb in tb_list:
|
||||
tdSql.execute(f'drop table if exists {tb}')
|
||||
|
||||
def getLongName(self, len, mode = "mixed"):
|
||||
"""
|
||||
generate long name
|
||||
mode could be numbers/letters/letters_mixed/mixed
|
||||
"""
|
||||
if mode == "numbers":
|
||||
chars = ''.join(random.choice(string.digits) for i in range(len))
|
||||
elif mode == "letters":
|
||||
chars = ''.join(random.choice(string.ascii_letters.lower()) for i in range(len))
|
||||
elif mode == "letters_mixed":
|
||||
chars = ''.join(random.choice(string.ascii_letters.upper() + string.ascii_letters.lower()) for i in range(len))
|
||||
else:
|
||||
chars = ''.join(random.choice(string.ascii_letters.lower() + string.digits) for i in range(len))
|
||||
return chars
|
||||
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
|
||||
tdCom = TDCom()
|
Loading…
Reference in New Issue