Merge pull request #29588 from taosdata/docs/chr1-readme

ci:modify test readme
This commit is contained in:
haoranchen 2025-01-16 17:51:41 +08:00 committed by GitHub
commit 33f0b8567f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 94 additions and 6 deletions

View File

@ -92,28 +92,34 @@ bash test.sh -e 0
#### How to add new cases? #### How to add new cases?
<details>
<summary>Detailed steps to add new unit test case</summary>
The Google test framwork is used for unit testing to specific function module, you can refer below steps to add one test case: The Google test framwork is used for unit testing to specific function module, you can refer below steps to add one test case:
##### Create test case file and develop the test scripts ##### 1. Create test case file and develop the test scripts
In the test directory corresponding to the target function module, create test files in CPP format and write corresponding test cases. In the test directory corresponding to the target function module, create test files in CPP format and write corresponding test cases.
##### Update build configuration ##### 2. Update build configuration
Modify the CMakeLists.txt file in this directory to ensure that the new test files are properly included in the compilation process. See the source\os\test\CMakeLists.txt file for configuration examples. Modify the CMakeLists.txt file in this directory to ensure that the new test files are properly included in the compilation process. See the source\os\test\CMakeLists.txt file for configuration examples.
##### Compile test code ##### 3. Compile test code
In the root directory of the project, create a compilation directory (e.g., debug), switch to the directory and run CMake commands (e.g., cmake .. -DBUILD_TEST=1) to generate a compilation file, and then run a compilation command (e.g. make) to complete the compilation of the test code. In the root directory of the project, create a compilation directory (e.g., debug), switch to the directory and run CMake commands (e.g., cmake .. -DBUILD_TEST=1) to generate a compilation file, and then run a compilation command (e.g. make) to complete the compilation of the test code.
##### Execute the test program ##### 4. Execute the test program
Find the executable file in the compiled directory(e.g. TDengine/debug/build/bin/) and run it. Find the executable file in the compiled directory(e.g. TDengine/debug/build/bin/) and run it.
##### Integrate into CI tests ##### 5. Integrate into CI tests
Use the add_test command to add new compiled test cases into CI test collection, ensure that the new added test cases can be run for every build. Use the add_test command to add new compiled test cases into CI test collection, ensure that the new added test cases can be run for every build.
</details>
## 3.1.2 System Test ## 3.1.2 System Test
Python test script includes all of the functions of TDengine OSS, so some test case maybe fail cause the function only Python test script includes all of the functions of TDengine OSS, so some test case maybe fail cause the function only
@ -135,7 +141,34 @@ cd tests
### How to add new case? ### How to add new case?
[Placeholder] <details>
<summary>Detailed steps to add new system test case</summary>
you can refer below steps to add one test case:
##### 1. Create test case file and develop the test scripts
In the test directory corresponding to the target function module, create test files in CPP format and write corresponding test cases.
##### 2. Update build configuration
Modify the CMakeLists.txt file in this directory to ensure that the new test files are properly included in the compilation process. See the source\os\test\CMakeLists.txt file for configuration examples.
##### 3. Compile test code
In the root directory of the project, create a compilation directory (e.g., debug), switch to the directory and run CMake commands (e.g., cmake .. -DBUILD_TEST=1) to generate a compilation file, and then run a compilation command (e.g. make) to complete the compilation of the test code.
##### 4. Execute the test program
Find the executable file in the compiled directory(e.g. TDengine/debug/build/bin/) and run it.
##### 5. Integrate into CI tests
Use the add_test command to add new compiled test cases into CI test collection, ensure that the new added test cases can be run for every build.
</details>
## 3.1.3 Legacy Test ## 3.1.3 Legacy Test

View File

@ -0,0 +1,55 @@
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
from util.dnodes import tdDnodes
from util.dnodes import *
from util.common import *
class TDTestCase:
"""
Here is the class description for the whole file cases
"""
# add the configuration of the client and server here
clientCfgDict = {'debugFlag': 131}
updatecfgDict = {
"debugFlag" : "131",
"queryBufferSize" : 10240,
'clientCfg' : clientCfgDict
}
def init(self, conn, logSql, replicaVar=1):
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
self.replicaVar = int(replicaVar)
def test_function(): # case function should be named start with test_
"""
Here is the function description for single test:
Test case for custom function
"""
tdLog.info(f"Test case test custom function")
# excute the sql
tdLog.execute(f"create database db_test_function")
tdSql.execute(f"create table db_test_function.stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned);")
# qury the result and return the result
tdSql.query(f"show databases")
# print result and check the result
database_info = tdLog.info(f"{tdSql.queryResult}")
tdSql.checkRows(3)
tdSql.checkData(2,0,"db_test_function")
def run(self):
self.test_5dnode_3mnode(dnodeNumbers=6,mnodeNums=3,restartNumbers=2,stopRole='vnode')
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())