fix: add new-frame public file
This commit is contained in:
parent
4b6bd14295
commit
f567c19d05
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"filetype": "insert",
|
||||||
|
"cfgdir": "/etc/taos",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 6030,
|
||||||
|
"user": "root",
|
||||||
|
"password": "taosdata",
|
||||||
|
"connection_pool_size": 8,
|
||||||
|
"num_of_records_per_req": 2000,
|
||||||
|
"thread_count": 2,
|
||||||
|
"create_table_thread_count": 1,
|
||||||
|
"confirm_parameter_prompt": "no",
|
||||||
|
"databases": [
|
||||||
|
{
|
||||||
|
"dbinfo": {
|
||||||
|
"name": "db",
|
||||||
|
"drop": "yes",
|
||||||
|
"vgroups": 2,
|
||||||
|
"replica": 1,
|
||||||
|
"duration":"1d",
|
||||||
|
"keep": "3d,6d,30d"
|
||||||
|
},
|
||||||
|
"super_tables": [
|
||||||
|
{
|
||||||
|
"name": "stb",
|
||||||
|
"child_table_exists": "no",
|
||||||
|
"childtable_count": 2,
|
||||||
|
"insert_rows": 1000000,
|
||||||
|
"childtable_prefix": "d",
|
||||||
|
"insert_mode": "taosc",
|
||||||
|
"timestamp_step": 1000,
|
||||||
|
"start_timestamp":"now-10d",
|
||||||
|
"columns": [
|
||||||
|
{ "type": "bool", "name": "bc"},
|
||||||
|
{ "type": "float", "name": "fc" },
|
||||||
|
{ "type": "double", "name": "dc"},
|
||||||
|
{ "type": "tinyint", "name": "ti", "values":["1"]},
|
||||||
|
{ "type": "smallint", "name": "si" },
|
||||||
|
{ "type": "int", "name": "ic" },
|
||||||
|
{ "type": "bigint", "name": "bi" },
|
||||||
|
{ "type": "utinyint", "name": "uti"},
|
||||||
|
{ "type": "usmallint", "name": "usi"},
|
||||||
|
{ "type": "uint", "name": "ui" },
|
||||||
|
{ "type": "ubigint", "name": "ubi"},
|
||||||
|
{ "type": "binary", "name": "bin", "len": 32},
|
||||||
|
{ "type": "nchar", "name": "nch", "len": 64}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
|
||||||
|
{"name": "location","type": "binary", "len": 16, "values":
|
||||||
|
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -15,26 +15,65 @@ import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import taos
|
import taos
|
||||||
|
import frame
|
||||||
|
|
||||||
from frame.log import *
|
from frame.log import *
|
||||||
from frame.cases import *
|
from frame.cases import *
|
||||||
from frame.sql import *
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
|
||||||
|
|
||||||
|
def insertData(self):
|
||||||
|
tdLog.info(f"insert data.")
|
||||||
|
# taosBenchmark run
|
||||||
|
json = frame.etool.curFile(__file__, "mlevel_basic.json")
|
||||||
|
frame.etool.runBenchmark(json=json)
|
||||||
|
|
||||||
|
# set insert data information
|
||||||
|
self.childtable_count = 2
|
||||||
|
self.insert_rows = 1000000
|
||||||
|
self.timestamp_step = 1000
|
||||||
|
|
||||||
|
def doAction(self):
|
||||||
|
tdLog.info(f"trim database.")
|
||||||
|
self.trimDb()
|
||||||
|
|
||||||
|
def saveData(self):
|
||||||
|
tdLog.info(f"check correct.")
|
||||||
|
|
||||||
|
def checkSaveCorrent(self):
|
||||||
|
tdLog.info(f"check correct.")
|
||||||
|
|
||||||
|
def checkCorrect(self):
|
||||||
|
tdLog.info(f"check correct.")
|
||||||
|
|
||||||
class TDTestCase:
|
|
||||||
# init
|
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
|
||||||
self.replicaVar = int(replicaVar)
|
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
|
||||||
tdSql.init(conn.cursor(), True)
|
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
# check two db query result same
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdLog.info(f"hello world.")
|
|
||||||
|
# insert data
|
||||||
|
self.insertData()
|
||||||
|
|
||||||
|
# check insert data correct
|
||||||
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
# save
|
||||||
|
self.snapshotAgg()
|
||||||
|
|
||||||
|
# do action
|
||||||
|
self.doAction()
|
||||||
|
|
||||||
|
# check save agg result correct
|
||||||
|
self.checkAggCorrect()
|
||||||
|
|
||||||
# stop
|
|
||||||
def stop(self):
|
|
||||||
tdSql.close()
|
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -16,10 +16,89 @@ import os
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
class caseBase:
|
from log import *
|
||||||
def __init__(self):
|
from sql import *
|
||||||
|
|
||||||
|
# test case base
|
||||||
|
class DbBase:
|
||||||
|
|
||||||
|
#
|
||||||
|
# frame call
|
||||||
|
#
|
||||||
|
|
||||||
|
# init
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
# save param
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
# record server information
|
# record server information
|
||||||
self.dnodeNum = 0
|
self.dnodeNum = 0
|
||||||
self.mnodeNum = 0
|
self.mnodeNum = 0
|
||||||
self.mLevel = 0
|
self.mLevel = 0
|
||||||
self.mLevelDisk = 0
|
self.mLevelDisk = 0
|
||||||
|
|
||||||
|
# test case information
|
||||||
|
self.db = "db"
|
||||||
|
self.stb = "stb"
|
||||||
|
|
||||||
|
# variant in taosBenchmark json
|
||||||
|
self.childtable_count = 2
|
||||||
|
self.insert_rows = 1000000
|
||||||
|
self.timestamp_step = 1000
|
||||||
|
|
||||||
|
# sql
|
||||||
|
self.sqlSum = f"select sum(ic) from {self.stb}"
|
||||||
|
self.sqlMax = f"select max(ic) from {self.stb}"
|
||||||
|
self.sqlMin = f"select min(ic) from {self.stb}"
|
||||||
|
self.sqlAvg = f"select avg(ic) from {self.stb}"
|
||||||
|
|
||||||
|
|
||||||
|
# stop
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# db action
|
||||||
|
#
|
||||||
|
|
||||||
|
def trimDb(self):
|
||||||
|
tdSql.execute(f"trim database {self.db}")
|
||||||
|
|
||||||
|
def compactDb(self):
|
||||||
|
tdSql.execute(f"compact database {self.db}")
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# check db correct
|
||||||
|
#
|
||||||
|
|
||||||
|
# basic
|
||||||
|
def checkInsertCorrect(self):
|
||||||
|
# check count
|
||||||
|
sql = f"select count(*) from {self.stb}"
|
||||||
|
tdSql.checkAgg(sql, self.childtable_count * self.insert_rows)
|
||||||
|
|
||||||
|
# check child table count
|
||||||
|
sql = f" select count(*) from (select count(*) as cnt , tbname from {self.stb} group by tbname) where cnt = {self.insert_rows} "
|
||||||
|
tdSql.checkAgg(sql, self.childtable_count)
|
||||||
|
|
||||||
|
# check step
|
||||||
|
sql = f"select count(*) from (select diff(ts) as dif from {self.stb} group by tbname) where dif != {self.timestamp_step}"
|
||||||
|
tdSql.checkAgg(sql, 0)
|
||||||
|
|
||||||
|
# save agg result
|
||||||
|
def snapshotAgg(self):
|
||||||
|
|
||||||
|
self.sum = tdSql.getFirstValue(self.sqlSum)
|
||||||
|
self.avg = tdSql.getFirstValue(self.sqlAvg)
|
||||||
|
self.min = tdSql.getFirstValue(self.sqlMin)
|
||||||
|
self.max = tdSql.getFirstValue(self.sqlMax)
|
||||||
|
|
||||||
|
# check agg
|
||||||
|
def checkAggCorrect(self):
|
||||||
|
tdSql.checkAgg(self.sqlSum, self.sum)
|
||||||
|
tdSql.checkAgg(self.sqlAvg, self.avg)
|
||||||
|
tdSql.checkAgg(self.sqlMin, self.min)
|
||||||
|
tdSql.checkAgg(self.sqlMax, self.max)
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2023 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 -*-
|
||||||
|
|
||||||
|
#
|
||||||
|
# about system funciton extension
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
# if windows platform return True
|
||||||
|
def isWin():
|
||||||
|
return sys.platform.system().lower() == 'windows'
|
||||||
|
|
||||||
|
# wait util execute file finished
|
||||||
|
def exe(file):
|
||||||
|
return os.system(file)
|
||||||
|
|
||||||
|
# execute file and return immediately
|
||||||
|
def exeNoWait(file):
|
||||||
|
print("exe no wait")
|
||||||
|
|
||||||
|
|
|
@ -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 -*-
|
||||||
|
|
||||||
|
#
|
||||||
|
# about path function extension
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
from frame.log import *
|
||||||
|
|
||||||
|
# build/bin path
|
||||||
|
binPath = ""
|
||||||
|
|
||||||
|
def binPath(self):
|
||||||
|
global binPath
|
||||||
|
|
||||||
|
if binPath != "":
|
||||||
|
return binPath
|
||||||
|
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community/tests" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community/tests")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("TDengine/tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root)-len("/build/bin")]
|
||||||
|
break
|
||||||
|
# check
|
||||||
|
if (buildPath == ""):
|
||||||
|
tdLog.exit("taosd not found!")
|
||||||
|
else:
|
||||||
|
tdLog.info(f"taosd found in {buildPath}")
|
||||||
|
# return
|
||||||
|
binPath = buildPath + "/build/bin/"
|
||||||
|
return binPath
|
||||||
|
|
||||||
|
def binFile(self, file):
|
||||||
|
return binPath() + file
|
|
@ -0,0 +1,23 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2023 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 -*-
|
||||||
|
|
||||||
|
#
|
||||||
|
# about tools funciton extension
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
###################################################################
|
||||||
|
# Copyright (c) 2023 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 -*-
|
||||||
|
|
||||||
|
#
|
||||||
|
# about system funciton extension
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
import epath
|
||||||
|
import eos
|
||||||
|
|
||||||
|
# run taosBenchmark with command or json file mode
|
||||||
|
def runBenchmark(command = "", json = "") :
|
||||||
|
# get taosBenchmark path
|
||||||
|
bmFile = epath.binFile("taosBenchmark")
|
||||||
|
if eos.isWin():
|
||||||
|
bmFile += ".exe"
|
||||||
|
|
||||||
|
# run
|
||||||
|
if command != "":
|
||||||
|
eos.exe(bmFile + " " + command)
|
||||||
|
if json != "":
|
||||||
|
eos.exe(bmFile + " -f " + json)
|
||||||
|
|
||||||
|
# get current directory file name
|
||||||
|
def curFile(fullPath, file):
|
||||||
|
return os.path.dirname(fullPath) + "/" + file
|
|
@ -1,83 +0,0 @@
|
||||||
###################################################################
|
|
||||||
# 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 os
|
|
||||||
from frame.log import *
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TDFindPath:
|
|
||||||
"""This class is for finding path within TDengine
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self.file = ""
|
|
||||||
|
|
||||||
|
|
||||||
def init(self, file):
|
|
||||||
"""[summary]
|
|
||||||
|
|
||||||
Args:
|
|
||||||
file (str): the file location you want to start the query. Generally using __file__
|
|
||||||
"""
|
|
||||||
self.file = file
|
|
||||||
|
|
||||||
def getTaosdemoPath(self):
|
|
||||||
"""for finding the path of directory containing taosdemo
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: the path to directory containing taosdemo
|
|
||||||
"""
|
|
||||||
selfPath = os.path.dirname(os.path.realpath(self.file))
|
|
||||||
|
|
||||||
if ("community" in selfPath):
|
|
||||||
projPath = selfPath[:selfPath.find("community")]
|
|
||||||
else:
|
|
||||||
projPath = selfPath[:selfPath.find("tests")]
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(projPath):
|
|
||||||
if ("taosd" in files):
|
|
||||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
|
||||||
if ("packaging" not in rootRealPath):
|
|
||||||
buildPath = root[:len(root)-len("/build/bin")]
|
|
||||||
break
|
|
||||||
if (buildPath == ""):
|
|
||||||
tdLog.exit("taosd not found!")
|
|
||||||
else:
|
|
||||||
tdLog.info(f"taosd found in {buildPath}")
|
|
||||||
return buildPath + "/build/bin/"
|
|
||||||
|
|
||||||
def getTDenginePath(self):
|
|
||||||
"""for finding the root path of TDengine
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: the root path of TDengine
|
|
||||||
"""
|
|
||||||
selfPath = os.path.dirname(os.path.realpath(self.file))
|
|
||||||
|
|
||||||
if ("community" in selfPath):
|
|
||||||
projPath = selfPath[:selfPath.find("community")]
|
|
||||||
else:
|
|
||||||
projPath = selfPath[:selfPath.find("tests")]
|
|
||||||
print(projPath)
|
|
||||||
for root, dirs, files in os.walk(projPath):
|
|
||||||
if ("sim" in dirs):
|
|
||||||
print(root)
|
|
||||||
rootRealPath = os.path.realpath(root)
|
|
||||||
if (rootRealPath == ""):
|
|
||||||
tdLog.exit("TDengine not found!")
|
|
||||||
else:
|
|
||||||
tdLog.info(f"TDengine found in {rootRealPath}")
|
|
||||||
return rootRealPath
|
|
||||||
|
|
||||||
tdFindPath = TDFindPath()
|
|
|
@ -535,6 +535,16 @@ class TDSql:
|
||||||
tdLog.info("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args)
|
tdLog.info("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args)
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
# check like select count(*) ... sql
|
||||||
|
def checkAgg(self, sql, expectCnt):
|
||||||
|
self.query(sql)
|
||||||
|
self.checkRowCol(0, 0, expectCnt)
|
||||||
|
|
||||||
|
# get first value
|
||||||
|
def getFirstValue(self, sql) :
|
||||||
|
self.query(sql)
|
||||||
|
return self.getData(0, 0)
|
||||||
|
|
||||||
def get_times(self, time_str, precision="ms"):
|
def get_times(self, time_str, precision="ms"):
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
if time_str[-1] not in TAOS_TIME_INIT:
|
if time_str[-1] not in TAOS_TIME_INIT:
|
||||||
|
@ -602,6 +612,7 @@ class TDSql:
|
||||||
if self.cursor.istype(col, "BIGINT UNSIGNED"):
|
if self.cursor.istype(col, "BIGINT UNSIGNED"):
|
||||||
return "BIGINT UNSIGNED"
|
return "BIGINT UNSIGNED"
|
||||||
|
|
||||||
|
'''
|
||||||
def taosdStatus(self, state):
|
def taosdStatus(self, state):
|
||||||
tdLog.sleep(5)
|
tdLog.sleep(5)
|
||||||
pstate = 0
|
pstate = 0
|
||||||
|
@ -630,7 +641,7 @@ class TDSql:
|
||||||
tdLog.exit("taosd state is %d != expect:%d" %args)
|
tdLog.exit("taosd state is %d != expect:%d" %args)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
'''
|
|
||||||
def haveFile(self, dir, state):
|
def haveFile(self, dir, state):
|
||||||
if os.path.exists(dir) and os.path.isdir(dir):
|
if os.path.exists(dir) and os.path.isdir(dir):
|
||||||
if not os.listdir(dir):
|
if not os.listdir(dir):
|
||||||
|
|
Loading…
Reference in New Issue