Merge pull request #28952 from taosdata/test/main/TD-32920
ci: set test step in ci when tdgpt file changed
This commit is contained in:
commit
675008dd18
42
Jenkinsfile2
42
Jenkinsfile2
|
@ -6,6 +6,7 @@ node {
|
|||
file_zh_changed = ''
|
||||
file_en_changed = ''
|
||||
file_no_doc_changed = '1'
|
||||
file_only_tdgpt_change_except = '1'
|
||||
def abortPreviousBuilds() {
|
||||
def currentJobName = env.JOB_NAME
|
||||
def currentBuildNumber = env.BUILD_NUMBER.toInteger()
|
||||
|
@ -73,9 +74,19 @@ def check_docs(){
|
|||
''',
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
file_only_tdgpt_change_except = sh (
|
||||
script: '''
|
||||
cd ${WKC}
|
||||
git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep -v "^docs/en/"|grep -v "^docs/zh/"|grep -v ".md$" | grep -v "forecastoperator.c\\|anomalywindowoperator.c" |grep -v "tsim/analytics" |grep -v "tdgpt_cases.task" || :
|
||||
''',
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
echo "file_zh_changed: ${file_zh_changed}"
|
||||
echo "file_en_changed: ${file_en_changed}"
|
||||
echo "file_no_doc_changed: ${file_no_doc_changed}"
|
||||
echo "file_only_tdgpt_change_except: ${file_only_tdgpt_change_except}"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,7 +396,7 @@ def run_win_test() {
|
|||
}
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
agent any
|
||||
options { skipDefaultCheckout() }
|
||||
environment{
|
||||
WKDIR = '/var/lib/jenkins/workspace'
|
||||
|
@ -462,6 +473,10 @@ pipeline {
|
|||
WIN_COMMUNITY_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community"
|
||||
WIN_SYSTEM_TEST_ROOT="C:\\workspace\\${env.EXECUTOR_NUMBER}\\TDinternal\\community\\tests\\system-test"
|
||||
}
|
||||
when {
|
||||
beforeAgent true
|
||||
expression { file_only_tdgpt_change_except != '' }
|
||||
}
|
||||
steps {
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 126, unit: 'MINUTES'){
|
||||
|
@ -475,6 +490,10 @@ pipeline {
|
|||
}
|
||||
stage('mac test') {
|
||||
agent{label " Mac_catalina "}
|
||||
when {
|
||||
beforeAgent true
|
||||
expression { file_only_tdgpt_change_except != '' }
|
||||
}
|
||||
steps {
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 60, unit: 'MINUTES'){
|
||||
|
@ -550,6 +569,15 @@ pipeline {
|
|||
cd ${WKC}/tests/parallel_test
|
||||
./run_scan_container.sh -d ${WKDIR} -b ${BRANCH_NAME}_${BUILD_ID} -f ${WKDIR}/tmp/${BRANCH_NAME}_${BUILD_ID}/docs_changed.txt ''' + extra_param + '''
|
||||
'''
|
||||
if ( file_no_doc_changed =~ /forecastoperator.c|anomalywindowoperator.c|tsim\/analytics|tdgpt_cases.task/ ) {
|
||||
sh '''
|
||||
cd ${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 ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 300 ''' + extra_param + '''
|
||||
'''
|
||||
}
|
||||
if ( file_only_tdgpt_change_except != '' ) {
|
||||
sh '''
|
||||
cd ${WKC}/tests/parallel_test
|
||||
export DEFAULT_RETRY_TIME=2
|
||||
|
@ -559,20 +587,8 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 15, unit: 'MINUTES'){
|
||||
script {
|
||||
sh '''
|
||||
echo "packaging ..."
|
||||
date
|
||||
rm -rf ${WKC}/release/*
|
||||
cd ${WKC}/packaging
|
||||
./release.sh -v cluster -n 3.0.0.100 -s static
|
||||
'''
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
import pytest
|
||||
import subprocess
|
||||
import os
|
||||
from versionCheckAndUninstallforPytest import UninstallTaos
|
||||
import platform
|
||||
import re
|
||||
import time
|
||||
import signal
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
system = platform.system()
|
||||
current_path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
with open("%s/test_server_unix_tdgpt" % current_path) as f:
|
||||
cases = f.read().splitlines()
|
||||
|
||||
OEM = ["ProDB"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def get_config(request):
|
||||
verMode = request.config.getoption("--verMode")
|
||||
taosVersion = request.config.getoption("--tVersion")
|
||||
baseVersion = request.config.getoption("--baseVersion")
|
||||
sourcePath = request.config.getoption("--sourcePath")
|
||||
config = {
|
||||
"verMode": verMode,
|
||||
"taosVersion": taosVersion,
|
||||
"baseVersion": baseVersion,
|
||||
"sourcePath": sourcePath,
|
||||
"system": platform.system(),
|
||||
"arch": platform.machine()
|
||||
}
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def setup_module(get_config):
|
||||
def run_cmd(command):
|
||||
print("CMD:", command)
|
||||
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
print("STDOUT:", result.stdout)
|
||||
print("STDERR:", result.stderr)
|
||||
print("Return Code:", result.returncode)
|
||||
assert result.returncode == 0
|
||||
return result
|
||||
|
||||
# setup before module tests
|
||||
config = get_config
|
||||
if config["system"] == "Windows":
|
||||
cmd = r"mkdir ..\..\debug\build\bin"
|
||||
else:
|
||||
cmd = "mkdir -p ../../debug/build/bin/"
|
||||
subprocess.getoutput(cmd)
|
||||
if config["system"] == "Linux" or config["system"] == "Darwin" : # add tmq_sim
|
||||
cmd = "cp -rf ../../../debug/build/bin/tmq_sim ../../debug/build/bin/."
|
||||
subprocess.getoutput(cmd)
|
||||
if config["system"] == "Darwin":
|
||||
cmd = "sudo cp -rf /usr/local/bin/taos* ../../debug/build/bin/"
|
||||
elif config["system"] == "Windows":
|
||||
cmd = r"xcopy C:\TDengine\taos*.exe ..\..\debug\build\bin /Y"
|
||||
else:
|
||||
if config["baseVersion"] in OEM:
|
||||
cmd = '''sudo find /usr/bin -name 'prodb*' -exec sh -c 'for file; do cp "$file" "../../debug/build/bin/taos${file##/usr/bin/%s}"; done' sh {} +''' % (
|
||||
config["baseVersion"].lower())
|
||||
else:
|
||||
cmd = "sudo cp /usr/bin/taos* ../../debug/build/bin/"
|
||||
run_cmd(cmd)
|
||||
if config["baseVersion"] in OEM: # mock OEM
|
||||
cmd = "sed -i 's/taos.cfg/%s.cfg/g' ../../tests/pytest/util/dnodes.py" % config["baseVersion"].lower()
|
||||
run_cmd(cmd)
|
||||
cmd = "sed -i 's/taosdlog.0/%sdlog.0/g' ../../tests/pytest/util/dnodes.py" % config["baseVersion"].lower()
|
||||
run_cmd(cmd)
|
||||
cmd = "sed -i 's/taos.cfg/%s.cfg/g' ../../tests/army/frame/server/dnode.py" % config["baseVersion"].lower()
|
||||
run_cmd(cmd)
|
||||
cmd = "sed -i 's/taosdlog.0/%sdlog.0/g' ../../tests/army/frame/server/dnode.py" % config["baseVersion"].lower()
|
||||
run_cmd(cmd)
|
||||
cmd = "ln -s /usr/bin/prodb /usr/local/bin/taos"
|
||||
subprocess.getoutput(cmd)
|
||||
|
||||
# yield
|
||||
#
|
||||
# name = "taos"
|
||||
# if config["baseVersion"] in OEM:
|
||||
# name = config["baseVersion"].lower()
|
||||
# subprocess.getoutput("rm /usr/local/bin/taos")
|
||||
# subprocess.getoutput("pkill taosd")
|
||||
# UninstallTaos(config["taosVersion"], config["verMode"], True, name)
|
||||
|
||||
|
||||
# use pytest fixture to exec case
|
||||
@pytest.fixture(params=cases)
|
||||
def run_command(request):
|
||||
commands = request.param
|
||||
if commands.strip().startswith("#"):
|
||||
pytest.skip("This case has been marked as skipped")
|
||||
d, command = commands.strip().split(",")
|
||||
if system == "Windows":
|
||||
cmd = r"cd %s\..\..\tests\%s && %s" % (current_path, d, command)
|
||||
else:
|
||||
cmd = "cd %s/../../tests/%s&&sudo %s" % (current_path, d, command)
|
||||
print(cmd)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, shell=True)
|
||||
return {
|
||||
"command": command,
|
||||
"stdout": result.stdout,
|
||||
"stderr": result.stderr,
|
||||
"returncode": result.returncode
|
||||
}
|
||||
|
||||
|
||||
class TestServer:
|
||||
|
||||
@pytest.mark.all
|
||||
def test_execute_cases(self, setup_module, run_command):
|
||||
# assert the result
|
||||
if run_command['returncode'] != 0:
|
||||
print(f"Running command: {run_command['command']}")
|
||||
print("STDOUT:", run_command['stdout'])
|
||||
print("STDERR:", run_command['stderr'])
|
||||
print("Return Code:", run_command['returncode'])
|
||||
else:
|
||||
print(f"Running command: {run_command['command']}")
|
||||
if len(run_command['stdout']) > 1000:
|
||||
print("STDOUT:", run_command['stdout'][:1000] + "...")
|
||||
else:
|
||||
print("STDOUT:", run_command['stdout'])
|
||||
print("STDERR:", run_command['stderr'])
|
||||
print("Return Code:", run_command['returncode'])
|
||||
|
||||
assert run_command[
|
||||
'returncode'] == 0, f"Command '{run_command['command']}' failed with return code {run_command['returncode']}"
|
|
@ -0,0 +1 @@
|
|||
system-test,python3 ./test.py -f 9-tdgpt/test_gpt.py
|
|
@ -169,6 +169,7 @@ static int32_t forecastCloseBuf(SForecastSupp* pSupp) {
|
|||
code = taosAnalBufWriteOptInt(pBuf, "start", start);
|
||||
if (code != 0) return code;
|
||||
|
||||
|
||||
bool hasEvery = taosAnalGetOptInt(pSupp->algoOpt, "every", &every);
|
||||
if (!hasEvery) {
|
||||
qDebug("forecast every not found from %s, use %" PRId64, pSupp->algoOpt, every);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#Column Define
|
||||
#caseID,rerunTimes,Run with Sanitizer,casePath,caseCommand
|
||||
#NA,NA,y or n,script,./test.sh -f tsim/analytics/basic0.sim
|
||||
|
||||
#tdgpt-test
|
||||
,,n,script,./test.sh -f tsim/analytics/basic0.sim
|
||||
#,,n,system-test,python3 ./test.py -f 9-tdgpt/test_gpt.py
|
||||
|
|
@ -4,7 +4,7 @@ system sh/exec.sh -n dnode1 -s start
|
|||
sql connect
|
||||
|
||||
print =============== create anode
|
||||
sql create anode '127.0.0.1:6090'
|
||||
sql create anode '192.168.1.116:6050'
|
||||
|
||||
sql show anodes
|
||||
if $rows != 1 then
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.common import *
|
||||
import taos
|
||||
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
clientCfgDict = {'debugFlag': 135}
|
||||
updatecfgDict = {
|
||||
"debugFlag" : "135",
|
||||
"queryBufferSize" : 10240,
|
||||
'clientCfg' : clientCfgDict
|
||||
}
|
||||
|
||||
def init(self, conn, logSql, replicaVal=1):
|
||||
self.replicaVar = int(replicaVal)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
self.conn = conn
|
||||
tdSql.init(conn.cursor(), False)
|
||||
self.passwd = {'root':'taosdata',
|
||||
'test':'test'}
|
||||
|
||||
def prepare_anode_data(self):
|
||||
tdSql.execute(f"create anode '127.0.0.1:6090'")
|
||||
tdSql.execute(f"create database db_gpt")
|
||||
tdSql.execute(f"create table if not exists db_gpt.stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned);")
|
||||
tdSql.execute(f"create table db_gpt.ct1 using db_gpt.stb tags(1000);")
|
||||
tdSql.execute(f"insert into db_gpt.ct1(ts, c1) values(now-1a, 5)(now+1a, 14)(now+2a, 15)(now+3a, 15)(now+4a, 14);")
|
||||
tdSql.execute(f"insert into db_gpt.ct1(ts, c1) values(now+5a, 19)(now+6a, 17)(now+7a, 16)(now+8a, 20)(now+9a, 22);")
|
||||
tdSql.execute(f"insert into db_gpt.ct1(ts, c1) values(now+10a, 8)(now+11a, 21)(now+12a, 28)(now+13a, 11)(now+14a, 9);")
|
||||
tdSql.execute(f"insert into db_gpt.ct1(ts, c1) values(now+15a, 29)(now+16a, 40);")
|
||||
|
||||
|
||||
def test_forecast(self):
|
||||
"""
|
||||
Test forecast
|
||||
"""
|
||||
tdLog.info(f"Test forecast")
|
||||
tdSql.query(f"SELECT _frowts, FORECAST(c1, \"algo=arima,alpha=95,period=10,start_p=1,max_p=5,start_q=1,max_q=5,d=1\") from db_gpt.ct1 ;")
|
||||
tdSql.checkRows(10)
|
||||
|
||||
def test_anomaly_window(self):
|
||||
"""
|
||||
Test anomaly window
|
||||
"""
|
||||
tdLog.info(f"Test anomaly window")
|
||||
tdSql.query(f"SELECT _wstart, _wend, SUM(c1) FROM db_gpt.ct1 ANOMALY_WINDOW(c1, \"algo=iqr\");")
|
||||
tdSql.checkData(0,2,40)
|
||||
|
||||
|
||||
def run(self):
|
||||
self.prepare_anode_data()
|
||||
self.test_forecast()
|
||||
self.test_anomaly_window()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue