From 152d945f3c7a7fcec18660b790de485e2c9f56f0 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 27 Nov 2024 11:44:57 +0800 Subject: [PATCH] enh: add case to describe --- tests/army/cmdline/json/taosCli.json | 57 ++++++++++++++++++++ tests/army/cmdline/taosCli.py | 63 ++++++++++++++++++++++ tests/army/frame/caseBase.py | 79 +++++++++++++++++++++++++++- tests/army/frame/eutil.py | 11 +++- 4 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 tests/army/cmdline/json/taosCli.json create mode 100644 tests/army/cmdline/taosCli.py diff --git a/tests/army/cmdline/json/taosCli.json b/tests/army/cmdline/json/taosCli.json new file mode 100644 index 0000000000..2dcd28afdb --- /dev/null +++ b/tests/army/cmdline/json/taosCli.json @@ -0,0 +1,57 @@ +{ + "filetype":"insert", + "cfgdir":"/etc/taos", + "host":"127.0.0.1", + "port":6030, + "user":"root", + "password":"taosdata", + "thread_count":1, + "create_table_thread_count":1, + "confirm_parameter_prompt":"no", + "prepare_rand":100, + "num_of_records_per_req":100, + "databases": [ + { + "dbinfo":{ + "name":"test", + "drop":"yes" + }, + "super_tables":[ + { + "name":"meters", + "child_table_exists":"no", + "childtable_prefix":"d", + "data_source":"rand", + "insert_mode":"taosc", + "childtable_count": 1, + "insert_rows":10, + "timestamp_step":1000, + "start_timestamp":"2022-10-01 00:00:00.000", + "columns":[ + { "type": "int", "count": 1000, "max": 2000, "min": 0 } + ], + "tags":[ + { + "type":"binary", + "name":"location", + "max":64, + "min":1, + "values":[ + "San Francisco", + "Los Angles", + "San Diego", + "San Jose", + "Palo Alto", + "Campbell", + "Mountain View", + "Sunnyvale", + "Santa Clara", + "Cupertino" + ] + } + ] + } + ] + } + ] +} diff --git a/tests/army/cmdline/taosCli.py b/tests/army/cmdline/taosCli.py new file mode 100644 index 0000000000..3248ac85ba --- /dev/null +++ b/tests/army/cmdline/taosCli.py @@ -0,0 +1,63 @@ +################################################################### +# 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 sys +import time +import random + +import frame.eos +import frame.etime +import frame.etool +import frame.etool +import frame.etool +import frame.etool +import taos +import frame.etool +import frame + +from frame.log import * +from frame.sql import * +from frame.cases import * +from frame.caseBase import * +from frame.srvCtl import * +from frame import * + + +class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"query" + } + + def checkDescribe(self): + tdLog.info(f"check describe show full.") + + # insert + json = "cmdline/json/taosCli.json" + db, stb, childCount, insertRows = self.insertBenchJson(json) + sql = f"describe {db}.{stb};" + # check result + tdSql.query(sql) + tdSql.checkRows(2 + 1000) + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + + # check show whole + self.checkDescribe() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/army/frame/caseBase.py b/tests/army/frame/caseBase.py index 491e432df7..9cd90a4d6f 100644 --- a/tests/army/frame/caseBase.py +++ b/tests/army/frame/caseBase.py @@ -17,9 +17,13 @@ import time import datetime import random import copy +import json +import frame.eutil from frame.log import * from frame.sql import * +from frame import * +import frame # test case base class TBase: @@ -305,4 +309,77 @@ class TBase: if strs != "": strs += sepa strs += f"'{ls}'" - return strs \ No newline at end of file + return strs + +# +# taosBenchmark +# + + # run taosBenchmark and check insert Result + def insertBenchJson(self, jsonFile, options="", checkStep=False): + # exe insert + cmd = f"{options} -f {jsonFile}" + frame.etool.benchMark(command = cmd) + + # + # check insert result + # + with open(jsonFile, "r") as file: + data = json.load(file) + + db = data["databases"][0]["dbinfo"]["name"] + stb = data["databases"][0]["super_tables"][0]["name"] + child_count = data["databases"][0]["super_tables"][0]["childtable_count"] + insert_rows = data["databases"][0]["super_tables"][0]["insert_rows"] + timestamp_step = data["databases"][0]["super_tables"][0]["timestamp_step"] + + # drop + try: + drop = data["databases"][0]["dbinfo"]["drop"] + except: + drop = "yes" + + # command is first + if options.find("-Q") != -1: + drop = "no" + + # cachemodel + try: + cachemode = data["databases"][0]["dbinfo"]["cachemodel"] + except: + cachemode = None + + # vgropus + try: + vgroups = data["databases"][0]["dbinfo"]["vgroups"] + except: + vgroups = None + + tdLog.info(f"get json info: db={db} stb={stb} child_count={child_count} insert_rows={insert_rows} \n") + + # all count insert_rows * child_table_count + sql = f"select * from {db}.{stb}" + tdSql.query(sql) + tdSql.checkRows(child_count * insert_rows) + + # timestamp step + if checkStep: + sql = f"select * from (select diff(ts) as dif from {db}.{stb} partition by tbname) where dif != {timestamp_step};" + tdSql.query(sql) + tdSql.checkRows(0) + + if drop.lower() == "yes": + # check database optins + sql = f"select `vgroups`,`cachemodel` from information_schema.ins_databases where name='{db}';" + tdSql.query(sql) + + if cachemode != None: + + value = frame.eutil.removeQuota(cachemode) + tdLog.info(f" deal both origin={cachemode} after={value}") + tdSql.checkData(0, 1, value) + + if vgroups != None: + tdSql.checkData(0, 0, vgroups) + + return db, stb,child_count, insert_rows \ No newline at end of file diff --git a/tests/army/frame/eutil.py b/tests/army/frame/eutil.py index a32e6e9a38..459a45b0b0 100644 --- a/tests/army/frame/eutil.py +++ b/tests/army/frame/eutil.py @@ -25,4 +25,13 @@ import psutil # cpu frequent as random def cpuRand(max): decimal = int(str(psutil.cpu_freq().current).split(".")[1]) - return decimal % max \ No newline at end of file + return decimal % max + +# remove single and doulbe quotation +def removeQuota(origin): + value = "" + for c in origin: + if c != '\'' and c != '"': + value += c + + return value \ No newline at end of file