From c852e541ea22613ef57de1942c1ebeafdb10f664 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Fri, 14 Mar 2025 15:55:06 +0800 Subject: [PATCH 1/7] ci: update TDgpt workflow to combine the unit test and function test --- .github/workflows/tdgpt-ci.yml | 51 -------------- .github/workflows/tdgpt-test.yml | 112 +++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/tdgpt-ci.yml create mode 100644 .github/workflows/tdgpt-test.yml diff --git a/.github/workflows/tdgpt-ci.yml b/.github/workflows/tdgpt-ci.yml deleted file mode 100644 index 4a438938dc..0000000000 --- a/.github/workflows/tdgpt-ci.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: TDgpt CI - -on: - pull_request: - branches: - - '3.0' - paths: - - 'tools/tdgpt/**' - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - python-version: ["3.10"] - - defaults: - run: - working-directory: ${{ github.workspace }}/tools/tdgpt - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pylint - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - - name: Checking the code with pylint - run: | - pylint $(git ls-files '*.py') --exit-zero - - - name: Checking the code with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: Run test cases with pytest - run: | - pytest diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml new file mode 100644 index 0000000000..e8a69debcb --- /dev/null +++ b/.github/workflows/tdgpt-test.yml @@ -0,0 +1,112 @@ +name: TDgpt Test + +on: + push: + pull_request: + branches: + - '3.0' + paths: + - 'tools/tdgpt/**' + - 'source/libs/executor/src/forecastoperator.c' + - 'source/libs/executor/src/anomalywindowoperator.c' + - 'include/common/tanalytics.h' + - 'source/common/src/tanalytics.c' + - 'tests/parallel/tdgpt_cases.task' + - 'tests/script/tsim/analytics' + +jobs: + unit-test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + + defaults: + run: + working-directory: ${{ github.workspace }}/tools/tdgpt + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest pylint + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Checking the code with pylint + run: | + pylint $(git ls-files '*.py') --exit-zero + + - name: Checking the code with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Run test cases with pytest + run: | + pytest + + function-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.18 + + - name: Install dependencies + run: | + sudo apt update -y + sudo apt install -y \ + build-essential \ + cmake \ + gawk \ + libgeos-dev \ + libjansson-dev \ + liblzma-dev \ + libsnappy-dev \ + libssl-dev \ + libz-dev \ + pkg-config \ + zlib1g + + - name: Build and install TDengine + run: | + mkdir debug && cd debug + cmake .. -DBUILD_TOOLS=true \ + -DBUILD_KEEPER=true \ + -DBUILD_HTTP=false \ + -DBUILD_TEST=true \ + -DBUILD_DEPENDENCY_TESTS=false + make -j 4 + sudo make install + which taosd + which taosadapter + which taoskeeper + + - name: Run tdgpt test + run: | + cd ${{ github.workspace }}/tests/sctipt + date + ./test.sh -f tsim/analytics/basic0.sim + echo "Test exit code: $?" + if [ $? -eq 0 ]; then + echo "Tests passed." + else + echo "Tests failed." + fi From 8b8dd6e749879b9a388fb8036747ae237ef12394 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Fri, 14 Mar 2025 16:05:33 +0800 Subject: [PATCH 2/7] fix: correct directory name in tdgpt test workflow --- .github/workflows/tdgpt-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index e8a69debcb..947df48a2a 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -101,7 +101,7 @@ jobs: - name: Run tdgpt test run: | - cd ${{ github.workspace }}/tests/sctipt + cd ${{ github.workspace }}/tests/script date ./test.sh -f tsim/analytics/basic0.sim echo "Test exit code: $?" From f20bc1f739a5c3dd5b8b259962b5342d29ae0878 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Fri, 14 Mar 2025 16:33:33 +0800 Subject: [PATCH 3/7] ci: enhance function test workflow with environment setup and logging --- .github/workflows/tdgpt-test.yml | 159 +++++++++++++++++++++---------- 1 file changed, 111 insertions(+), 48 deletions(-) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index 947df48a2a..f7fa17fa75 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -58,55 +58,118 @@ jobs: pytest function-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.18 - - - name: Install dependencies - run: | - sudo apt update -y - sudo apt install -y \ - build-essential \ - cmake \ - gawk \ - libgeos-dev \ - libjansson-dev \ - liblzma-dev \ - libsnappy-dev \ - libssl-dev \ - libz-dev \ - pkg-config \ - zlib1g - - - name: Build and install TDengine - run: | - mkdir debug && cd debug - cmake .. -DBUILD_TOOLS=true \ - -DBUILD_KEEPER=true \ - -DBUILD_HTTP=false \ - -DBUILD_TEST=true \ - -DBUILD_DEPENDENCY_TESTS=false - make -j 4 - sudo make install - which taosd - which taosadapter - which taoskeeper + runs-on: + group: CI + labels: [self-hosted, Linux, X64, testing] - - name: Run tdgpt test + env: + CONTAINER_NAME: 'taosd-test' + WKDIR: '/var/lib/jenkins/workspace' + WK: '/var/lib/jenkins/workspace/TDinternal' + WKC: '/var/lib/jenkins/workspace/TDinternal/community' + SOURCE_BRANCH: ${{ github.event.pull_request.head.ref }} + TARGET_BRANCH: ${{ github.event.pull_request.base.ref }} + PR_NUMBER: ${{ github.event.pull_request.number }} + + steps: + - name: Output the environment information run: | - cd ${{ github.workspace }}/tests/script + echo "::group::Environment Info" date - ./test.sh -f tsim/analytics/basic0.sim - echo "Test exit code: $?" - if [ $? -eq 0 ]; then - echo "Tests passed." - else - echo "Tests failed." + hostname + env + echo "Runner: ${{ runner.name }}" + echo "Workspace: ${{ env.WKDIR }}" + git --version + echo "${{ env.WKDIR }}/restore.sh -p PR-${{ env.PR_NUMBER }} -n ${{ github.run_number }} -c ${{ env.CONTAINER_NAME }}" + echo "::endgroup::" + + - name: Prepare repositories + run: | + set -euo pipefail + prepare_environment() { + cd "$1" + git reset --hard + git clean -f + git remote prune origin + git fetch + git checkout "$2" + } + prepare_environment "${{ env.WK }}" "${{ env.TARGET_BRANCH }}" + prepare_environment "${{ env.WKC }}" "${{ env.TARGET_BRANCH }}" + + - name: Get latest codes and logs + run: | + cd ${{ env.WKC }} + git remote prune origin + git pull >/dev/null + git log -5 + echo "`date "+%Y%m%d-%H%M%S"` TDengineTest/${{ env.PR_NUMBER }}:${{ github.run_number }}:${{ env.TARGET_BRANCH }}" >>${{ env.WKDIR }}/jenkins.log + echo "CHANGE_BRANCH:${{ env.SOURCE_BRANCH }}" >>${{ env.WKDIR }}/jenkins.log + echo "community log: `git log -5`" >>${{ env.WKDIR }}/jenkins.log + git fetch origin +refs/pull/${{ env.PR_NUMBER }}/merge + git checkout -qf FETCH_HEAD + git log -5 + echo "community log merged: `git log -5`" >>${{ env.WKDIR }}/jenkins.log + cd ${{ env.WK }} + git pull >/dev/null + git log -5 + echo "TDinternal log: `git log -5`" >>${{ env.WKDIR }}/jenkins.log + + - name: Update submodule + run: | + cd ${{ env.WKC }} + git submodule update --init --recursive + + - name: Check assert testing + run: | + cd ${{ env.WKC }}/tests/parallel_test + ./run_check_assert_container.sh -d ${{ env.WKDIR }} + + - name: Check void function testing + run: | + cd ${{ env.WKC }}/tests/parallel_test + ./run_check_void_container.sh -d ${{ env.WKDIR }} + + - name: Build docker container + run: | + date + rm -rf ${{ env.WKC }}/debug + cd ${{ env.WKC }}/tests/parallel_test + time ./container_build.sh -w ${{ env.WKDIR }} -e + + - name: Get parameters for testing + id: get_param + run: | + log_server_file="/home/log_server.json" + timeout_cmd="" + extra_param="" + + if [ -f "$log_server_file" ]; then + log_server_enabled=$(jq '.enabled' "$log_server_file") + timeout_param=$(jq '.timeout' "$log_server_file") + if [ "$timeout_param" != "null" ] && [ "$timeout_param" != "0" ]; then + timeout_cmd="timeout $timeout_param" + fi + + if [ "$log_server_enabled" == "1" ]; then + log_server=$(jq '.server' "$log_server_file" | sed 's/\\\"//g') + if [ "$log_server" != "null" ] && [ "$log_server" != "" ]; then + extra_param="-w $log_server" + fi + fi fi + echo "timeout_cmd=$timeout_cmd" >> $GITHUB_OUTPUT + echo "extra_param=$extra_param" >> $GITHUB_OUTPUT + + - name: Run function returns with a null pointer scan testing + run: | + cd ${{ env.WKC }}/tests/parallel_test + ./run_scan_container.sh -d ${{ env.WKDIR }} -b ${{ env.PR_NUMBER }}_${{ github.run_number }} -f ${{ env.WKDIR }}/tmp/${{ env.PR_NUMBER }}_${{ github.run_number }}/docs_changed.txt ${{ steps.get_param.outputs.extra_param }} + + - name: Run tdgpt test cases + run: | + cd ${{ env.WKC }}/tests/parallel_test + export DEFAULT_RETRY_TIME=2 + date + timeout 600 time ./run.sh -e -m /home/m.json -t tdgpt_cases.task -b "${{ env.PR_NUMBER }}_${{ github.run_number }}" -l ${{ env.WKDIR }}/log -o 300 ${{ steps.get_param.outputs.extra_param }} From ee1144f7d1a0f72dadf1ff65b2f4075430d47390 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Fri, 14 Mar 2025 16:34:55 +0800 Subject: [PATCH 4/7] ci: remove push trigger from TDgpt test workflow --- .github/workflows/tdgpt-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index f7fa17fa75..3036b8d3b4 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -1,7 +1,6 @@ name: TDgpt Test on: - push: pull_request: branches: - '3.0' From 4bf0c591c812b27d83164a631ed66b0cc01f671c Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Sat, 15 Mar 2025 09:31:40 +0800 Subject: [PATCH 5/7] Update .github/workflows/tdgpt-test.yml Co-authored-by: WANG Xu --- .github/workflows/tdgpt-test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index 3036b8d3b4..019cc2f162 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -164,7 +164,11 @@ jobs: - name: Run function returns with a null pointer scan testing run: | cd ${{ env.WKC }}/tests/parallel_test - ./run_scan_container.sh -d ${{ env.WKDIR }} -b ${{ env.PR_NUMBER }}_${{ github.run_number }} -f ${{ env.WKDIR }}/tmp/${{ env.PR_NUMBER }}_${{ github.run_number }}/docs_changed.txt ${{ steps.get_param.outputs.extra_param }} + ./run_scan_container.sh \ + -d ${{ env.WKDIR }} \ + -b ${{ env.PR_NUMBER }}_${{ github.run_number }} \ + -f ${{ env.WKDIR }}/tmp/${{ env.PR_NUMBER }}_${{ github.run_number }}/docs_changed.txt \ + ${{ steps.get_param.outputs.extra_param }} - name: Run tdgpt test cases run: | From 4e10ca262a87dbf3ed70029d1600107127aeb4d3 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Sat, 15 Mar 2025 09:31:53 +0800 Subject: [PATCH 6/7] Update .github/workflows/tdgpt-test.yml Co-authored-by: WANG Xu --- .github/workflows/tdgpt-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index 019cc2f162..6b8802ec17 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -3,7 +3,9 @@ name: TDgpt Test on: pull_request: branches: + - 'main' - '3.0' + - '3.3.6' paths: - 'tools/tdgpt/**' - 'source/libs/executor/src/forecastoperator.c' From 33a63fd4cf293d53647d6e7e895b44d69a9482e8 Mon Sep 17 00:00:00 2001 From: Feng Chao Date: Sat, 15 Mar 2025 09:32:01 +0800 Subject: [PATCH 7/7] Update .github/workflows/tdgpt-test.yml Co-authored-by: WANG Xu --- .github/workflows/tdgpt-test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tdgpt-test.yml b/.github/workflows/tdgpt-test.yml index 6b8802ec17..48962141d8 100644 --- a/.github/workflows/tdgpt-test.yml +++ b/.github/workflows/tdgpt-test.yml @@ -177,4 +177,9 @@ jobs: cd ${{ env.WKC }}/tests/parallel_test export DEFAULT_RETRY_TIME=2 date - timeout 600 time ./run.sh -e -m /home/m.json -t tdgpt_cases.task -b "${{ env.PR_NUMBER }}_${{ github.run_number }}" -l ${{ env.WKDIR }}/log -o 300 ${{ steps.get_param.outputs.extra_param }} + timeout 600 time ./run.sh -e \ + -m /home/m.json \ + -t tdgpt_cases.task \ + -b "${{ env.PR_NUMBER }}_${{ github.run_number }}" \ + -l ${{ env.WKDIR }}/log \ + -o 300 ${{ steps.get_param.outputs.extra_param }}