new case arch demo
This commit is contained in:
parent
de49403b5f
commit
b1f409be37
|
@ -1,3 +1,4 @@
|
|||
## \brief Test create view and drop view functions
|
||||
sql connect
|
||||
sql use testa;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
::: data_write.stmt.test_stmt_set_tbname_tag
|
|
@ -0,0 +1 @@
|
|||
::: high_availability.2_replica.test_replica2
|
|
@ -0,0 +1,205 @@
|
|||
# 用例编写规范
|
||||
## 1. 背景
|
||||
在 TDengine 的测试中,长期存在以下两个问题:
|
||||
### 问题一:测试用例缺乏整理
|
||||
在 TDengine 的 CI 测试中,执行了 1,600+ 个测试用例。但随着产品迭代,这些用例覆盖了哪些功能,没有覆盖哪些功能,缺乏文档整理。构建和维护一个详尽的测试用例描述文档,将有助于我们识别缺失的用例,并进行针对性地补充。但使用传统的方法,用文档或测试用例管理系统来维护测试用例,存在以下两个弊端:
|
||||
|
||||
1. 维护成本高
|
||||
2. 文档和代码分离,导致文档容易“生锈”
|
||||
### 问题二:多个测试框架并存
|
||||
由于历史原因,TDengine 的 CI 测试用例是使用不同的语言、框架 (包括 TSIM, System Test, ARMY 等) 编写的,分布在 TDengine/tests 目录中的不同的子目录下,用例的管理稍显混乱。为了执行“全量测试”,需要使用不同的框架,分别执行多个不同子目录下的用例才能完成。每个框架编写的用例,编写方式和执行方式都存在差异,也很难生成统一风格的测试报告。## 2. 变更历史
|
||||
|
||||
## 2. 变更历史
|
||||
| 日期 | 版本 | 负责人 |主要修改内容|
|
||||
|:-----------|:-----------|:-------------| :--- |
|
||||
| 2025/2/12 | 0.1 | @冯超 @霍宏 @王旭 | 初始文档|
|
||||
| 2025/2/17 | 0.2 | @霍宏 @王旭 | 修改用例编写规范 |
|
||||
|
||||
## 3. 解决方案
|
||||
为了解决以上问题,平台部经和研发负责人的讨论,达成一致意见,研发部需要进行以下调整:
|
||||
|
||||
1. 平台部负责对现有的测试框架进行整合和优化,以后所有用例的编写,均使用统一的语言、框架,主要改动如下:
|
||||
- 统一使用 Python 进行功能用例的编写
|
||||
- 引入 pytest 作为 test runner, pytest 是 Python 生态中应用非常广泛,可以方便地控制用例的执行粒度(执行一个用例、一组用例、按 marker 执行用例等),除此以外,它还提供了丰富的插件,例如:与测试报告相关的 allure-pytest 等
|
||||
- 将 system-test, TestNG 等现有框架的核心库进行整合,以简化测试用例的编写
|
||||
2. 产品研发人员,编写用例时,需要以统一的格式为用例添加描述信息等 metadata, 平台部将使用工具,以自动化的方式,从测试用例代码自动生成测试用例文档,这也符合我们公司推行的“一切代码化”的要求。
|
||||
3. 工具平台部将使用工具 mkdocs + mkdocstrings 提取以上信息,生成用例文档,并将其部署至 Github Pages 或内网
|
||||
## 4. 目标和范围
|
||||
本规范适用于以下范围:
|
||||
|
||||
- 仓库
|
||||
- TDengine: /tests/test_new (暂定名,为了和当前的 /tests 目录下存量用例进行区分)
|
||||
- taosX: /tests/e2e
|
||||
- 测试类型:端到端的功能测试
|
||||
- 编程语言:Python
|
||||
|
||||
其它仓库或其它类型的测试,基于不同框架/语言实现,暂时不对用例规范做强制要求,可仅作为参考。
|
||||
## 5. 用例编写规范
|
||||
### 5.1 用例目录
|
||||
对用例目录的要求如下:
|
||||
|
||||
1. 新增用例统一存放至 tests/test_new
|
||||
2. 用例采用两级目录的形式组织,详见:附录1
|
||||
### 5.2 用例文件
|
||||
对用例文件的要求如下:
|
||||
|
||||
1. 用例 Python 文件命名应以 test_开头,例如:test_join.py
|
||||
5.3 用例规范
|
||||
对用例文件内容的要求如下:
|
||||
|
||||
1. 用例 Python 文件中,需要定义一个 Class,以 Test 开头命名,建议与文件名一致,例如:TestJoin
|
||||
2. 一个用例 Python 文件可以包含多个用例,以 test class 下的 test method 的形式存在,test method 的命名需要以 test_ 开头,例如:test_join()
|
||||
3. Class 中通常定义 init(),run(), stop()等方法,用于用例初始化数据、用例执行、用例清理环境等操作;这里,主要是为了与当前的 system-test 框架兼容,保证大家使用新规范编写的用例,可以用当前的框架执行,待新框架的整合完成后,将不存在这种要求,平台将进行统一的替换。
|
||||
4. run()方法中,需要调用该类中定义的所有 test methods, 不涉及其他逻辑
|
||||
5. 在每个 test method 中,以标准的 Python docstring 的形式,添加用例描述信息,包括多个字段,每个字段之间用空行间隔,字段及其要求,如下所示:
|
||||
| 字段名称|字段描述|是否必填|
|
||||
|:--------| ---- | :---: |
|
||||
| |用例的一句话描述,仅支持一行|是|
|
||||
| |用例的详细描述,支持多行|是|
|
||||
| Since | 用例开始支持的 TDengine 版本,新 Feature 必填 | 是 |
|
||||
| Lables | 用例标签,多个标签用英文逗号分隔,标签采用 snake case, 即全部小写,多个单词用 _ 连接|否|
|
||||
| Jira | Jira ID, 多个用英文逗号分隔 | 否 |
|
||||
| History |用例变更历史|否|
|
||||
|
||||
### 5.4 其它要求、建议
|
||||
|
||||
1. 建议相同环境/数据配置的用例放在同一文件中执行,提高运行效率
|
||||
2. 用例中的调试信息,应使用框架提供的 log 打印,例如:util.log.tdLog,而不要使用 print() 函数
|
||||
### 5.5 用例模板
|
||||
```Python
|
||||
# tests/test_new/xxx/xxx/test_xxx.py
|
||||
import ...
|
||||
|
||||
class TestXxxx:
|
||||
def init(self, args=value ...):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
...
|
||||
|
||||
|
||||
def user_defined_function(self, args=value ...):
|
||||
...
|
||||
|
||||
|
||||
def test_template(self):
|
||||
"""用例目标,必填,用一行简短总结
|
||||
<空行>
|
||||
用例详细描述,必填,允许多行
|
||||
<空行>
|
||||
Since: 用例开始支持的TDengine版本,新增用例必填
|
||||
<空行>
|
||||
Labels: 筛选标签,选填,多个标签用英文逗号分隔
|
||||
<空行>
|
||||
Jira: 相关jira任务id,选填
|
||||
<空行>
|
||||
History: 用例变更历史,选填,每行一次变更信息
|
||||
- 日期1 变更人1 变更原因1
|
||||
- 日期2 变更人2 变更原因2
|
||||
"""
|
||||
... # test case code
|
||||
|
||||
|
||||
def test_demo(self):
|
||||
"""测试超级表插入各种数据类型
|
||||
|
||||
使用多种数据类型创建超级表,向超级表插入数据,
|
||||
包括:常规数据,空数据,边界值等,插入均执行成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable, data_type
|
||||
|
||||
Jira: TD-12345, TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
- 2024-2-7 Huo Hong updated for feature TD-23456
|
||||
"""
|
||||
... # test case code
|
||||
|
||||
|
||||
def run(self):
|
||||
self.test_template()
|
||||
self.test_demo()
|
||||
...# case function list
|
||||
|
||||
|
||||
def stop(self):
|
||||
...
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
```
|
||||
说明:
|
||||
|
||||
- 在 Docstring 中,每一部分之间需要用空行分隔,否则会出现格式错误
|
||||
|
||||
## 6. 附录
|
||||
### 6.1 附录1:用例目录结构
|
||||
新增用例在 TDengine/tests/test_new 目录下,采用二级目录的形式组织,以下仅作为建议,大家可以提出 comments:
|
||||
|
||||
```
|
||||
test_new/
|
||||
├── data_write/
|
||||
│ ├── csv/
|
||||
│ ├── sql_statement/
|
||||
│ ├── stmt/
|
||||
│ ├── stmt2/
|
||||
│ └── schemaless/
|
||||
├── metadata/
|
||||
│ ├── child_table/
|
||||
│ ├── data_type/
|
||||
│ ├── db/
|
||||
│ ├── dnode/
|
||||
│ ├── mnode/
|
||||
│ ├── naming_rule/
|
||||
│ ├── qnode/
|
||||
│ ├── reqular_table/
|
||||
│ ├── snode/
|
||||
│ ├── super_table/
|
||||
│ ├── system_table/
|
||||
│ ├── tag_index/
|
||||
│ └── time_precision/
|
||||
├── high_availability/
|
||||
│ ├── 2_replica/
|
||||
│ ├── 3_replica/
|
||||
│ ├── active_active/
|
||||
│ ├── cluster_expansion_reduction/
|
||||
│ └── replica_change/
|
||||
├── operation/
|
||||
│ ├── balance/
|
||||
│ ├── configuration/
|
||||
│ ├── redistribute/
|
||||
│ ├── restore/
|
||||
│ ├── slow_query/
|
||||
│ ├── split/
|
||||
│ ├── transaction/
|
||||
│ └── upgrade/
|
||||
├── query/
|
||||
│ ├── case_when/
|
||||
│ ├── escape_character/
|
||||
│ ├── function/
|
||||
│ ├── having/
|
||||
│ ├── hint/
|
||||
│ ├── index/
|
||||
│ ├── join/
|
||||
│ ├── nested/
|
||||
│ ├── operator/
|
||||
│ ├── pseudo_column/
|
||||
│ ├── sql_syntax/
|
||||
│ ├── union/
|
||||
│ ├── view/
|
||||
│ └── window/
|
||||
├── security/
|
||||
│ ├── audit/
|
||||
│ ├── authorization/
|
||||
│ ├── permission/
|
||||
│ └── encryption/
|
||||
├── storage/
|
||||
│ ├── compress/
|
||||
│ ├── multilevel/
|
||||
│ ├── sma/
|
||||
│ ├── tsma/
|
||||
│ └── s3/
|
||||
├── stream/
|
||||
├── tdgpt/
|
||||
├── tmq/
|
||||
└── udf/
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
::: metadata.time_precision.test_precision_ns
|
|
@ -0,0 +1 @@
|
|||
::: query.function.test_sin
|
|
@ -0,0 +1 @@
|
|||
::: query.hint.test_hint
|
|
@ -0,0 +1 @@
|
|||
::: query.join.test_join
|
|
@ -9,7 +9,7 @@ from math import inf
|
|||
import taos
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
class TestInsertStb:
|
||||
def caseDescription(self):
|
||||
'''
|
||||
case1<shenglian zhou>: [TS-3932] insert into stb
|
||||
|
@ -28,7 +28,22 @@ class TDTestCase:
|
|||
tdSql.execute(f"use insert_stb")
|
||||
|
||||
|
||||
def run_normal(self):
|
||||
def test_normal(self):
|
||||
"""测试超级表基本插入操作
|
||||
|
||||
插入语句使用using、dbname.stable、tbname等关键字插入数据,插入单表数据,单表多条数据,多表多条数据,带标签插入等语句,执行成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
|
||||
print("running {}".format(__file__))
|
||||
tdSql.execute("drop database if exists insert_stb")
|
||||
tdSql.execute("create database if not exists insert_stb")
|
||||
|
@ -181,7 +196,22 @@ class TDTestCase:
|
|||
tdSql.checkData(4, 1, 1)
|
||||
tdSql.checkData(4, 2, 1)
|
||||
|
||||
def run_insert_stb(self):
|
||||
def test_insert_stb(self):
|
||||
"""测试超级表插入各种数据类型
|
||||
|
||||
使用多种数据类型创建超级表,向超级表插入数据,包括常规数据,空数据,边界值等,插入均执行成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable, dataType
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
|
||||
print("running {}".format('insert_stb'))
|
||||
self.conn.select_db('insert_stb')
|
||||
tdSql.execute('create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);')
|
||||
|
@ -349,7 +379,21 @@ class TDTestCase:
|
|||
tdSql.checkData(7, 16, '6')
|
||||
tdSql.checkData(7, 17, 6.0)
|
||||
|
||||
def run_stmt_error(self):
|
||||
def test_stmt_error(self):
|
||||
"""测试超级表插入stmt数据失败
|
||||
|
||||
创建参数绑定对象,tag设置为填充对象,绑定参数后插入预期失败
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable, negative
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
conn = self.conn
|
||||
conn.select_db('insert_stb')
|
||||
conn.execute('create table stb9(ts timestamp, f int) tags (t int)')
|
||||
|
@ -363,7 +407,21 @@ class TDTestCase:
|
|||
except Exception as err:
|
||||
print(str(err))
|
||||
|
||||
def run_consecutive_seq(self):
|
||||
def test_consecutive_seq(self):
|
||||
"""测试超级表连续插入
|
||||
|
||||
向超级表连续插入多条数据,插入均执行成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
print("running {}".format("consecutive_seq"))
|
||||
tdSql.execute("drop database if exists insert_stb3")
|
||||
tdSql.execute("create database if not exists insert_stb3")
|
||||
|
@ -616,10 +674,10 @@ class TDTestCase:
|
|||
tdSql.execute('drop database insert_stb3')
|
||||
|
||||
def run(self):
|
||||
self.run_normal()
|
||||
self.run_insert_stb()
|
||||
self.run_stmt_error()
|
||||
self.run_consecutive_seq()
|
||||
self.test_normal()
|
||||
self.test_insert_stb()
|
||||
self.test_stmt_error()
|
||||
self.test_consecutive_seq()
|
||||
|
||||
|
||||
def stop(self):
|
|
@ -29,7 +29,7 @@ import time
|
|||
# constant define
|
||||
WAITS = 5 # wait seconds
|
||||
|
||||
class TDTestCase:
|
||||
class TestStmtSetTbnameTag:
|
||||
#
|
||||
# --------------- main frame -------------------
|
||||
def caseDescription(self):
|
||||
|
@ -91,6 +91,20 @@ class TDTestCase:
|
|||
return rows
|
||||
|
||||
def test_stmt_set_tbname_tag(self,conn):
|
||||
"""测试参数绑定tbname和tag
|
||||
|
||||
创建参数绑定对象,绑定tbname和多种数据类型tag,插入数据成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stmt,
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
dbname = "stmt_tag"
|
||||
stablename = 'log'
|
||||
try:
|
|
@ -13,12 +13,28 @@ from util.sql import *
|
|||
from util.dnodes import *
|
||||
from util.log import *
|
||||
|
||||
class TDTestCase:
|
||||
class TestReplica2:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
tdLog.debug(f"start to init {__file__}")
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
||||
def test_replica2(self):
|
||||
"""测试双副本
|
||||
|
||||
创建双副本db,查看vgroups,停止dnode2和3,校验assigned
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: 3nodes, replica
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.run()
|
||||
def run(self):
|
||||
tdSql.execute('CREATE DATABASE db vgroups 1 replica 2;')
|
||||
|
|
@ -20,7 +20,7 @@ from util.log import *
|
|||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
class TDTestCase:
|
||||
class TestPrecisionNs:
|
||||
|
||||
# get col value and total max min ...
|
||||
def getColsValue(self, i, j):
|
||||
|
@ -171,7 +171,22 @@ class TDTestCase:
|
|||
return True
|
||||
|
||||
|
||||
|
||||
def test_time_macro(self):
|
||||
"""测试time函数使用ns时间戳
|
||||
|
||||
创建数据库指定precision为ns,查询语句使用ns时间戳查询、timetruncate函数使用ns时间戳查询、timediff函数使用ns时间戳查询均返回正确结果
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: precision
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.checkTimeMacro()
|
||||
|
||||
# check time macro
|
||||
def checkTimeMacro(self):
|
||||
|
@ -267,6 +282,25 @@ class TDTestCase:
|
|||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
|
||||
|
||||
def test_where(self):
|
||||
"""测试where使用ns时间戳
|
||||
|
||||
创建数据库指定precision为ns,查询语句中where使用ns时间戳查询均返回正确结果
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: precision
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.checkWhere()
|
||||
|
||||
|
||||
# where
|
||||
def checkWhere(self):
|
||||
cnt = 300
|
||||
|
@ -282,6 +316,24 @@ class TDTestCase:
|
|||
sql = f"select count(ts) from st where ts >= {start} and ts < {end}"
|
||||
self.checkExpect(sql, cnt)
|
||||
|
||||
|
||||
def test_stream(self):
|
||||
"""测试steam使用ns时间戳
|
||||
|
||||
创建数据库指定precision为ns,创建stream,查询流计算表的字段、时间戳返回正确结果
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: precision
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.checkStream()
|
||||
|
||||
# stream
|
||||
def checkStream(self):
|
||||
allRows = self.childCnt * self.childRow
|
|
@ -22,4 +22,4 @@ plugins:
|
|||
show_bases: false
|
||||
show_source: false
|
||||
show_object_full_path: false
|
||||
filters: [ "^test_", "TDTestCase" ]
|
||||
filters: [ "^test_", "^Test" ]
|
|
@ -22,7 +22,7 @@ from util.log import *
|
|||
from util.cases import *
|
||||
from util.sql import *
|
||||
|
||||
class TDTestCase:
|
||||
class TestSplitVGroup:
|
||||
|
||||
# random string
|
||||
def random_string(self, count):
|
||||
|
@ -409,6 +409,22 @@ class TDTestCase:
|
|||
# check result
|
||||
self.checkResult()
|
||||
|
||||
|
||||
def test_run(self):
|
||||
"""测试split vgroup
|
||||
|
||||
创建两个数据库,写入多条同样的数据并落盘内存中的数据,在db2上执行split vgroup,相同数据重写写入,比较两个数据库数据一致
|
||||
|
||||
Since: v3.0.6.0
|
||||
|
||||
Labels: vgroup
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
# run
|
||||
def run(self):
|
||||
# prepare env
|
|
@ -8,7 +8,7 @@ from util.sql import *
|
|||
from util.cases import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
class TestSin:
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
@ -89,6 +89,20 @@ class TDTestCase:
|
|||
|
||||
|
||||
def test_errors(self, dbname="db"):
|
||||
"""测试sin()函数error
|
||||
|
||||
执行非法select语句包含sin()函数,返回预期错误
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin, negative
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
error_sql_lists = [
|
||||
f"select sin from {dbname}.t1",
|
||||
# f"select sin(-+--+c1 ) from {dbname}.t1",
|
||||
|
@ -122,6 +136,24 @@ class TDTestCase:
|
|||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
|
||||
def test_types(self):
|
||||
"""测试sin()函数数据类型
|
||||
|
||||
select语句包含sin()函数,参数传入不同数据类型,不支持的类型返回预期错误,支持的类型返回执行成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin, dataType
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
- 2024-2-7 Hong updated for feature TD-23456
|
||||
|
||||
"""
|
||||
self.support_types()
|
||||
def support_types(self, dbname="db"):
|
||||
type_error_sql_lists = [
|
||||
f"select sin(ts) from {dbname}.t1" ,
|
||||
|
@ -193,6 +225,23 @@ class TDTestCase:
|
|||
for type_sql in type_sql_lists:
|
||||
tdSql.query(type_sql)
|
||||
|
||||
def test_basic_sin_function(self):
|
||||
"""测试sin()函数基础功能
|
||||
|
||||
使用包含sin()函数的select语句,查询空表、子表、普通表、不存在表;嵌套sin函数查询均返回成功,与聚合函数一起查询返回失败
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.basic_sin_function()
|
||||
|
||||
def basic_sin_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
|
@ -334,6 +383,20 @@ class TDTestCase:
|
|||
tdSql.query(f"select c1, sin(c1), c2, sin(c2), c3, sin(c3) from {dbname}.ct1")
|
||||
|
||||
def test_big_number(self, dbname="db"):
|
||||
"""测试sin()函数大数参数
|
||||
|
||||
使用包含sin()函数的select语句查询,参数为几十位的double参数,返回结果正确
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
|
||||
tdSql.query(f"select c1, sin(100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.checkData(4, 1, math.sin(100000000))
|
||||
|
@ -357,6 +420,23 @@ class TDTestCase:
|
|||
|
||||
tdSql.query(f"select c1, sin(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
|
||||
|
||||
def test_func_filter(self):
|
||||
"""测试sin()函数filter
|
||||
|
||||
使用包含sin()函数的where语句查询,返回结果正确
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.abs_func_filter()
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(sin(c1)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||
tdSql.checkRows(3)
|
||||
|
@ -383,6 +463,23 @@ class TDTestCase:
|
|||
tdSql.checkData(0,4,-0.100000000)
|
||||
tdSql.checkData(0,5,0.000000000)
|
||||
|
||||
|
||||
def test_basic_sin_function(self):
|
||||
"""测试sin()函数边界值
|
||||
|
||||
使用包含sin()函数的select语句,参数为不同数字类型的边界值,查询均返回成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.check_boundary_values()
|
||||
def check_boundary_values(self, dbname="testdb"):
|
||||
|
||||
PI=3.1415926
|
||||
|
@ -457,6 +554,22 @@ class TDTestCase:
|
|||
|
||||
self.check_result_auto_sin(f"select num1,num2 from {dbname}.tb3;" , f"select sin(num1),sin(num2) from {dbname}.tb3")
|
||||
|
||||
def test_super_table(self):
|
||||
"""测试sin()函数查询超表
|
||||
|
||||
Description: 使用包含sin()函数的select语句,查询超级表返回成功
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: sin
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
Update history:
|
||||
2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.support_super_table_test()
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
self.check_result_auto_sin( f"select c5 from {dbname}.stb1 order by ts " , f"select sin(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_sin( f"select c5 from {dbname}.stb1 order by tbname " , f"select sin(c5) from {dbname}.stb1 order by tbname" )
|
|
@ -5,7 +5,7 @@ from util.sql import *
|
|||
import numpy as np
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
class TestHint:
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
|
@ -15,6 +15,23 @@ class TDTestCase:
|
|||
self.batchNum = 5
|
||||
self.ts = 1537146000000
|
||||
|
||||
def test_hint(self):
|
||||
"""测试hint查询
|
||||
|
||||
执行支持的hint查询,返回结果正确
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: stable
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.run()
|
||||
|
||||
def run(self):
|
||||
dbname = "db"
|
||||
tdSql.prepare()
|
|
@ -61,7 +61,7 @@ class DataSet:
|
|||
nchar_data : List[str] = field(default_factory=list)
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
class TestJoin:
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
|
@ -186,6 +186,24 @@ class TDTestCase:
|
|||
)
|
||||
return list(filter(None, sqls))
|
||||
|
||||
|
||||
def test_join_check(self):
|
||||
"""测试join关键字合法查询
|
||||
|
||||
join语句select查询,与多种where语句、having语句、group语句组合查询,查询结果返回正确
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: join
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.__join_check()
|
||||
|
||||
def __join_check(self,):
|
||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||
for i in range(len(self.__sqls_list)):
|
||||
|
@ -226,6 +244,23 @@ class TDTestCase:
|
|||
tdSql.query(sql=sql)
|
||||
# tdSql.checkRows(checkrows)
|
||||
|
||||
def test_error(self):
|
||||
"""测试join关键字非法查询
|
||||
|
||||
join语句select查询,与不支持的where语句、having语句、group语句组合查询,查询结果返回期望错误
|
||||
|
||||
Since: v3.3.0.0
|
||||
|
||||
Labels: join, negative
|
||||
|
||||
Jira: TD-12345,TS-1234
|
||||
|
||||
History:
|
||||
- 2024-2-6 Feng Chao Created
|
||||
|
||||
"""
|
||||
self.__test_error()
|
||||
|
||||
def __test_error(self, dbname=DBNAME):
|
||||
# sourcery skip: extract-duplicate-method, move-assign-in-block
|
||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
|
@ -23,7 +23,7 @@ from util.sql import tdSql
|
|||
from util.dnodes import tdDnodes
|
||||
from util.dnodes import *
|
||||
|
||||
class TDTestCase:
|
||||
class TestNestedQuery:
|
||||
updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 131 ,"cDebugFlag":131,"uDebugFlag":131 ,"rpcDebugFlag":131 , "tmrDebugFlag":131 ,
|
||||
"jniDebugFlag":131 ,"simDebugFlag":131,"dDebugFlag":131, "dDebugFlag":131,"vDebugFlag":131,"mDebugFlag":131,"qDebugFlag":131,
|
||||
"wDebugFlag":131,"sDebugFlag":131,"tsdbDebugFlag":131,"tqDebugFlag":131 ,"fsDebugFlag":131 ,"fnDebugFlag":131}
|
|
@ -25,7 +25,7 @@ import importlib
|
|||
print(f"Python version: {sys.version}")
|
||||
print(f"Version info: {sys.version_info}")
|
||||
|
||||
sys.path.append("../tests/pytest")
|
||||
sys.path.append("../pytest")
|
||||
from util.log import *
|
||||
from util.dnodes import *
|
||||
from util.cases import *
|
Loading…
Reference in New Issue