doc: add README

This commit is contained in:
jiajingbin 2025-01-23 14:21:42 +08:00
parent 4504f5a6fd
commit bcdb50e499
2 changed files with 53 additions and 177 deletions

View File

@ -0,0 +1,43 @@
# 目录
1. [介绍](#1-介绍)
1. [前置条件](#2-前置条件)
1. [运行](#3-运行)
# 1. 介绍
本手册旨在为开发人员提供全面的指导以收集过去7天的崩溃信息并将其报告到飞书通知群。
> [!注意]
> - 下面的命令和脚本已在 LinuxCentOS 7.9.2009)上验证.
# 2. 前置条件
- 安装 Python3
```bash
yum install python3
yum install python3-pip
```
- 安装 Python 依赖
```bash
pip3 install requests python-dotenv
```
- 调整 .env 文件
```bash
cd $DIR/telemetry/crash-report
cp .env.example .env
```
# 3. 运行
在 $DIR/telemetry/crash-report 目录中,有类似文件名为 202501**.txt 的一些文件。Python 脚本会将从这些文本文件中收集崩溃信息,并将报告发送到您的飞书机器人群组中。
```bash
cd $DIR/telemetry/crash-report
python3 CrashCounter.py
```

View File

@ -10,7 +10,6 @@ This manual is intended to give developers comprehensive guidance to collect cra
> [!NOTE]
> - The commands and scripts below are verified on Linux (CentOs 7.9.2009).
> - The commands and steps described below are to run the tests on a single host.
# 2. Prerequisites
@ -27,184 +26,18 @@ yum install python3-pip
pip3 install requests python-dotenv
```
- Adjust .env file
```bash
cd $DIR/telemetry/crash-report
cp .env.example .env
```
# 3. Running
In `crash-report` directory, there are different types of tests for TDengine. Below is a brief introduction about how to run them and how to add new cases.
### 3.1 Unit Test
Unit tests are the smallest testable units, which are used to test functions, methods or classes in TDengine code.
### 3.1.1 How to run single test case?
In `$DIR/telemetry/crash-report` directory, there are several files with names like 202501**.txt. The python script will collect crash information from these text files and send report to your Feishu bot group.
```bash
cd debug/build/bin
./osTimeTests
cd $DIR/telemetry/crash-report
python3 CrashCounter.py
```
### 3.1.2 How to run all unit test cases?
```bash
cd tests/unit-test/
bash test.sh -e 0
```
### 3.1.3 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, please refer to steps below to add a new test case:
##### a. 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.
##### b. 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.
##### c. 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.
##### d. Execute the test program
Find the executable file in the compiled directory(e.g. `TDengine/debug/build/bin/`) and run it.
##### e. 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.2 System Test
System tests are end-to-end test cases written in Python from a system point of view. Some of them are designed to test features only in enterprise ediiton, so when running on community edition, they may fail. We'll fix this issue by separating the cases into different gruops in the future.
### 3.2.1 How to run a single test case?
Take test file `system-test/2-query/avg.py` for example:
```bash
cd tests/system-test
python3 ./test.py -f 2-query/avg.py
```
### 3.2.2 How to run all system test cases?
```bash
cd tests
./run_all_ci_cases.sh -t python # all python cases
```
### 3.2.3 How to add new case?
<details>
<summary>Detailed steps to add new system test case</summary>
The Python test framework is developed by TDengine team, and test.py is the test case execution and monitoring of the entry program, Use `python3 ./test.py -h` to view more features.
Please refer to steps below for how to add a new test case:
##### a. Create a test case file and develop the test cases
Create a file in `tests/system-test` containing each functional directory and refer to the use case template `tests/system-test/0-others/test_case_template.py` to add a new test case.
##### b. Execute the test case
Ensure the test case execution is successful.
``` bash
cd tests/system-test && python3 ./test.py -f 0-others/test_case_template.py
```
##### c. Integrate into CI tests
Edit `tests/parallel_test/cases.task` and add the testcase path and executions in the specified format. The third column indicates whether to use Address Sanitizer mode for testing.
```bash
#caseID,rerunTimes,Run with Sanitizer,casePath,caseCommand
,,n,system-test, python3 ./test.py -f 0-others/test_case_template.py
```
</details>
## 3.3 Legacy Test
In the early stage of TDengine development, test cases are run by an internal test framework called TSIM, which is developed in C++.
### 3.3.1 How to run single test case?
To run the legacy test cases, please execute the following commands:
```bash
cd tests/script
./test.sh -f tsim/db/basic1.sim
```
### 3.3.2 How to run all legacy test cases?
```bash
cd tests
./run_all_ci_cases.sh -t legacy # all legacy cases
```
### 3.3.3 How to add new cases?
> [!NOTE]
> TSIM test framwork is deprecated by system test now, it is encouraged to add new test cases in system test, please refer to [System Test](#32-system-test) for details.
## 3.4 Smoke Test
Smoke test is a group of test cases selected from system test, which is also known as sanity test to ensure the critical functionalities of TDengine.
### 3.4.1 How to run test?
```bash
cd /root/TDengine/packaging/smokeTest
./test_smoking_selfhost.sh
```
### 3.4.2 How to add new cases?
New cases can be added by updating the value of `commands` variable in `test_smoking_selfhost.sh`.
## 3.5 Chaos Test
A simple tool to execute various functions of the system in a randomized way, hoping to expose potential problems without a pre-defined test scenario.
### 3.5.1 How to run test?
```bash
cd tests/pytest
python3 auto_crash_gen.py
```
### 3.5.2 How to add new cases?
1. Add a function, such as `TaskCreateNewFunction` in `pytest/crash_gen/crash_gen_main.py`.
2. Integrate `TaskCreateNewFunction` into the `balance_pickTaskType` function in `crash_gen_main.py`.
## 3.6 CI Test
CI testing (Continuous Integration testing), is an important practice in software development that aims to automate frequent integration of code into a shared codebase, build and test it to ensure code quality and stability.
TDengine CI testing will run all the test cases from the following three types of tests: unit test, system test and legacy test.
### 3.6.1 How to run all CI test cases?
If this is the first time to run all the CI test cases, it is recommended to add the test branch, please run it with following commands:
```bash
cd tests
./run_all_ci_cases.sh -b main # on main branch
```
### 3.6.2 How to add new cases?
Please refer to the [Unit Test](#31-unit-test)、[System Test](#32-system-test) and [Legacy Test](#33-legacy-test) sections for detailed steps to add new test cases, when new cases are added in aboved tests, they will be run automatically by CI test.