提交 8a3ed09e 编写于 作者: S slzhou

Merge branch '3.0' of github.com:taosdata/TDengine into szhou/feature/sma

...@@ -219,17 +219,12 @@ void mndSyncStart(SMnode *pMnode) { ...@@ -219,17 +219,12 @@ void mndSyncStart(SMnode *pMnode) {
SSyncMgmt *pMgmt = &pMnode->syncMgmt; SSyncMgmt *pMgmt = &pMnode->syncMgmt;
syncSetMsgCb(pMgmt->sync, &pMnode->msgCb); syncSetMsgCb(pMgmt->sync, &pMnode->msgCb);
syncStart(pMgmt->sync);
#if 0
if (pMgmt->standby) { if (pMgmt->standby) {
syncStartStandBy(pMgmt->sync); syncStartStandBy(pMgmt->sync);
} else { } else {
syncStart(pMgmt->sync); syncStart(pMgmt->sync);
} }
#endif mDebug("sync:%" PRId64 " is started, standby:%d", pMgmt->sync, pMgmt->standby);
mDebug("sync:%" PRId64 " is started", pMgmt->sync);
} }
void mndSyncStop(SMnode *pMnode) {} void mndSyncStop(SMnode *pMnode) {}
......
...@@ -1194,7 +1194,7 @@ void catalogDestroy(void) { ...@@ -1194,7 +1194,7 @@ void catalogDestroy(void) {
taosHashCleanup(gCtgMgmt.pCluster); taosHashCleanup(gCtgMgmt.pCluster);
gCtgMgmt.pCluster = NULL; gCtgMgmt.pCluster = NULL;
CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.lock); if (CTG_IS_LOCKED(&gCtgMgmt.lock) == TD_RWLATCH_WRITE_FLAG_COPY) CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.lock);
qInfo("catalog destroyed"); qInfo("catalog destroyed");
} }
......
...@@ -714,7 +714,13 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { ...@@ -714,7 +714,13 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
pValue->notReserved = true; pValue->notReserved = true;
} }
pFunc->node.resType = (SDataType){.bytes = tDataTypes[colType].bytes, .type = colType}; uint8_t resType;
if (IS_SIGNED_NUMERIC_TYPE(colType)) {
resType = TSDB_DATA_TYPE_BIGINT;
} else {
resType = TSDB_DATA_TYPE_DOUBLE;
}
pFunc->node.resType = (SDataType){.bytes = tDataTypes[resType].bytes, .type = resType};
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -2299,15 +2299,15 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) { ...@@ -2299,15 +2299,15 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) {
} }
static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, int32_t order) { static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SColumnInfoData* pOutput, int32_t pos, int32_t order) {
int32_t factor = (order == TSDB_ORDER_ASC)? 1:-1; int32_t factor = (order == TSDB_ORDER_ASC)? 1:-1;
switch (type) { switch (type) {
case TSDB_DATA_TYPE_INT: { case TSDB_DATA_TYPE_INT: {
int32_t v = *(int32_t*)pv; int32_t v = *(int32_t*)pv;
int32_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null
if (delta < 0 && pDiffInfo->ignoreNegative) { if (delta < 0 && pDiffInfo->ignoreNegative) {
colDataSetNull_f(pOutput->nullbitmap, pos); colDataSetNull_f(pOutput->nullbitmap, pos);
} else { } else {
colDataAppendInt32(pOutput, pos, &delta); colDataAppendInt64(pOutput, pos, &delta);
} }
pDiffInfo->prev.i64 = v; pDiffInfo->prev.i64 = v;
break; break;
...@@ -2315,22 +2315,22 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo ...@@ -2315,22 +2315,22 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: { case TSDB_DATA_TYPE_TINYINT: {
int8_t v = *(int8_t*)pv; int8_t v = *(int8_t*)pv;
int8_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null
if (delta < 0 && pDiffInfo->ignoreNegative) { if (delta < 0 && pDiffInfo->ignoreNegative) {
colDataSetNull_f(pOutput->nullbitmap, pos); colDataSetNull_f(pOutput->nullbitmap, pos);
} else { } else {
colDataAppendInt8(pOutput, pos, &delta); colDataAppendInt64(pOutput, pos, &delta);
} }
pDiffInfo->prev.i64 = v; pDiffInfo->prev.i64 = v;
break; break;
} }
case TSDB_DATA_TYPE_SMALLINT: { case TSDB_DATA_TYPE_SMALLINT: {
int16_t v = *(int16_t*)pv; int16_t v = *(int16_t*)pv;
int16_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null int64_t delta = factor*(v - pDiffInfo->prev.i64); // direct previous may be null
if (delta < 0 && pDiffInfo->ignoreNegative) { if (delta < 0 && pDiffInfo->ignoreNegative) {
colDataSetNull_f(pOutput->nullbitmap, pos); colDataSetNull_f(pOutput->nullbitmap, pos);
} else { } else {
colDataAppendInt16(pOutput, pos, &delta); colDataAppendInt64(pOutput, pos, &delta);
} }
pDiffInfo->prev.i64 = v; pDiffInfo->prev.i64 = v;
break; break;
...@@ -2348,11 +2348,11 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo ...@@ -2348,11 +2348,11 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
float v = *(float*)pv; float v = *(float*)pv;
float delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null double delta = factor*(v - pDiffInfo->prev.d64); // direct previous may be null
if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow if ((delta < 0 && pDiffInfo->ignoreNegative) || isinf(delta) || isnan(delta)) { //check for overflow
colDataSetNull_f(pOutput->nullbitmap, pos); colDataSetNull_f(pOutput->nullbitmap, pos);
} else { } else {
colDataAppendFloat(pOutput, pos, &delta); colDataAppendDouble(pOutput, pos, &delta);
} }
pDiffInfo->prev.d64 = v; pDiffInfo->prev.d64 = v;
break; break;
......
...@@ -1780,7 +1780,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols ...@@ -1780,7 +1780,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
// 1. set the parsed value from sql string // 1. set the parsed value from sql string
for (int c = 0, j = 0; c < spd->numOfBound; ++c) { for (int c = 0, j = 0; c < spd->numOfBound; ++c) {
SSchema* pColSchema = &pSchema[spd->boundColumns[c] - 1]; SSchema* pColSchema = &pSchema[spd->boundColumns[c]];
param.schema = pColSchema; param.schema = pColSchema;
getSTSRowAppendInfo(pBuilder->rowType, spd, c, &param.toffset, &param.colIdx); getSTSRowAppendInfo(pBuilder->rowType, spd, c, &param.toffset, &param.colIdx);
......
...@@ -27,6 +27,8 @@ extern "C" { ...@@ -27,6 +27,8 @@ extern "C" {
#include "syncInt.h" #include "syncInt.h"
#include "taosdef.h" #include "taosdef.h"
#define CONFIG_FILE_LEN 1024
typedef struct SRaftCfg { typedef struct SRaftCfg {
SSyncCfg cfg; SSyncCfg cfg;
TdFilePtr pFile; TdFilePtr pFile;
......
...@@ -50,10 +50,18 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) { ...@@ -50,10 +50,18 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
char *s = raftCfg2Str(pRaftCfg); char *s = raftCfg2Str(pRaftCfg);
taosLSeekFile(pRaftCfg->pFile, 0, SEEK_SET); taosLSeekFile(pRaftCfg->pFile, 0, SEEK_SET);
int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1);
assert(ret == strlen(s) + 1);
taosMemoryFree(s);
char buf[CONFIG_FILE_LEN];
memset(buf, 0, sizeof(buf));
ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN);
snprintf(buf, sizeof(buf), "%s", s);
int64_t ret = taosWriteFile(pRaftCfg->pFile, buf, sizeof(buf));
assert(ret == sizeof(buf));
//int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1);
//assert(ret == strlen(s) + 1);
taosMemoryFree(s);
taosFsyncFile(pRaftCfg->pFile); taosFsyncFile(pRaftCfg->pFile);
return 0; return 0;
} }
...@@ -163,8 +171,16 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) { ...@@ -163,8 +171,16 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) {
raftCfg.cfg = *pCfg; raftCfg.cfg = *pCfg;
raftCfg.isStandBy = isStandBy; raftCfg.isStandBy = isStandBy;
char * s = raftCfg2Str(&raftCfg); char * s = raftCfg2Str(&raftCfg);
int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1);
assert(ret == strlen(s) + 1); char buf[CONFIG_FILE_LEN];
memset(buf, 0, sizeof(buf));
ASSERT(strlen(s) + 1 <= CONFIG_FILE_LEN);
snprintf(buf, sizeof(buf), "%s", s);
int64_t ret = taosWriteFile(pFile, buf, sizeof(buf));
assert(ret == sizeof(buf));
//int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1);
//assert(ret == strlen(s) + 1);
taosMemoryFree(s); taosMemoryFree(s);
taosCloseFile(&pFile); taosCloseFile(&pFile);
......
...@@ -204,7 +204,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) { ...@@ -204,7 +204,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) { int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
wordexp_t full_path; wordexp_t full_path;
if (0 != wordexp(dirname, &full_path, 0)) { if (0 != wordexp(dirname, &full_path, 0)) {
// printf("failed to expand path:%s since %s", dirname, strerror(errno)); printf("failed to expand path:%s since %s", dirname, strerror(errno));
wordfree(&full_path); wordfree(&full_path);
return -1; return -1;
} }
......
此差异已折叠。
...@@ -92,13 +92,13 @@ class Node: ...@@ -92,13 +92,13 @@ class Node:
self.conn.run("yes|./install.sh") self.conn.run("yes|./install.sh")
def configTaosd(self, taosConfigKey, taosConfigValue): def configTaosd(self, taosConfigKey, taosConfigValue):
self.conn.run("sudo echo '%s %s' >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) self.conn.run("sudo echo %s %s >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg"))
def removeTaosConfig(self, taosConfigKey, taosConfigValue): def removeTaosConfig(self, taosConfigKey, taosConfigValue):
self.conn.run("sudo sed -in-place -e '/%s %s/d' %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) self.conn.run("sudo sed -in-place -e '/%s %s/d' %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg"))
def configHosts(self, ip, name): def configHosts(self, ip, name):
self.conn.run("echo '%s %s' >> %s" % (ip, name, '/etc/hosts')) self.conn.run("echo %s %s >> %s" % (ip, name, '/etc/hosts'))
def removeData(self): def removeData(self):
try: try:
......
...@@ -113,7 +113,7 @@ class BuildDockerCluser: ...@@ -113,7 +113,7 @@ class BuildDockerCluser:
def cfg(self, option, value, nodeIndex): def cfg(self, option, value, nodeIndex):
cfgPath = "%s/node%d/cfg/taos.cfg" % (self.dockerDir, nodeIndex) cfgPath = "%s/node%d/cfg/taos.cfg" % (self.dockerDir, nodeIndex)
cmd = "echo '%s %s' >> %s" % (option, value, cfgPath) cmd = "echo %s %s >> %s" % (option, value, cfgPath)
self.execCmd(cmd) self.execCmd(cmd)
def updateLocalhosts(self): def updateLocalhosts(self):
...@@ -122,7 +122,7 @@ class BuildDockerCluser: ...@@ -122,7 +122,7 @@ class BuildDockerCluser:
print(result) print(result)
if result is None or result.isspace(): if result is None or result.isspace():
print("==========") print("==========")
cmd = "echo '172.27.0.7 tdnode1' >> /etc/hosts" cmd = "echo 172.27.0.7 tdnode1 >> /etc/hosts"
display = "echo %s" % cmd display = "echo %s" % cmd
self.execCmd(display) self.execCmd(display)
self.execCmd(cmd) self.execCmd(cmd)
......
python .\test.py -f insert\basic.py python .\test.py -f insert\basic.py
\ No newline at end of file python .\test.py -f insert\int.py
python .\test.py -f insert\float.py
python .\test.py -f insert\bigint.py
python .\test.py -f insert\bool.py
python .\test.py -f insert\double.py
python .\test.py -f insert\smallint.py
python .\test.py -f insert\tinyint.py
python .\test.py -f insert\date.py
python .\test.py -f insert\binary.py
python .\test.py -f insert\nchar.py
python .\test.py -f query\filter.py
python .\test.py -f query\filterCombo.py
python .\test.py -f query\queryNormal.py
python .\test.py -f query\queryError.py
python .\test.py -f query\filterAllIntTypes.py
python .\test.py -f query\filterFloatAndDouble.py
python .\test.py -f query\filterOtherTypes.py
python .\test.py -f query\querySort.py
python .\test.py -f query\queryJoin.py
\ No newline at end of file
...@@ -38,7 +38,7 @@ class Node: ...@@ -38,7 +38,7 @@ class Node:
def buildTaosd(self): def buildTaosd(self):
try: try:
print(self.conn) print(self.conn)
# self.conn.run('echo "1234" > /home/chr/installtest/test.log') # self.conn.run('echo 1234 > /home/chr/installtest/test.log')
self.conn.run("cd /home/chr/installtest/ && tar -xvf %s " %self.verName) self.conn.run("cd /home/chr/installtest/ && tar -xvf %s " %self.verName)
self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath) self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath)
except Exception as e: except Exception as e:
...@@ -49,7 +49,7 @@ class Node: ...@@ -49,7 +49,7 @@ class Node:
def rebuildTaosd(self): def rebuildTaosd(self):
try: try:
print(self.conn) print(self.conn)
# self.conn.run('echo "1234" > /home/chr/installtest/test.log') # self.conn.run('echo 1234 > /home/chr/installtest/test.log')
self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath) self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath)
except Exception as e: except Exception as e:
print("Build Taosd error for node %d " % self.index) print("Build Taosd error for node %d " % self.index)
...@@ -108,7 +108,7 @@ class oneNode: ...@@ -108,7 +108,7 @@ class oneNode:
# install TDengine at 192.168.103/104/141 # install TDengine at 192.168.103/104/141
try: try:
node = Node(id, username, IP, passwd, version) node = Node(id, username, IP, passwd, version)
node.conn.run('echo "start taosd"') node.conn.run('echo start taosd')
node.buildTaosd() node.buildTaosd()
# clear DataPath , if need clear data # clear DataPath , if need clear data
node.clearData() node.clearData()
...@@ -128,7 +128,7 @@ class oneNode: ...@@ -128,7 +128,7 @@ class oneNode:
# start TDengine # start TDengine
try: try:
node = Node(id, username, IP, passwd, version) node = Node(id, username, IP, passwd, version)
node.conn.run('echo "restart taosd"') node.conn.run('echo restart taosd')
# clear DataPath , if need clear data # clear DataPath , if need clear data
node.clearData() node.clearData()
node.restartTaosd() node.restartTaosd()
...@@ -149,14 +149,14 @@ class oneNode: ...@@ -149,14 +149,14 @@ class oneNode:
verName = "TDengine-enterprise-server-%s-Linux-x64.tar.gz" % version verName = "TDengine-enterprise-server-%s-Linux-x64.tar.gz" % version
# installPath = "TDengine-enterprise-server-%s" % self.version # installPath = "TDengine-enterprise-server-%s" % self.version
node131 = Node(131, 'ubuntu', '192.168.1.131', 'tbase125!', '2.0.20.0') node131 = Node(131, 'ubuntu', '192.168.1.131', 'tbase125!', '2.0.20.0')
node131.conn.run('echo "upgrade cluster"') node131.conn.run('echo upgrade cluster')
node131.conn.run('sshpass -p tbase125! scp /nas/TDengine/v%s/enterprise/%s root@192.168.1.%d:/home/chr/installtest/' % (version,verName,id)) node131.conn.run('sshpass -p tbase125! scp /nas/TDengine/v%s/enterprise/%s root@192.168.1.%d:/home/chr/installtest/' % (version,verName,id))
node131.conn.close() node131.conn.close()
# upgrade TDengine at 192.168.103/104/141 # upgrade TDengine at 192.168.103/104/141
try: try:
node = Node(id, username, IP, passwd, version) node = Node(id, username, IP, passwd, version)
node.conn.run('echo "start taosd"') node.conn.run('echo start taosd')
node.conn.run('echo "1234" > /home/chr/test.log') node.conn.run('echo 1234 > /home/chr/test.log')
node.buildTaosd() node.buildTaosd()
time.sleep(5) time.sleep(5)
node.startTaosd() node.startTaosd()
...@@ -176,7 +176,7 @@ class oneNode: ...@@ -176,7 +176,7 @@ class oneNode:
# backCluster TDengine at 192.168.103/104/141 # backCluster TDengine at 192.168.103/104/141
try: try:
node = Node(id, username, IP, passwd, version) node = Node(id, username, IP, passwd, version)
node.conn.run('echo "rollback taos"') node.conn.run('echo rollback taos')
node.rebuildTaosd() node.rebuildTaosd()
time.sleep(5) time.sleep(5)
node.startTaosd() node.startTaosd()
......
...@@ -14,12 +14,14 @@ for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( ...@@ -14,12 +14,14 @@ for /F "usebackq tokens=*" %%i in (fulltest.bat) do (
echo Processing %%i echo Processing %%i
set /a a+=1 set /a a+=1
call %%i ARG1 -w 1 -m %1 > result_!a!.txt 2>error_!a!.txt call %%i ARG1 -w 1 -m %1 > result_!a!.txt 2>error_!a!.txt
if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && goto :end ) else ( call :colorEcho 0a "Success" &echo. )
) )
exit goto :end
:colorEcho :colorEcho
echo off echo off
<nul set /p ".=%DEL%" > "%~2" <nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i del "%~2" > nul 2>&1i
\ No newline at end of file
:end
\ No newline at end of file
...@@ -247,7 +247,7 @@ class TDDnode: ...@@ -247,7 +247,7 @@ class TDDnode:
paths = [] paths = []
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ((tool) in files): if ((tool) in files or ("%s.exe"%tool) in files):
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if ("packaging" not in rootRealPath):
paths.append(os.path.join(root, tool)) paths.append(os.path.join(root, tool))
......
...@@ -31,7 +31,7 @@ class TDTestCase: ...@@ -31,7 +31,7 @@ class TDTestCase:
def createOldDirAndAddWal(self): def createOldDirAndAddWal(self):
oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old"
os.system("sudo echo 'test' >> %s/wal" % oldDir) os.system("sudo echo test >> %s/wal" % oldDir)
def run(self): def run(self):
......
...@@ -36,13 +36,14 @@ if $data(2)[4] != ready then ...@@ -36,13 +36,14 @@ if $data(2)[4] != ready then
goto step1 goto step1
endi endi
print =============== create drop mnode 1
sql_error create mnode on dnode 1 sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1 sql_error drop mnode on dnode 1
print =============== create mnode 2
sql create mnode on dnode 2 sql create mnode on dnode 2
$x = 0 $x = 0
step1: step2:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 20 then
...@@ -65,11 +66,11 @@ if $data(2)[0] != 2 then ...@@ -65,11 +66,11 @@ if $data(2)[0] != 2 then
return -1 return -1
endi endi
if $data(2)[2] != FOLLOWER then if $data(2)[2] != FOLLOWER then
goto step1 goto step2
endi endi
sleep 2000 sleep 2000
print ============ drop mnodes print ============ drop mnode 2
sql drop mnode on dnode 2 sql drop mnode on dnode 2
sql show mnodes sql show mnodes
if $rows != 1 then if $rows != 1 then
......
...@@ -3,8 +3,12 @@ import taos ...@@ -3,8 +3,12 @@ import taos
import sys import sys
import time import time
import socket import socket
import pexpect
import os import os
import platform
if platform.system().lower() == 'windows':
import wexpect as taosExpect
else:
import pexpect as taosExpect
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -15,7 +19,11 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key ...@@ -15,7 +19,11 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
if len(key) == 0: if len(key) == 0:
tdLog.exit("taos test key is null!") tdLog.exit("taos test key is null!")
taosCmd = buildPath + '/build/bin/taos ' if platform.system().lower() == 'windows':
taosCmd = buildPath + '\\build\\bin\\taos.exe '
taosCmd = taosCmd.replace('\\','\\\\')
else:
taosCmd = buildPath + '/build/bin/taos '
if len(cfgDir) != 0: if len(cfgDir) != 0:
taosCmd = taosCmd + '-c ' + cfgDir taosCmd = taosCmd + '-c ' + cfgDir
...@@ -36,25 +44,30 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key ...@@ -36,25 +44,30 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key
tdLog.info ("taos cmd: %s" % taosCmd) tdLog.info ("taos cmd: %s" % taosCmd)
child = pexpect.spawn(taosCmd, timeout=3) child = taosExpect.spawn(taosCmd, timeout=3)
#output = child.readline() #output = child.readline()
#print (output.decode()) #print (output.decode())
if len(expectString) != 0: if len(expectString) != 0:
i = child.expect([expectString, pexpect.TIMEOUT, pexpect.EOF], timeout=6) i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
else: else:
i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6) i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6)
retResult = child.before.decode() if platform.system().lower() == 'windows':
retResult = child.before
else:
retResult = child.before.decode()
print(retResult) print(retResult)
#print(child.after.decode()) #print(child.after.decode())
if i == 0: if i == 0:
print ('taos login success! Here can run sql, taos> ') print ('taos login success! Here can run sql, taos> ')
if len(sqlString) != 0: if len(sqlString) != 0:
child.sendline (sqlString) child.sendline (sqlString)
w = child.expect(["Query OK", pexpect.TIMEOUT, pexpect.EOF], timeout=1) w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1)
if w == 0: if w == 0:
return "TAOS_OK" return "TAOS_OK"
else: else:
print(1)
print(retResult)
return "TAOS_FAIL" return "TAOS_FAIL"
else: else:
if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V': if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V':
...@@ -102,7 +115,7 @@ class TDTestCase: ...@@ -102,7 +115,7 @@ class TDTestCase:
projPath = selfPath[:selfPath.find("tests")] projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath): for root, dirs, files in os.walk(projPath):
if ("taosd" in files): if ("taosd" in files or "taosd.exe" in files):
rootRealPath = os.path.dirname(os.path.realpath(root)) rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath): if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")] buildPath = root[:len(root) - len("/build/bin")]
...@@ -275,11 +288,15 @@ class TDTestCase: ...@@ -275,11 +288,15 @@ class TDTestCase:
pwd=os.getcwd() pwd=os.getcwd()
newDbName="dbf" newDbName="dbf"
sqlFile = pwd + "/0-others/sql.txt" sqlFile = pwd + "/0-others/sql.txt"
sql1 = "echo 'create database " + newDbName + "' > " + sqlFile sql1 = "echo create database " + newDbName + " > " + sqlFile
sql2 = "echo 'use " + newDbName + "' >> " + sqlFile sql2 = "echo use " + newDbName + " >> " + sqlFile
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile if platform.system().lower() == 'windows':
sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile
sql5 = "echo 'show databases' >> " + sqlFile sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile
else:
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile
sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile
sql5 = "echo show databases >> " + sqlFile
os.system(sql1) os.system(sql1)
os.system(sql2) os.system(sql2)
os.system(sql3) os.system(sql3)
......
...@@ -216,11 +216,15 @@ class TDTestCase: ...@@ -216,11 +216,15 @@ class TDTestCase:
pwd=os.getcwd() pwd=os.getcwd()
newDbName="dbf" newDbName="dbf"
sqlFile = pwd + "/0-others/sql.txt" sqlFile = pwd + "/0-others/sql.txt"
sql1 = "echo 'create database " + newDbName + "' > " + sqlFile sql1 = "echo create database " + newDbName + " > " + sqlFile
sql2 = "echo 'use " + newDbName + "' >> " + sqlFile sql2 = "echo use " + newDbName + " >> " + sqlFile
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile if platform.system().lower() == 'windows':
sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile sql3 = "echo create table ntbf (ts timestamp, c binary(40)) no this item >> " + sqlFile
sql5 = "echo 'show databases' >> " + sqlFile sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile
else:
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile
sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile
sql5 = "echo show databases >> " + sqlFile
os.system(sql1) os.system(sql1)
os.system(sql2) os.system(sql2)
os.system(sql3) os.system(sql3)
......
...@@ -17,6 +17,8 @@ import sys ...@@ -17,6 +17,8 @@ import sys
import getopt import getopt
import subprocess import subprocess
import time import time
import base64
import json
from distutils.log import warn as printf from distutils.log import warn as printf
from fabric2 import Connection from fabric2 import Connection
sys.path.append("../pytest") sys.path.append("../pytest")
...@@ -38,8 +40,9 @@ if __name__ == "__main__": ...@@ -38,8 +40,9 @@ if __name__ == "__main__":
stop = 0 stop = 0
restart = False restart = False
windows = 0 windows = 0
opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [ updateCfgDict = {}
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows']) opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrwd:', [
'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows', 'updateCfgDict'])
for key, value in opts: for key, value in opts:
if key in ['-h', '--help']: if key in ['-h', '--help']:
tdLog.printNoPrefix( tdLog.printNoPrefix(
...@@ -53,6 +56,7 @@ if __name__ == "__main__": ...@@ -53,6 +56,7 @@ if __name__ == "__main__":
tdLog.printNoPrefix('-g valgrind Test Flag') tdLog.printNoPrefix('-g valgrind Test Flag')
tdLog.printNoPrefix('-r taosd restart test') tdLog.printNoPrefix('-r taosd restart test')
tdLog.printNoPrefix('-w taos on windows') tdLog.printNoPrefix('-w taos on windows')
tdLog.printNoPrefix('-d update cfg dict, base64 json str')
sys.exit(0) sys.exit(0)
if key in ['-r', '--restart']: if key in ['-r', '--restart']:
...@@ -88,6 +92,12 @@ if __name__ == "__main__": ...@@ -88,6 +92,12 @@ if __name__ == "__main__":
if key in ['-w', '--windows']: if key in ['-w', '--windows']:
windows = 1 windows = 1
if key in ['-d', '--updateCfgDict']:
try:
updateCfgDict = eval(base64.b64decode(value.encode()).decode())
except:
print('updateCfgDict convert fail.')
sys.exit(0)
if (stop != 0): if (stop != 0):
if (valgrind == 0): if (valgrind == 0):
toBeKilled = "taosd" toBeKilled = "taosd"
...@@ -127,15 +137,47 @@ if __name__ == "__main__": ...@@ -127,15 +137,47 @@ if __name__ == "__main__":
if windows: if windows:
tdCases.logSql(logSql) tdCases.logSql(logSql)
tdLog.info("Procedures for testing self-deployment") tdLog.info("Procedures for testing self-deployment")
td_clinet = TDSimClient("C:\\TDengine") tdDnodes.init(deployPath)
td_clinet.deploy() tdDnodes.setTestCluster(testCluster)
remote_conn = Connection("root@%s"%host) tdDnodes.setValgrind(valgrind)
with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): tdDnodes.stopAll()
remote_conn.run("python3 ./test.py") key_word = 'tdCases.addWindows'
is_test_framework = 0
try:
if key_word in open(fileName).read():
is_test_framework = 1
except:
pass
updateCfgDictStr = ''
if is_test_framework:
moduleName = fileName.replace(".py", "").replace(os.sep, ".")
uModule = importlib.import_module(moduleName)
try:
ucase = uModule.TDTestCase()
if ((json.dumps(updateCfgDict) == '{}') and (ucase.updatecfgDict is not None)):
updateCfgDict = ucase.updatecfgDict
updateCfgDictStr = "-d %s"%base64.b64encode(json.dumps(updateCfgDict).encode()).decode()
except :
pass
else:
pass
tdDnodes.deploy(1,updateCfgDict)
if masterIp == "" or masterIp == "localhost":
tdDnodes.startWin(1)
else:
remote_conn = Connection("root@%s"%host)
with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'):
remote_conn.run("python3 ./test.py %s"%updateCfgDictStr)
# print("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr)
# os.system("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr)
# time.sleep(2)
conn = taos.connect( conn = taos.connect(
host="%s"%(host), host="%s"%(host),
config=td_clinet.cfgDir) config=tdDnodes.sim.getCfgDir())
tdCases.runOneWindows(conn, fileName) if is_test_framework:
tdCases.runOneWindows(conn, fileName)
else:
tdCases.runAllWindows(conn)
else: else:
tdDnodes.init(deployPath) tdDnodes.init(deployPath)
tdDnodes.setTestCluster(testCluster) tdDnodes.setTestCluster(testCluster)
...@@ -153,16 +195,13 @@ if __name__ == "__main__": ...@@ -153,16 +195,13 @@ if __name__ == "__main__":
uModule = importlib.import_module(moduleName) uModule = importlib.import_module(moduleName)
try: try:
ucase = uModule.TDTestCase() ucase = uModule.TDTestCase()
tdDnodes.deploy(1,ucase.updatecfgDict) if (json.dumps(updateCfgDict) == '{}'):
except : updateCfgDict = ucase.updatecfgDict
tdDnodes.deploy(1,{}) except:
else: pass
pass tdDnodes.deploy(1,updateCfgDict)
tdDnodes.deploy(1,{})
tdDnodes.start(1) tdDnodes.start(1)
tdCases.logSql(logSql) tdCases.logSql(logSql)
if testCluster: if testCluster:
......
aux_source_directory(src SHELL_SRC) aux_source_directory(src SHELL_SRC)
add_executable(shell ${SHELL_SRC}) add_executable(shell ${SHELL_SRC})
if(TD_WINDOWS)
target_link_libraries(shell PUBLIC taos_static)
else()
target_link_libraries(shell PUBLIC taos)
endif ()
target_link_libraries( target_link_libraries(
shell shell
PUBLIC taos
PRIVATE os common transport util PRIVATE os common transport util
) )
target_include_directories( target_include_directories(
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define SHELL_VERSION "Print program version." #define SHELL_VERSION "Print program version."
#define SHELL_EMAIL "<support@taosdata.com>" #define SHELL_EMAIL "<support@taosdata.com>"
static int32_t shellParseSingleOpt(int32_t key, char *arg);
void shellPrintHelp() { void shellPrintHelp() {
char indent[] = " "; char indent[] = " ";
printf("Usage: taos [OPTION...] \n\n"); printf("Usage: taos [OPTION...] \n\n");
...@@ -90,6 +92,21 @@ static struct argp_option shellOptions[] = { ...@@ -90,6 +92,21 @@ static struct argp_option shellOptions[] = {
{0}, {0},
}; };
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); }
static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
static void shellParseArgsUseArgp(int argc, char *argv[]) {
argp_program_version = shell.info.programVersion;
argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args);
}
#endif
#ifndef ARGP_ERR_UNKNOWN
#define ARGP_ERR_UNKNOWN E2BIG
#endif
static int32_t shellParseSingleOpt(int32_t key, char *arg) { static int32_t shellParseSingleOpt(int32_t key, char *arg) {
SShellArgs *pArgs = &shell.args; SShellArgs *pArgs = &shell.args;
...@@ -196,8 +213,8 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { ...@@ -196,8 +213,8 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
} }
shellParseSingleOpt(key[1], val); shellParseSingleOpt(key[1], val);
i++; i++;
} else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'c' || key[1] == 'r' || key[1] == 'k' || key[1] == 't' || } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'C' || key[1] == 'r' || key[1] == 'k' ||
key[1] == 'V') { key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1) {
shellParseSingleOpt(key[1], NULL); shellParseSingleOpt(key[1], NULL);
} else { } else {
fprintf(stderr, "invalid option %s\n", key); fprintf(stderr, "invalid option %s\n", key);
...@@ -208,21 +225,10 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { ...@@ -208,21 +225,10 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
return 0; return 0;
} }
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); }
static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
static void shellParseArgsUseArgp(int argc, char *argv[]) {
argp_program_version = shell.info.programVersion;
argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args);
}
#endif
static void shellInitArgs(int argc, char *argv[]) { static void shellInitArgs(int argc, char *argv[]) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (strncmp(argv[i], "-p", 2) == 0) { if (strncmp(argv[i], "-p", 2) == 0) {
printf(shell.info.clientVersion, tsOsName, taos_get_client_info()); // printf(shell.info.clientVersion, tsOsName, taos_get_client_info());
if (strlen(argv[i]) == 2) { if (strlen(argv[i]) == 2) {
printf("Enter password: "); printf("Enter password: ");
taosSetConsoleEcho(false); taosSetConsoleEcho(false);
...@@ -341,7 +347,7 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { ...@@ -341,7 +347,7 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) {
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
shell.info.osname = "Windows"; shell.info.osname = "Windows";
snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE); snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE);
// if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1; if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
shell.info.osname = "Darwin"; shell.info.osname = "Darwin";
snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE); snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册