From d27848fe3b07b01c3734620e91e117e63a3d9987 Mon Sep 17 00:00:00 2001
From: Alex Duan <51781608+DuanKuanJun@users.noreply.github.com>
Date: Thu, 20 Mar 2025 15:59:07 +0800
Subject: [PATCH] docs: query forbid super table and special-table together
(#30284)
* docs: query forbid super table and special-table together
* fix: taosBenchmark official case add to CI
* fix: tmq check consumer result
* docs: adjust json format and add note tips for both query
* docs: json format indent for query.json
* fix: forbid both query from v3.3.5.6
---
.../14-reference/02-tools/10-taosbenchmark.md | 10 +
.../14-reference/02-tools/10-taosbenchmark.md | 11 +
.../benchmark/basic/json/queryModeSpec.json | 2 +-
.../basic/json/queryModeSpecMix.json | 2 +-
.../basic/json/queryModeSpecMixBatch.json | 2 +-
.../basic/json/queryModeSpecMixBatchRest.json | 2 +-
.../basic/json/queryModeSpecMixRest.json | 2 +-
.../basic/json/queryModeSpecRest.json | 2 +-
.../benchmark/basic/json/queryModeSuper.json | 2 +-
.../basic/json/queryModeSuperRest.json | 2 +-
.../army/tools/benchmark/basic/websiteCase.py | 257 ++++++++++++++++++
tests/parallel_test/cases.task | 1 +
tools/taos-tools/example/insert.json | 2 +-
tools/taos-tools/example/query.json | 15 +-
tools/taos-tools/example/queryStb.json | 24 ++
15 files changed, 314 insertions(+), 22 deletions(-)
create mode 100644 tests/army/tools/benchmark/basic/websiteCase.py
create mode 100644 tools/taos-tools/example/queryStb.json
diff --git a/docs/en/14-reference/02-tools/10-taosbenchmark.md b/docs/en/14-reference/02-tools/10-taosbenchmark.md
index c85893b51b..eae5085853 100644
--- a/docs/en/14-reference/02-tools/10-taosbenchmark.md
+++ b/docs/en/14-reference/02-tools/10-taosbenchmark.md
@@ -355,6 +355,7 @@ Specify the configuration parameters for tag and data columns in `super_tables`
`query_times` specifies the number of times to run the query, numeric type.
+**Note: from version 3.3.5.6 and beyond, simultaneous configuration for `specified_table_query` and `super_table_query` in a JSON file is no longer supported **
For other common parameters, see [General Configuration Parameters](#general-configuration-parameters)
@@ -484,6 +485,15 @@ Note: Data types in the taosBenchmark configuration file must be in lowercase to
+
+queryStb.json
+
+```json
+{{#include /TDengine/tools/taos-tools/example/queryStb.json}}
+```
+
+
+
#### Subscription Example
diff --git a/docs/zh/14-reference/02-tools/10-taosbenchmark.md b/docs/zh/14-reference/02-tools/10-taosbenchmark.md
index a596d8e151..6d173142fb 100644
--- a/docs/zh/14-reference/02-tools/10-taosbenchmark.md
+++ b/docs/zh/14-reference/02-tools/10-taosbenchmark.md
@@ -263,6 +263,8 @@ taosBenchmark -f
其它通用参数详见 [通用配置参数](#通用配置参数)。
+**说明:从 v3.3.5.6 及以上版本不再支持 json 文件中同时配置 `specified_table_query` 和 `super_table_query`**
+
#### 执行指定查询语句
查询指定表(可以指定超级表、子表或普通表)的配置参数在 `specified_table_query` 中设置。
@@ -389,6 +391,15 @@ taosBenchmark -f
+
+queryStb.json
+
+```json
+{{#include /TDengine/tools/taos-tools/example/queryStb.json}}
+```
+
+
+
### 订阅 JSON 示例
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpec.json b/tests/army/tools/benchmark/basic/json/queryModeSpec.json
index 533cb05c2b..5b7420a973 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpec.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpec.json
@@ -10,7 +10,7 @@
"query_times": 100,
"query_mode": "taosc",
"specified_table_query": {
- "concurrent": 3,
+ "threads": 3,
"sqls": [
{
"sql": "select last_row(*) from meters"
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMix.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMix.json
index 39a9593d2e..6418adc35c 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpecMix.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMix.json
@@ -10,7 +10,7 @@
"query_times": 100,
"query_mode": "taosc",
"specified_table_query": {
- "concurrent": 4,
+ "threads": 4,
"mixed_query": "yes",
"sqls": [
{
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json
index 6740c585c3..97b7be72ea 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatch.json
@@ -10,7 +10,7 @@
"query_times": 5,
"query_mode": "taosc",
"specified_table_query": {
- "concurrent": 5,
+ "threads": 5,
"query_interval": 1000,
"mixed_query": "yes",
"batch_query": "yes",
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json
index b2ffbe1434..9cd21bd1fc 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMixBatchRest.json
@@ -10,7 +10,7 @@
"query_times": 5,
"query_mode": "taosc",
"specified_table_query": {
- "concurrent": 5,
+ "threads": 5,
"query_interval": 100,
"mixed_query": "yes",
"batch_query": "no",
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecMixRest.json b/tests/army/tools/benchmark/basic/json/queryModeSpecMixRest.json
index 5d962f1354..35b1fa0188 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpecMixRest.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpecMixRest.json
@@ -10,7 +10,7 @@
"query_times": 100,
"query_mode": "rest",
"specified_table_query": {
- "concurrent": 3,
+ "threads": 3,
"mixed_query": "yes",
"sqls": [
{
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSpecRest.json b/tests/army/tools/benchmark/basic/json/queryModeSpecRest.json
index 5b00ee6479..561f7c1883 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSpecRest.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSpecRest.json
@@ -10,7 +10,7 @@
"query_times": 100,
"query_mode": "rest",
"specified_table_query": {
- "concurrent": 3,
+ "threads": 3,
"sqls": [
{
"sql": "select last_row(*) from meters"
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSuper.json b/tests/army/tools/benchmark/basic/json/queryModeSuper.json
index 9d20154d49..3682594b42 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSuper.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSuper.json
@@ -12,7 +12,7 @@
"query_mode": "taosc",
"super_table_query": {
"stblname": "meters",
- "concurrent": 3,
+ "threads": 3,
"query_interval": 0,
"sqls": [
{
diff --git a/tests/army/tools/benchmark/basic/json/queryModeSuperRest.json b/tests/army/tools/benchmark/basic/json/queryModeSuperRest.json
index 4ae43062a6..1380a958c0 100644
--- a/tests/army/tools/benchmark/basic/json/queryModeSuperRest.json
+++ b/tests/army/tools/benchmark/basic/json/queryModeSuperRest.json
@@ -12,7 +12,7 @@
"query_mode": "rest",
"super_table_query": {
"stblname": "meters",
- "concurrent": 3,
+ "threads": 3,
"query_interval": 0,
"sqls": [
{
diff --git a/tests/army/tools/benchmark/basic/websiteCase.py b/tests/army/tools/benchmark/basic/websiteCase.py
new file mode 100644
index 0000000000..67b5620931
--- /dev/null
+++ b/tests/army/tools/benchmark/basic/websiteCase.py
@@ -0,0 +1,257 @@
+###################################################################
+# 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
+import json
+import sys
+import os
+import time
+import datetime
+import platform
+import subprocess
+
+import frame
+import frame.eos
+import frame.etool
+from frame.log import *
+from frame.cases import *
+from frame.sql import *
+from frame.caseBase import *
+from frame import *
+
+
+# reomve single and double quotation
+def removeQuotation(origin):
+ value = ""
+ for c in origin:
+ if c != '\'' and c != '"':
+ value += c
+
+ return value
+
+class TDTestCase(TBase):
+ def caseDescription(self):
+ """
+ taosBenchmark query->Basic test cases
+ """
+
+ def runSeconds(self, command, timeout = 180):
+ tdLog.info(f"runSeconds {command} ...")
+ process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process.wait(timeout)
+
+ # get output
+ output = process.stdout.read().decode(encoding="gbk")
+ error = process.stderr.read().decode(encoding="gbk")
+ return output, error
+
+ def getKeyValue(self, content, key, end):
+ # find key
+ s = content.find(key)
+ if s == -1:
+ return False,""
+
+ # skip self
+ s += len(key)
+ # skip blank
+ while s < len(content):
+ if content[s] != " ":
+ break
+ s += 1
+
+ # end check
+ if s + 1 == len(content):
+ return False, ""
+
+ # find end
+ if len(end) == 0:
+ e = -1
+ else:
+ e = content.find(end, s)
+
+ # get value
+ if e == -1:
+ value = content[s : ]
+ else:
+ value = content[s : e]
+
+ return True, value
+
+ def getDbRows(self, times):
+ sql = f"select count(*) from test.meters"
+ tdSql.waitedQuery(sql, 1, times)
+ dbRows = tdSql.getData(0, 0)
+ return dbRows
+
+ def checkItem(self, output, key, end, expect, equal):
+ ret, value = self.getKeyValue(output, key, end)
+ if ret == False:
+ tdLog.exit(f"not found key:{key}. end:{end} output:\n{output}")
+
+ fval = float(value)
+ # compare
+ if equal and fval != expect:
+ tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:'{key}' end:'{end}' output:\n{output}")
+ elif equal == False and fval <= expect:
+ tdLog.exit(f"failed because {fval} <= {expect}, key:'{key}' end:'{end}' output:\n{output}")
+ else:
+ # succ
+ if equal:
+ tdLog.info(f"check successfully. key:'{key}' expect:{expect} real:{fval}")
+ else:
+ tdLog.info(f"check successfully. key:'{key}' {fval} > {expect}")
+
+
+ def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
+ # run
+ cmd = f"{benchmark} -f {jsonFile}"
+ output, error = self.runSeconds(cmd)
+
+ if specMode :
+ label = "specified_table_query"
+ else:
+ label = "super_table_query"
+
+ #
+ # check insert result
+ #
+ with open(jsonFile, "r") as file:
+ data = json.load(file)
+
+ queryTimes = data["query_times"]
+ # contineIfFail
+ try:
+ continueIfFail = data["continue_if_fail"]
+ except:
+ continueIfFail = "no"
+
+ threads = data[label]["threads"]
+ sqls = data[label]["sqls"]
+
+
+ # batch_query
+ try:
+ batchQuery = data[label]["batch_query"]
+ except:
+ batchQuery = "no"
+
+ # mixed_query
+ try:
+ mixedQuery = data[label]["mixed_query"]
+ except:
+ mixedQuery = "no"
+
+ tdLog.info(f"queryTimes={queryTimes} threads={threads} mixedQuery={mixedQuery} "
+ f"batchQuery={batchQuery} len(sqls)={len(sqls)} label={label}\n")
+
+ totalQueries = 0
+ threadQueries = 0
+ QPS = 10
+
+ if continueIfFail.lower() == "yes":
+ allEnd = " "
+ else:
+ allEnd = "\n"
+
+ if specMode and mixedQuery.lower() != "yes":
+ # spec
+ threadQueries = queryTimes * threads
+ totalQueries = queryTimes * threads * len(sqls)
+ threadKey = f"complete query with {threads} threads and "
+ qpsKey = "QPS: "
+ avgKey = "query delay avg: "
+ minKey = "min:"
+ else:
+ # spec mixed or super
+
+ if specMode:
+ totalQueries = queryTimes * len(sqls)
+ # spec mixed
+ if batchQuery.lower() == "yes":
+ # batch
+ threadQueries = len(sqls)
+ QPS = 2
+ else:
+ threadQueries = totalQueries
+ else:
+ # super
+ totalQueries = queryTimes * len(sqls) * tbCnt
+ threadQueries = totalQueries
+
+ nSql = len(sqls)
+ if specMode and nSql < threads :
+ tdLog.info(f"set threads = {nSql} because len(sqls) < threads")
+ threads = nSql
+ threadKey = f"using {threads} threads complete query "
+ qpsKey = ""
+ avgKey = "avg delay:"
+ minKey = "min delay:"
+
+ items = [
+ [threadKey, " ", threadQueries, True],
+ [qpsKey, " ", 5, False], # qps need > 1
+ [avgKey, "s", 0, False],
+ [minKey, "s", 0, False],
+ ["max: ", "s", 0, False],
+ ["p90: ", "s", 0, False],
+ ["p95: ", "s", 0, False],
+ ["p99: ", "s", 0, False],
+ ["INFO: Spend ", " ", 0, False],
+ ["completed total queries: ", ",", totalQueries, True],
+ ["the QPS of all threads:", allEnd, QPS , False] # all qps need > 5
+ ]
+
+ # check
+ for item in items:
+ if len(item[0]) > 0:
+ self.checkItem(output, item[0], item[1], item[2], item[3])
+
+
+
+ # tmq check
+ def checkTmqJson(self, benchmark, json):
+ OK_RESULT = "Consumed total msgs: 30, total rows: 300000"
+ cmd = benchmark + " -f " + json
+ output,error = frame.eos.run(cmd, 600)
+ if output.find(OK_RESULT) != -1:
+ tdLog.info(f"succ: {cmd} found '{OK_RESULT}'")
+ else:
+ tdLog.exit(f"failed: {cmd} not found {OK_RESULT} in:\n{output} \nerror:{error}")
+
+
+ def run(self):
+ tbCnt = 10
+ benchmark = etool.benchMarkFile()
+
+ # insert
+ json = "../../tools/taos-tools/example/insert.json"
+ self.insertBenchJson(json, checkStep=True)
+
+ # query
+ json = "../../tools/taos-tools/example/query.json"
+ self.checkAfterRun(benchmark, json, True, tbCnt)
+ json = "../../tools/taos-tools/example/queryStb.json"
+ self.checkAfterRun(benchmark, json, False, tbCnt)
+
+ # tmq
+ json = "../../tools/taos-tools/example/tmq.json"
+ self.checkTmqJson(benchmark, json)
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task
index 3ffe5fcc5d..054014d89c 100644
--- a/tests/parallel_test/cases.task
+++ b/tests/parallel_test/cases.task
@@ -77,6 +77,7 @@
#
# benchmark 64 cases
+,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/websiteCase.py
,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/rest_insert_alltypes_json.py -R
,,n,army,python3 ./test.py -f tools/benchmark/basic/taosdemoTestQueryWithJson-mixed-query.py -R
,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_sample_csv_json.py
diff --git a/tools/taos-tools/example/insert.json b/tools/taos-tools/example/insert.json
index 1e40883b8b..0f3316fd5b 100644
--- a/tools/taos-tools/example/insert.json
+++ b/tools/taos-tools/example/insert.json
@@ -27,7 +27,7 @@
{
"name": "meters",
"child_table_exists": "no",
- "childtable_count": 1000,
+ "childtable_count": 10,
"childtable_prefix": "d",
"auto_create_table": "no",
"batch_create_tbl_num": 5,
diff --git a/tools/taos-tools/example/query.json b/tools/taos-tools/example/query.json
index bf74d8da3f..4d218eca7a 100644
--- a/tools/taos-tools/example/query.json
+++ b/tools/taos-tools/example/query.json
@@ -6,13 +6,13 @@
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
- "continue_if_fail": "yes",
+ "continue_if_fail": "yes",
"databases": "test",
"query_times": 10,
"query_mode": "taosc",
"specified_table_query": {
"query_interval": 1,
- "concurrent": 3,
+ "threads": 3,
"sqls": [
{
"sql": "select last_row(*) from meters",
@@ -23,16 +23,5 @@
"result": "./query_res1.txt"
}
]
- },
- "super_table_query": {
- "stblname": "meters",
- "query_interval": 1,
- "threads": 3,
- "sqls": [
- {
- "sql": "select last_row(ts) from xxxx",
- "result": "./query_res2.txt"
- }
- ]
}
}
diff --git a/tools/taos-tools/example/queryStb.json b/tools/taos-tools/example/queryStb.json
new file mode 100644
index 0000000000..cb44e0dfc1
--- /dev/null
+++ b/tools/taos-tools/example/queryStb.json
@@ -0,0 +1,24 @@
+{
+ "filetype": "query",
+ "cfgdir": "/etc/taos",
+ "host": "127.0.0.1",
+ "port": 6030,
+ "user": "root",
+ "password": "taosdata",
+ "confirm_parameter_prompt": "no",
+ "continue_if_fail": "yes",
+ "databases": "test",
+ "query_times": 10,
+ "query_mode": "taosc",
+ "super_table_query": {
+ "stblname": "meters",
+ "query_interval": 1,
+ "threads": 3,
+ "sqls": [
+ {
+ "sql": "select last_row(ts) from xxxx",
+ "result": "./query_res2.txt"
+ }
+ ]
+ }
+}