From ddfa4afda33c6ff81e7afba4c9793c93d7d8d76e Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 09:16:17 +0800 Subject: [PATCH 1/7] add test case --- tests/system-test/1-insert/update_data.py | 28 +++- .../1-insert/update_data_muti_tables.py | 150 ++++++++++++++++++ 2 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 tests/system-test/1-insert/update_data_muti_tables.py diff --git a/tests/system-test/1-insert/update_data.py b/tests/system-test/1-insert/update_data.py index 27e1559d7e..a9c5f39179 100644 --- a/tests/system-test/1-insert/update_data.py +++ b/tests/system-test/1-insert/update_data.py @@ -81,39 +81,63 @@ class TDTestCase: if col_type.lower() == 'double': for error_value in [tdCom.getLongName(self.str_length),True,False,1.1*constant.DOUBLE_MIN,1.1*constant.DOUBLE_MAX]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'float': for error_value in [tdCom.getLongName(self.str_length),True,False,1.1*constant.FLOAT_MIN,1.1*constant.FLOAT_MAX]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif 'binary' in col_type.lower() or 'nchar' in col_type.lower(): for error_value in [tdCom.getLongName(str_length)]: tdSql.error(f'insert into {tbname} values({self.ts},"{error_value}")') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'bool': for error_value in [tdCom.getLongName(self.str_length)]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'tinyint': for error_value in [constant.TINYINT_MIN-1,constant.TINYINT_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'smallint': for error_value in [constant.SMALLINT_MIN-1,constant.SMALLINT_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'int': for error_value in [constant.INT_MIN-1,constant.INT_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'bigint': for error_value in [constant.BIGINT_MIN-1,constant.BIGINT_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'tinyint unsigned': for error_value in [constant.TINYINT_UN_MIN-1,constant.TINYINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'smallint unsigned': for error_value in [constant.SMALLINT_UN_MIN-1,constant.SMALLINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'int unsigned': for error_value in [constant.INT_UN_MIN-1,constant.INT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') elif col_type.lower() == 'bigint unsigned': for error_value in [constant.BIGINT_UN_MIN-1,constant.BIGINT_UN_MAX+1,random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX),tdCom.getLongName(self.str_length),True,False]: - tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + tdSql.error(f'insert into {tbname} values({self.ts},{error_value})') + if tb_type == 'ctb': + tdSql.error(f'insert into {stbname} values({self.ts},{error_value})') tdSql.execute(f'drop table {tbname}') if tb_type == 'ctb': tdSql.execute(f'drop table {stbname}') diff --git a/tests/system-test/1-insert/update_data_muti_tables.py b/tests/system-test/1-insert/update_data_muti_tables.py new file mode 100644 index 0000000000..d1dce286df --- /dev/null +++ b/tests/system-test/1-insert/update_data_muti_tables.py @@ -0,0 +1,150 @@ +################################################################### +# 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 import constant +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.dbname = 'db_test' + self.ntbname = 'ntb' + self.stbname = 'stb' + self.rowNum = 5 + self.tbnum = 2 + self.ts = 1537146000000 + self.str_length = 20 + self.column_dict = { + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': f'binary({self.str_length})', + 'col13': f'nchar({self.str_length})', + 'col_ts' : 'timestamp' + } + self.tinyint_val = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) + self.smallint_val = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) + self.int_val = random.randint(constant.INT_MIN,constant.INT_MAX) + self.bigint_val = random.randint(constant.BIGINT_MIN,constant.BIGINT_MAX) + self.untingint_val = random.randint(constant.TINYINT_UN_MIN,constant.TINYINT_UN_MAX) + self.unsmallint_val = random.randint(constant.SMALLINT_UN_MIN,constant.SMALLINT_UN_MAX) + self.unint_val = random.randint(constant.INT_UN_MIN,constant.INT_MAX) + self.unbigint_val = random.randint(constant.BIGINT_UN_MIN,constant.BIGINT_UN_MAX) + self.float_val = random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX) + self.double_val = random.uniform(constant.DOUBLE_MIN*(1E-300),constant.DOUBLE_MAX*(1E-300)) + self.bool_val = random.randint(0,2)%2 + self.binary_val = tdCom.getLongName(random.randint(0,self.str_length)) + self.nchar_val = tdCom.getLongName(random.randint(0,self.str_length)) + self.data = { + 'tinyint':self.tinyint_val, + 'smallint':self.smallint_val, + 'int':self.int_val, + 'bigint':self.bigint_val, + 'tinyint unsigned':self.untingint_val, + 'smallint unsigned':self.unsmallint_val, + 'int unsigned':self.unint_val, + 'bigint unsigned':self.unbigint_val, + 'bool':self.bool_val, + 'float':self.float_val, + 'double':self.double_val, + 'binary':self.binary_val, + 'nchar':self.nchar_val + } + def update_data(self,dbname,tbname,tb_num,rows,values,col_type): + sql = f'insert into ' + for j in range(tb_num): + sql += f'{dbname}.{tbname}_{j} values' + for i in range(rows): + if 'binary' in col_type.lower() or 'nchar' in col_type.lower(): + sql += f'({self.ts+i},"{values}")' + else: + sql += f'({self.ts+i},{values})' + sql += ' ' + tdSql.execute(sql) + + def insert_data(self,col_type,tbname,rows,data): + for i in range(rows): + if col_type.lower() == 'tinyint': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["tinyint"]})') + elif col_type.lower() == 'smallint': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["smallint"]})') + elif col_type.lower() == 'int': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["int"]})') + elif col_type.lower() == 'bigint': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint"]})') + elif col_type.lower() == 'tinyint unsigned': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["tinyint unsigned"]})') + elif col_type.lower() == 'smallint unsigned': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["smallint unsigned"]})') + elif col_type.lower() == 'int unsigned': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["int unsigned"]})') + elif col_type.lower() == 'bigint unsigned': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bigint unsigned"]})') + elif col_type.lower() == 'bool': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["bool"]})') + elif col_type.lower() == 'float': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["float"]})') + elif col_type.lower() == 'double': + tdSql.execute(f'insert into {tbname} values({self.ts+i},{data["double"]})') + elif 'binary' in col_type.lower(): + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['binary']}")''') + elif 'nchar' in col_type.lower(): + tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') + + def update_data_ntb(self): + tdSql.execute(f'drop database if exists {self.dbname}') + tdSql.execute(f'create database {self.dbname}') + tdSql.execute(f'use {self.dbname}') + for col_name,col_type in self.column_dict.items(): + for i in range(self.tbnum): + tdSql.execute(f'create table {self.dbname}.{self.ntbname}_{i} (ts timestamp,{col_name} {col_type})') + for j in range(self.rowNum): + tdSql.execute(f'insert into {self.dbname}.{self.ntbname}_{i} values({self.ts+j},null)' ) + self.update_data(self.dbname,f'{self.ntbname}',self.tbnum,self.rowNum,self.data[col_type],col_type) + for i in range(self.tbnum): + tdSql.query('select {col_name} from {self.dbname}.{self.ntbname}_{i}') + for j in range(self.rowNum): + if col_type.lower() == 'float' or col_type.lower() == 'double': + if abs(tdSql.queryResult[0][0] - value) / value <= 0.0001: + tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) + + # for i in range(self.tbnum): + # tdSql.execute(f'drop table {self.ntbname}_{i}') + + def run(self): + self.update_data_ntb() + # self.update_data() + pass + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From 3ce47ac0bd21b21ca953ef3ab3ff51eb12ce0667 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 10:01:50 +0800 Subject: [PATCH 2/7] update --- ...uti_tables.py => update_data_muti_rows.py} | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) rename tests/system-test/1-insert/{update_data_muti_tables.py => update_data_muti_rows.py} (73%) diff --git a/tests/system-test/1-insert/update_data_muti_tables.py b/tests/system-test/1-insert/update_data_muti_rows.py similarity index 73% rename from tests/system-test/1-insert/update_data_muti_tables.py rename to tests/system-test/1-insert/update_data_muti_rows.py index d1dce286df..03eba2c13e 100644 --- a/tests/system-test/1-insert/update_data_muti_tables.py +++ b/tests/system-test/1-insert/update_data_muti_rows.py @@ -13,6 +13,8 @@ import random import string + +from numpy import logspace from util import constant from util.log import * from util.cases import * @@ -23,7 +25,7 @@ from util.common import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(),logSql) self.dbname = 'db_test' self.ntbname = 'ntb' @@ -45,8 +47,7 @@ class TDTestCase: 'col10': 'double', 'col11': 'bool', 'col12': f'binary({self.str_length})', - 'col13': f'nchar({self.str_length})', - 'col_ts' : 'timestamp' + '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) @@ -86,6 +87,7 @@ class TDTestCase: else: sql += f'({self.ts+i},{values})' sql += ' ' + print(sql) tdSql.execute(sql) def insert_data(self,col_type,tbname,rows,data): @@ -117,6 +119,25 @@ class TDTestCase: elif 'nchar' in col_type.lower(): tdSql.execute(f'''insert into {tbname} values({self.ts+i},"{data['nchar']}")''') + def data_check(self,dbname,tbname,tbnum,rownum,data,col_name,col_type): + if 'binary' in col_type.lower(): + self.update_data(dbname,f'{tbname}',tbnum,rownum,data['binary'],col_type) + elif 'nchar' in col_type.lower(): + self.update_data(dbname,f'{tbname}',tbnum,rownum,data['nchar'],col_type) + else: + self.update_data(dbname,f'{tbname}',tbnum,rownum,data[col_type],col_type) + for i in range(self.tbnum): + tdSql.query(f'select {col_name} from {dbname}.{tbname}_{i}') + for j in range(rownum): + if col_type.lower() == 'float' or col_type.lower() == 'double': + if abs(tdSql.queryResult[j][0] - data[col_type]) / data[col_type] <= 0.0001: + tdSql.checkEqual(tdSql.queryResult[j][0],tdSql.queryResult[j][0]) + elif 'binary' in col_type.lower(): + tdSql.checkEqual(tdSql.queryResult[j][0],data['binary']) + elif 'nchar' in col_type.lower(): + tdSql.checkEqual(tdSql.queryResult[j][0],data['nchar']) + else: + tdSql.checkEqual(tdSql.queryResult[j][0],data[col_type]) def update_data_ntb(self): tdSql.execute(f'drop database if exists {self.dbname}') tdSql.execute(f'create database {self.dbname}') @@ -126,21 +147,25 @@ class TDTestCase: tdSql.execute(f'create table {self.dbname}.{self.ntbname}_{i} (ts timestamp,{col_name} {col_type})') for j in range(self.rowNum): tdSql.execute(f'insert into {self.dbname}.{self.ntbname}_{i} values({self.ts+j},null)' ) - self.update_data(self.dbname,f'{self.ntbname}',self.tbnum,self.rowNum,self.data[col_type],col_type) + self.data_check(self.dbname,self.ntbname,self.tbnum,self.rowNum,self.data,col_name,col_type) for i in range(self.tbnum): - tdSql.query('select {col_name} from {self.dbname}.{self.ntbname}_{i}') + tdSql.execute(f'drop table {self.ntbname}_{i}') + def update_data_ctb(self): + tdSql.execute(f'drop database if exists {self.dbname}') + tdSql.execute(f'create database {self.dbname}') + tdSql.execute(f'use {self.dbname}') + for col_name,col_type in self.column_dict.items(): + tdSql.execute(f'create table {self.dbname}.{self.stbname} (ts timestamp,{col_name} {col_type}) tags(t0 int)') + for i in range(self.tbnum): + tdSql.execute(f'create table {self.dbname}.{self.stbname}_{i} using {self.dbname}.{self.stbname} tags(1)') for j in range(self.rowNum): - if col_type.lower() == 'float' or col_type.lower() == 'double': - if abs(tdSql.queryResult[0][0] - value) / value <= 0.0001: - tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) - - # for i in range(self.tbnum): - # tdSql.execute(f'drop table {self.ntbname}_{i}') - + tdSql.execute(f'insert into {self.dbname}.{self.stbname}_{i} values({self.ts+j},null)' ) + self.data_check(self.dbname,self.stbname,self.tbnum,self.rowNum,self.data,col_name,col_type) + tdSql.execute(f'drop table {self.stbname}') def run(self): self.update_data_ntb() - # self.update_data() - pass + self.update_data_ctb() + def stop(self): tdSql.close() From 49a5049eb6ef757a7d2398c7d5a36468a1bc6d19 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 10:05:33 +0800 Subject: [PATCH 3/7] update --- tests/system-test/1-insert/update_data_muti_rows.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/system-test/1-insert/update_data_muti_rows.py b/tests/system-test/1-insert/update_data_muti_rows.py index 03eba2c13e..2da2f1f035 100644 --- a/tests/system-test/1-insert/update_data_muti_rows.py +++ b/tests/system-test/1-insert/update_data_muti_rows.py @@ -25,13 +25,12 @@ from util.common import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(),logSql) - + tdSql.init(conn.cursor()) self.dbname = 'db_test' self.ntbname = 'ntb' self.stbname = 'stb' - self.rowNum = 5 - self.tbnum = 2 + self.rowNum = 10 + self.tbnum = 5 self.ts = 1537146000000 self.str_length = 20 self.column_dict = { @@ -87,7 +86,6 @@ class TDTestCase: else: sql += f'({self.ts+i},{values})' sql += ' ' - print(sql) tdSql.execute(sql) def insert_data(self,col_type,tbname,rows,data): From aed462f21f6ec8b97dbbca950ce0a2499d8b58a5 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 10:09:13 +0800 Subject: [PATCH 4/7] add test case into ci --- tests/system-test/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index dd5f3809e8..2fdb22ff3f 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -31,7 +31,7 @@ python3 ./test.py -f 1-insert/time_range_wise.py python3 ./test.py -f 1-insert/block_wise.py python3 ./test.py -f 1-insert/create_retentions.py python3 ./test.py -f 1-insert/table_param_ttl.py - +python3 ./test.py -f 1-insert/update_data_muti_rows.py python3 ./test.py -f 1-insert/update_data.py python3 ./test.py -f 1-insert/delete_data.py python3 ./test.py -f 2-query/db.py From 2bb8a3dcfb9f1887415f5b65f973bd91fda85d88 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 10:12:19 +0800 Subject: [PATCH 5/7] update --- tests/system-test/1-insert/update_data_muti_rows.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/system-test/1-insert/update_data_muti_rows.py b/tests/system-test/1-insert/update_data_muti_rows.py index 2da2f1f035..e7da35426a 100644 --- a/tests/system-test/1-insert/update_data_muti_rows.py +++ b/tests/system-test/1-insert/update_data_muti_rows.py @@ -124,6 +124,8 @@ class TDTestCase: self.update_data(dbname,f'{tbname}',tbnum,rownum,data['nchar'],col_type) else: self.update_data(dbname,f'{tbname}',tbnum,rownum,data[col_type],col_type) + tdSql.execute(f'flush database {dbname}') + tdSql.execute('reset query cache') for i in range(self.tbnum): tdSql.query(f'select {col_name} from {dbname}.{tbname}_{i}') for j in range(rownum): @@ -145,6 +147,8 @@ class TDTestCase: tdSql.execute(f'create table {self.dbname}.{self.ntbname}_{i} (ts timestamp,{col_name} {col_type})') for j in range(self.rowNum): tdSql.execute(f'insert into {self.dbname}.{self.ntbname}_{i} values({self.ts+j},null)' ) + tdSql.execute(f'flush database {self.dbname}') + tdSql.execute('reset query cache') self.data_check(self.dbname,self.ntbname,self.tbnum,self.rowNum,self.data,col_name,col_type) for i in range(self.tbnum): tdSql.execute(f'drop table {self.ntbname}_{i}') @@ -158,6 +162,8 @@ class TDTestCase: tdSql.execute(f'create table {self.dbname}.{self.stbname}_{i} using {self.dbname}.{self.stbname} tags(1)') for j in range(self.rowNum): tdSql.execute(f'insert into {self.dbname}.{self.stbname}_{i} values({self.ts+j},null)' ) + tdSql.execute(f'flush database {self.dbname}') + tdSql.execute('reset query cache') self.data_check(self.dbname,self.stbname,self.tbnum,self.rowNum,self.data,col_name,col_type) tdSql.execute(f'drop table {self.stbname}') def run(self): From cdc5270b7ff90fceac98e06a7538edd1c29ae793 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 10:46:53 +0800 Subject: [PATCH 6/7] update --- tests/system-test/1-insert/delete_data.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/system-test/1-insert/delete_data.py b/tests/system-test/1-insert/delete_data.py index 4c1426d0b1..1eb270d997 100644 --- a/tests/system-test/1-insert/delete_data.py +++ b/tests/system-test/1-insert/delete_data.py @@ -214,6 +214,24 @@ class TDTestCase: tdSql.checkRows((row_num-i)*tb_num) for j in range(tb_num): self.insert_base_data(col_type,f'{tbname}_{j}',row_num,base_data) + for i in range(row_num): + tdSql.execute(f'delete from {tbname} where ts between {self.ts} and {self.ts+i}') + tdSql.execute(f'flush database {dbname}') + tdSql.execute('reset query cache') + tdSql.query(f'select {col_name} from {tbname}') + if tb_type == 'ntb' or tb_type == 'ctb': + tdSql.checkRows(row_num - i-1) + self.insert_base_data(col_type,tbname,row_num,base_data) + elif tb_type == 'stb': + tdSql.checkRows(tb_num*(row_num - i-1)) + for j in range(tb_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+i+1} and {self.ts}') + tdSql.query(f'select {col_name} from {tbname}') + if tb_type == 'ntb' or tb_type == 'ctb': + tdSql.checkRows(row_num) + elif tb_type == 'stb': + tdSql.checkRows(tb_num*row_num) def delete_error(self,tbname,column_name,column_type,base_data): for error_list in ['',f'ts = {self.ts} and',f'ts = {self.ts} or']: if 'binary' in column_type.lower(): @@ -221,7 +239,8 @@ class TDTestCase: elif 'nchar' in column_type.lower(): tdSql.error(f'''delete from {tbname} where {error_list} {column_name} ="{base_data['nchar']}"''') else: - tdSql.error(f'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}') + 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}') tdSql.execute(f'use {self.dbname}') From bea57c8ce2875fbb51b7f80c57c43f3133893058 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Thu, 21 Jul 2022 13:51:02 +0800 Subject: [PATCH 7/7] update --- tests/system-test/2-query/count.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/system-test/2-query/count.py b/tests/system-test/2-query/count.py index c83ff43c51..e047225c1f 100644 --- a/tests/system-test/2-query/count.py +++ b/tests/system-test/2-query/count.py @@ -94,17 +94,15 @@ class TDTestCase: tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) for i in range(self.tbnum): tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_values[i]})') - #!TODO - # tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})') - # tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum) + tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})') + tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum) tdSql.query(f'select count(tbname) from {self.stbname}') tdSql.checkRows(0) tdSql.execute('flush database db') tdSql.query(f'select count(tbname) from {self.stbname}') tdSql.checkRows(0) - #!TODO - # tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})') - # tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum) + tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})') + tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum) for i in range(self.tbnum): self.insert_data(self.column_dict,f'{self.stbname}_{i}',self.rowNum) self.count_query_stb(self.column_dict,self.tag_dict,self.stbname,self.tbnum,self.rowNum)