fix case
This commit is contained in:
parent
e68f14a029
commit
53f2fbb664
|
@ -11,7 +11,6 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from collections import defaultdict
|
||||
import random
|
||||
import string
|
||||
import requests
|
||||
|
@ -25,6 +24,79 @@ from util.sql import *
|
|||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
from util.common import *
|
||||
from util.constant import *
|
||||
from dataclasses import dataclass,field
|
||||
from typing import List
|
||||
|
||||
@dataclass
|
||||
class DataSet:
|
||||
ts_data : List[int] = field(default_factory=list)
|
||||
int_data : List[int] = field(default_factory=list)
|
||||
bint_data : List[int] = field(default_factory=list)
|
||||
sint_data : List[int] = field(default_factory=list)
|
||||
tint_data : List[int] = field(default_factory=list)
|
||||
uint_data : List[int] = field(default_factory=list)
|
||||
ubint_data : List[int] = field(default_factory=list)
|
||||
usint_data : List[int] = field(default_factory=list)
|
||||
utint_data : List[int] = field(default_factory=list)
|
||||
float_data : List[float] = field(default_factory=list)
|
||||
double_data : List[float] = field(default_factory=list)
|
||||
bool_data : List[int] = field(default_factory=list)
|
||||
vchar_data : List[str] = field(default_factory=list)
|
||||
nchar_data : List[str] = field(default_factory=list)
|
||||
|
||||
def get_order_set(self,
|
||||
rows,
|
||||
int_step :int = 1,
|
||||
bint_step :int = 1,
|
||||
sint_step :int = 1,
|
||||
tint_step :int = 1,
|
||||
uint_step :int = 1,
|
||||
ubint_step :int = 1,
|
||||
usint_step :int = 1,
|
||||
utint_step :int = 1,
|
||||
float_step :float = 1,
|
||||
double_step :float = 1,
|
||||
bool_start :int = 1,
|
||||
vchar_prefix:str = "vachar_",
|
||||
vchar_step :int = 1,
|
||||
nchar_prefix:str = "nchar_测试_",
|
||||
nchar_step :int = 1,
|
||||
ts_step :int = 1
|
||||
):
|
||||
for i in range(rows):
|
||||
self.int_data.append( int(i * int_step % INT_MAX ))
|
||||
self.bint_data.append( int(i * bint_step % BIGINT_MAX ))
|
||||
self.sint_data.append( int(i * sint_step % SMALLINT_MAX ))
|
||||
self.tint_data.append( int(i * tint_step % TINYINT_MAX ))
|
||||
self.uint_data.append( int(i * uint_step % INT_UN_MAX ))
|
||||
self.ubint_data.append( int(i * ubint_step % BIGINT_UN_MAX ))
|
||||
self.usint_data.append( int(i * usint_step % SMALLINT_UN_MAX ))
|
||||
self.utint_data.append( int(i * utint_step % TINYINT_UN_MAX ))
|
||||
self.float_data.append( float(i * float_step % FLOAT_MAX ))
|
||||
self.double_data.append( float(i * double_step % DOUBLE_MAX ))
|
||||
self.bool_data.append( bool((i + bool_start) % 2 ))
|
||||
self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" )
|
||||
self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}")
|
||||
self.ts_data.append( int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000 - i * ts_step))
|
||||
|
||||
def get_disorder_set(self,
|
||||
rows,
|
||||
int_low :int = INT_MIN,
|
||||
int_up :int = INT_MAX,
|
||||
bint_low :int = BIGINT_MIN,
|
||||
bint_up :int = BIGINT_MAX,
|
||||
sint_low :int = SMALLINT_MIN,
|
||||
sint_up :int = SMALLINT_MAX,
|
||||
tint_low :int = TINYINT_MIN,
|
||||
tint_up :int = TINYINT_MAX,
|
||||
ubint_low :int = BIGINT_UN_MIN,
|
||||
ubint_up :int = BIGINT_UN_MAX,
|
||||
|
||||
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
class TDCom:
|
||||
def __init__(self):
|
||||
|
@ -650,7 +722,7 @@ class TDCom:
|
|||
else:
|
||||
column_value_str += f'{column_value}, '
|
||||
idx += 1
|
||||
column_value_str = column_value_str.rstrip()[:-1]
|
||||
column_value_str = column_value_str.rstrip()[:-1]
|
||||
insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});'
|
||||
tsql.execute(insert_sql)
|
||||
def getOneRow(self, location, containElm):
|
||||
|
@ -662,12 +734,12 @@ class TDCom:
|
|||
return res_list
|
||||
else:
|
||||
tdLog.exit(f"getOneRow out of range: row_index={location} row_count={self.query_row}")
|
||||
|
||||
def killProcessor(self, processorName):
|
||||
|
||||
def killProcessor(self, processorName):
|
||||
if (platform.system().lower() == 'windows'):
|
||||
os.system("TASKKILL /F /IM %s.exe"%processorName)
|
||||
else:
|
||||
os.system('pkill %s'%processorName)
|
||||
os.system('pkill %s'%processorName)
|
||||
|
||||
|
||||
def is_json(msg):
|
||||
|
|
|
@ -9,31 +9,41 @@ from util.dnodes import *
|
|||
|
||||
PRIMARY_COL = "ts"
|
||||
|
||||
INT_COL = "c_int"
|
||||
BINT_COL = "c_bint"
|
||||
SINT_COL = "c_sint"
|
||||
TINT_COL = "c_tint"
|
||||
FLOAT_COL = "c_float"
|
||||
DOUBLE_COL = "c_double"
|
||||
BOOL_COL = "c_bool"
|
||||
TINT_UN_COL = "c_tint_un"
|
||||
SINT_UN_COL = "c_sint_un"
|
||||
BINT_UN_COL = "c_bint_un"
|
||||
INT_UN_COL = "c_int_un"
|
||||
INT_COL = "c_int"
|
||||
BINT_COL = "c_bint"
|
||||
SINT_COL = "c_sint"
|
||||
TINT_COL = "c_tint"
|
||||
FLOAT_COL = "c_float"
|
||||
DOUBLE_COL = "c_double"
|
||||
BOOL_COL = "c_bool"
|
||||
TINT_UN_COL = "c_utint"
|
||||
SINT_UN_COL = "c_usint"
|
||||
BINT_UN_COL = "c_ubint"
|
||||
INT_UN_COL = "c_uint"
|
||||
BINARY_COL = "c_binary"
|
||||
NCHAR_COL = "c_nchar"
|
||||
TS_COL = "c_ts"
|
||||
|
||||
BINARY_COL = "c_binary"
|
||||
NCHAR_COL = "c_nchar"
|
||||
TS_COL = "c_ts"
|
||||
NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, TINT_UN_COL, SINT_UN_COL, BINT_UN_COL, INT_UN_COL]
|
||||
CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
||||
BOOLEAN_COL = [BOOL_COL, ]
|
||||
TS_TYPE_COL = [TS_COL, ]
|
||||
|
||||
NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
||||
CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
|
||||
BOOLEAN_COL = [ BOOL_COL, ]
|
||||
TS_TYPE_COL = [ TS_COL, ]
|
||||
INT_TAG = "t_int"
|
||||
|
||||
ALL_COL = [PRIMARY_COL, INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BINARY_COL, NCHAR_COL, BOOL_COL, TS_COL]
|
||||
TAG_COL = [INT_TAG]
|
||||
|
||||
## insert data args:
|
||||
TIME_STEP = 10000
|
||||
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
|
||||
# init db/table
|
||||
DBNAME = "db"
|
||||
STBNAME = "stb1"
|
||||
CTBNAME = "ct1"
|
||||
NTBNAME = "nt1"
|
||||
|
||||
@dataclass
|
||||
class DataSet:
|
||||
ts_data : List[int] = field(default_factory=list)
|
||||
|
@ -152,29 +162,31 @@ class TDTestCase:
|
|||
self.test_create_databases()
|
||||
self.test_create_stb()
|
||||
|
||||
def __create_tb(self):
|
||||
def __create_tb(self, stb=STBNAME, ctb_num=20, ntbnum=1, rsma=False):
|
||||
tdLog.printNoPrefix("==========step: create table")
|
||||
create_stb_sql = f'''create table stb1(
|
||||
create_stb_sql = f'''create table {stb}(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||
) tags (t1 int)
|
||||
'''
|
||||
create_ntb_sql = f'''create table t1(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||
)
|
||||
) tags ({INT_TAG} int)
|
||||
'''
|
||||
for i in range(ntbnum):
|
||||
|
||||
create_ntb_sql = f'''create table nt{i+1}(
|
||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||
)
|
||||
'''
|
||||
tdSql.execute(create_stb_sql)
|
||||
tdSql.execute(create_ntb_sql)
|
||||
|
||||
for i in range(4):
|
||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
||||
for i in range(ctb_num):
|
||||
tdSql.execute(f'create table ct{i+1} using {stb} tags ( {i+1} )')
|
||||
|
||||
def __data_set(self, rows):
|
||||
data_set = DataSet()
|
||||
|
@ -220,7 +232,7 @@ class TDTestCase:
|
|||
tdSql.execute( f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )" )
|
||||
tdSql.execute( f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )" )
|
||||
tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )" )
|
||||
tdSql.execute( f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" )
|
||||
tdSql.execute( f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" )
|
||||
|
||||
tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )" )
|
||||
|
@ -230,9 +242,9 @@ class TDTestCase:
|
|||
tdSql.execute( f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )" )
|
||||
|
||||
tdSql.execute( f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into {NTBNAME} values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )" )
|
||||
tdSql.execute( f"insert into {NTBNAME} values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" )
|
||||
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -325,10 +325,17 @@ class TDTestCase:
|
|||
def __sma_create_check(self, sma:SMAschema):
|
||||
if self.updatecfgDict["querySmaOptimize"] == 0:
|
||||
return False
|
||||
# TODO: if database is a rollup-db, can not create sma index
|
||||
# tdSql.query("select database()")
|
||||
# if sma.rollup_db :
|
||||
# return False
|
||||
tdSql.query("select database()")
|
||||
dbname = tdSql.getData(0,0)
|
||||
tdSql.query("show databases")
|
||||
for row in tdSql.queryResult:
|
||||
if row[0] == dbname:
|
||||
if row[-1] is None:
|
||||
continue
|
||||
if ":" in row[-1]:
|
||||
sma.rollup_db = True
|
||||
if sma.rollup_db :
|
||||
return False
|
||||
tdSql.query("show stables")
|
||||
if not sma.tbname:
|
||||
return False
|
||||
|
@ -379,12 +386,15 @@ class TDTestCase:
|
|||
tdSql.query(self.__create_sma_index(sma))
|
||||
self.sma_count += 1
|
||||
self.sma_created_index.append(sma.index_name)
|
||||
tdSql.query("show streams")
|
||||
tdSql.query(self.__show_sma_index(sma))
|
||||
tdSql.checkRows(self.sma_count)
|
||||
tdSql.checkData(0, 2, sma.tbname)
|
||||
|
||||
else:
|
||||
tdSql.error(self.__create_sma_index(sma))
|
||||
|
||||
|
||||
|
||||
def __drop_sma_index(self, sma:SMAschema):
|
||||
sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}"
|
||||
return sql
|
||||
|
@ -402,12 +412,12 @@ class TDTestCase:
|
|||
def sma_drop_check(self, sma:SMAschema):
|
||||
if self.__sma_drop_check(sma):
|
||||
tdSql.query(self.__drop_sma_index(sma))
|
||||
print(self.__drop_sma_index(sma))
|
||||
self.sma_count -= 1
|
||||
self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index))
|
||||
tdSql.query("show streams")
|
||||
tdSql.checkRows(self.sma_count)
|
||||
|
||||
|
||||
else:
|
||||
tdSql.error(self.__drop_sma_index(sma))
|
||||
|
||||
|
|
Loading…
Reference in New Issue