fix case
This commit is contained in:
parent
e68f14a029
commit
53f2fbb664
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from collections import defaultdict
|
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import requests
|
import requests
|
||||||
|
@ -25,6 +24,79 @@ from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.dnodes import *
|
from util.dnodes import *
|
||||||
from util.common 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:
|
class TDCom:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -16,24 +16,34 @@ TINT_COL = "c_tint"
|
||||||
FLOAT_COL = "c_float"
|
FLOAT_COL = "c_float"
|
||||||
DOUBLE_COL = "c_double"
|
DOUBLE_COL = "c_double"
|
||||||
BOOL_COL = "c_bool"
|
BOOL_COL = "c_bool"
|
||||||
TINT_UN_COL = "c_tint_un"
|
TINT_UN_COL = "c_utint"
|
||||||
SINT_UN_COL = "c_sint_un"
|
SINT_UN_COL = "c_usint"
|
||||||
BINT_UN_COL = "c_bint_un"
|
BINT_UN_COL = "c_ubint"
|
||||||
INT_UN_COL = "c_int_un"
|
INT_UN_COL = "c_uint"
|
||||||
|
|
||||||
BINARY_COL = "c_binary"
|
BINARY_COL = "c_binary"
|
||||||
NCHAR_COL = "c_nchar"
|
NCHAR_COL = "c_nchar"
|
||||||
TS_COL = "c_ts"
|
TS_COL = "c_ts"
|
||||||
|
|
||||||
NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
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, ]
|
CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
||||||
BOOLEAN_COL = [ BOOL_COL, ]
|
BOOLEAN_COL = [BOOL_COL, ]
|
||||||
TS_TYPE_COL = [ TS_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:
|
## insert data args:
|
||||||
TIME_STEP = 10000
|
TIME_STEP = 10000
|
||||||
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
|
|
||||||
|
# init db/table
|
||||||
|
DBNAME = "db"
|
||||||
|
STBNAME = "stb1"
|
||||||
|
CTBNAME = "ct1"
|
||||||
|
NTBNAME = "nt1"
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DataSet:
|
class DataSet:
|
||||||
ts_data : List[int] = field(default_factory=list)
|
ts_data : List[int] = field(default_factory=list)
|
||||||
|
@ -152,17 +162,19 @@ class TDTestCase:
|
||||||
self.test_create_databases()
|
self.test_create_databases()
|
||||||
self.test_create_stb()
|
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")
|
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,
|
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,
|
||||||
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||||
) tags (t1 int)
|
) tags ({INT_TAG} int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
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,
|
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,
|
||||||
|
@ -173,8 +185,8 @@ class TDTestCase:
|
||||||
tdSql.execute(create_stb_sql)
|
tdSql.execute(create_stb_sql)
|
||||||
tdSql.execute(create_ntb_sql)
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(ctb_num):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table ct{i+1} using {stb} tags ( {i+1} )')
|
||||||
|
|
||||||
def __data_set(self, rows):
|
def __data_set(self, rows):
|
||||||
data_set = DataSet()
|
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 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 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 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 + 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} )" )
|
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 + 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 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 {NTBNAME} 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 {NTBNAME} 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 - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" )
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
|
@ -325,10 +325,17 @@ class TDTestCase:
|
||||||
def __sma_create_check(self, sma:SMAschema):
|
def __sma_create_check(self, sma:SMAschema):
|
||||||
if self.updatecfgDict["querySmaOptimize"] == 0:
|
if self.updatecfgDict["querySmaOptimize"] == 0:
|
||||||
return False
|
return False
|
||||||
# TODO: if database is a rollup-db, can not create sma index
|
tdSql.query("select database()")
|
||||||
# tdSql.query("select database()")
|
dbname = tdSql.getData(0,0)
|
||||||
# if sma.rollup_db :
|
tdSql.query("show databases")
|
||||||
# return False
|
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")
|
tdSql.query("show stables")
|
||||||
if not sma.tbname:
|
if not sma.tbname:
|
||||||
return False
|
return False
|
||||||
|
@ -379,12 +386,15 @@ class TDTestCase:
|
||||||
tdSql.query(self.__create_sma_index(sma))
|
tdSql.query(self.__create_sma_index(sma))
|
||||||
self.sma_count += 1
|
self.sma_count += 1
|
||||||
self.sma_created_index.append(sma.index_name)
|
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.checkRows(self.sma_count)
|
||||||
|
tdSql.checkData(0, 2, sma.tbname)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tdSql.error(self.__create_sma_index(sma))
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __drop_sma_index(self, sma:SMAschema):
|
def __drop_sma_index(self, sma:SMAschema):
|
||||||
sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}"
|
sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}"
|
||||||
return sql
|
return sql
|
||||||
|
@ -402,12 +412,12 @@ class TDTestCase:
|
||||||
def sma_drop_check(self, sma:SMAschema):
|
def sma_drop_check(self, sma:SMAschema):
|
||||||
if self.__sma_drop_check(sma):
|
if self.__sma_drop_check(sma):
|
||||||
tdSql.query(self.__drop_sma_index(sma))
|
tdSql.query(self.__drop_sma_index(sma))
|
||||||
print(self.__drop_sma_index(sma))
|
|
||||||
self.sma_count -= 1
|
self.sma_count -= 1
|
||||||
self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index))
|
self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index))
|
||||||
tdSql.query("show streams")
|
tdSql.query("show streams")
|
||||||
tdSql.checkRows(self.sma_count)
|
tdSql.checkRows(self.sma_count)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tdSql.error(self.__drop_sma_index(sma))
|
tdSql.error(self.__drop_sma_index(sma))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue