未验证 提交 32b90b09 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #17858 from taosdata/test/jcy

test:update test case for delete 
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc. ###################################################################
# All rights reserved. # 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, # This file is proprietary and confidential to TAOS Technologies.
# disclosed or used in any form or by any means other than as # No part of this file may be reproduced, stored, transmitted,
# expressly provided by the written permission from Jianhui Tao # 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 -*-
# -*- coding: utf-8 -*-
import random
import string import random
import string
from numpy import logspace
from util import constant from numpy import logspace
from util.log import * from util import constant
from util.cases import * from util.log import *
from util.sql import * from util.cases import *
from util.common import * from util.sql import *
from util.sqlset import TDSetSql from util.common import *
from util.sqlset import TDSetSql
class TDTestCase:
def init(self, conn, logSql, replicaVar=1): class TDTestCase:
self.replicaVar = int(replicaVar) def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__) self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor(), True) tdLog.debug("start to execute %s" % __file__)
self.dbname = 'db_test' tdSql.init(conn.cursor(), True)
self.setsql = TDSetSql() self.dbname = 'db_test'
self.stbname = 'stb' self.setsql = TDSetSql()
self.ntbname = 'ntb' self.stbname = 'stb'
self.rowNum = 10 self.ntbname = 'ntb'
self.tbnum = 3 self.rowNum = 10
self.ts = 1537146000000 self.tbnum = 3
self.binary_str = 'taosdata' self.ts = 1537146000000
self.nchar_str = '涛思数据' self.binary_str = 'taosdata'
self.str_length = 20 self.nchar_str = '涛思数据'
self.column_dict = { self.str_length = 20
'col1': 'tinyint', self.column_dict = {
'col2': 'smallint', 'col1': 'tinyint',
'col3': 'int', 'col2': 'smallint',
'col4': 'bigint', 'col3': 'int',
'col5': 'tinyint unsigned', 'col4': 'bigint',
'col6': 'smallint unsigned', 'col5': 'tinyint unsigned',
'col7': 'int unsigned', 'col6': 'smallint unsigned',
'col8': 'bigint unsigned', 'col7': 'int unsigned',
'col9': 'float', 'col8': 'bigint unsigned',
'col10': 'double', 'col9': 'float',
'col11': 'bool', 'col10': 'double',
'col12': f'binary({self.str_length})', 'col11': 'bool',
'col13': f'nchar({self.str_length})', 'col12': f'binary({self.str_length})',
'col13': f'nchar({self.str_length})',
}
}
self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX)
self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX)
self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX) self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX)
self.bigint_val = random.randint(constant.BIGINT_MIN,constant.BIGINT_MAX) self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX)
self.untingint_val = random.randint(constant.TINYINT_UN_MIN,constant.TINYINT_UN_MAX) self.bigint_val = random.randint(constant.BIGINT_MIN,constant.BIGINT_MAX)
self.unsmallint_val = random.randint(constant.SMALLINT_UN_MIN,constant.SMALLINT_UN_MAX) self.untingint_val = random.randint(constant.TINYINT_UN_MIN,constant.TINYINT_UN_MAX)
self.unint_val = random.randint(constant.INT_UN_MIN,constant.INT_MAX) self.unsmallint_val = random.randint(constant.SMALLINT_UN_MIN,constant.SMALLINT_UN_MAX)
self.unbigint_val = random.randint(constant.BIGINT_UN_MIN,constant.BIGINT_UN_MAX) self.unint_val = random.randint(constant.INT_UN_MIN,constant.INT_MAX)
self.float_val = random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX) self.unbigint_val = random.randint(constant.BIGINT_UN_MIN,constant.BIGINT_UN_MAX)
self.double_val = random.uniform(constant.DOUBLE_MIN*(1E-300),constant.DOUBLE_MAX*(1E-300)) self.float_val = random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX)
self.bool_val = random.randint(0,100)%2 self.double_val = random.uniform(constant.DOUBLE_MIN*(1E-300),constant.DOUBLE_MAX*(1E-300))
self.binary_val = tdCom.getLongName(random.randint(0,self.str_length)) self.bool_val = random.randint(0,100)%2
self.nchar_val = tdCom.getLongName(random.randint(0,self.str_length)) self.binary_val = tdCom.getLongName(random.randint(0,self.str_length))
self.base_data = { self.nchar_val = tdCom.getLongName(random.randint(0,self.str_length))
'tinyint':self.tinyint_val, self.base_data = {
'smallint':self.smallint_val, 'tinyint':self.tinyint_val,
'int':self.int_val, 'smallint':self.smallint_val,
'bigint':self.bigint_val, 'int':self.int_val,
'tinyint unsigned':self.untingint_val, 'bigint':self.bigint_val,
'smallint unsigned':self.unsmallint_val, 'tinyint unsigned':self.untingint_val,
'int unsigned':self.unint_val, 'smallint unsigned':self.unsmallint_val,
'bigint unsigned':self.unbigint_val, 'int unsigned':self.unint_val,
'bool':self.bool_val, 'bigint unsigned':self.unbigint_val,
'float':self.float_val, 'bool':self.bool_val,
'double':self.double_val, 'float':self.float_val,
'binary':self.binary_val, 'double':self.double_val,
'nchar':self.nchar_val 'binary':self.binary_val,
} 'nchar':self.nchar_val
}
def insert_base_data(self,col_type,tbname,rows,base_data):
for i in range(rows): def insert_base_data(self,col_type,tbname,rows,base_data):
if col_type.lower() == 'tinyint': for i in range(rows):
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["tinyint"]})') if col_type.lower() == 'tinyint':
elif col_type.lower() == 'smallint': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["tinyint"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["smallint"]})') elif col_type.lower() == 'smallint':
elif col_type.lower() == 'int': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["smallint"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["int"]})') elif col_type.lower() == 'int':
elif col_type.lower() == 'bigint': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["int"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint"]})') elif col_type.lower() == 'bigint':
elif col_type.lower() == 'tinyint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["tinyint unsigned"]})') elif col_type.lower() == 'tinyint unsigned':
elif col_type.lower() == 'smallint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["tinyint unsigned"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["smallint unsigned"]})') elif col_type.lower() == 'smallint unsigned':
elif col_type.lower() == 'int unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["smallint unsigned"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["int unsigned"]})') elif col_type.lower() == 'int unsigned':
elif col_type.lower() == 'bigint unsigned': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["int unsigned"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})') elif col_type.lower() == 'bigint unsigned':
elif col_type.lower() == 'bool': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bigint unsigned"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})') elif col_type.lower() == 'bool':
elif col_type.lower() == 'float': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["bool"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})') elif col_type.lower() == 'float':
elif col_type.lower() == 'double': tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["float"]})')
tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})') elif col_type.lower() == 'double':
elif 'binary' in col_type.lower(): tdSql.execute(f'insert into {tbname} values({self.ts+i},{base_data["double"]})')
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''') elif 'binary' in col_type.lower():
elif 'nchar' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['binary']}")''')
tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''') elif 'nchar' in col_type.lower():
def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1,stbname=''): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{base_data['nchar']}")''')
tdSql.query(f'select count(*) from {tbname}') def delete_all_data(self,tbname,col_type,row_num,base_data,dbname,tb_type,tb_num=1,stbname=''):
tdSql.execute(f'delete from {tbname}') tdSql.query(f'select count(*) from {tbname}')
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select * from {tbname}') tdSql.execute('reset query cache')
tdSql.checkRows(0) tdSql.query(f'select * from {tbname}')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.checkRows(0)
if tb_type == 'ctb': if tb_type == 'ntb' or tb_type == 'ctb':
tdSql.query(f'select count(*) from {stbname}') if tb_type == 'ctb':
if tb_num <= 1: tdSql.query(f'select count(*) from {stbname}')
if len(tdSql.queryResult) != 0: if tb_num <= 1:
tdLog.exit('delete case failure!') if len(tdSql.queryResult) != 0:
else: tdLog.exit('delete case failure!')
tdSql.checkEqual(tdSql.queryResult[0][0],(tb_num-1)*row_num) else:
tdSql.checkEqual(tdSql.queryResult[0][0],(tb_num-1)*row_num)
self.insert_base_data(col_type,tbname,row_num,base_data)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
for i in range(tb_num): elif tb_type == 'stb':
self.insert_base_data(col_type,f'{tbname}_{i}',row_num,base_data) for i in range(tb_num):
tdSql.execute(f'flush database {dbname}') self.insert_base_data(col_type,f'{tbname}_{i}',row_num,base_data)
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select * from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select * from {tbname}')
tdSql.checkRows(row_num) if tb_type == 'ntb' or tb_type == 'ctb':
elif tb_type =='stb': tdSql.checkRows(row_num)
tdSql.checkRows(row_num*tb_num) elif tb_type =='stb':
def delete_one_row(self,tbname,column_type,column_name,base_data,row_num,dbname,tb_type,tb_num=1): tdSql.checkRows(row_num*tb_num)
tdSql.execute(f'delete from {tbname} where ts={self.ts}') def delete_one_row(self,tbname,column_type,column_name,base_data,row_num,dbname,tb_type,tb_num=1):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts={self.ts}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {column_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {column_name} from {tbname}')
tdSql.checkRows(row_num-1) if tb_type == 'ntb' or tb_type == 'ctb':
elif tb_type == 'stb': tdSql.checkRows(row_num-1)
tdSql.checkRows((row_num-1)*tb_num) elif tb_type == 'stb':
tdSql.query(f'select {column_name} from {tbname} where ts={self.ts}') tdSql.checkRows((row_num-1)*tb_num)
tdSql.checkRows(0) tdSql.query(f'select {column_name} from {tbname} where ts={self.ts}')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.checkRows(0)
if 'binary' in column_type.lower(): if tb_type == 'ntb' or tb_type == 'ctb':
tdSql.execute(f'''insert into {tbname} values({self.ts},"{base_data['binary']}")''') if 'binary' in column_type.lower():
elif 'nchar' in column_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts},"{base_data['binary']}")''')
tdSql.execute(f'''insert into {tbname} values({self.ts},"{base_data['nchar']}")''') elif 'nchar' in column_type.lower():
else: tdSql.execute(f'''insert into {tbname} values({self.ts},"{base_data['nchar']}")''')
tdSql.execute(f'insert into {tbname} values({self.ts},{base_data[column_type]})') else:
elif tb_type == 'stb': tdSql.execute(f'insert into {tbname} values({self.ts},{base_data[column_type]})')
for i in range(tb_num): elif tb_type == 'stb':
if 'binary' in column_type.lower(): for i in range(tb_num):
tdSql.execute(f'''insert into {tbname}_{i} values({self.ts},"{base_data['binary']}")''') if 'binary' in column_type.lower():
elif 'nchar' in column_type.lower(): tdSql.execute(f'''insert into {tbname}_{i} values({self.ts},"{base_data['binary']}")''')
tdSql.execute(f'''insert into {tbname}_{i} values({self.ts},"{base_data['nchar']}")''') elif 'nchar' in column_type.lower():
else: tdSql.execute(f'''insert into {tbname}_{i} values({self.ts},"{base_data['nchar']}")''')
tdSql.execute(f'insert into {tbname}_{i} values({self.ts},{base_data[column_type]})') else:
tdSql.query(f'select {column_name} from {tbname} where ts={self.ts}') tdSql.execute(f'insert into {tbname}_{i} values({self.ts},{base_data[column_type]})')
if column_type.lower() == 'float' or column_type.lower() == 'double': tdSql.query(f'select {column_name} from {tbname} where ts={self.ts}')
if abs(tdSql.queryResult[0][0] - base_data[column_type]) / base_data[column_type] <= 0.0001: if column_type.lower() == 'float' or column_type.lower() == 'double':
tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) if abs(tdSql.queryResult[0][0] - base_data[column_type]) / base_data[column_type] <= 0.0001:
else: tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0])
tdLog.exit(f'{column_type} data check failure') else:
elif 'binary' in column_type.lower(): tdLog.exit(f'{column_type} data check failure')
tdSql.checkEqual(tdSql.queryResult[0][0],base_data['binary']) elif 'binary' in column_type.lower():
elif 'nchar' in column_type.lower(): tdSql.checkEqual(tdSql.queryResult[0][0],base_data['binary'])
tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar']) elif 'nchar' in column_type.lower():
else: tdSql.checkEqual(tdSql.queryResult[0][0],base_data['nchar'])
tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type]) else:
def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1): tdSql.checkEqual(tdSql.queryResult[0][0],base_data[column_type])
for i in range(row_num): def delete_rows(self,dbname,tbname,col_name,col_type,base_data,row_num,tb_type,tb_num=1):
tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}') for i in range(row_num):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts>{self.ts+i}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(i+1) if tb_type == 'ntb' or tb_type == 'ctb':
self.insert_base_data(col_type,tbname,row_num,base_data) tdSql.checkRows(i+1)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
tdSql.checkRows((i+1)*tb_num) elif tb_type == 'stb':
for j in range(tb_num): tdSql.checkRows((i+1)*tb_num)
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for j in range(tb_num):
for i in range(row_num): self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
tdSql.execute(f'delete from {tbname} where ts>={self.ts+i}') for i in range(row_num):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts>={self.ts+i}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(i) if tb_type == 'ntb' or tb_type == 'ctb':
self.insert_base_data(col_type,tbname,row_num,base_data) tdSql.checkRows(i)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
tdSql.checkRows(i*tb_num) elif tb_type == 'stb':
for j in range(tb_num): tdSql.checkRows(i*tb_num)
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for j in range(tb_num):
for i in range(row_num): self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}') for i in range(row_num):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts<={self.ts+i}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(row_num-i-1) if tb_type == 'ntb' or tb_type == 'ctb':
self.insert_base_data(col_type,tbname,row_num,base_data) tdSql.checkRows(row_num-i-1)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
tdSql.checkRows((row_num-i-1)*tb_num) elif tb_type == 'stb':
for j in range(tb_num): tdSql.checkRows((row_num-i-1)*tb_num)
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for j in range(tb_num):
for i in range(row_num): self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
tdSql.execute(f'delete from {tbname} where ts<{self.ts+i}') for i in range(row_num):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts<{self.ts+i}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(row_num-i) if tb_type == 'ntb' or tb_type == 'ctb':
self.insert_base_data(col_type,tbname,row_num,base_data) tdSql.checkRows(row_num-i)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
tdSql.checkRows((row_num-i)*tb_num) elif tb_type == 'stb':
for j in range(tb_num): tdSql.checkRows((row_num-i)*tb_num)
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for j in range(tb_num):
for i in range(row_num): self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
tdSql.execute(f'delete from {tbname} where ts between {self.ts} and {self.ts+i}') for i in range(row_num):
tdSql.execute(f'flush database {dbname}') tdSql.execute(f'delete from {tbname} where ts between {self.ts} and {self.ts+i}')
tdSql.execute('reset query cache') tdSql.execute(f'flush database {dbname}')
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute('reset query cache')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(row_num - i-1) if tb_type == 'ntb' or tb_type == 'ctb':
self.insert_base_data(col_type,tbname,row_num,base_data) tdSql.checkRows(row_num - i-1)
elif tb_type == 'stb': self.insert_base_data(col_type,tbname,row_num,base_data)
tdSql.checkRows(tb_num*(row_num - i-1)) elif tb_type == 'stb':
for j in range(tb_num): tdSql.checkRows(tb_num*(row_num - i-1))
self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) for j in range(tb_num):
tdSql.execute(f'delete from {tbname} where ts between {self.ts+i+1} and {self.ts}') self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data)
tdSql.query(f'select {col_name} from {tbname}') tdSql.execute(f'delete from {tbname} where ts between {self.ts+i+1} and {self.ts}')
if tb_type == 'ntb' or tb_type == 'ctb': tdSql.query(f'select {col_name} from {tbname}')
tdSql.checkRows(row_num) if tb_type == 'ntb' or tb_type == 'ctb':
elif tb_type == 'stb': tdSql.checkRows(row_num)
tdSql.checkRows(tb_num*row_num) elif tb_type == 'stb':
def delete_error(self,tbname,column_name,column_type,base_data): tdSql.checkRows(tb_num*row_num)
for error_list in ['',f'ts = {self.ts} and',f'ts = {self.ts} or']: def delete_error(self,tbname,column_name,column_type,base_data):
if 'binary' in column_type.lower(): for error_list in ['',f'ts = {self.ts} and',f'ts = {self.ts} or']:
tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['binary']}"''') if 'binary' in column_type.lower():
elif 'nchar' in column_type.lower(): tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['binary']}"''')
tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''') elif 'nchar' in column_type.lower():
else: tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''')
tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}') else:
tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}')
def delete_data_ntb(self):
tdSql.execute(f'create database if not exists {self.dbname}') def delete_data_ntb(self):
tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create database if not exists {self.dbname}')
for col_name,col_type in self.column_dict.items(): tdSql.execute(f'use {self.dbname}')
tdSql.execute(f'create table {self.ntbname} (ts timestamp,{col_name} {col_type})') for col_name,col_type in self.column_dict.items():
self.insert_base_data(col_type,self.ntbname,self.rowNum,self.base_data) tdSql.execute(f'create table {self.ntbname} (ts timestamp,{col_name} {col_type})')
self.delete_one_row(self.ntbname,col_type,col_name,self.base_data,self.rowNum,self.dbname,'ntb') self.insert_base_data(col_type,self.ntbname,self.rowNum,self.base_data)
self.delete_all_data(self.ntbname,col_type,self.rowNum,self.base_data,self.dbname,'ntb') self.delete_one_row(self.ntbname,col_type,col_name,self.base_data,self.rowNum,self.dbname,'ntb')
self.delete_error(self.ntbname,col_name,col_type,self.base_data) self.delete_all_data(self.ntbname,col_type,self.rowNum,self.base_data,self.dbname,'ntb')
self.delete_rows(self.dbname,self.ntbname,col_name,col_type,self.base_data,self.rowNum,'ntb') self.delete_error(self.ntbname,col_name,col_type,self.base_data)
for func in ['first','last']: self.delete_rows(self.dbname,self.ntbname,col_name,col_type,self.base_data,self.rowNum,'ntb')
tdSql.query(f'select {func}(*) from {self.ntbname}') for func in ['first','last']:
tdSql.execute(f'drop table {self.ntbname}') tdSql.query(f'select {func}(*) from {self.ntbname}')
tdSql.execute(f'drop database {self.dbname}') tdSql.execute(f'drop table {self.ntbname}')
def delete_data_ctb(self): tdSql.execute(f'drop database {self.dbname}')
tdSql.execute(f'create database if not exists {self.dbname}') def delete_data_ctb(self):
tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create database if not exists {self.dbname}')
for col_name,col_type in self.column_dict.items(): tdSql.execute(f'use {self.dbname}')
tdSql.execute(f'create table {self.stbname} (ts timestamp,{col_name} {col_type}) tags(t1 int)') for col_name,col_type in self.column_dict.items():
for i in range(self.tbnum): tdSql.execute(f'create table {self.stbname} (ts timestamp,{col_name} {col_type}) tags(t1 int)')
tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags(1)') for i in range(self.tbnum):
self.insert_base_data(col_type,f'{self.stbname}_{i}',self.rowNum,self.base_data) tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags(1)')
self.delete_one_row(f'{self.stbname}_{i}',col_type,col_name,self.base_data,self.rowNum,self.dbname,'ctb') self.insert_base_data(col_type,f'{self.stbname}_{i}',self.rowNum,self.base_data)
self.delete_all_data(f'{self.stbname}_{i}',col_type,self.rowNum,self.base_data,self.dbname,'ctb',i+1,self.stbname) self.delete_one_row(f'{self.stbname}_{i}',col_type,col_name,self.base_data,self.rowNum,self.dbname,'ctb')
self.delete_error(f'{self.stbname}_{i}',col_name,col_type,self.base_data) self.delete_all_data(f'{self.stbname}_{i}',col_type,self.rowNum,self.base_data,self.dbname,'ctb',i+1,self.stbname)
self.delete_rows(self.dbname,f'{self.stbname}_{i}',col_name,col_type,self.base_data,self.rowNum,'ctb') self.delete_error(f'{self.stbname}_{i}',col_name,col_type,self.base_data)
for func in ['first','last']: self.delete_rows(self.dbname,f'{self.stbname}_{i}',col_name,col_type,self.base_data,self.rowNum,'ctb')
tdSql.query(f'select {func}(*) from {self.stbname}_{i}') for func in ['first','last']:
tdSql.execute(f'drop table {self.stbname}') tdSql.query(f'select {func}(*) from {self.stbname}_{i}')
def delete_data_stb(self): tdSql.execute(f'drop table {self.stbname}')
tdSql.execute(f'create database if not exists {self.dbname}') def delete_data_stb(self):
tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create database if not exists {self.dbname}')
for col_name,col_type in self.column_dict.items(): tdSql.execute(f'use {self.dbname}')
tdSql.execute(f'create table {self.stbname} (ts timestamp,{col_name} {col_type}) tags(t1 int)') for col_name,col_type in self.column_dict.items():
for i in range(self.tbnum): tdSql.execute(f'create table {self.stbname} (ts timestamp,{col_name} {col_type}) tags(t1 int)')
tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags(1)') for i in range(self.tbnum):
self.insert_base_data(col_type,f'{self.stbname}_{i}',self.rowNum,self.base_data) tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags(1)')
self.delete_error(self.stbname,col_name,col_type,self.base_data) self.insert_base_data(col_type,f'{self.stbname}_{i}',self.rowNum,self.base_data)
self.delete_one_row(self.stbname,col_type,col_name,self.base_data,self.rowNum,self.dbname,'stb',self.tbnum) self.delete_error(self.stbname,col_name,col_type,self.base_data)
self.delete_all_data(self.stbname,col_type,self.rowNum,self.base_data,self.dbname,'stb',self.tbnum) self.delete_one_row(self.stbname,col_type,col_name,self.base_data,self.rowNum,self.dbname,'stb',self.tbnum)
self.delete_rows(self.dbname,self.stbname,col_name,col_type,self.base_data,self.rowNum,'stb',self.tbnum) self.delete_all_data(self.stbname,col_type,self.rowNum,self.base_data,self.dbname,'stb',self.tbnum)
for func in ['first','last']: self.delete_rows(self.dbname,self.stbname,col_name,col_type,self.base_data,self.rowNum,'stb',self.tbnum)
tdSql.query(f'select {func}(*) from {self.stbname}') for func in ['first','last']:
tdSql.execute(f'drop table {self.stbname}') tdSql.query(f'select {func}(*) from {self.stbname}')
tdSql.execute(f'drop database {self.dbname}') tdSql.execute(f'drop table {self.stbname}')
def run(self): tdSql.execute(f'drop database {self.dbname}')
self.delete_data_ntb() def run(self):
self.delete_data_ctb() self.delete_data_ntb()
self.delete_data_stb() self.delete_data_ctb()
tdDnodes.stoptaosd(1) self.delete_data_stb()
tdDnodes.starttaosd(1) tdDnodes.stoptaosd(1)
self.delete_data_ntb() tdDnodes.starttaosd(1)
def stop(self): self.delete_data_ntb()
tdSql.close() def stop(self):
tdLog.success("%s successfully executed" % __file__) tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册