提交 4dc3d88b 编写于 作者: sangshuduo's avatar sangshuduo

Merge branch '3.0' into feat/sangshuduo/TD-14141-update-taostools-for3.0

[submodule "src/connector/go"]
path = src/connector/go
url = git@github.com:taosdata/driver-go.git
[submodule "src/connector/hivemq-tdengine-extension"]
path = src/connector/hivemq-tdengine-extension
url = git@github.com:taosdata/hivemq-tdengine-extension.git
[submodule "deps/TSZ"]
path = deps/TSZ
url = https://github.com/taosdata/TSZ.git
[submodule "examples/rust"]
path = examples/rust
url = https://github.com/songtianyi/tdengine-rust-bindings.git
...@@ -118,6 +118,7 @@ def pre_test(){ ...@@ -118,6 +118,7 @@ def pre_test(){
git rm --cached tools/taos-tools 2>/dev/null || : git rm --cached tools/taos-tools 2>/dev/null || :
git rm --cached tools/taosadapter 2>/dev/null || : git rm --cached tools/taosadapter 2>/dev/null || :
git rm --cached tools/taosws-rs 2>/dev/null || : git rm --cached tools/taosws-rs 2>/dev/null || :
git rm --cached examples/rust 2>/dev/null || :
''' '''
sh ''' sh '''
cd ${WKC} cd ${WKC}
...@@ -269,6 +270,7 @@ def pre_test_win(){ ...@@ -269,6 +270,7 @@ def pre_test_win(){
git rm --cached tools/taos-tools 2>nul git rm --cached tools/taos-tools 2>nul
git rm --cached tools/taosadapter 2>nul git rm --cached tools/taosadapter 2>nul
git rm --cached tools/taosws-rs 2>nul git rm --cached tools/taosws-rs 2>nul
git rm --cached examples/rust 2>nul
exit 0 exit 0
''' '''
bat ''' bat '''
......
...@@ -90,6 +90,12 @@ ELSE () ...@@ -90,6 +90,12 @@ ELSE ()
ENDIF () ENDIF ()
ENDIF () ENDIF ()
option(
RUST_BINDINGS
"If build with rust-bindings"
ON
)
option( option(
JEMALLOC_ENABLED JEMALLOC_ENABLED
"If build with jemalloc" "If build with jemalloc"
......
# rust-bindings
ExternalProject_Add(rust-bindings
GIT_REPOSITORY https://github.com/songtianyi/tdengine-rust-bindings.git
GIT_TAG 7ed7a97
SOURCE_DIR "${TD_SOURCE_DIR}/examples/rust"
BINARY_DIR "${TD_SOURCE_DIR}/examples/rust"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
...@@ -105,6 +105,11 @@ if(${BUILD_WITH_SQLITE}) ...@@ -105,6 +105,11 @@ if(${BUILD_WITH_SQLITE})
cat("${TD_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) cat("${TD_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${BUILD_WITH_SQLITE}) endif(${BUILD_WITH_SQLITE})
# rust-bindings
if(${RUST_BINDINGS})
cat("${TD_SUPPORT_DIR}/rust-bindings_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${RUST_BINDINGS})
# lucene # lucene
if(${BUILD_WITH_LUCENE}) if(${BUILD_WITH_LUCENE})
cat("${TD_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) cat("${TD_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
...@@ -135,6 +140,24 @@ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . ...@@ -135,6 +140,24 @@ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build . execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
# clear submodule
execute_process(COMMAND git submodule deinit -f tools/taos-tools
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git rm --cached tools/taos-tools
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git submodule deinit -f tools/taosadapter
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git rm --cached tools/taosadapter
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git submodule deinit -f tools/taosws-rs
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git rm --cached tools/taosws-rs
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git submodule deinit -f examples/rust
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
execute_process(COMMAND git rm --cached examples/rust
WORKING_DIRECTORY "${TD_SOURCE_DIR}")
# ================================================================================================ # ================================================================================================
# Build # Build
......
Subproject commit 7ed7a97715388fa144718764d6bf20f9bfc29a12
...@@ -155,7 +155,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t ...@@ -155,7 +155,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet); void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet);
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes); int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList/*,int32_t* resNum, SExplainExecInfo** pRes*/);
int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len); int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len);
......
...@@ -16,65 +16,9 @@ ...@@ -16,65 +16,9 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "tdatablock.h" #include "tdatablock.h"
#include "tcompare.h" #include "tcompare.h"
#include "tglobal.h"
#include "tlog.h" #include "tlog.h"
#include "tname.h" #include "tname.h"
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
pEp->port = 0;
strcpy(pEp->fqdn, ep);
char* temp = strchr(pEp->fqdn, ':');
if (temp) {
*temp = 0;
pEp->port = atoi(temp + 1);
}
if (pEp->port == 0) {
pEp->port = tsServerPort;
}
return 0;
}
void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port) {
if (pEpSet == NULL || fqdn == NULL || strlen(fqdn) == 0) {
return;
}
int32_t index = pEpSet->numOfEps;
tstrncpy(pEpSet->eps[index].fqdn, fqdn, tListLen(pEpSet->eps[index].fqdn));
pEpSet->eps[index].port = port;
pEpSet->numOfEps += 1;
}
bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2) {
if (s1->numOfEps != s2->numOfEps || s1->inUse != s2->inUse) {
return false;
}
for (int32_t i = 0; i < s1->numOfEps; i++) {
if (s1->eps[i].port != s2->eps[i].port || strncmp(s1->eps[i].fqdn, s2->eps[i].fqdn, TSDB_FQDN_LEN) != 0)
return false;
}
return true;
}
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) {
taosCorBeginWrite(&pEpSet->version);
pEpSet->epSet = *pNewEpSet;
taosCorEndWrite(&pEpSet->version);
}
SEpSet getEpSet_s(SCorEpSet* pEpSet) {
SEpSet ep = {0};
taosCorBeginRead(&pEpSet->version);
ep = pEpSet->epSet;
taosCorEndRead(&pEpSet->version);
return ep;
}
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) { int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
ASSERT(pColumnInfoData != NULL); ASSERT(pColumnInfoData != NULL);
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "tdatablock.h"
#include "tglobal.h"
#include "tlog.h"
#include "tname.h"
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
pEp->port = 0;
strcpy(pEp->fqdn, ep);
char* temp = strchr(pEp->fqdn, ':');
if (temp) {
*temp = 0;
pEp->port = atoi(temp + 1);
}
if (pEp->port == 0) {
pEp->port = tsServerPort;
}
return 0;
}
void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port) {
if (pEpSet == NULL || fqdn == NULL || strlen(fqdn) == 0) {
return;
}
int32_t index = pEpSet->numOfEps;
tstrncpy(pEpSet->eps[index].fqdn, fqdn, tListLen(pEpSet->eps[index].fqdn));
pEpSet->eps[index].port = port;
pEpSet->numOfEps += 1;
}
bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2) {
if (s1->numOfEps != s2->numOfEps || s1->inUse != s2->inUse) {
return false;
}
for (int32_t i = 0; i < s1->numOfEps; i++) {
if (s1->eps[i].port != s2->eps[i].port || strncmp(s1->eps[i].fqdn, s2->eps[i].fqdn, TSDB_FQDN_LEN) != 0)
return false;
}
return true;
}
void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) {
taosCorBeginWrite(&pEpSet->version);
pEpSet->epSet = *pNewEpSet;
taosCorEndWrite(&pEpSet->version);
}
SEpSet getEpSet_s(SCorEpSet* pEpSet) {
SEpSet ep = {0};
taosCorBeginRead(&pEpSet->version);
ep = pEpSet->epSet;
taosCorEndRead(&pEpSet->version);
return ep;
}
...@@ -20,34 +20,6 @@ ...@@ -20,34 +20,6 @@
#define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T) #define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T)
bool tscValidateTableNameLength(size_t len) { return len < TSDB_TABLE_NAME_LEN; }
#if 0
// TODO refactor
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) {
if (numOfFilters == 0 || src == NULL) {
assert(src == NULL);
return NULL;
}
SColumnFilterInfo* pFilter = taosMemoryCalloc(1, numOfFilters * sizeof(SColumnFilterInfo));
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
for (int32_t j = 0; j < numOfFilters; ++j) {
if (pFilter[j].filterstr) {
size_t len = (size_t) pFilter[j].len + 1 * TSDB_NCHAR_SIZE;
pFilter[j].pz = (int64_t) taosMemoryCalloc(1, len);
memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t) pFilter[j].len);
}
}
assert(src->filterstr == 0 || src->filterstr == 1);
assert(!(src->lowerRelOptr == 0 && src->upperRelOptr == 0));
return pFilter;
}
#endif
#if 0 #if 0
int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision) { int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision) {
if (slidingTime == 0) { if (slidingTime == 0) {
......
...@@ -447,6 +447,7 @@ _err: ...@@ -447,6 +447,7 @@ _err:
static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) { static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
SDecoder decoder = {0}; SDecoder decoder = {0};
SEncoder encoder = {0};
int32_t rcode = 0; int32_t rcode = 0;
SVCreateTbBatchReq req = {0}; SVCreateTbBatchReq req = {0};
SVCreateTbReq *pCreateReq; SVCreateTbReq *pCreateReq;
...@@ -515,7 +516,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR ...@@ -515,7 +516,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
tdUidStoreFree(pStore); tdUidStoreFree(pStore);
// prepare rsp // prepare rsp
SEncoder encoder = {0};
int32_t ret = 0; int32_t ret = 0;
tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret); tEncodeSize(tEncodeSVCreateTbBatchRsp, &rsp, pRsp->contLen, ret);
pRsp->pCont = rpcMallocCont(pRsp->contLen); pRsp->pCont = rpcMallocCont(pRsp->contLen);
......
...@@ -855,7 +855,6 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin ...@@ -855,7 +855,6 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData, int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total, int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
SArray* pColList); SArray* pColList);
STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key);
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag); int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag);
...@@ -986,9 +985,8 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length); ...@@ -986,9 +985,8 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length);
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId,
const char* sql, EOPTR_EXEC_MODEL model); const char* sql, EOPTR_EXEC_MODEL model);
int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList);
int32_t* resNum);
int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result); int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length); int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length);
......
...@@ -496,11 +496,9 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) { ...@@ -496,11 +496,9 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) {
doDestroyTask(pTaskInfo); doDestroyTask(pTaskInfo);
} }
int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t* resNum, SExplainExecInfo** pRes) { int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList) {
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
int32_t capacity = 0; return getOperatorExplainExecInfo(pTaskInfo->pRoot, pExecInfoList);
return getOperatorExplainExecInfo(pTaskInfo->pRoot, pRes, &capacity, resNum);
} }
int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) { int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) {
......
...@@ -4613,42 +4613,29 @@ void releaseQueryBuf(size_t numOfTables) { ...@@ -4613,42 +4613,29 @@ void releaseQueryBuf(size_t numOfTables) {
atomic_add_fetch_64(&tsQueryBufferSizeBytes, t); atomic_add_fetch_64(&tsQueryBufferSizeBytes, t);
} }
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo** pRes, int32_t* capacity, int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList) {
int32_t* resNum) { SExplainExecInfo execInfo = {0};
if (*resNum >= *capacity) { SExplainExecInfo* pExplainInfo = taosArrayPush(pExecInfoList, &execInfo);
*capacity += 10;
*pRes = taosMemoryRealloc(*pRes, (*capacity) * sizeof(SExplainExecInfo));
if (NULL == *pRes) {
qError("malloc %d failed", (*capacity) * (int32_t)sizeof(SExplainExecInfo));
return TSDB_CODE_QRY_OUT_OF_MEMORY;
}
}
SExplainExecInfo* pInfo = &(*pRes)[*resNum];
pInfo->numOfRows = operatorInfo->resultInfo.totalRows; pExplainInfo->numOfRows = operatorInfo->resultInfo.totalRows;
pInfo->startupCost = operatorInfo->cost.openCost; pExplainInfo->startupCost = operatorInfo->cost.openCost;
pInfo->totalCost = operatorInfo->cost.totalCost; pExplainInfo->totalCost = operatorInfo->cost.totalCost;
pExplainInfo->verboseLen = 0;
pExplainInfo->verboseInfo = NULL;
if (operatorInfo->fpSet.getExplainFn) { if (operatorInfo->fpSet.getExplainFn) {
int32_t code = operatorInfo->fpSet.getExplainFn(operatorInfo, &pInfo->verboseInfo, &pInfo->verboseLen); int32_t code = operatorInfo->fpSet.getExplainFn(operatorInfo, &pExplainInfo->verboseInfo, &pExplainInfo->verboseLen);
if (code) { if (code) {
qError("%s operator getExplainFn failed, code:%s", GET_TASKID(operatorInfo->pTaskInfo), tstrerror(code)); qError("%s operator getExplainFn failed, code:%s", GET_TASKID(operatorInfo->pTaskInfo), tstrerror(code));
return code; return code;
} }
} else {
pInfo->verboseLen = 0;
pInfo->verboseInfo = NULL;
} }
++(*resNum);
int32_t code = 0; int32_t code = 0;
for (int32_t i = 0; i < operatorInfo->numOfDownstream; ++i) { for (int32_t i = 0; i < operatorInfo->numOfDownstream; ++i) {
code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pRes, capacity, resNum); code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pExecInfoList);
if (code) { if (code != TSDB_CODE_SUCCESS) {
taosMemoryFreeClear(*pRes); // taosMemoryFreeClear(*pRes);
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
} }
......
...@@ -31,14 +31,21 @@ static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity ...@@ -31,14 +31,21 @@ static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity
static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes, static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup); uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup);
static void freeGroupKey(void* param) {
SGroupKeys* pKey = (SGroupKeys*) param;
taosMemoryFree(pKey->pData);
}
static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) { static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param; SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*)param;
cleanupBasicInfo(&pInfo->binfo); cleanupBasicInfo(&pInfo->binfo);
taosMemoryFreeClear(pInfo->keyBuf); taosMemoryFreeClear(pInfo->keyBuf);
taosArrayDestroy(pInfo->pGroupCols); taosArrayDestroy(pInfo->pGroupCols);
taosArrayDestroy(pInfo->pGroupColVals); taosArrayDestroyEx(pInfo->pGroupColVals, freeGroupKey);
cleanupExprSupp(&pInfo->scalarSup); cleanupExprSupp(&pInfo->scalarSup);
cleanupGroupResInfo(&pInfo->groupResInfo);
cleanupAggSup(&pInfo->aggSup);
taosMemoryFreeClear(param); taosMemoryFreeClear(param);
} }
...@@ -414,8 +421,6 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx ...@@ -414,8 +421,6 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pOperator->blocking = true; pOperator->blocking = true;
pOperator->status = OP_NOT_OPENED; pOperator->status = OP_NOT_OPENED;
// pOperator->operatorType = OP_Groupby; // pOperator->operatorType = OP_Groupby;
pOperator->exprSupp.pExprInfo = pExprInfo;
pOperator->exprSupp.numOfExprs = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
pOperator->pTaskInfo = pTaskInfo; pOperator->pTaskInfo = pTaskInfo;
......
...@@ -2414,7 +2414,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2414,7 +2414,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "hyperloglog", .name = "hyperloglog",
.type = FUNCTION_TYPE_HYPERLOGLOG, .type = FUNCTION_TYPE_HYPERLOGLOG,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateHLL, .translateFunc = translateHLL,
.getEnvFunc = getHLLFuncEnv, .getEnvFunc = getHLLFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
...@@ -2428,7 +2428,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2428,7 +2428,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
}, },
{ {
.name = "_hyperloglog_partial", .name = "_hyperloglog_partial",
.type = FUNCTION_TYPE_HYPERLOGLOG_PARTIAL, .type = FUNCTION_TYPE_HYPERLOGLOG_PARTIAL | FUNC_MGT_TIMELINE_FUNC,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateHLLPartial, .translateFunc = translateHLLPartial,
.getEnvFunc = getHLLFuncEnv, .getEnvFunc = getHLLFuncEnv,
...@@ -2440,7 +2440,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2440,7 +2440,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
}, },
{ {
.name = "_hyperloglog_merge", .name = "_hyperloglog_merge",
.type = FUNCTION_TYPE_HYPERLOGLOG_MERGE, .type = FUNCTION_TYPE_HYPERLOGLOG_MERGE | FUNC_MGT_TIMELINE_FUNC,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateHLLMerge, .translateFunc = translateHLLMerge,
.getEnvFunc = getHLLFuncEnv, .getEnvFunc = getHLLFuncEnv,
......
...@@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieve ...@@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieve
void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete); void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete);
int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn); int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn);
int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx); int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx);
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num); int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList);
int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code); int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code);
void qwFreeFetchRsp(void *msg); void qwFreeFetchRsp(void *msg);
int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp); int32_t qwMallocFetchRsp(int32_t length, SRetrieveTableRsp **rsp);
......
...@@ -82,8 +82,9 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c ...@@ -82,8 +82,9 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execInfo, int32_t num) { int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) {
SExplainRsp rsp = {.numOfPlans = num, .subplanInfo = execInfo}; SExplainExecInfo* pInfo = taosArrayGet(pExecList, 0);
SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo};
int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp); int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp);
void * pRsp = rpcMallocCont(contLen); void * pRsp = rpcMallocCont(contLen);
...@@ -96,10 +97,9 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execIn ...@@ -96,10 +97,9 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SExplainExecInfo *execIn
.code = 0, .code = 0,
.info = *pConn, .info = *pConn,
}; };
rpcRsp.info.ahandle = NULL;
rpcRsp.info.ahandle = NULL;
tmsgSendRsp(&rpcRsp); tmsgSendRsp(&rpcRsp);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -44,18 +44,24 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re ...@@ -44,18 +44,24 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re
QW_RET(TSDB_CODE_SUCCESS); QW_RET(TSDB_CODE_SUCCESS);
} }
static void freeItem(void* param) {
SExplainExecInfo* pInfo = param;
taosMemoryFree(pInfo->verboseInfo);
}
int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) { int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
qTaskInfo_t taskHandle = ctx->taskHandle; qTaskInfo_t taskHandle = ctx->taskHandle;
if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) { if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) {
if (ctx->explain) { if (ctx->explain) {
SExplainExecInfo *execInfo = NULL; SArray* execInfoList = taosArrayInit(4, sizeof(SExplainExecInfo));
int32_t resNum = 0; QW_ERR_RET(qGetExplainExecInfo(taskHandle, execInfoList));
QW_ERR_RET(qGetExplainExecInfo(taskHandle, &resNum, &execInfo));
SRpcHandleInfo connInfo = ctx->ctrlConnInfo; SRpcHandleInfo connInfo = ctx->ctrlConnInfo;
connInfo.ahandle = NULL; connInfo.ahandle = NULL;
QW_ERR_RET(qwBuildAndSendExplainRsp(&connInfo, execInfo, resNum)); int32_t code = qwBuildAndSendExplainRsp(&connInfo, execInfoList);
taosArrayDestroyEx(execInfoList, freeItem);
QW_ERR_RET(code);
} }
if (!ctx->needFetch) { if (!ctx->needFetch) {
......
...@@ -790,65 +790,6 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs ...@@ -790,65 +790,6 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
} }
} while (0); } while (0);
#if 0
// fake match
//
// condition1:
// I have snapshot, no log, preIndex > myLastIndex
//
// condition2:
// I have snapshot, have log, log <= snapshot, preIndex > myLastIndex
//
// condition3:
// I have snapshot, preIndex < snapshot.lastApplyIndex
//
// condition4:
// I have snapshot, preIndex == snapshot.lastApplyIndex, no data
//
// operation:
// match snapshot.lastApplyIndex - 1;
// no operation on log
do {
SyncIndex myLastIndex = syncNodeGetLastIndex(ths);
SSnapshot snapshot;
ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot);
bool condition0 = (pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) &&
syncNodeHasSnapshot(ths);
bool condition1 =
condition0 && (ths->pLogStore->syncLogEntryCount(ths->pLogStore) == 0) && (pMsg->prevLogIndex > myLastIndex); // donot use syncLogEntryCount!!! use isEmpty
bool condition2 = condition0 && (ths->pLogStore->syncLogLastIndex(ths->pLogStore) <= snapshot.lastApplyIndex) &&
(pMsg->prevLogIndex > myLastIndex);
bool condition3 = condition0 && (pMsg->prevLogIndex < snapshot.lastApplyIndex);
bool condition4 = condition0 && (pMsg->prevLogIndex == snapshot.lastApplyIndex) && (pMsg->dataLen == 0);
bool condition = condition1 || condition2 || condition3 || condition4;
if (condition) {
char logBuf[128];
snprintf(logBuf, sizeof(logBuf), "recv sync-append-entries, fake match, pre-index:%" PRId64 ", pre-term:%" PRIu64,
pMsg->prevLogIndex, pMsg->prevLogTerm);
syncNodeEventLog(ths, logBuf);
// prepare response msg
SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(ths->vgId);
pReply->srcId = ths->myRaftId;
pReply->destId = pMsg->srcId;
pReply->term = ths->pRaftStore->currentTerm;
pReply->privateTerm = ths->pNewNodeReceiver->privateTerm;
pReply->success = true;
pReply->matchIndex = snapshot.lastApplyIndex;
// send response
SRpcMsg rpcMsg;
syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg);
syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg);
syncAppendEntriesReplyDestroy(pReply);
return ret;
}
} while (0);
#endif
// fake match // fake match
// //
// condition1: // condition1:
......
...@@ -11,7 +11,7 @@ from util.dnodes import * ...@@ -11,7 +11,7 @@ from util.dnodes import *
class TDTestCase: class TDTestCase:
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
def init(self, conn, logSql): def init(self, conn, logSql):
...@@ -37,7 +37,7 @@ class TDTestCase: ...@@ -37,7 +37,7 @@ class TDTestCase:
def illegal_params(self): def illegal_params(self):
illegal_params = ["1","0","NULL","False","True" ,"keep","now" ,"*" , "," ,"_" , "abc" ,"keep"] illegal_params = ["1","0","NULL","False","True" ,"keep","now" ,"*" , "," ,"_" , "abc" ,"keep"]
for value in illegal_params: for value in illegal_params:
tdSql.error("create database testdb replica 1 cachemodel '%s' " %value) tdSql.error("create database testdb replica 1 cachemodel '%s' " %value)
...@@ -80,9 +80,9 @@ class TDTestCase: ...@@ -80,9 +80,9 @@ class TDTestCase:
tdSql.execute(" insert into tb2 values(now , %d, %f)" %(k,k*10) ) tdSql.execute(" insert into tb2 values(now , %d, %f)" %(k,k*10) )
def check_cachemodel_sets(self): def check_cachemodel_sets(self):
# check cache_last value for database # check cache_last value for database
tdSql.query(" show databases ") tdSql.query(" show databases ")
databases_infos = tdSql.queryResult databases_infos = tdSql.queryResult
...@@ -96,10 +96,10 @@ class TDTestCase: ...@@ -96,10 +96,10 @@ class TDTestCase:
continue continue
cache_lasts[dbname]=self.getCacheModelNum(cache_last_value) cache_lasts[dbname]=self.getCacheModelNum(cache_last_value)
# cache_last_set value # cache_last_set value
for k , v in cache_lasts.items(): for k , v in cache_lasts.items():
if k=="testdb_"+str(self.getCacheModelStr(v)): if k=="testdb_"+str(self.getCacheModelStr(v)):
tdLog.info(" database %s cache_last value check pass, value is %s "%(k,self.getCacheModelStr(v)) ) tdLog.info(" database %s cache_last value check pass, value is %s "%(k,self.getCacheModelStr(v)) )
else: else:
...@@ -116,7 +116,7 @@ class TDTestCase: ...@@ -116,7 +116,7 @@ class TDTestCase:
dataPath = buildPath + "/../sim/dnode1/data" dataPath = buildPath + "/../sim/dnode1/data"
abs_vnodePath = os.path.abspath(dataPath)+"/vnode/" abs_vnodePath = os.path.abspath(dataPath)+"/vnode/"
tdLog.info("abs_vnodePath: %s" % abs_vnodePath) tdLog.info("abs_vnodePath: %s" % abs_vnodePath)
tdSql.query(" show dnodes ") tdSql.query(" show dnodes ")
dnode_id = tdSql.queryResult[0][0] dnode_id = tdSql.queryResult[0][0]
...@@ -127,7 +127,7 @@ class TDTestCase: ...@@ -127,7 +127,7 @@ class TDTestCase:
vgroups_infos = tdSql.queryResult vgroups_infos = tdSql.queryResult
for vgroup_info in vgroups_infos: for vgroup_info in vgroups_infos:
vnode_json = abs_vnodePath + "/vnode" +f"{vgroup_info[0]}/" + "vnode.json" vnode_json = abs_vnodePath + "/vnode" +f"{vgroup_info[0]}/" + "vnode.json"
vnode_info_of_db = f"cat {vnode_json}" vnode_info_of_db = f"cat {vnode_json}"
vnode_info = subprocess.check_output(vnode_info_of_db, shell=True).decode("utf-8") vnode_info = subprocess.check_output(vnode_info_of_db, shell=True).decode("utf-8")
infoDict = json.loads(vnode_info) infoDict = json.loads(vnode_info)
vnode_json_of_dbname = f"{dnode_id}."+ dbname vnode_json_of_dbname = f"{dnode_id}."+ dbname
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
tdLog.exit("cacheLast not found in vnode.json of vnode%d "%(vgroup_info[0])) tdLog.exit("cacheLast not found in vnode.json of vnode%d "%(vgroup_info[0]))
def restart_check_cachemodel_sets(self): def restart_check_cachemodel_sets(self):
for i in range(3): for i in range(3):
tdSql.query("show dnodes") tdSql.query("show dnodes")
index = tdSql.getData(0, 0) index = tdSql.getData(0, 0)
...@@ -157,7 +157,7 @@ class TDTestCase: ...@@ -157,7 +157,7 @@ class TDTestCase:
self.prepare_datas() self.prepare_datas()
self.check_cachemodel_sets() self.check_cachemodel_sets()
self.restart_check_cachemodel_sets() self.restart_check_cachemodel_sets()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -33,14 +33,14 @@ class TDTestCase: ...@@ -33,14 +33,14 @@ class TDTestCase:
tdSql.query('select database()') tdSql.query('select database()')
tdSql.checkData(0,0,self.dbname) tdSql.checkData(0,0,self.dbname)
tdSql.execute(f'drop database {self.dbname}') tdSql.execute(f'drop database {self.dbname}')
def check_version(self): def check_version(self):
taos_list = ['server','client'] taos_list = ['server','client']
for i in taos_list: for i in taos_list:
tdSql.query(f'select {i}_version()') tdSql.query(f'select {i}_version()')
version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1] version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1]
tdSql.checkData(0,0,version_info) tdSql.checkData(0,0,version_info)
def get_server_status(self): def get_server_status(self):
sleep(self.delaytime) sleep(self.delaytime)
tdSql.query('select server_status()') tdSql.query('select server_status()')
...@@ -51,7 +51,7 @@ class TDTestCase: ...@@ -51,7 +51,7 @@ class TDTestCase:
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sleep(10) sleep(10)
tdSql.error('select server_status()') tdSql.error('select server_status()')
def run(self): def run(self):
self.get_database_info() self.get_database_info()
self.check_version() self.check_version()
...@@ -61,4 +61,4 @@ class TDTestCase: ...@@ -61,4 +61,4 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -18,7 +18,7 @@ from util.dnodes import * ...@@ -18,7 +18,7 @@ from util.dnodes import *
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
if len(key) == 0: if len(key) == 0:
tdLog.exit("taos test key is null!") tdLog.exit("taos test key is null!")
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = buildPath + '\\build\\bin\\taos.exe '
taosCmd = taosCmd.replace('\\','\\\\') taosCmd = taosCmd.replace('\\','\\\\')
...@@ -214,7 +214,7 @@ class TDTestCase: ...@@ -214,7 +214,7 @@ class TDTestCase:
retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '') retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '')
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
tdLog.exit("taos -A fail") tdLog.exit("taos -A fail")
sqlString = 'create database ' + newDbName + ';' sqlString = 'create database ' + newDbName + ';'
retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal) retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal)
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
...@@ -237,7 +237,7 @@ class TDTestCase: ...@@ -237,7 +237,7 @@ class TDTestCase:
tdLog.exit("taos -s fail") tdLog.exit("taos -s fail")
print ("========== check new db ==========") print ("========== check new db ==========")
tdSql.query("show databases") tdSql.query("show databases")
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
if tdSql.getData(i, 0) == newDbName: if tdSql.getData(i, 0) == newDbName:
break break
...@@ -259,24 +259,24 @@ class TDTestCase: ...@@ -259,24 +259,24 @@ class TDTestCase:
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
tdLog.exit("taos -s insert data fail") tdLog.exit("taos -s insert data fail")
sqlString = "select * from " + newDbName + ".ctb0" sqlString = "select * from " + newDbName + ".ctb0"
tdSql.query(sqlString) tdSql.query(sqlString)
tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
tdSql.checkData(0, 1, 10) tdSql.checkData(0, 1, 10)
tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
tdSql.checkData(1, 1, 20) tdSql.checkData(1, 1, 20)
sqlString = "select * from " + newDbName + ".ctb1" sqlString = "select * from " + newDbName + ".ctb1"
tdSql.query(sqlString) tdSql.query(sqlString)
tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
tdSql.checkData(0, 1, 11) tdSql.checkData(0, 1, 11)
tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
tdSql.checkData(1, 1, 21) tdSql.checkData(1, 1, 21)
keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" keyDict['s'] = "\"select * from " + newDbName + ".ctb0\""
retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '') retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '')
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
tdLog.exit("taos -r show fail") tdLog.exit("taos -r show fail")
tdLog.printNoPrefix("================================ parameter: -r") tdLog.printNoPrefix("================================ parameter: -r")
keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" keyDict['s'] = "\"select * from " + newDbName + ".ctb0\""
retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '') retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '')
...@@ -287,9 +287,9 @@ class TDTestCase: ...@@ -287,9 +287,9 @@ class TDTestCase:
retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '') retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '')
if retCode != "TAOS_OK": if retCode != "TAOS_OK":
tdLog.exit("taos -r show fail") tdLog.exit("taos -r show fail")
tdSql.query('drop database %s'%newDbName) tdSql.query('drop database %s'%newDbName)
tdLog.printNoPrefix("================================ parameter: -f") tdLog.printNoPrefix("================================ parameter: -f")
pwd=os.getcwd() pwd=os.getcwd()
newDbName="dbf" newDbName="dbf"
...@@ -298,15 +298,15 @@ class TDTestCase: ...@@ -298,15 +298,15 @@ class TDTestCase:
sql2 = "echo use " + newDbName + " >> " + sqlFile sql2 = "echo use " + newDbName + " >> " + sqlFile
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile 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 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: else:
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile 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 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 sql5 = "echo show databases >> " + sqlFile
os.system(sql1) os.system(sql1)
os.system(sql2) os.system(sql2)
os.system(sql3) os.system(sql3)
os.system(sql4) os.system(sql4)
os.system(sql5) os.system(sql5)
keyDict['f'] = pwd + "/0-others/sql.txt" keyDict['f'] = pwd + "/0-others/sql.txt"
...@@ -316,7 +316,7 @@ class TDTestCase: ...@@ -316,7 +316,7 @@ class TDTestCase:
tdLog.exit("taos -f fail") tdLog.exit("taos -f fail")
print ("========== check new db ==========") print ("========== check new db ==========")
tdSql.query("show databases") tdSql.query("show databases")
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
#print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0)))
if tdSql.getData(i, 0) == newDbName: if tdSql.getData(i, 0) == newDbName:
...@@ -324,13 +324,13 @@ class TDTestCase: ...@@ -324,13 +324,13 @@ class TDTestCase:
else: else:
tdLog.exit("create db fail after taos -f fail") tdLog.exit("create db fail after taos -f fail")
sqlString = "select * from " + newDbName + ".ntbf" sqlString = "select * from " + newDbName + ".ntbf"
tdSql.query(sqlString) tdSql.query(sqlString)
tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') tdSql.checkData(0, 0, '2021-04-01 08:00:00.000')
tdSql.checkData(0, 1, 'test taos -f1') tdSql.checkData(0, 1, 'test taos -f1')
tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') tdSql.checkData(1, 0, '2021-04-01 08:00:01.000')
tdSql.checkData(1, 1, 'test taos -f2') tdSql.checkData(1, 1, 'test taos -f2')
shellCmd = "rm -f " + sqlFile shellCmd = "rm -f " + sqlFile
os.system(shellCmd) os.system(shellCmd)
tdSql.query('drop database %s'%newDbName) tdSql.query('drop database %s'%newDbName)
...@@ -345,9 +345,9 @@ class TDTestCase: ...@@ -345,9 +345,9 @@ class TDTestCase:
#print ("-C return content:\n ", retVal) #print ("-C return content:\n ", retVal)
totalCfgItem = {"firstEp":['', '', ''], } totalCfgItem = {"firstEp":['', '', ''], }
for line in retVal.splitlines(): for line in retVal.splitlines():
strList = line.split() strList = line.split()
if (len(strList) > 2): if (len(strList) > 2):
totalCfgItem[strList[1]] = strList totalCfgItem[strList[1]] = strList
#print ("dict content:\n ", totalCfgItem) #print ("dict content:\n ", totalCfgItem)
firstEp = keyDict["h"] + ':' + keyDict['P'] firstEp = keyDict["h"] + ':' + keyDict['P']
...@@ -356,8 +356,8 @@ class TDTestCase: ...@@ -356,8 +356,8 @@ class TDTestCase:
if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'): if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'):
tdLog.exit("taos -C return rpcDebugFlag error!") tdLog.exit("taos -C return rpcDebugFlag error!")
count = os.cpu_count() count = os.cpu_count()
if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'): if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'):
tdLog.exit("taos -C return numOfCores error!") tdLog.exit("taos -C return numOfCores error!")
......
...@@ -18,7 +18,7 @@ from util.dnodes import * ...@@ -18,7 +18,7 @@ from util.dnodes import *
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
if len(key) == 0: if len(key) == 0:
tdLog.exit("taos test key is null!") tdLog.exit("taos test key is null!")
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = buildPath + '\\build\\bin\\taos.exe '
taosCmd = taosCmd.replace('\\','\\\\') taosCmd = taosCmd.replace('\\','\\\\')
...@@ -231,7 +231,7 @@ class TDTestCase: ...@@ -231,7 +231,7 @@ class TDTestCase:
tdLog.info("taos -P %s test success"%keyDict['P']) tdLog.info("taos -P %s test success"%keyDict['P'])
else: else:
tdLog.exit("taos -P %s fail"%keyDict['P']) tdLog.exit("taos -P %s fail"%keyDict['P'])
tdLog.printNoPrefix("================================ parameter: -f with error sql ") tdLog.printNoPrefix("================================ parameter: -f with error sql ")
pwd=os.getcwd() pwd=os.getcwd()
newDbName="dbf" newDbName="dbf"
...@@ -240,15 +240,15 @@ class TDTestCase: ...@@ -240,15 +240,15 @@ class TDTestCase:
sql2 = "echo use " + newDbName + " >> " + sqlFile sql2 = "echo use " + newDbName + " >> " + sqlFile
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
sql3 = "echo create table ntbf (ts timestamp, c binary(40)) no this item >> " + sqlFile 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 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: else:
sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile 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 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 sql5 = "echo show databases >> " + sqlFile
os.system(sql1) os.system(sql1)
os.system(sql2) os.system(sql2)
os.system(sql3) os.system(sql3)
os.system(sql4) os.system(sql4)
os.system(sql5) os.system(sql5)
keyDict['f'] = pwd + "/0-others/sql.txt" keyDict['f'] = pwd + "/0-others/sql.txt"
...@@ -258,7 +258,7 @@ class TDTestCase: ...@@ -258,7 +258,7 @@ class TDTestCase:
tdLog.exit("taos -f fail") tdLog.exit("taos -f fail")
print ("========== check new db ==========") print ("========== check new db ==========")
tdSql.query("show databases") tdSql.query("show databases")
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
#print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0)))
if tdSql.getData(i, 0) == newDbName: if tdSql.getData(i, 0) == newDbName:
...@@ -266,9 +266,9 @@ class TDTestCase: ...@@ -266,9 +266,9 @@ class TDTestCase:
else: else:
tdLog.exit("create db fail after taos -f fail") tdLog.exit("create db fail after taos -f fail")
sqlString = "select * from " + newDbName + ".ntbf" sqlString = "select * from " + newDbName + ".ntbf"
tdSql.error(sqlString) tdSql.error(sqlString)
shellCmd = "rm -f " + sqlFile shellCmd = "rm -f " + sqlFile
os.system(shellCmd) os.system(shellCmd)
...@@ -281,16 +281,16 @@ class TDTestCase: ...@@ -281,16 +281,16 @@ class TDTestCase:
tdSql.query('drop database %s'%newDbName) tdSql.query('drop database %s'%newDbName)
tdLog.printNoPrefix("================================ parameter: -a with error value") tdLog.printNoPrefix("================================ parameter: -a with error value")
#newDbName="dba" #newDbName="dba"
errorPassword = 'errorPassword' errorPassword = 'errorPassword'
sqlString = 'create database ' + newDbName + ';' sqlString = 'create database ' + newDbName + ';'
retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', errorPassword) retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', errorPassword)
if retCode != "TAOS_FAIL": if retCode != "TAOS_FAIL":
tdLog.exit("taos -u %s -a %s"%(keyDict['u'], errorPassword)) tdLog.exit("taos -u %s -a %s"%(keyDict['u'], errorPassword))
tdLog.printNoPrefix("================================ parameter: -p with error value") tdLog.printNoPrefix("================================ parameter: -p with error value")
#newDbName="dba" #newDbName="dba"
keyDict['p'] = 'errorPassword' keyDict['p'] = 'errorPassword'
retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'p', keyDict['p']) retCode, retVal = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'p', keyDict['p'])
if retCode == "TAOS_FAIL" and "Authentication failure" in retVal: if retCode == "TAOS_FAIL" and "Authentication failure" in retVal:
tdLog.info("taos -p %s test success"%keyDict['p']) tdLog.info("taos -p %s test success"%keyDict['p'])
......
...@@ -18,7 +18,7 @@ from util.dnodes import * ...@@ -18,7 +18,7 @@ from util.dnodes import *
def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''): def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key1='', value1=''):
if len(key) == 0: if len(key) == 0:
tdLog.exit("taos test key is null!") tdLog.exit("taos test key is null!")
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
taosCmd = buildPath + '\\build\\bin\\taos.exe ' taosCmd = buildPath + '\\build\\bin\\taos.exe '
taosCmd = taosCmd.replace('\\','\\\\') taosCmd = taosCmd.replace('\\','\\\\')
...@@ -158,34 +158,34 @@ class TDTestCase: ...@@ -158,34 +158,34 @@ class TDTestCase:
if "2: service ok" in retVal: if "2: service ok" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 1") tdLog.exit("taos -k fail 1")
# stop taosd # stop taosd
tdDnodes.stop(1) tdDnodes.stop(1)
#sleep(10) #sleep(10)
#tdDnodes.start(1) #tdDnodes.start(1)
#sleep(5) #sleep(5)
retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString)
if "0: unavailable" in retVal: if "0: unavailable" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 2") tdLog.exit("taos -k fail 2")
# restart taosd # restart taosd
tdDnodes.start(1) tdDnodes.start(1)
#sleep(5) #sleep(5)
retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString) retCode, retVal = taos_command(buildPath, "k", '', "", keyDict['c'], sqlString)
if "2: service ok" in retVal: if "2: service ok" in retVal:
tdLog.info("taos -k success") tdLog.info("taos -k success")
else: else:
tdLog.info(retVal) tdLog.info(retVal)
tdLog.exit("taos -k fail 3") tdLog.exit("taos -k fail 3")
tdLog.printNoPrefix("================================ parameter: -n") tdLog.printNoPrefix("================================ parameter: -n")
# stop taosd # stop taosd
tdDnodes.stop(1) tdDnodes.stop(1)
try: try:
role = 'server' role = 'server'
...@@ -220,7 +220,7 @@ class TDTestCase: ...@@ -220,7 +220,7 @@ class TDTestCase:
#print(child.after.decode()) #print(child.after.decode())
if i == 0: if i == 0:
tdLog.exit('taos -n server fail!') tdLog.exit('taos -n server fail!')
expectString1 = 'response is received, size:' + pktLen expectString1 = 'response is received, size:' + pktLen
expectSTring2 = pktNum + '/' + pktNum expectSTring2 = pktNum + '/' + pktNum
if expectString1 in retResult and expectSTring2 in retResult: if expectString1 in retResult and expectSTring2 in retResult:
......
...@@ -51,7 +51,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -51,7 +51,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "version" not in infoDict["cluster_info"] or infoDict["cluster_info"]["version"] == None: if "version" not in infoDict["cluster_info"] or infoDict["cluster_info"]["version"] == None:
tdLog.exit("first_ep_dnode_id is null!") tdLog.exit("first_ep_dnode_id is null!")
if "master_uptime" not in infoDict["cluster_info"] or infoDict["cluster_info"]["master_uptime"] == None: if "master_uptime" not in infoDict["cluster_info"] or infoDict["cluster_info"]["master_uptime"] == None:
tdLog.exit("master_uptime is null!") tdLog.exit("master_uptime is null!")
...@@ -69,13 +69,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -69,13 +69,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None : if "dnodes" not in infoDict["cluster_info"] or infoDict["cluster_info"]["dnodes"] == None :
tdLog.exit("dnodes is null!") tdLog.exit("dnodes is null!")
dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"} dnodes_info = { "dnode_id": 1,"dnode_ep": self.hostPort,"status":"ready"}
for k ,v in dnodes_info.items(): for k ,v in dnodes_info.items():
if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] : if k not in infoDict["cluster_info"]["dnodes"][0] or v != infoDict["cluster_info"]["dnodes"][0][k] :
tdLog.exit("dnodes info is null!") tdLog.exit("dnodes info is null!")
mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" } mnodes_info = { "mnode_id":1, "mnode_ep": self.hostPort,"role": "leader" }
for k ,v in mnodes_info.items(): for k ,v in mnodes_info.items():
...@@ -86,7 +86,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -86,7 +86,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "vgroup_infos" not in infoDict or infoDict["vgroup_infos"]== None: if "vgroup_infos" not in infoDict or infoDict["vgroup_infos"]== None:
tdLog.exit("vgroup_infos is null!") tdLog.exit("vgroup_infos is null!")
vgroup_infos_nums = len(infoDict["vgroup_infos"]) vgroup_infos_nums = len(infoDict["vgroup_infos"])
for index in range(vgroup_infos_nums): for index in range(vgroup_infos_nums):
...@@ -116,14 +116,14 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -116,14 +116,14 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "timeseries_total" not in infoDict["grant_info"] or not infoDict["grant_info"]["timeseries_total"] > 0: if "timeseries_total" not in infoDict["grant_info"] or not infoDict["grant_info"]["timeseries_total"] > 0:
tdLog.exit("timeseries_total is null!") tdLog.exit("timeseries_total is null!")
# dnode_info ==================================== # dnode_info ====================================
if "dnode_info" not in infoDict or infoDict["dnode_info"]== None: if "dnode_info" not in infoDict or infoDict["dnode_info"]== None:
tdLog.exit("dnode_info is null!") tdLog.exit("dnode_info is null!")
dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine', dnode_infos = ['uptime', 'cpu_engine', 'cpu_system', 'cpu_cores', 'mem_engine', 'mem_system', 'mem_total', 'disk_engine',
'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select', 'disk_used', 'disk_total', 'net_in', 'net_out', 'io_read', 'io_write', 'io_read_disk', 'io_write_disk', 'req_select',
'req_select_rate', 'req_insert', 'req_insert_success', 'req_insert_rate', 'req_insert_batch', 'req_insert_batch_success', 'req_select_rate', 'req_insert', 'req_insert_success', 'req_insert_rate', 'req_insert_batch', 'req_insert_batch_success',
'req_insert_batch_rate', 'errors', 'vnodes_num', 'masters', 'has_mnode', 'has_qnode', 'has_snode', 'has_bnode'] 'req_insert_batch_rate', 'errors', 'vnodes_num', 'masters', 'has_mnode', 'has_qnode', 'has_snode', 'has_bnode']
for elem in dnode_infos: for elem in dnode_infos:
...@@ -134,7 +134,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -134,7 +134,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "disk_infos" not in infoDict or infoDict["disk_infos"]== None: if "disk_infos" not in infoDict or infoDict["disk_infos"]== None:
tdLog.exit("disk_infos is null!") tdLog.exit("disk_infos is null!")
# bug for data_dir # bug for data_dir
if "datadir" not in infoDict["disk_infos"] or len(infoDict["disk_infos"]["datadir"]) <=0 : if "datadir" not in infoDict["disk_infos"] or len(infoDict["disk_infos"]["datadir"]) <=0 :
tdLog.exit("datadir is null!") tdLog.exit("datadir is null!")
...@@ -187,7 +187,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -187,7 +187,7 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
# log_infos ==================================== # log_infos ====================================
if "log_infos" not in infoDict or infoDict["log_infos"]== None: if "log_infos" not in infoDict or infoDict["log_infos"]== None:
tdLog.exit("log_infos is null!") tdLog.exit("log_infos is null!")
...@@ -206,13 +206,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -206,13 +206,13 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if "summary" not in infoDict["log_infos"] or len(infoDict["log_infos"]["summary"])!= 4: if "summary" not in infoDict["log_infos"] or len(infoDict["log_infos"]["summary"])!= 4:
tdLog.exit("summary is null!") tdLog.exit("summary is null!")
if "total" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["total"] < 0 : if "total" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["total"] < 0 :
tdLog.exit("total is null!") tdLog.exit("total is null!")
if "level" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["level"] not in ["error" ,"info" , "debug" ,"trace"]: if "level" not in infoDict["log_infos"]["summary"][0] or infoDict["log_infos"]["summary"][0]["level"] not in ["error" ,"info" , "debug" ,"trace"]:
tdLog.exit("level is null!") tdLog.exit("level is null!")
def do_GET(self): def do_GET(self):
""" """
process GET request process GET request
...@@ -227,25 +227,25 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -227,25 +227,25 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if contentEncoding == 'gzip': if contentEncoding == 'gzip':
req_body = self.rfile.read(int(self.headers["Content-Length"])) req_body = self.rfile.read(int(self.headers["Content-Length"]))
plainText = gzip.decompress(req_body).decode() plainText = gzip.decompress(req_body).decode()
else: else:
plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() plainText = self.rfile.read(int(self.headers["Content-Length"])).decode()
print(plainText) print(plainText)
# 1. send response code and header # 1. send response code and header
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers() self.end_headers()
# 2. send response content # 2. send response content
#self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8"))
# 3. check request body info # 3. check request body info
infoDict = json.loads(plainText) infoDict = json.loads(plainText)
#print("================") #print("================")
# print(infoDict) # print(infoDict)
self.telemetryInfoCheck(infoDict) self.telemetryInfoCheck(infoDict)
# 4. shutdown the server and exit case # 4. shutdown the server and exit case
assassin = threading.Thread(target=self.server.shutdown) assassin = threading.Thread(target=self.server.shutdown)
assassin.daemon = True assassin.daemon = True
assassin.start() assassin.start()
...@@ -287,7 +287,7 @@ class TDTestCase: ...@@ -287,7 +287,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare() tdSql.prepare()
# time.sleep(2) # time.sleep(2)
......
...@@ -100,9 +100,9 @@ def telemetryInfoCheck(infoDict=''): ...@@ -100,9 +100,9 @@ def telemetryInfoCheck(infoDict=''):
if "compStorage" not in infoDict or infoDict["compStorage"] < 0: if "compStorage" not in infoDict or infoDict["compStorage"] < 0:
tdLog.exit("compStorage is null!") tdLog.exit("compStorage is null!")
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
""" """
process GET request process GET request
...@@ -117,26 +117,26 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler): ...@@ -117,26 +117,26 @@ class RequestHandlerImpl(http.server.BaseHTTPRequestHandler):
if contentEncoding == 'gzip': if contentEncoding == 'gzip':
req_body = self.rfile.read(int(self.headers["Content-Length"])) req_body = self.rfile.read(int(self.headers["Content-Length"]))
plainText = gzip.decompress(req_body).decode() plainText = gzip.decompress(req_body).decode()
else: else:
plainText = self.rfile.read(int(self.headers["Content-Length"])).decode() plainText = self.rfile.read(int(self.headers["Content-Length"])).decode()
print("monitor info:\n%s"%plainText) print("monitor info:\n%s"%plainText)
# 1. send response code and header # 1. send response code and header
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers() self.end_headers()
# 2. send response content # 2. send response content
#self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8")) #self.wfile.write(("Hello World: " + req_body + "\n").encode("utf-8"))
# 3. check request body info # 3. check request body info
infoDict = json.loads(plainText) infoDict = json.loads(plainText)
#print("================") #print("================")
#print(infoDict) #print(infoDict)
telemetryInfoCheck(infoDict) telemetryInfoCheck(infoDict)
# 4. shutdown the server and exit case # 4. shutdown the server and exit case
assassin = threading.Thread(target=self.server.shutdown) assassin = threading.Thread(target=self.server.shutdown)
assassin.daemon = True assassin.daemon = True
assassin.start() assassin.start()
...@@ -176,7 +176,7 @@ class TDTestCase: ...@@ -176,7 +176,7 @@ class TDTestCase:
def init(self, conn, logSql): def init(self, conn, logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql.prepare() tdSql.prepare()
# time.sleep(2) # time.sleep(2)
......
...@@ -512,7 +512,7 @@ class TDTestCase: ...@@ -512,7 +512,7 @@ class TDTestCase:
"select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" ,
"select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" ,
"select c1,c6,udf1(c1,c6) from stb1 order by ts" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" ,
"select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;"
] ]
udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" ,
"select udf2(c1) from stb1 group by 1-udf1(c1)" , "select udf2(c1) from stb1 group by 1-udf1(c1)" ,
......
...@@ -190,7 +190,7 @@ class TDTestCase: ...@@ -190,7 +190,7 @@ class TDTestCase:
tdSql.execute("use db ") tdSql.execute("use db ")
tdSql.error("select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb") tdSql.error("select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb")
tdSql.error("select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1") tdSql.error("select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1")
# aggregate functions # aggregate functions
tdSql.error("select udf2(num1) ,udf2(num2), udf2(num3) from tb") tdSql.error("select udf2(num1) ,udf2(num2), udf2(num3) from tb")
......
...@@ -514,7 +514,7 @@ class TDTestCase: ...@@ -514,7 +514,7 @@ class TDTestCase:
"select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" ,
"select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" ,
"select c1,c6,udf1(c1,c6) from stb1 order by ts" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" ,
"select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;"
] ]
udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" ,
"select udf2(c1) from stb1 group by 1-udf1(c1)" , "select udf2(c1) from stb1 group by 1-udf1(c1)" ,
......
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -16,7 +16,7 @@ class MyDnodes(TDDnodes): ...@@ -16,7 +16,7 @@ class MyDnodes(TDDnodes):
super(MyDnodes,self).__init__() super(MyDnodes,self).__init__()
self.dnodes = dnodes_lists # dnode must be TDDnode instance self.dnodes = dnodes_lists # dnode must be TDDnode instance
self.simDeployed = False self.simDeployed = False
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -26,7 +26,7 @@ class TDTestCase: ...@@ -26,7 +26,7 @@ class TDTestCase:
self.master_dnode = self.TDDnodes.dnodes[0] self.master_dnode = self.TDDnodes.dnodes[0]
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
tdSql.init(conn1.cursor()) tdSql.init(conn1.cursor())
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -43,7 +43,7 @@ class TDTestCase: ...@@ -43,7 +43,7 @@ class TDTestCase:
buildPath = root[:len(root) - len("/build/bin")] buildPath = root[:len(root) - len("/build/bin")]
break break
return buildPath return buildPath
def prepare_udf_so(self): def prepare_udf_so(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -61,7 +61,7 @@ class TDTestCase: ...@@ -61,7 +61,7 @@ class TDTestCase:
def prepare_data(self): def prepare_data(self):
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
tdSql.execute("create database if not exists db replica 1 duration 300") tdSql.execute("create database if not exists db replica 1 duration 300")
tdSql.execute("use db") tdSql.execute("use db")
...@@ -71,7 +71,7 @@ class TDTestCase: ...@@ -71,7 +71,7 @@ class TDTestCase:
tags (t1 int) tags (t1 int)
''' '''
) )
tdSql.execute( tdSql.execute(
''' '''
create table t1 create table t1
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
# create aggregate functions # create aggregate functions
tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;") tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;")
# functions = tdSql.getResult("show functions") # functions = tdSql.getResult("show functions")
# function_nums = len(functions) # function_nums = len(functions)
# if function_nums == 2: # if function_nums == 2:
...@@ -167,14 +167,14 @@ class TDTestCase: ...@@ -167,14 +167,14 @@ class TDTestCase:
# create aggregate functions # create aggregate functions
tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;") tdSql.execute("create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8;")
functions = tdSql.getResult("show functions") functions = tdSql.getResult("show functions")
function_nums = len(functions) function_nums = len(functions)
if function_nums == 2: if function_nums == 2:
tdLog.info("create two udf functions success ") tdLog.info("create two udf functions success ")
def basic_udf_query(self , dnode): def basic_udf_query(self , dnode):
mytdSql = self.getConnection(dnode) mytdSql = self.getConnection(dnode)
# scalar functions # scalar functions
...@@ -229,7 +229,7 @@ class TDTestCase: ...@@ -229,7 +229,7 @@ class TDTestCase:
else: else:
tdLog.info(" UDF query check failed at :dnode_index %s" %dnode.index) tdLog.info(" UDF query check failed at :dnode_index %s" %dnode.index)
tdLog.exit("query check failed at :dnode_index %s" %dnode.index ) tdLog.exit("query check failed at :dnode_index %s" %dnode.index )
def check_UDF_query(self): def check_UDF_query(self):
...@@ -238,10 +238,10 @@ class TDTestCase: ...@@ -238,10 +238,10 @@ class TDTestCase:
self.basic_udf_query(dnode) self.basic_udf_query(dnode)
def depoly_cluster(self ,dnodes_nums): def depoly_cluster(self ,dnodes_nums):
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
hostname = socket.gethostname() hostname = socket.gethostname()
dnodes = [] dnodes = []
start_port = 6030 start_port = 6030
...@@ -253,7 +253,7 @@ class TDTestCase: ...@@ -253,7 +253,7 @@ class TDTestCase:
dnode.addExtraCfg("monitorFqdn", hostname) dnode.addExtraCfg("monitorFqdn", hostname)
dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("monitorPort", 7043)
dnodes.append(dnode) dnodes.append(dnode)
self.TDDnodes = MyDnodes(dnodes) self.TDDnodes = MyDnodes(dnodes)
self.TDDnodes.init("") self.TDDnodes.init("")
self.TDDnodes.setTestCluster(testCluster) self.TDDnodes.setTestCluster(testCluster)
...@@ -261,11 +261,11 @@ class TDTestCase: ...@@ -261,11 +261,11 @@ class TDTestCase:
self.TDDnodes.stopAll() self.TDDnodes.stopAll()
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.deploy(dnode.index,{}) self.TDDnodes.deploy(dnode.index,{})
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.start(dnode.index) self.TDDnodes.start(dnode.index)
# create cluster # create cluster
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
print(dnode.cfgDict) print(dnode.cfgDict)
...@@ -275,12 +275,12 @@ class TDTestCase: ...@@ -275,12 +275,12 @@ class TDTestCase:
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)
time.sleep(2) time.sleep(2)
tdLog.info(" create cluster done! ") tdLog.info(" create cluster done! ")
def getConnection(self, dnode): def getConnection(self, dnode):
host = dnode.cfgDict["fqdn"] host = dnode.cfgDict["fqdn"]
port = dnode.cfgDict["serverPort"] port = dnode.cfgDict["serverPort"]
...@@ -288,23 +288,23 @@ class TDTestCase: ...@@ -288,23 +288,23 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def restart_udfd(self, dnode): def restart_udfd(self, dnode):
buildPath = self.getBuildPath() buildPath = self.getBuildPath()
if (buildPath == ""): if (buildPath == ""):
tdLog.exit("taosd not found!") tdLog.exit("taosd not found!")
else: else:
tdLog.info("taosd found in %s" % buildPath) tdLog.info("taosd found in %s" % buildPath)
cfgPath = dnode.cfgDir cfgPath = dnode.cfgDir
udfdPath = buildPath +'/build/bin/udfd' udfdPath = buildPath +'/build/bin/udfd'
for i in range(5): for i in range(5):
tdLog.info(" loop restart udfd %d_th at dnode_index : %s" % (i ,dnode.index)) tdLog.info(" loop restart udfd %d_th at dnode_index : %s" % (i ,dnode.index))
self.basic_udf_query(dnode) self.basic_udf_query(dnode)
# stop udfd cmds # stop udfd cmds
get_processID = "ps -ef | grep -w udfd | grep %s | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'"%cfgPath get_processID = "ps -ef | grep -w udfd | grep %s | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'"%cfgPath
processID = subprocess.check_output(get_processID, shell=True).decode("utf-8") processID = subprocess.check_output(get_processID, shell=True).decode("utf-8")
stop_udfd = " kill -9 %s" % processID stop_udfd = " kill -9 %s" % processID
...@@ -327,12 +327,12 @@ class TDTestCase: ...@@ -327,12 +327,12 @@ class TDTestCase:
# self.check_UDF_query() # self.check_UDF_query()
self.restart_udfd(self.master_dnode) self.restart_udfd(self.master_dnode)
# self.test_restart_udfd_All_dnodes() # self.test_restart_udfd_All_dnodes()
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -514,7 +514,7 @@ class TDTestCase: ...@@ -514,7 +514,7 @@ class TDTestCase:
"select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" , "select c1,c2, udf1(c1,c2) from stb1 group by c1,c2" ,
"select num1,num2,num3,udf1(num1,num2,num3) from tb" , "select num1,num2,num3,udf1(num1,num2,num3) from tb" ,
"select c1,c6,udf1(c1,c6) from stb1 order by ts" , "select c1,c6,udf1(c1,c6) from stb1 order by ts" ,
"select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;" "select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;"
] ]
udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" , udf2_sqls = ["select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null" ,
"select udf2(c1) from stb1 group by 1-udf1(c1)" , "select udf2(c1) from stb1 group by 1-udf1(c1)" ,
......
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -18,7 +18,7 @@ class MyDnodes(TDDnodes): ...@@ -18,7 +18,7 @@ class MyDnodes(TDDnodes):
super(MyDnodes,self).__init__() super(MyDnodes,self).__init__()
self.dnodes = dnodes_lists # dnode must be TDDnode instance self.dnodes = dnodes_lists # dnode must be TDDnode instance
self.simDeployed = False self.simDeployed = False
class TDTestCase: class TDTestCase:
noConn = True noConn = True
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -29,7 +29,7 @@ class TDTestCase: ...@@ -29,7 +29,7 @@ class TDTestCase:
self.host=self.master_dnode.cfgDict["fqdn"] self.host=self.master_dnode.cfgDict["fqdn"]
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
tdSql.init(conn1.cursor()) tdSql.init(conn1.cursor())
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -46,12 +46,12 @@ class TDTestCase: ...@@ -46,12 +46,12 @@ class TDTestCase:
buildPath = root[:len(root) - len("/build/bin")] buildPath = root[:len(root) - len("/build/bin")]
break break
return buildPath return buildPath
def depoly_cluster(self ,dnodes_nums):
def depoly_cluster(self ,dnodes_nums):
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
hostname = socket.gethostname() hostname = socket.gethostname()
dnodes = [] dnodes = []
start_port = 6030 start_port = 6030
...@@ -63,7 +63,7 @@ class TDTestCase: ...@@ -63,7 +63,7 @@ class TDTestCase:
dnode.addExtraCfg("monitorFqdn", hostname) dnode.addExtraCfg("monitorFqdn", hostname)
dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("monitorPort", 7043)
dnodes.append(dnode) dnodes.append(dnode)
self.TDDnodes = MyDnodes(dnodes) self.TDDnodes = MyDnodes(dnodes)
self.TDDnodes.init("") self.TDDnodes.init("")
self.TDDnodes.setTestCluster(testCluster) self.TDDnodes.setTestCluster(testCluster)
...@@ -71,11 +71,11 @@ class TDTestCase: ...@@ -71,11 +71,11 @@ class TDTestCase:
self.TDDnodes.stopAll() self.TDDnodes.stopAll()
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.deploy(dnode.index,{}) self.TDDnodes.deploy(dnode.index,{})
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.starttaosd(dnode.index) self.TDDnodes.starttaosd(dnode.index)
# create cluster # create cluster
for dnode in self.TDDnodes.dnodes[1:]: for dnode in self.TDDnodes.dnodes[1:]:
# print(dnode.cfgDict) # print(dnode.cfgDict)
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\"" cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s \"create dnode \\\"{dnode_id}\\\"\""
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)
time.sleep(2) time.sleep(2)
tdLog.info(" create cluster done! ") tdLog.info(" create cluster done! ")
...@@ -94,7 +94,7 @@ class TDTestCase: ...@@ -94,7 +94,7 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -120,7 +120,7 @@ class TDTestCase: ...@@ -120,7 +120,7 @@ class TDTestCase:
) )
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
tdSql.query('show databases;') tdSql.query('show databases;')
tdSql.checkData(2,5,'off') tdSql.checkData(2,5,'off')
tdSql.error("alter database db strict 'off'") tdSql.error("alter database db strict 'off'")
...@@ -135,7 +135,7 @@ class TDTestCase: ...@@ -135,7 +135,7 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.five_dnode_one_mnode() self.five_dnode_one_mnode()
...@@ -145,4 +145,4 @@ class TDTestCase: ...@@ -145,4 +145,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -17,8 +17,8 @@ import subprocess ...@@ -17,8 +17,8 @@ import subprocess
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
tdLog.debug(f"start to excute {__file__}") tdLog.debug(f"start to excute {__file__}")
...@@ -48,7 +48,7 @@ class TDTestCase: ...@@ -48,7 +48,7 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -63,7 +63,7 @@ class TDTestCase: ...@@ -63,7 +63,7 @@ class TDTestCase:
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(2) tdSql.checkRows(2)
if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[0][2]=='leader' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
print("two mnodes is ready") print("two mnodes is ready")
...@@ -73,7 +73,7 @@ class TDTestCase: ...@@ -73,7 +73,7 @@ class TDTestCase:
print("two mnodes is not ready in 10s ") print("two mnodes is not ready in 10s ")
# fisrt check statut ready # fisrt check statut ready
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -106,7 +106,7 @@ class TDTestCase: ...@@ -106,7 +106,7 @@ class TDTestCase:
clusterComCheck.checkDnodes(5) clusterComCheck.checkDnodes(5)
# restart all taosd # restart all taosd
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
# stop follower # stop follower
tdLog.info("stop follower") tdLog.info("stop follower")
tdDnodes[1].stoptaosd() tdDnodes[1].stoptaosd()
...@@ -118,7 +118,7 @@ class TDTestCase: ...@@ -118,7 +118,7 @@ class TDTestCase:
tdDnodes[1].starttaosd() tdDnodes[1].starttaosd()
if clusterComCheck.checkMnodeStatus(2) : if clusterComCheck.checkMnodeStatus(2) :
print("both mnodes are ready") print("both mnodes are ready")
# stop leader # stop leader
tdLog.info("stop leader") tdLog.info("stop leader")
tdDnodes[0].stoptaosd() tdDnodes[0].stoptaosd()
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
if clusterComCheck.checkMnodeStatus(2) : if clusterComCheck.checkMnodeStatus(2) :
print("both mnodes are ready") print("both mnodes are ready")
def run(self): def run(self):
self.five_dnode_two_mnode() self.five_dnode_two_mnode()
...@@ -142,4 +142,4 @@ class TDTestCase: ...@@ -142,4 +142,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from numpy import row_stack ...@@ -3,7 +3,7 @@ from numpy import row_stack
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode ...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -57,7 +57,7 @@ class TDTestCase: ...@@ -57,7 +57,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -118,7 +118,7 @@ class TDTestCase: ...@@ -118,7 +118,7 @@ class TDTestCase:
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers'] rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
# dnode6=cluster.addDnode(6) # dnode6=cluster.addDnode(6)
...@@ -166,7 +166,7 @@ class TDTestCase: ...@@ -166,7 +166,7 @@ class TDTestCase:
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]))) threads.append(threading.Thread(target=clusterComCreate.insert_data, args=(newTdSql, paraDict["dbName"],stableName,paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])))
for tr in threads: for tr in threads:
tr.start() tr.start()
dnode6Port=int(6030+5*100) dnode6Port=int(6030+5*100)
tdSql.execute("create dnode '%s:%d'"%(hostname,dnode6Port)) tdSql.execute("create dnode '%s:%d'"%(hostname,dnode6Port))
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -179,7 +179,7 @@ class TDTestCase: ...@@ -179,7 +179,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -191,20 +191,20 @@ class TDTestCase: ...@@ -191,20 +191,20 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123") tdLog.info("123")
else: else:
print("456") print("456")
self.stopThread(threads) self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers) clusterComCheck.checkDbRows(dbNumbers)
...@@ -217,7 +217,7 @@ class TDTestCase: ...@@ -217,7 +217,7 @@ class TDTestCase:
stableName= '%s_%d'%(paraDict['stbName'],i) stableName= '%s_%d'%(paraDict['stbName'],i)
tdSql.query("select * from %s"%stableName) tdSql.query("select * from %s"%stableName)
tdSql.checkRows(rowsPerStb) tdSql.checkRows(rowsPerStb)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
...@@ -226,4 +226,4 @@ class TDTestCase: ...@@ -226,4 +226,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from paramiko import HostKeys ...@@ -3,7 +3,7 @@ from paramiko import HostKeys
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -19,7 +19,7 @@ class MyDnodes(TDDnodes): ...@@ -19,7 +19,7 @@ class MyDnodes(TDDnodes):
super(MyDnodes,self).__init__() super(MyDnodes,self).__init__()
self.dnodes = dnodes_lists # dnode must be TDDnode instance self.dnodes = dnodes_lists # dnode must be TDDnode instance
self.simDeployed = False self.simDeployed = False
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -48,7 +48,7 @@ class TDTestCase: ...@@ -48,7 +48,7 @@ class TDTestCase:
buildPath = root[:len(root) - len("/build/bin")] buildPath = root[:len(root) - len("/build/bin")]
break break
return buildPath return buildPath
def insert_data(self,count): def insert_data(self,count):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in count: for couti in count:
...@@ -70,10 +70,10 @@ class TDTestCase: ...@@ -70,10 +70,10 @@ class TDTestCase:
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def depoly_cluster(self ,dnodes_nums): def depoly_cluster(self ,dnodes_nums):
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
hostname = socket.gethostname() hostname = socket.gethostname()
tdLog.debug(hostname) tdLog.debug(hostname)
dnodes = [] dnodes = []
...@@ -88,7 +88,7 @@ class TDTestCase: ...@@ -88,7 +88,7 @@ class TDTestCase:
dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("monitorPort", 7043)
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
dnodes.append(dnode) dnodes.append(dnode)
self.TDDnodes = MyDnodes(dnodes) self.TDDnodes = MyDnodes(dnodes)
self.TDDnodes.init("") self.TDDnodes.init("")
self.TDDnodes.setTestCluster(testCluster) self.TDDnodes.setTestCluster(testCluster)
...@@ -96,11 +96,11 @@ class TDTestCase: ...@@ -96,11 +96,11 @@ class TDTestCase:
self.TDDnodes.stopAll() self.TDDnodes.stopAll()
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.deploy(dnode.index,{}) self.TDDnodes.deploy(dnode.index,{})
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.starttaosd(dnode.index) self.TDDnodes.starttaosd(dnode.index)
# create cluster # create cluster
for dnode in self.TDDnodes.dnodes[1:]: for dnode in self.TDDnodes.dnodes[1:]:
# tdLog.debug(dnode.cfgDict) # tdLog.debug(dnode.cfgDict)
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
...@@ -109,7 +109,7 @@ class TDTestCase: ...@@ -109,7 +109,7 @@ class TDTestCase:
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
tdLog.debug(cmd) tdLog.debug(cmd)
os.system(cmd) os.system(cmd)
time.sleep(2) time.sleep(2)
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
...@@ -118,8 +118,8 @@ class TDTestCase: ...@@ -118,8 +118,8 @@ class TDTestCase:
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
if tdSql.checkRows(3) : if tdSql.checkRows(3) :
tdLog.debug("mnode is three nodes") tdLog.debug("mnode is three nodes")
if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[0][2]=='leader' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
...@@ -129,20 +129,20 @@ class TDTestCase: ...@@ -129,20 +129,20 @@ class TDTestCase:
if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[1][2]=='leader':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
tdLog.debug("three mnodes is ready in 10s") tdLog.debug("three mnodes is ready in 10s")
break break
elif tdSql.queryResult[0][2]=='follower' : elif tdSql.queryResult[0][2]=='follower' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='leader': if tdSql.queryResult[2][2]=='leader':
tdLog.debug("three mnodes is ready in 10s") tdLog.debug("three mnodes is ready in 10s")
break break
count+=1 count+=1
else: else:
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
tdLog.debug("three mnodes is not ready in 10s ") tdLog.debug("three mnodes is not ready in 10s ")
return -1 return -1
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,1,'%s:6130'%self.host)
...@@ -169,11 +169,11 @@ class TDTestCase: ...@@ -169,11 +169,11 @@ class TDTestCase:
count+=1 count+=1
else: else:
tdLog.debug("stop mnodes on dnode 2 failed in 10s ") tdLog.debug("stop mnodes on dnode 2 failed in 10s ")
return -1 return -1
tdSql.error("drop mnode on dnode 1;") tdSql.error("drop mnode on dnode 1;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'offline') tdSql.checkData(0,2,'offline')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -200,8 +200,8 @@ class TDTestCase: ...@@ -200,8 +200,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 2;") tdSql.error("drop mnode on dnode 2;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -229,8 +229,8 @@ class TDTestCase: ...@@ -229,8 +229,8 @@ class TDTestCase:
tdLog.debug("stop mnodes on dnode 3 failed in 10s") tdLog.debug("stop mnodes on dnode 3 failed in 10s")
return -1 return -1
tdSql.error("drop mnode on dnode 3;") tdSql.error("drop mnode on dnode 3;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -249,8 +249,8 @@ class TDTestCase: ...@@ -249,8 +249,8 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -270,8 +270,8 @@ class TDTestCase: ...@@ -270,8 +270,8 @@ class TDTestCase:
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
# drop follower of mnode # drop follower of mnode
dropcount =0 dropcount =0
while dropcount <= 10: while dropcount <= 10:
for i in range(1,3): for i in range(1,3):
tdLog.debug("drop mnode on dnode %d"%(i+1)) tdLog.debug("drop mnode on dnode %d"%(i+1))
...@@ -306,7 +306,7 @@ class TDTestCase: ...@@ -306,7 +306,7 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def run(self): def run(self):
# tdLog.debug(self.master_dnode.cfgDict) # tdLog.debug(self.master_dnode.cfgDict)
self.buildcluster(5) self.buildcluster(5)
self.five_dnode_three_mnode() self.five_dnode_three_mnode()
...@@ -316,4 +316,4 @@ class TDTestCase: ...@@ -316,4 +316,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,7 +13,7 @@ import time ...@@ -13,7 +13,7 @@ import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -37,7 +37,7 @@ class TDTestCase: ...@@ -37,7 +37,7 @@ class TDTestCase:
self.host=self.master_dnode.cfgDict["fqdn"] self.host=self.master_dnode.cfgDict["fqdn"]
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
tdSql.init(conn1.cursor()) tdSql.init(conn1.cursor())
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -63,7 +63,7 @@ class TDTestCase: ...@@ -63,7 +63,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -74,7 +74,7 @@ class TDTestCase: ...@@ -74,7 +74,7 @@ class TDTestCase:
def createDbTbale(self,dbcountStart,dbcountStop,stbname,chilCount): def createDbTbale(self,dbcountStart,dbcountStop,stbname,chilCount):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(dbcountStart,dbcountStop): for couti in range(dbcountStart,dbcountStop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -98,7 +98,7 @@ class TDTestCase: ...@@ -98,7 +98,7 @@ class TDTestCase:
def insertTabaleData(self,dbcountStart,dbcountStop,stbname,chilCount,ts_start,rowCount): def insertTabaleData(self,dbcountStart,dbcountStop,stbname,chilCount,ts_start,rowCount):
# insert data : create childtable and data # insert data : create childtable and data
for couti in range(dbcountStart,dbcountStop): for couti in range(dbcountStart,dbcountStop):
tdSql.execute("use db%d" %couti) tdSql.execute("use db%d" %couti)
pre_insert = "insert into " pre_insert = "insert into "
...@@ -115,7 +115,7 @@ class TDTestCase: ...@@ -115,7 +115,7 @@ class TDTestCase:
# print(sql) # print(sql)
tdSql.execute(sql) tdSql.execute(sql)
sql = "insert into %s_%d values " %(stbname,i) sql = "insert into %s_%d values " %(stbname,i)
# end sql # end sql
if sql != pre_insert: if sql != pre_insert:
# print(sql) # print(sql)
print(len(sql)) print(len(sql))
...@@ -134,13 +134,13 @@ class TDTestCase: ...@@ -134,13 +134,13 @@ class TDTestCase:
for i in range(stableCount): for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
def depoly_cluster(self ,dnodes_nums):
def depoly_cluster(self ,dnodes_nums):
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
hostname = socket.gethostname() hostname = socket.gethostname()
dnodes = [] dnodes = []
start_port = 6030 start_port = 6030
...@@ -154,7 +154,7 @@ class TDTestCase: ...@@ -154,7 +154,7 @@ class TDTestCase:
dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("monitorPort", 7043)
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
dnodes.append(dnode) dnodes.append(dnode)
self.TDDnodes = MyDnodes(dnodes) self.TDDnodes = MyDnodes(dnodes)
self.TDDnodes.init("") self.TDDnodes.init("")
self.TDDnodes.setTestCluster(testCluster) self.TDDnodes.setTestCluster(testCluster)
...@@ -162,11 +162,11 @@ class TDTestCase: ...@@ -162,11 +162,11 @@ class TDTestCase:
self.TDDnodes.stopAll() self.TDDnodes.stopAll()
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.deploy(dnode.index,{}) self.TDDnodes.deploy(dnode.index,{})
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.starttaosd(dnode.index) self.TDDnodes.starttaosd(dnode.index)
# create cluster # create cluster
for dnode in self.TDDnodes.dnodes[1:]: for dnode in self.TDDnodes.dnodes[1:]:
# print(dnode.cfgDict) # print(dnode.cfgDict)
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
...@@ -175,7 +175,7 @@ class TDTestCase: ...@@ -175,7 +175,7 @@ class TDTestCase:
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)
time.sleep(2) time.sleep(2)
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
...@@ -185,8 +185,8 @@ class TDTestCase: ...@@ -185,8 +185,8 @@ class TDTestCase:
time.sleep(1) time.sleep(1)
statusReadyBumber=0 statusReadyBumber=0
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
if tdSql.checkRows(dnodenumber) : if tdSql.checkRows(dnodenumber) :
print("dnode is %d nodes"%dnodenumber) print("dnode is %d nodes"%dnodenumber)
for i in range(dnodenumber): for i in range(dnodenumber):
if tdSql.queryResult[i][4] !='ready' : if tdSql.queryResult[i][4] !='ready' :
status=tdSql.queryResult[i][4] status=tdSql.queryResult[i][4]
...@@ -203,15 +203,15 @@ class TDTestCase: ...@@ -203,15 +203,15 @@ class TDTestCase:
else: else:
print("%d mnodes is not ready in 10s "%dnodenumber) print("%d mnodes is not ready in 10s "%dnodenumber)
return False return False
def check3mnode(self): def check3mnode(self):
count=0 count=0
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
if tdSql.checkRows(3) : if tdSql.checkRows(3) :
print("mnode is three nodes") print("mnode is three nodes")
if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[0][2]=='leader' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
...@@ -221,19 +221,19 @@ class TDTestCase: ...@@ -221,19 +221,19 @@ class TDTestCase:
if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[1][2]=='leader':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
print("three mnodes is ready in 10s") print("three mnodes is ready in 10s")
break break
elif tdSql.queryResult[0][2]=='follower' : elif tdSql.queryResult[0][2]=='follower' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='leader': if tdSql.queryResult[2][2]=='leader':
print("three mnodes is ready in 10s") print("three mnodes is ready in 10s")
break break
count+=1 count+=1
else: else:
print("three mnodes is not ready in 10s ") print("three mnodes is not ready in 10s ")
return -1 return -1
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,1,'%s:6130'%self.host)
...@@ -263,8 +263,8 @@ class TDTestCase: ...@@ -263,8 +263,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 1;") tdSql.error("drop mnode on dnode 1;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'offline') tdSql.checkData(0,2,'offline')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -291,8 +291,8 @@ class TDTestCase: ...@@ -291,8 +291,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 2;") tdSql.error("drop mnode on dnode 2;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -320,8 +320,8 @@ class TDTestCase: ...@@ -320,8 +320,8 @@ class TDTestCase:
print("stop mnodes on dnode 3 failed in 10s") print("stop mnodes on dnode 3 failed in 10s")
return -1 return -1
tdSql.error("drop mnode on dnode 3;") tdSql.error("drop mnode on dnode 3;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -348,8 +348,8 @@ class TDTestCase: ...@@ -348,8 +348,8 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -364,7 +364,7 @@ class TDTestCase: ...@@ -364,7 +364,7 @@ class TDTestCase:
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
print(tdSql.queryResult) print(tdSql.queryResult)
tdLog.debug("stop all of mnode ") tdLog.debug("stop all of mnode ")
# drop follower of mnode and insert data # drop follower of mnode and insert data
self.createDbTbale(dbcountStart, dbcountStop,stbname,tablesPerStb) self.createDbTbale(dbcountStart, dbcountStop,stbname,tablesPerStb)
...@@ -378,7 +378,7 @@ class TDTestCase: ...@@ -378,7 +378,7 @@ class TDTestCase:
rowsPerTable)) rowsPerTable))
threads.start() threads.start()
dropcount =0 dropcount =0
while dropcount <= 10: while dropcount <= 10:
for i in range(1,3): for i in range(1,3):
tdLog.debug("drop mnode on dnode %d"%(i+1)) tdLog.debug("drop mnode on dnode %d"%(i+1))
...@@ -415,7 +415,7 @@ class TDTestCase: ...@@ -415,7 +415,7 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.buildcluster(5) self.buildcluster(5)
self.five_dnode_three_mnode(5) self.five_dnode_three_mnode(5)
...@@ -425,4 +425,4 @@ class TDTestCase: ...@@ -425,4 +425,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from numpy import row_stack ...@@ -3,7 +3,7 @@ from numpy import row_stack
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode ...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -57,7 +57,7 @@ class TDTestCase: ...@@ -57,7 +57,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -112,7 +112,7 @@ class TDTestCase: ...@@ -112,7 +112,7 @@ class TDTestCase:
} }
username="user1" username="user1"
passwd="123" passwd="123"
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
...@@ -120,7 +120,7 @@ class TDTestCase: ...@@ -120,7 +120,7 @@ class TDTestCase:
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers'] rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -135,7 +135,7 @@ class TDTestCase: ...@@ -135,7 +135,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -162,10 +162,10 @@ class TDTestCase: ...@@ -162,10 +162,10 @@ class TDTestCase:
for i in range(tdSql.queryRows): for i in range(tdSql.queryRows):
if tdSql.queryResult[i][0] == "%s"%username : if tdSql.queryResult[i][0] == "%s"%username :
tdLog.info("create user:%s successfully"%username) tdLog.info("create user:%s successfully"%username)
# # create database and stable # # create database and stable
# clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) # clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
# tdLog.info("Take turns stopping Mnodes ") # tdLog.info("Take turns stopping Mnodes ")
# tdDnodes=cluster.dnodes # tdDnodes=cluster.dnodes
# stopcount =0 # stopcount =0
...@@ -197,7 +197,7 @@ class TDTestCase: ...@@ -197,7 +197,7 @@ class TDTestCase:
# tdDnodes[i].stoptaosd() # tdDnodes[i].stoptaosd()
# # sleep(10) # # sleep(10)
# tdDnodes[i].starttaosd() # tdDnodes[i].starttaosd()
# # sleep(10) # # sleep(10)
# elif stopRole == "vnode": # elif stopRole == "vnode":
# for i in range(vnodeNumbers): # for i in range(vnodeNumbers):
# tdDnodes[i+mnodeNums].stoptaosd() # tdDnodes[i+mnodeNums].stoptaosd()
...@@ -209,7 +209,7 @@ class TDTestCase: ...@@ -209,7 +209,7 @@ class TDTestCase:
# tdDnodes[i].stoptaosd() # tdDnodes[i].stoptaosd()
# # sleep(10) # # sleep(10)
# tdDnodes[i].starttaosd() # tdDnodes[i].starttaosd()
# # sleep(10) # # sleep(10)
# # dnodeNumbers don't include database of schema # # dnodeNumbers don't include database of schema
# if clusterComCheck.checkDnodes(dnodeNumbers): # if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -220,7 +220,7 @@ class TDTestCase: ...@@ -220,7 +220,7 @@ class TDTestCase:
# tdLog.exit("one or more of dnodes failed to start ") # tdLog.exit("one or more of dnodes failed to start ")
# # self.check3mnode() # # self.check3mnode()
# stopcount+=1 # stopcount+=1
# clusterComCheck.checkDnodes(dnodeNumbers) # clusterComCheck.checkDnodes(dnodeNumbers)
# clusterComCheck.checkDbRows(dbNumbers) # clusterComCheck.checkDbRows(dbNumbers)
...@@ -234,7 +234,7 @@ class TDTestCase: ...@@ -234,7 +234,7 @@ class TDTestCase:
# # tdSql.query("select * from %s"%stableName) # # tdSql.query("select * from %s"%stableName)
# # tdSql.checkRows(rowsPerStb) # # tdSql.checkRows(rowsPerStb)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
...@@ -243,4 +243,4 @@ class TDTestCase: ...@@ -243,4 +243,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from numpy import row_stack ...@@ -3,7 +3,7 @@ from numpy import row_stack
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode ...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -57,7 +57,7 @@ class TDTestCase: ...@@ -57,7 +57,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
"rowsPerTbl": 100, "rowsPerTbl": 100,
"batchNum": 5000 "batchNum": 5000
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
...@@ -118,7 +118,7 @@ class TDTestCase: ...@@ -118,7 +118,7 @@ class TDTestCase:
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers'] rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
...@@ -174,7 +174,7 @@ class TDTestCase: ...@@ -174,7 +174,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -186,7 +186,7 @@ class TDTestCase: ...@@ -186,7 +186,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -197,7 +197,7 @@ class TDTestCase: ...@@ -197,7 +197,7 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers) clusterComCheck.checkDbRows(dbNumbers)
...@@ -211,7 +211,7 @@ class TDTestCase: ...@@ -211,7 +211,7 @@ class TDTestCase:
# tdSql.query("select * from %s"%stableName) # tdSql.query("select * from %s"%stableName)
# tdSql.checkRows(rowsPerStb) # tdSql.checkRows(rowsPerStb)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
...@@ -220,4 +220,4 @@ class TDTestCase: ...@@ -220,4 +220,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from numpy import row_stack ...@@ -3,7 +3,7 @@ from numpy import row_stack
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode ...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -57,7 +57,7 @@ class TDTestCase: ...@@ -57,7 +57,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
"rowsPerTbl": 100, "rowsPerTbl": 100,
"batchNum": 5000 "batchNum": 5000
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
...@@ -118,7 +118,7 @@ class TDTestCase: ...@@ -118,7 +118,7 @@ class TDTestCase:
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers'] rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
...@@ -173,7 +173,7 @@ class TDTestCase: ...@@ -173,7 +173,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -185,7 +185,7 @@ class TDTestCase: ...@@ -185,7 +185,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -196,10 +196,10 @@ class TDTestCase: ...@@ -196,10 +196,10 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
clusterComCheck.checkDbRows(dbNumbers) clusterComCheck.checkDbRows(dbNumbers)
# clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"]) # clusterComCheck.checkDb(dbNumbers,1,paraDict["dbName"])
...@@ -212,7 +212,7 @@ class TDTestCase: ...@@ -212,7 +212,7 @@ class TDTestCase:
# tdSql.query("select * from %s"%stableName) # tdSql.query("select * from %s"%stableName)
# tdSql.checkRows(rowsPerStb) # tdSql.checkRows(rowsPerStb)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=1,stopRole='dnode')
...@@ -221,4 +221,4 @@ class TDTestCase: ...@@ -221,4 +221,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -67,7 +67,7 @@ class TDTestCase: ...@@ -67,7 +67,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -107,13 +107,13 @@ class TDTestCase: ...@@ -107,13 +107,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -128,7 +128,7 @@ class TDTestCase: ...@@ -128,7 +128,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -149,7 +149,7 @@ class TDTestCase: ...@@ -149,7 +149,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -157,7 +157,7 @@ class TDTestCase: ...@@ -157,7 +157,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -169,7 +169,7 @@ class TDTestCase: ...@@ -169,7 +169,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -180,7 +180,7 @@ class TDTestCase: ...@@ -180,7 +180,7 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
tdLog.info("check dnode number:") tdLog.info("check dnode number:")
...@@ -196,7 +196,7 @@ class TDTestCase: ...@@ -196,7 +196,7 @@ class TDTestCase:
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='dnode')
...@@ -205,4 +205,4 @@ class TDTestCase: ...@@ -205,4 +205,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -81,13 +81,13 @@ class TDTestCase: ...@@ -81,13 +81,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -102,7 +102,7 @@ class TDTestCase: ...@@ -102,7 +102,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -111,7 +111,7 @@ class TDTestCase: ...@@ -111,7 +111,7 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
...@@ -130,7 +130,7 @@ class TDTestCase: ...@@ -130,7 +130,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -142,19 +142,19 @@ class TDTestCase: ...@@ -142,19 +142,19 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123") tdLog.info("123")
else: else:
print("456") print("456")
self.stopThread(threads) self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -169,7 +169,7 @@ class TDTestCase: ...@@ -169,7 +169,7 @@ class TDTestCase:
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
...@@ -178,4 +178,4 @@ class TDTestCase: ...@@ -178,4 +178,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from numpy import row_stack ...@@ -3,7 +3,7 @@ from numpy import row_stack
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode ...@@ -13,13 +13,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -57,7 +57,7 @@ class TDTestCase: ...@@ -57,7 +57,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -68,7 +68,7 @@ class TDTestCase: ...@@ -68,7 +68,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
"rowsPerTbl": 10000, "rowsPerTbl": 10000,
"batchNum": 5000 "batchNum": 5000
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
...@@ -118,7 +118,7 @@ class TDTestCase: ...@@ -118,7 +118,7 @@ class TDTestCase:
rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"] rowsPerStb=paraDict["ctbNum"]*paraDict["rowsPerTbl"]
rowsall=rowsPerStb*paraDict['stbNumbers'] rowsall=rowsPerStb*paraDict['stbNumbers']
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
...@@ -171,7 +171,7 @@ class TDTestCase: ...@@ -171,7 +171,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -183,19 +183,19 @@ class TDTestCase: ...@@ -183,19 +183,19 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123") tdLog.info("123")
else: else:
print("456") print("456")
self.stopThread(threads) self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -209,7 +209,7 @@ class TDTestCase: ...@@ -209,7 +209,7 @@ class TDTestCase:
stableName= '%s_%d'%(paraDict['stbName'],i) stableName= '%s_%d'%(paraDict['stbName'],i)
tdSql.query("select * from %s"%stableName) tdSql.query("select * from %s"%stableName)
tdSql.checkRows(rowsPerStb) tdSql.checkRows(rowsPerStb)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='dnode')
...@@ -218,4 +218,4 @@ class TDTestCase: ...@@ -218,4 +218,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -82,13 +82,13 @@ class TDTestCase: ...@@ -82,13 +82,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -105,14 +105,14 @@ class TDTestCase: ...@@ -105,14 +105,14 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
print(tdSql.queryResult) print(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
tdLog.info("create database and stable") tdLog.info("create database and stable")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
threads=[] threads=[]
...@@ -124,7 +124,7 @@ class TDTestCase: ...@@ -124,7 +124,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -132,7 +132,7 @@ class TDTestCase: ...@@ -132,7 +132,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -144,7 +144,7 @@ class TDTestCase: ...@@ -144,7 +144,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -155,7 +155,7 @@ class TDTestCase: ...@@ -155,7 +155,7 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
tdLog.info("check dnode number:") tdLog.info("check dnode number:")
...@@ -170,7 +170,7 @@ class TDTestCase: ...@@ -170,7 +170,7 @@ class TDTestCase:
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='mnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='mnode')
...@@ -179,4 +179,4 @@ class TDTestCase: ...@@ -179,4 +179,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -82,13 +82,13 @@ class TDTestCase: ...@@ -82,13 +82,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -103,14 +103,14 @@ class TDTestCase: ...@@ -103,14 +103,14 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
print(tdSql.queryResult) print(tdSql.queryResult)
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
tdLog.info("create database and stable") tdLog.info("create database and stable")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
threads=[] threads=[]
...@@ -122,7 +122,7 @@ class TDTestCase: ...@@ -122,7 +122,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -130,7 +130,7 @@ class TDTestCase: ...@@ -130,7 +130,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -153,14 +153,14 @@ class TDTestCase: ...@@ -153,14 +153,14 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
tdLog.info("check dnode number:") tdLog.info("check dnode number:")
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
tdSql.query("show databases") tdSql.query("show databases")
tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2)) tdLog.debug("we find %d databases but exepect to create %d databases "%(tdSql.queryRows-2,allDbNumbers-2))
# tdLog.info("check DB Rows:") # tdLog.info("check DB Rows:")
# clusterComCheck.checkDbRows(allDbNumbers) # clusterComCheck.checkDbRows(allDbNumbers)
# tdLog.info("check DB Status on by on") # tdLog.info("check DB Status on by on")
...@@ -168,7 +168,7 @@ class TDTestCase: ...@@ -168,7 +168,7 @@ class TDTestCase:
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode')
...@@ -177,4 +177,4 @@ class TDTestCase: ...@@ -177,4 +177,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -67,7 +67,7 @@ class TDTestCase: ...@@ -67,7 +67,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -106,13 +106,13 @@ class TDTestCase: ...@@ -106,13 +106,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -127,7 +127,7 @@ class TDTestCase: ...@@ -127,7 +127,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -148,7 +148,7 @@ class TDTestCase: ...@@ -148,7 +148,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
...@@ -157,7 +157,7 @@ class TDTestCase: ...@@ -157,7 +157,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -169,19 +169,19 @@ class TDTestCase: ...@@ -169,19 +169,19 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123") tdLog.info("123")
else: else:
print("456") print("456")
self.stopThread(threads) self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -195,7 +195,7 @@ class TDTestCase: ...@@ -195,7 +195,7 @@ class TDTestCase:
# tdSql.checkRows(allStbNumbers) # tdSql.checkRows(allStbNumbers)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='mnode')
...@@ -204,4 +204,4 @@ class TDTestCase: ...@@ -204,4 +204,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -82,13 +82,13 @@ class TDTestCase: ...@@ -82,13 +82,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allDbNumbers=(paraDict['dbNumbers']*restartNumbers) allDbNumbers=(paraDict['dbNumbers']*restartNumbers)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -103,7 +103,7 @@ class TDTestCase: ...@@ -103,7 +103,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -124,7 +124,7 @@ class TDTestCase: ...@@ -124,7 +124,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -132,7 +132,7 @@ class TDTestCase: ...@@ -132,7 +132,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -144,7 +144,7 @@ class TDTestCase: ...@@ -144,7 +144,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
...@@ -155,7 +155,7 @@ class TDTestCase: ...@@ -155,7 +155,7 @@ class TDTestCase:
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -169,7 +169,7 @@ class TDTestCase: ...@@ -169,7 +169,7 @@ class TDTestCase:
# clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i)) # clusterComCheck.checkDb(paraDict['dbNumbers'],restartNumbers,dbNameIndex = '%s%d'%(paraDict["dbName"],i))
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='vnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=10,stopRole='vnode')
...@@ -178,4 +178,4 @@ class TDTestCase: ...@@ -178,4 +178,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode ...@@ -12,13 +12,13 @@ from util.dnodes import TDDnode
from util.cluster import * from util.cluster import *
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import clusterComCheck from clusterCommonCheck import clusterComCheck
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -31,7 +31,7 @@ class TDTestCase: ...@@ -31,7 +31,7 @@ class TDTestCase:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
self.host = socket.gethostname() self.host = socket.gethostname()
print(tdSql) print(tdSql)
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -56,7 +56,7 @@ class TDTestCase: ...@@ -56,7 +56,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -67,7 +67,7 @@ class TDTestCase: ...@@ -67,7 +67,7 @@ class TDTestCase:
def insertData(self,countstart,countstop): def insertData(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -106,13 +106,13 @@ class TDTestCase: ...@@ -106,13 +106,13 @@ class TDTestCase:
'ctbPrefix': 'ctb', 'ctbPrefix': 'ctb',
'ctbNum': 1, 'ctbNum': 1,
} }
dnodeNumbers=int(dnodeNumbers) dnodeNumbers=int(dnodeNumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
vnodeNumbers = int(dnodeNumbers-mnodeNums) vnodeNumbers = int(dnodeNumbers-mnodeNums)
allStbNumbers=(paraDict['stbNumbers']*restartNumbers) allStbNumbers=(paraDict['stbNumbers']*restartNumbers)
dbNumbers = 1 dbNumbers = 1
print(tdSql) print(tdSql)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -128,7 +128,7 @@ class TDTestCase: ...@@ -128,7 +128,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -137,12 +137,12 @@ class TDTestCase: ...@@ -137,12 +137,12 @@ class TDTestCase:
# create database and stable # create database and stable
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
stopcount =0 stopcount =0
threads=[] threads=[]
for i in range(restartNumbers): for i in range(restartNumbers):
stableName= '%s%d'%(paraDict['stbName'],i) stableName= '%s%d'%(paraDict['stbName'],i)
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
...@@ -151,7 +151,7 @@ class TDTestCase: ...@@ -151,7 +151,7 @@ class TDTestCase:
for tr in threads: for tr in threads:
tr.start() tr.start()
tdLog.info("Take turns stopping Mnodes ") tdLog.info("Take turns stopping Mnodes ")
while stopcount < restartNumbers: while stopcount < restartNumbers:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
if stopRole == "mnode": if stopRole == "mnode":
...@@ -159,7 +159,7 @@ class TDTestCase: ...@@ -159,7 +159,7 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
elif stopRole == "vnode": elif stopRole == "vnode":
for i in range(vnodeNumbers): for i in range(vnodeNumbers):
tdDnodes[i+mnodeNums].stoptaosd() tdDnodes[i+mnodeNums].stoptaosd()
...@@ -171,19 +171,19 @@ class TDTestCase: ...@@ -171,19 +171,19 @@ class TDTestCase:
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
# sleep(10) # sleep(10)
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
# sleep(10) # sleep(10)
# dnodeNumbers don't include database of schema # dnodeNumbers don't include database of schema
if clusterComCheck.checkDnodes(dnodeNumbers): if clusterComCheck.checkDnodes(dnodeNumbers):
tdLog.info("123") tdLog.info("123")
else: else:
print("456") print("456")
self.stopThread(threads) self.stopThread(threads)
tdLog.exit("one or more of dnodes failed to start ") tdLog.exit("one or more of dnodes failed to start ")
# self.check3mnode() # self.check3mnode()
stopcount+=1 stopcount+=1
for tr in threads: for tr in threads:
tr.join() tr.join()
clusterComCheck.checkDnodes(dnodeNumbers) clusterComCheck.checkDnodes(dnodeNumbers)
...@@ -197,7 +197,7 @@ class TDTestCase: ...@@ -197,7 +197,7 @@ class TDTestCase:
tdSql.checkRows(allStbNumbers) tdSql.checkRows(allStbNumbers)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='vnode') self.fiveDnodeThreeMnode(dnodeNumbers=5,mnodeNums=3,restartNumbers=2,stopRole='vnode')
...@@ -206,4 +206,4 @@ class TDTestCase: ...@@ -206,4 +206,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -18,7 +18,7 @@ import time ...@@ -18,7 +18,7 @@ import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -54,7 +54,7 @@ class TDTestCase: ...@@ -54,7 +54,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -65,7 +65,7 @@ class TDTestCase: ...@@ -65,7 +65,7 @@ class TDTestCase:
def insert_data(self,countstart,countstop): def insert_data(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -96,7 +96,7 @@ class TDTestCase: ...@@ -96,7 +96,7 @@ class TDTestCase:
for i in range(stableCount): for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
def checkdnodes(self,dnodenumber): def checkdnodes(self,dnodenumber):
count=0 count=0
...@@ -104,8 +104,8 @@ class TDTestCase: ...@@ -104,8 +104,8 @@ class TDTestCase:
time.sleep(1) time.sleep(1)
statusReadyBumber=0 statusReadyBumber=0
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
if tdSql.checkRows(dnodenumber) : if tdSql.checkRows(dnodenumber) :
print("dnode is %d nodes"%dnodenumber) print("dnode is %d nodes"%dnodenumber)
for i in range(dnodenumber): for i in range(dnodenumber):
if tdSql.queryResult[i][4] !='ready' : if tdSql.queryResult[i][4] !='ready' :
status=tdSql.queryResult[i][4] status=tdSql.queryResult[i][4]
...@@ -122,15 +122,15 @@ class TDTestCase: ...@@ -122,15 +122,15 @@ class TDTestCase:
else: else:
print("%d mnodes is not ready in 10s "%dnodenumber) print("%d mnodes is not ready in 10s "%dnodenumber)
return False return False
def check3mnode(self): def check3mnode(self):
count=0 count=0
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
if tdSql.checkRows(3) : if tdSql.checkRows(3) :
print("mnode is three nodes") print("mnode is three nodes")
if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[0][2]=='leader' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
...@@ -140,19 +140,19 @@ class TDTestCase: ...@@ -140,19 +140,19 @@ class TDTestCase:
if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[1][2]=='leader':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
print("three mnodes is ready in 10s") print("three mnodes is ready in 10s")
break break
elif tdSql.queryResult[0][2]=='follower' : elif tdSql.queryResult[0][2]=='follower' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='leader': if tdSql.queryResult[2][2]=='leader':
print("three mnodes is ready in 10s") print("three mnodes is ready in 10s")
break break
count+=1 count+=1
else: else:
print("three mnodes is not ready in 10s ") print("three mnodes is not ready in 10s ")
return -1 return -1
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,1,'%s:6130'%self.host)
...@@ -182,8 +182,8 @@ class TDTestCase: ...@@ -182,8 +182,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 1;") tdSql.error("drop mnode on dnode 1;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'offline') tdSql.checkData(0,2,'offline')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -210,8 +210,8 @@ class TDTestCase: ...@@ -210,8 +210,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 2;") tdSql.error("drop mnode on dnode 2;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -239,8 +239,8 @@ class TDTestCase: ...@@ -239,8 +239,8 @@ class TDTestCase:
print("stop mnodes on dnode 3 failed in 10s") print("stop mnodes on dnode 3 failed in 10s")
return -1 return -1
tdSql.error("drop mnode on dnode 3;") tdSql.error("drop mnode on dnode 3;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -258,15 +258,15 @@ class TDTestCase: ...@@ -258,15 +258,15 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
def five_dnode_three_mnode(self,dnodenumber): def five_dnode_three_mnode(self,dnodenumber):
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -281,15 +281,15 @@ class TDTestCase: ...@@ -281,15 +281,15 @@ class TDTestCase:
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
print(tdSql.queryResult) print(tdSql.queryResult)
tdLog.debug("stop all of mnode ") tdLog.debug("stop all of mnode ")
# seperate vnode and mnode in different dnodes. # seperate vnode and mnode in different dnodes.
# create database and stable # create database and stable
stopcount =0 stopcount =0
while stopcount < 2: while stopcount < 2:
for i in range(dnodenumber): for i in range(dnodenumber):
# threads=[] # threads=[]
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) # threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
threads=threading.Thread(target=self.insert_data, args=(i,i+1)) threads=threading.Thread(target=self.insert_data, args=(i,i+1))
threads.start() threads.start()
self.TDDnodes.stoptaosd(i+1) self.TDDnodes.stoptaosd(i+1)
...@@ -306,13 +306,13 @@ class TDTestCase: ...@@ -306,13 +306,13 @@ class TDTestCase:
return False return False
# self.check3mnode() # self.check3mnode()
self.check3mnode() self.check3mnode()
stopcount+=1 stopcount+=1
self.check3mnode() self.check3mnode()
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.five_dnode_three_mnode(5) self.five_dnode_three_mnode(5)
...@@ -321,4 +321,4 @@ class TDTestCase: ...@@ -321,4 +321,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -15,13 +15,13 @@ from test import tdDnodes ...@@ -15,13 +15,13 @@ from test import tdDnodes
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers=int(dnodenumbers) dnodenumbers=int(dnodenumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
dbNumbers = int(dnodenumbers * restartNumber) dbNumbers = int(dnodenumbers * restartNumber)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -109,10 +109,10 @@ class TDTestCase: ...@@ -109,10 +109,10 @@ class TDTestCase:
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -15,13 +15,13 @@ from test import tdDnodes ...@@ -15,13 +15,13 @@ from test import tdDnodes
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers=int(dnodenumbers) dnodenumbers=int(dnodenumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -99,7 +99,7 @@ class TDTestCase: ...@@ -99,7 +99,7 @@ class TDTestCase:
tdLog.info("check whether 2 mnode status is offline") tdLog.info("check whether 2 mnode status is offline")
clusterComCheck.check3mnode2off() clusterComCheck.check3mnode2off()
# tdSql.error("create user user1 pass '123';") # tdSql.error("create user user1 pass '123';")
tdLog.info("start two follower") tdLog.info("start two follower")
tdDnodes[1].starttaosd() tdDnodes[1].starttaosd()
tdDnodes[2].starttaosd() tdDnodes[2].starttaosd()
...@@ -107,10 +107,10 @@ class TDTestCase: ...@@ -107,10 +107,10 @@ class TDTestCase:
clusterComCheck.checkMnodeStatus(mnodeNums) clusterComCheck.checkMnodeStatus(mnodeNums)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -16,13 +16,13 @@ from test import tdDnodes ...@@ -16,13 +16,13 @@ from test import tdDnodes
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers=int(dnodenumbers) dnodenumbers=int(dnodenumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
dbNumbers = int(dnodenumbers * restartNumber) dbNumbers = int(dnodenumbers * restartNumber)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -96,21 +96,21 @@ class TDTestCase: ...@@ -96,21 +96,21 @@ class TDTestCase:
# restart all taosd # restart all taosd
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
for i in range(mnodeNums): for i in range(mnodeNums):
tdDnodes[i].stoptaosd() tdDnodes[i].stoptaosd()
for j in range(dnodenumbers): for j in range(dnodenumbers):
if j != i: if j != i:
cluster.checkConnectStatus(j) cluster.checkConnectStatus(j)
clusterComCheck.check3mnodeoff(i+1,3) clusterComCheck.check3mnodeoff(i+1,3)
clusterComCheck.init(cluster.checkConnectStatus(i+1)) clusterComCheck.init(cluster.checkConnectStatus(i+1))
tdDnodes[i].starttaosd() tdDnodes[i].starttaosd()
clusterComCheck.checkMnodeStatus(mnodeNums) clusterComCheck.checkMnodeStatus(mnodeNums)
tdLog.info("Take turns stopping all dnodes ") tdLog.info("Take turns stopping all dnodes ")
# seperate vnode and mnode in different dnodes. # seperate vnode and mnode in different dnodes.
# create database and stable # create database and stable
stopcount =0 stopcount =0
while stopcount < restartNumber: while stopcount < restartNumber:
tdLog.info("first restart loop") tdLog.info("first restart loop")
for i in range(dnodenumbers): for i in range(dnodenumbers):
...@@ -120,13 +120,13 @@ class TDTestCase: ...@@ -120,13 +120,13 @@ class TDTestCase:
clusterComCheck.checkDnodes(dnodenumbers) clusterComCheck.checkDnodes(dnodenumbers)
clusterComCheck.checkMnodeStatus(mnodeNums) clusterComCheck.checkMnodeStatus(mnodeNums)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(5,3,1) self.fiveDnodeThreeMnode(5,3,1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -15,13 +15,13 @@ from test import tdDnodes ...@@ -15,13 +15,13 @@ from test import tdDnodes
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers=int(dnodenumbers) dnodenumbers=int(dnodenumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
dbNumbers = 1 dbNumbers = 1
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -100,20 +100,20 @@ class TDTestCase: ...@@ -100,20 +100,20 @@ class TDTestCase:
# tdLog.info("check whether 2 mnode status is offline") # tdLog.info("check whether 2 mnode status is offline")
# clusterComCheck.check3mnode2off() # clusterComCheck.check3mnode2off()
# tdSql.error("create user user1 pass '123';") # tdSql.error("create user user1 pass '123';")
tdLog.info("start one mnode" ) tdLog.info("start one mnode" )
tdDnodes[0].starttaosd() tdDnodes[0].starttaosd()
clusterComCheck.check3mnodeoff(2) clusterComCheck.check3mnodeoff(2)
clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica']) clusterComCreate.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], paraDict["vgroups"],paraDict['replica'])
clusterComCheck.checkDb(dbNumbers,1,'db0') clusterComCheck.checkDb(dbNumbers,1,'db0')
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1) self.fiveDnodeThreeMnode(dnodenumbers=5,mnodeNums=3,restartNumber=1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -13,7 +13,7 @@ import time ...@@ -13,7 +13,7 @@ import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
import threading import threading
import time import time
import inspect import inspect
import ctypes import ctypes
...@@ -36,7 +36,7 @@ class TDTestCase: ...@@ -36,7 +36,7 @@ class TDTestCase:
self.host=self.master_dnode.cfgDict["fqdn"] self.host=self.master_dnode.cfgDict["fqdn"]
conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir)
tdSql.init(conn1.cursor()) tdSql.init(conn1.cursor())
def getBuildPath(self): def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
...@@ -62,7 +62,7 @@ class TDTestCase: ...@@ -62,7 +62,7 @@ class TDTestCase:
if res == 0: if res == 0:
raise ValueError("invalid thread id") raise ValueError("invalid thread id")
elif res != 1: elif res != 1:
# """if it returns a number greater than one, you're in trouble, # """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect""" # and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed") raise SystemError("PyThreadState_SetAsyncExc failed")
...@@ -73,7 +73,7 @@ class TDTestCase: ...@@ -73,7 +73,7 @@ class TDTestCase:
def insert_data(self,countstart,countstop): def insert_data(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table # fisrt add data : db\stable\childtable\general table
for couti in range(countstart,countstop): for couti in range(countstart,countstop):
tdLog.debug("drop database if exists db%d" %couti) tdLog.debug("drop database if exists db%d" %couti)
tdSql.execute("drop database if exists db%d" %couti) tdSql.execute("drop database if exists db%d" %couti)
...@@ -95,10 +95,10 @@ class TDTestCase: ...@@ -95,10 +95,10 @@ class TDTestCase:
for i in range(4): for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
def depoly_cluster(self ,dnodes_nums): def depoly_cluster(self ,dnodes_nums):
testCluster = False testCluster = False
valgrind = 0 valgrind = 0
hostname = socket.gethostname() hostname = socket.gethostname()
dnodes = [] dnodes = []
start_port = 6030 start_port = 6030
...@@ -112,7 +112,7 @@ class TDTestCase: ...@@ -112,7 +112,7 @@ class TDTestCase:
dnode.addExtraCfg("monitorPort", 7043) dnode.addExtraCfg("monitorPort", 7043)
dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}")
dnodes.append(dnode) dnodes.append(dnode)
self.TDDnodes = MyDnodes(dnodes) self.TDDnodes = MyDnodes(dnodes)
self.TDDnodes.init("") self.TDDnodes.init("")
self.TDDnodes.setTestCluster(testCluster) self.TDDnodes.setTestCluster(testCluster)
...@@ -120,11 +120,11 @@ class TDTestCase: ...@@ -120,11 +120,11 @@ class TDTestCase:
self.TDDnodes.stopAll() self.TDDnodes.stopAll()
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.deploy(dnode.index,{}) self.TDDnodes.deploy(dnode.index,{})
for dnode in self.TDDnodes.dnodes: for dnode in self.TDDnodes.dnodes:
self.TDDnodes.starttaosd(dnode.index) self.TDDnodes.starttaosd(dnode.index)
# create cluster # create cluster
for dnode in self.TDDnodes.dnodes[1:]: for dnode in self.TDDnodes.dnodes[1:]:
# tdLog.debug(dnode.cfgDict) # tdLog.debug(dnode.cfgDict)
dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"]
...@@ -133,7 +133,7 @@ class TDTestCase: ...@@ -133,7 +133,7 @@ class TDTestCase:
cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;"
tdLog.debug(cmd) tdLog.debug(cmd)
os.system(cmd) os.system(cmd)
time.sleep(2) time.sleep(2)
tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) tdLog.info(" create cluster with %d dnode done! " %dnodes_nums)
...@@ -143,8 +143,8 @@ class TDTestCase: ...@@ -143,8 +143,8 @@ class TDTestCase:
time.sleep(1) time.sleep(1)
statusReadyBumber=0 statusReadyBumber=0
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
if tdSql.checkRows(dnodenumber) : if tdSql.checkRows(dnodenumber) :
tdLog.debug("dnode is %d nodes"%dnodenumber) tdLog.debug("dnode is %d nodes"%dnodenumber)
for i in range(dnodenumber): for i in range(dnodenumber):
if tdSql.queryResult[i][4] !='ready' : if tdSql.queryResult[i][4] !='ready' :
status=tdSql.queryResult[i][4] status=tdSql.queryResult[i][4]
...@@ -161,15 +161,15 @@ class TDTestCase: ...@@ -161,15 +161,15 @@ class TDTestCase:
else: else:
tdLog.debug("%d mnodes is not ready in 10s "%dnodenumber) tdLog.debug("%d mnodes is not ready in 10s "%dnodenumber)
return False return False
def check3mnode(self): def check3mnode(self):
count=0 count=0
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
if tdSql.checkRows(3) : if tdSql.checkRows(3) :
tdLog.debug("mnode is three nodes") tdLog.debug("mnode is three nodes")
if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[0][2]=='leader' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
...@@ -179,19 +179,19 @@ class TDTestCase: ...@@ -179,19 +179,19 @@ class TDTestCase:
if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[1][2]=='leader':
if tdSql.queryResult[2][2]=='follower': if tdSql.queryResult[2][2]=='follower':
tdLog.debug("three mnodes is ready in 10s") tdLog.debug("three mnodes is ready in 10s")
break break
elif tdSql.queryResult[0][2]=='follower' : elif tdSql.queryResult[0][2]=='follower' :
if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[1][2]=='follower':
if tdSql.queryResult[2][2]=='leader': if tdSql.queryResult[2][2]=='leader':
tdLog.debug("three mnodes is ready in 10s") tdLog.debug("three mnodes is ready in 10s")
break break
count+=1 count+=1
else: else:
tdLog.debug("three mnodes is not ready in 10s ") tdLog.debug("three mnodes is not ready in 10s ")
return -1 return -1
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
tdSql.checkData(1,1,'%s:6130'%self.host) tdSql.checkData(1,1,'%s:6130'%self.host)
...@@ -221,8 +221,8 @@ class TDTestCase: ...@@ -221,8 +221,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 1;") tdSql.error("drop mnode on dnode 1;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'offline') tdSql.checkData(0,2,'offline')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -249,8 +249,8 @@ class TDTestCase: ...@@ -249,8 +249,8 @@ class TDTestCase:
return -1 return -1
tdSql.error("drop mnode on dnode 2;") tdSql.error("drop mnode on dnode 2;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -278,8 +278,8 @@ class TDTestCase: ...@@ -278,8 +278,8 @@ class TDTestCase:
tdLog.debug("stop mnodes on dnode 3 failed in 10s") tdLog.debug("stop mnodes on dnode 3 failed in 10s")
return -1 return -1
tdSql.error("drop mnode on dnode 3;") tdSql.error("drop mnode on dnode 3;")
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -296,8 +296,8 @@ class TDTestCase: ...@@ -296,8 +296,8 @@ class TDTestCase:
tdSql.checkData(4,1,'%s:6430'%self.host) tdSql.checkData(4,1,'%s:6430'%self.host)
tdSql.checkData(0,4,'ready') tdSql.checkData(0,4,'ready')
tdSql.checkData(4,4,'ready') tdSql.checkData(4,4,'ready')
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
tdSql.checkData(0,2,'leader') tdSql.checkData(0,2,'leader')
tdSql.checkData(0,3,'ready') tdSql.checkData(0,3,'ready')
...@@ -312,13 +312,13 @@ class TDTestCase: ...@@ -312,13 +312,13 @@ class TDTestCase:
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
tdLog.debug("stop all of mnode ") tdLog.debug("stop all of mnode ")
stopcount =0 stopcount =0
while stopcount <= 2: while stopcount <= 2:
for i in range(dnodenumber): for i in range(dnodenumber):
# threads=[] # threads=[]
# threads = MyThreadFunc(self.insert_data(i*2,i*2+2)) # threads = MyThreadFunc(self.insert_data(i*2,i*2+2))
threads=threading.Thread(target=self.insert_data, args=((stopcount+i)*2,(i+stopcount)*2+2)) threads=threading.Thread(target=self.insert_data, args=((stopcount+i)*2,(i+stopcount)*2+2))
threads.start() threads.start()
self.TDDnodes.stoptaosd(i+1) self.TDDnodes.stoptaosd(i+1)
...@@ -344,7 +344,7 @@ class TDTestCase: ...@@ -344,7 +344,7 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def run(self): def run(self):
# tdLog.debug(self.master_dnode.cfgDict) # tdLog.debug(self.master_dnode.cfgDict)
self.buildcluster(5) self.buildcluster(5)
self.five_dnode_three_mnode(5) self.five_dnode_three_mnode(5)
...@@ -354,4 +354,4 @@ class TDTestCase: ...@@ -354,4 +354,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -2,7 +2,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -15,13 +15,13 @@ from test import tdDnodes ...@@ -15,13 +15,13 @@ from test import tdDnodes
sys.path.append("./6-cluster") sys.path.append("./6-cluster")
from clusterCommonCreate import * from clusterCommonCreate import *
from clusterCommonCheck import * from clusterCommonCheck import *
import time import time
import socket import socket
import subprocess import subprocess
from multiprocessing import Process from multiprocessing import Process
class TDTestCase: class TDTestCase:
def init(self,conn ,logSql): def init(self,conn ,logSql):
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
dnodenumbers=int(dnodenumbers) dnodenumbers=int(dnodenumbers)
mnodeNums=int(mnodeNums) mnodeNums=int(mnodeNums)
dbNumbers = int(dnodenumbers * restartNumber) dbNumbers = int(dnodenumbers * restartNumber)
tdLog.info("first check dnode and mnode") tdLog.info("first check dnode and mnode")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,1,'%s:6030'%self.host)
...@@ -84,7 +84,7 @@ class TDTestCase: ...@@ -84,7 +84,7 @@ class TDTestCase:
tdSql.execute("create mnode on dnode 3") tdSql.execute("create mnode on dnode 3")
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
# add some error operations and # add some error operations and
tdLog.info("Confirm the status of the dnode again") tdLog.info("Confirm the status of the dnode again")
tdSql.error("create mnode on dnode 2") tdSql.error("create mnode on dnode 2")
tdSql.query("show dnodes;") tdSql.query("show dnodes;")
...@@ -93,10 +93,10 @@ class TDTestCase: ...@@ -93,10 +93,10 @@ class TDTestCase:
# restart all taosd # restart all taosd
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
tdLog.info("Take turns stopping all dnodes ") tdLog.info("Take turns stopping all dnodes ")
# seperate vnode and mnode in different dnodes. # seperate vnode and mnode in different dnodes.
# create database and stable # create database and stable
stopcount =0 stopcount =0
while stopcount <= 2: while stopcount <= 2:
tdLog.info(" restart loop: %d"%stopcount ) tdLog.info(" restart loop: %d"%stopcount )
for i in range(dnodenumbers): for i in range(dnodenumbers):
...@@ -106,10 +106,10 @@ class TDTestCase: ...@@ -106,10 +106,10 @@ class TDTestCase:
clusterComCheck.checkDnodes(dnodenumbers) clusterComCheck.checkDnodes(dnodenumbers)
clusterComCheck.checkMnodeStatus(3) clusterComCheck.checkMnodeStatus(3)
def run(self): def run(self):
# print(self.master_dnode.cfgDict) # print(self.master_dnode.cfgDict)
self.fiveDnodeThreeMnode(5,3,1) self.fiveDnodeThreeMnode(5,3,1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
......
...@@ -48,10 +48,10 @@ class ClusterComCheck: ...@@ -48,10 +48,10 @@ class ClusterComCheck:
if tdSql.queryResult[i][4] == "ready": if tdSql.queryResult[i][4] == "ready":
status+=1 status+=1
tdLog.info(status) tdLog.info(status)
if status == dnodeNumbers: if status == dnodeNumbers:
tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within 30s! " %dnodeNumbers) tdLog.success("it find cluster with %d dnodes and check that all cluster dnodes are ready within 30s! " %dnodeNumbers)
return True return True
count+=1 count+=1
time.sleep(1) time.sleep(1)
else: else:
...@@ -77,15 +77,15 @@ class ClusterComCheck: ...@@ -77,15 +77,15 @@ class ClusterComCheck:
def checkDb(self,dbNumbers,restartNumber,dbNameIndex): def checkDb(self,dbNumbers,restartNumber,dbNameIndex):
count=0 count=0
alldbNumbers=(dbNumbers*restartNumber)+2 alldbNumbers=(dbNumbers*restartNumber)+2
while count < 5: while count < 5:
query_status=0 query_status=0
for j in range(dbNumbers): for j in range(dbNumbers):
for i in range(alldbNumbers): for i in range(alldbNumbers):
tdSql.query("show databases;") tdSql.query("show databases;")
if "%s_%d"%(dbNameIndex,j) == tdSql.queryResult[i][0] : if "%s_%d"%(dbNameIndex,j) == tdSql.queryResult[i][0] :
if tdSql.queryResult[i][15] == "ready": if tdSql.queryResult[i][15] == "ready":
query_status+=1 query_status+=1
tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j)) tdLog.debug("check %s_%d that status is ready "%(dbNameIndex,j))
else: else:
continue continue
# print(query_status) # print(query_status)
...@@ -107,7 +107,7 @@ class ClusterComCheck: ...@@ -107,7 +107,7 @@ class ClusterComCheck:
for i in range(stableCount): for i in range(stableCount):
tdSql.query("select count(*) from %s%d"%(stbname,i)) tdSql.query("select count(*) from %s%d"%(stbname,i))
tdSql.checkData(0,0,rowsPerSTable) tdSql.checkData(0,0,rowsPerSTable)
return return
def checkMnodeStatus(self,mnodeNums): def checkMnodeStatus(self,mnodeNums):
self.mnodeNums=int(mnodeNums) self.mnodeNums=int(mnodeNums)
...@@ -118,15 +118,15 @@ class ClusterComCheck: ...@@ -118,15 +118,15 @@ class ClusterComCheck:
while count < 10: while count < 10:
time.sleep(1) time.sleep(1)
tdSql.query("show mnodes;") tdSql.query("show mnodes;")
if tdSql.checkRows(self.mnodeNums) : if tdSql.checkRows(self.mnodeNums) :
tdLog.success("cluster has %d mnodes" %self.mnodeNums ) tdLog.success("cluster has %d mnodes" %self.mnodeNums )
if self.mnodeNums == 1: if self.mnodeNums == 1:
if tdSql.queryResult[0][2]== 'leader' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[0][2]== 'leader' and tdSql.queryResult[0][3]== 'ready' :
tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums)
return True return True
count+=1 count+=1
elif self.mnodeNums == 3 : elif self.mnodeNums == 3 :
if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' :
if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' :
if tdSql.queryResult[2][2]=='follower' and tdSql.queryResult[2][3]== 'ready' : if tdSql.queryResult[2][2]=='follower' and tdSql.queryResult[2][3]== 'ready' :
...@@ -141,9 +141,9 @@ class ClusterComCheck: ...@@ -141,9 +141,9 @@ class ClusterComCheck:
if tdSql.queryResult[0][2]=='follower' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[0][2]=='follower' and tdSql.queryResult[0][3]== 'ready' :
if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' :
tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums)
return True return True
count+=1 count+=1
elif self.mnodeNums == 2 : elif self.mnodeNums == 2 :
if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' : if tdSql.queryResult[0][2]=='leader' and tdSql.queryResult[0][3]== 'ready' :
if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' : if tdSql.queryResult[1][2]=='follower' and tdSql.queryResult[1][3]== 'ready' :
tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums) tdLog.success("%d mnodes is ready in 10s"%self.mnodeNums)
...@@ -157,7 +157,7 @@ class ClusterComCheck: ...@@ -157,7 +157,7 @@ class ClusterComCheck:
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
tdLog.exit("cluster of %d mnodes is not ready in 10s " %self.mnodeNums) tdLog.exit("cluster of %d mnodes is not ready in 10s " %self.mnodeNums)
def check3mnodeoff(self,offlineDnodeNo,mnodeNums=3): def check3mnodeoff(self,offlineDnodeNo,mnodeNums=3):
...@@ -224,7 +224,7 @@ class ClusterComCheck: ...@@ -224,7 +224,7 @@ class ClusterComCheck:
else: else:
tdLog.debug(tdSql.queryResult) tdLog.debug(tdSql.queryResult)
tdLog.exit("stop mnodes on dnode %d failed in 10s ") tdLog.exit("stop mnodes on dnode %d failed in 10s ")
......
...@@ -37,23 +37,23 @@ class ClusterComCreate: ...@@ -37,23 +37,23 @@ class ClusterComCreate:
tdSql.init(conn.cursor()) tdSql.init(conn.cursor())
# tdSql.init(conn.cursor(), logSql) # output sql.txt file # tdSql.init(conn.cursor(), logSql) # output sql.txt file
def initConsumerTable(self,cdbName='cdb'): def initConsumerTable(self,cdbName='cdb'):
tdLog.info("create consume database, and consume info table, and consume result table") tdLog.info("create consume database, and consume info table, and consume result table")
tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("create database if not exists %s vgroups 1"%(cdbName))
tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName))
tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) tdSql.query("drop table if exists %s.notifyinfo "%(cdbName))
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName) tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName)
def initConsumerInfoTable(self,cdbName='cdb'): def initConsumerInfoTable(self,cdbName='cdb'):
tdLog.info("drop consumeinfo table") tdLog.info("drop consumeinfo table")
tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName))
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName)
def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'): def insertConsumerInfo(self,consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifmanualcommit,cdbName='cdb'):
sql = "insert into %s.consumeinfo values "%cdbName sql = "insert into %s.consumeinfo values "%cdbName
sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit) sql += "(now, %d, '%s', '%s', %d, %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata, ifmanualcommit)
tdLog.info("consume info sql: %s"%sql) tdLog.info("consume info sql: %s"%sql)
...@@ -68,11 +68,11 @@ class ClusterComCreate: ...@@ -68,11 +68,11 @@ class ClusterComCreate:
break break
else: else:
time.sleep(5) time.sleep(5)
for i in range(expectRows): for i in range(expectRows):
tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3))) tdLog.info ("consume id: %d, consume msgs: %d, consume rows: %d"%(tdSql.getData(i , 1), tdSql.getData(i , 2), tdSql.getData(i , 3)))
resultList.append(tdSql.getData(i , 3)) resultList.append(tdSql.getData(i , 3))
return resultList return resultList
def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0): def startTmqSimProcess(self,pollDelay,dbName,showMsg=1,showRow=1,cdbName='cdb',valgrind=0):
...@@ -82,14 +82,14 @@ class ClusterComCreate: ...@@ -82,14 +82,14 @@ class ClusterComCreate:
logFile = cfgPath + '/../log/valgrind-tmq.log' logFile = cfgPath + '/../log/valgrind-tmq.log'
shellCmd = 'nohup valgrind --log-file=' + logFile shellCmd = 'nohup valgrind --log-file=' + logFile
shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes ' shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes '
if (platform.system().lower() == 'windows'): if (platform.system().lower() == 'windows'):
shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath shellCmd = 'mintty -h never -w hide ' + buildPath + '\\build\\bin\\tmq_sim.exe -c ' + cfgPath
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
shellCmd += "> nul 2>&1 &" shellCmd += "> nul 2>&1 &"
else: else:
shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName) shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
shellCmd += "> /dev/null 2>&1 &" shellCmd += "> /dev/null 2>&1 &"
tdLog.info(shellCmd) tdLog.info(shellCmd)
os.system(shellCmd) os.system(shellCmd)
...@@ -142,7 +142,7 @@ class ClusterComCreate: ...@@ -142,7 +142,7 @@ class ClusterComCreate:
tdLog.debug("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i)) tdLog.debug("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i)) tsql.execute("create table if not exists %s.%s_%d (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbNameIndex, stbNameIndex,i))
tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i)) tdLog.debug("complete to create %s.%s_%d" %(dbNameIndex, stbNameIndex,i))
return return
def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1):
tsql.execute("use %s" %dbName) tsql.execute("use %s" %dbName)
...@@ -153,14 +153,14 @@ class ClusterComCreate: ...@@ -153,14 +153,14 @@ class ClusterComCreate:
tagValue = 'beijing' tagValue = 'beijing'
if (i % 2 == 0): if (i % 2 == 0):
tagValue = 'shanghai' tagValue = 'shanghai'
sql += " %s_%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) sql += " %s_%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue)
if (i > 0) and (i%100 == 0): if (i > 0) and (i%100 == 0):
tsql.execute(sql) tsql.execute(sql)
sql = pre_create sql = pre_create
if sql != pre_create: if sql != pre_create:
tsql.execute(sql) tsql.execute(sql)
tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
return return
...@@ -189,7 +189,7 @@ class ClusterComCreate: ...@@ -189,7 +189,7 @@ class ClusterComCreate:
#print("insert sql:%s"%sql) #print("insert sql:%s"%sql)
tsql.execute(sql) tsql.execute(sql)
tdLog.debug("insert data ............ [OK]") tdLog.debug("insert data ............ [OK]")
return return
def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs):
tdLog.debug("start to insert data ............") tdLog.debug("start to insert data ............")
...@@ -235,7 +235,7 @@ class ClusterComCreate: ...@@ -235,7 +235,7 @@ class ClusterComCreate:
ctbDict[i] = 0 ctbDict[i] = 0
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
rowsOfCtb = 0 rowsOfCtb = 0
while rowsOfCtb < rowsPerTbl: while rowsOfCtb < rowsPerTbl:
for i in range(ctbNum): for i in range(ctbNum):
sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) sql += " %s.%s_%d values "%(dbName,ctbPrefix,i)
...@@ -262,7 +262,7 @@ class ClusterComCreate: ...@@ -262,7 +262,7 @@ class ClusterComCreate:
startTs = int(round(t * 1000)) startTs = int(round(t * 1000))
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
rowsOfSql = 0 rowsOfSql = 0
for i in range(ctbNum): for i in range(ctbNum):
sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i)
for j in range(rowsPerTbl): for j in range(rowsPerTbl):
...@@ -294,7 +294,7 @@ class ClusterComCreate: ...@@ -294,7 +294,7 @@ class ClusterComCreate:
for i in range(ctbNum): for i in range(ctbNum):
tbName = '%s%s'%(ctbPrefix,i) tbName = '%s%s'%(ctbPrefix,i)
tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl']) tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl'])
return return
def threadFunction(self, **paraDict): def threadFunction(self, **paraDict):
# create new connector for new tdSql instance in my thread # create new connector for new tdSql instance in my thread
......
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -95,7 +95,7 @@ class TDTestCase: ...@@ -95,7 +95,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -126,7 +126,7 @@ class TDTestCase: ...@@ -126,7 +126,7 @@ class TDTestCase:
return taos.connect(host=host, port=int(port), config=config_dir) return taos.connect(host=host, port=int(port), config=config_dir)
def run(self): def run(self):
self.check_setup_cluster_status() self.check_setup_cluster_status()
self.create_db_check_vgroups() self.create_db_check_vgroups()
...@@ -135,4 +135,4 @@ class TDTestCase: ...@@ -135,4 +135,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -26,9 +26,9 @@ class TDTestCase: ...@@ -26,9 +26,9 @@ class TDTestCase:
self.dnode_list = {} self.dnode_list = {}
self.ts = 1483200000000 self.ts = 1483200000000
self.db_name ='testdb' self.db_name ='testdb'
self.replica = 1 self.replica = 1
self.vgroups = 2 self.vgroups = 2
self.tb_nums = 10 self.tb_nums = 10
self.row_nums = 100 self.row_nums = 100
def getBuildPath(self): def getBuildPath(self):
...@@ -101,7 +101,7 @@ class TDTestCase: ...@@ -101,7 +101,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -145,7 +145,7 @@ class TDTestCase: ...@@ -145,7 +145,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(tb_nums): for i in range(tb_nums):
sub_tbname = "sub_tb_{}".format(i) sub_tbname = "sub_tb_{}".format(i)
tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i))
...@@ -164,7 +164,7 @@ class TDTestCase: ...@@ -164,7 +164,7 @@ class TDTestCase:
tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1'))
tdSql.checkRows(tb_nums) tdSql.checkRows(tb_nums)
def run(self): def run(self):
self.check_setup_cluster_status() self.check_setup_cluster_status()
self.create_db_check_vgroups() self.create_db_check_vgroups()
self.create_db_replica_1_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums) self.create_db_replica_1_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)
...@@ -176,4 +176,4 @@ class TDTestCase: ...@@ -176,4 +176,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -26,9 +26,9 @@ class TDTestCase: ...@@ -26,9 +26,9 @@ class TDTestCase:
self.dnode_list = {} self.dnode_list = {}
self.ts = 1483200000000 self.ts = 1483200000000
self.db_name ='testdb' self.db_name ='testdb'
self.replica = 3 self.replica = 3
self.vgroups = 2 self.vgroups = 2
self.tb_nums = 10 self.tb_nums = 10
self.row_nums = 100 self.row_nums = 100
def getBuildPath(self): def getBuildPath(self):
...@@ -101,7 +101,7 @@ class TDTestCase: ...@@ -101,7 +101,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -145,7 +145,7 @@ class TDTestCase: ...@@ -145,7 +145,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(tb_nums): for i in range(tb_nums):
sub_tbname = "sub_tb_{}".format(i) sub_tbname = "sub_tb_{}".format(i)
tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i)) tdSql.execute("create table {} using stb1 tags({})".format(sub_tbname,i))
...@@ -164,7 +164,7 @@ class TDTestCase: ...@@ -164,7 +164,7 @@ class TDTestCase:
tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1')) tdSql.query("select distinct tbname from {}.{}".format(dbname,'stb1'))
tdSql.checkRows(tb_nums) tdSql.checkRows(tb_nums)
def run(self): def run(self):
self.check_setup_cluster_status() self.check_setup_cluster_status()
self.create_db_check_vgroups() self.create_db_check_vgroups()
self.create_db_replica_3_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums) self.create_db_replica_3_insertdatas(self.db_name , self.replica , self.vgroups , self.tb_nums , self.row_nums)
...@@ -176,4 +176,4 @@ class TDTestCase: ...@@ -176,4 +176,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -30,9 +30,9 @@ class TDTestCase: ...@@ -30,9 +30,9 @@ class TDTestCase:
self.ts = 1483200000000 self.ts = 1483200000000
self.ts_step =1000 self.ts_step =1000
self.db_name ='testdb' self.db_name ='testdb'
self.replica = 3 self.replica = 3
self.vgroups = 1 self.vgroups = 1
self.tb_nums = 10 self.tb_nums = 10
self.row_nums = 100 self.row_nums = 100
self.stop_dnode_id = None self.stop_dnode_id = None
self.loop_restart_times = 5 self.loop_restart_times = 5
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
tdSql.execute(drop_db_sql) tdSql.execute(drop_db_sql)
tdSql.execute(create_db_sql) tdSql.execute(create_db_sql)
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.execute( tdSql.execute(
...@@ -151,7 +151,7 @@ class TDTestCase: ...@@ -151,7 +151,7 @@ class TDTestCase:
tags (t1 int) tags (t1 int)
'''.format(stablename) '''.format(stablename)
) )
for i in range(tb_nums): for i in range(tb_nums):
sub_tbname = "sub_{}_{}".format(stablename,i) sub_tbname = "sub_{}_{}".format(stablename,i)
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
...@@ -162,11 +162,11 @@ class TDTestCase: ...@@ -162,11 +162,11 @@ class TDTestCase:
tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
for row_num in range(append_nums): for row_num in range(append_nums):
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
...@@ -174,9 +174,9 @@ class TDTestCase: ...@@ -174,9 +174,9 @@ class TDTestCase:
os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename))
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
...@@ -184,8 +184,8 @@ class TDTestCase: ...@@ -184,8 +184,8 @@ class TDTestCase:
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname)) os.system("taos -s ' show {}.vgroups; '".format(dbname))
...@@ -199,14 +199,14 @@ class TDTestCase: ...@@ -199,14 +199,14 @@ class TDTestCase:
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) tdLog.debug(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
count += 1 count += 1
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
time.sleep(0.1) time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname)) os.system("taos -s ' show {}.vgroups;'".format(dbname))
...@@ -224,7 +224,7 @@ class TDTestCase: ...@@ -224,7 +224,7 @@ class TDTestCase:
tdSql.query("show {}.vgroups".format(dbname)) tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos: for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4] leader_infos = vgroup_info[3:-4]
# print(vgroup_info) # print(vgroup_info)
for ind ,role in enumerate(leader_infos): for ind ,role in enumerate(leader_infos):
if role =='follower': if role =='follower':
...@@ -236,7 +236,7 @@ class TDTestCase: ...@@ -236,7 +236,7 @@ class TDTestCase:
return self.stop_dnode_id return self.stop_dnode_id
def wait_stop_dnode_OK(self): def wait_stop_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
...@@ -249,7 +249,7 @@ class TDTestCase: ...@@ -249,7 +249,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="offline": while status !="offline":
...@@ -259,7 +259,7 @@ class TDTestCase: ...@@ -259,7 +259,7 @@ class TDTestCase:
tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id)) tdLog.notice("==== stop_dnode has stopped , id is {} ====".format(self.stop_dnode_id))
def wait_start_dnode_OK(self): def wait_start_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
status = "" status = ""
...@@ -271,7 +271,7 @@ class TDTestCase: ...@@ -271,7 +271,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="ready": while status !="ready":
...@@ -365,7 +365,7 @@ class TDTestCase: ...@@ -365,7 +365,7 @@ class TDTestCase:
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
check_status = False check_status = False
return check_status return check_status
def sync_run_case(self): def sync_run_case(self):
# stop follower and insert datas , update tables and create new stables # stop follower and insert datas , update tables and create new stables
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
...@@ -375,19 +375,19 @@ class TDTestCase: ...@@ -375,19 +375,19 @@ class TDTestCase:
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name) self.stop_dnode_id = self._get_stop_dnode_id(db_name)
# check rows of datas # check rows of datas
self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin stop dnode # begin stop dnode
start = time.time() start = time.time()
tdDnodes[self.stop_dnode_id-1].stoptaosd() tdDnodes[self.stop_dnode_id-1].stoptaosd()
self.wait_stop_dnode_OK() self.wait_stop_dnode_OK()
# append rows of stablename when dnode stop # append rows of stablename when dnode stop
tbname = "sub_{}_{}".format(stablename , 0) tbname = "sub_{}_{}".format(stablename , 0)
tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id))
self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 )
...@@ -400,20 +400,20 @@ class TDTestCase: ...@@ -400,20 +400,20 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin start dnode # begin start dnode
tdDnodes[self.stop_dnode_id-1].starttaosd() tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end -start) time_cost = int(end -start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
def unsync_run_case(self): def unsync_run_case(self):
def _restart_dnode_of_db_unsync(dbname): def _restart_dnode_of_db_unsync(dbname):
...@@ -427,18 +427,18 @@ class TDTestCase: ...@@ -427,18 +427,18 @@ class TDTestCase:
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end-start) time_cost = int(end-start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
def _create_threading(dbname): def _create_threading(dbname):
self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,))
return self.current_thread return self.current_thread
''' '''
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
''' '''
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
for loop in range(self.loop_restart_times): for loop in range(self.loop_restart_times):
...@@ -449,7 +449,7 @@ class TDTestCase: ...@@ -449,7 +449,7 @@ class TDTestCase:
tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name))
# create sync threading and start it # create sync threading and start it
self.current_thread = _create_threading(db_name) self.current_thread = _create_threading(db_name)
self.current_thread.start() self.current_thread.start()
...@@ -468,7 +468,7 @@ class TDTestCase: ...@@ -468,7 +468,7 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
...@@ -477,7 +477,7 @@ class TDTestCase: ...@@ -477,7 +477,7 @@ class TDTestCase:
self.current_thread.join() self.current_thread.join()
def run(self): def run(self):
# basic insert and check of cluster # basic insert and check of cluster
self.check_setup_cluster_status() self.check_setup_cluster_status()
...@@ -485,7 +485,7 @@ class TDTestCase: ...@@ -485,7 +485,7 @@ class TDTestCase:
self.sync_run_case() self.sync_run_case()
# self.unsync_run_case() # self.unsync_run_case()
def stop(self): def stop(self):
...@@ -493,4 +493,4 @@ class TDTestCase: ...@@ -493,4 +493,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -30,9 +30,9 @@ class TDTestCase: ...@@ -30,9 +30,9 @@ class TDTestCase:
self.ts = 1483200000000 self.ts = 1483200000000
self.ts_step =1000 self.ts_step =1000
self.db_name ='testdb' self.db_name ='testdb'
self.replica = 3 self.replica = 3
self.vgroups = 1 self.vgroups = 1
self.tb_nums = 10 self.tb_nums = 10
self.row_nums = 100 self.row_nums = 100
self.stop_dnode_id = None self.stop_dnode_id = None
self.loop_restart_times = 5 self.loop_restart_times = 5
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
tdSql.execute(drop_db_sql) tdSql.execute(drop_db_sql)
tdSql.execute(create_db_sql) tdSql.execute(create_db_sql)
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.execute( tdSql.execute(
...@@ -151,7 +151,7 @@ class TDTestCase: ...@@ -151,7 +151,7 @@ class TDTestCase:
tags (t1 int) tags (t1 int)
'''.format(stablename) '''.format(stablename)
) )
for i in range(tb_nums): for i in range(tb_nums):
sub_tbname = "sub_{}_{}".format(stablename,i) sub_tbname = "sub_{}_{}".format(stablename,i)
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
...@@ -162,11 +162,11 @@ class TDTestCase: ...@@ -162,11 +162,11 @@ class TDTestCase:
tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
for row_num in range(append_nums): for row_num in range(append_nums):
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
...@@ -174,9 +174,9 @@ class TDTestCase: ...@@ -174,9 +174,9 @@ class TDTestCase:
os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename)) os.system("taos -s 'select count(*) from {}.{}';".format(dbname,stablename))
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
...@@ -184,8 +184,8 @@ class TDTestCase: ...@@ -184,8 +184,8 @@ class TDTestCase:
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname)) os.system("taos -s ' show {}.vgroups; '".format(dbname))
...@@ -199,14 +199,14 @@ class TDTestCase: ...@@ -199,14 +199,14 @@ class TDTestCase:
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
count += 1 count += 1
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
time.sleep(0.1) time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname)) os.system("taos -s ' show {}.vgroups;'".format(dbname))
...@@ -220,12 +220,12 @@ class TDTestCase: ...@@ -220,12 +220,12 @@ class TDTestCase:
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname)) tdLog.notice(" ==== check insert tbnames first failed , this is {}_th retry check tbnames of database {}".format(count , dbname))
count += 1 count += 1
def _get_stop_dnode_id(self,dbname): def _get_stop_dnode_id(self,dbname):
tdSql.query("show {}.vgroups".format(dbname)) tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos: for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4] leader_infos = vgroup_info[3:-4]
# print(vgroup_info) # print(vgroup_info)
for ind ,role in enumerate(leader_infos): for ind ,role in enumerate(leader_infos):
if role =='follower': if role =='follower':
...@@ -237,7 +237,7 @@ class TDTestCase: ...@@ -237,7 +237,7 @@ class TDTestCase:
return self.stop_dnode_id return self.stop_dnode_id
def wait_stop_dnode_OK(self): def wait_stop_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
...@@ -250,7 +250,7 @@ class TDTestCase: ...@@ -250,7 +250,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="offline": while status !="offline":
...@@ -260,7 +260,7 @@ class TDTestCase: ...@@ -260,7 +260,7 @@ class TDTestCase:
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self): def wait_start_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
status = "" status = ""
...@@ -272,7 +272,7 @@ class TDTestCase: ...@@ -272,7 +272,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="ready": while status !="ready":
...@@ -366,7 +366,7 @@ class TDTestCase: ...@@ -366,7 +366,7 @@ class TDTestCase:
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
check_status = False check_status = False
return check_status return check_status
def sync_run_case(self): def sync_run_case(self):
# stop follower and insert datas , update tables and create new stables # stop follower and insert datas , update tables and create new stables
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
...@@ -376,19 +376,19 @@ class TDTestCase: ...@@ -376,19 +376,19 @@ class TDTestCase:
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name) self.stop_dnode_id = self._get_stop_dnode_id(db_name)
# check rows of datas # check rows of datas
self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin stop dnode # begin stop dnode
start = time.time() start = time.time()
tdDnodes[self.stop_dnode_id-1].stoptaosd() tdDnodes[self.stop_dnode_id-1].stoptaosd()
self.wait_stop_dnode_OK() self.wait_stop_dnode_OK()
# append rows of stablename when dnode stop # append rows of stablename when dnode stop
tbname = "sub_{}_{}".format(stablename , 0) tbname = "sub_{}_{}".format(stablename , 0)
tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id))
self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 )
...@@ -401,20 +401,20 @@ class TDTestCase: ...@@ -401,20 +401,20 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin start dnode # begin start dnode
tdDnodes[self.stop_dnode_id-1].starttaosd() tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end -start) time_cost = int(end -start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
def unsync_run_case(self): def unsync_run_case(self):
def _restart_dnode_of_db_unsync(dbname): def _restart_dnode_of_db_unsync(dbname):
...@@ -428,18 +428,18 @@ class TDTestCase: ...@@ -428,18 +428,18 @@ class TDTestCase:
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end-start) time_cost = int(end-start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
def _create_threading(dbname): def _create_threading(dbname):
self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,))
return self.current_thread return self.current_thread
''' '''
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
''' '''
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
for loop in range(self.loop_restart_times): for loop in range(self.loop_restart_times):
...@@ -450,7 +450,7 @@ class TDTestCase: ...@@ -450,7 +450,7 @@ class TDTestCase:
tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name))
# create sync threading and start it # create sync threading and start it
self.current_thread = _create_threading(db_name) self.current_thread = _create_threading(db_name)
self.current_thread.start() self.current_thread.start()
...@@ -469,7 +469,7 @@ class TDTestCase: ...@@ -469,7 +469,7 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
...@@ -478,7 +478,7 @@ class TDTestCase: ...@@ -478,7 +478,7 @@ class TDTestCase:
self.current_thread.join() self.current_thread.join()
def run(self): def run(self):
# basic insert and check of cluster # basic insert and check of cluster
self.check_setup_cluster_status() self.check_setup_cluster_status()
...@@ -486,7 +486,7 @@ class TDTestCase: ...@@ -486,7 +486,7 @@ class TDTestCase:
# self.sync_run_case() # self.sync_run_case()
self.unsync_run_case() self.unsync_run_case()
def stop(self): def stop(self):
...@@ -494,4 +494,4 @@ class TDTestCase: ...@@ -494,4 +494,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ...@@ -3,7 +3,7 @@ from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
import taos import taos
import sys import sys
import time import time
import os import os
from util.log import * from util.log import *
from util.sql import * from util.sql import *
...@@ -30,9 +30,9 @@ class TDTestCase: ...@@ -30,9 +30,9 @@ class TDTestCase:
self.ts = 1483200000000 self.ts = 1483200000000
self.ts_step =1000 self.ts_step =1000
self.db_name ='testdb' self.db_name ='testdb'
self.replica = 3 self.replica = 3
self.vgroups = 1 self.vgroups = 1
self.tb_nums = 10 self.tb_nums = 10
self.row_nums = 100 self.row_nums = 100
self.stop_dnode_id = None self.stop_dnode_id = None
self.loop_restart_times = 5 self.loop_restart_times = 5
...@@ -110,7 +110,7 @@ class TDTestCase: ...@@ -110,7 +110,7 @@ class TDTestCase:
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
''' '''
) )
for i in range(5): for i in range(5):
tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i)) tdSql.execute("create table sub_tb_{} using stb1 tags({})".format(i,i))
tdSql.query("show stables") tdSql.query("show stables")
...@@ -142,7 +142,7 @@ class TDTestCase: ...@@ -142,7 +142,7 @@ class TDTestCase:
tdSql.execute(drop_db_sql) tdSql.execute(drop_db_sql)
tdSql.execute(create_db_sql) tdSql.execute(create_db_sql)
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums): def create_stable_insert_datas(self,dbname ,stablename , tb_nums , row_nums):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.execute( tdSql.execute(
...@@ -151,7 +151,7 @@ class TDTestCase: ...@@ -151,7 +151,7 @@ class TDTestCase:
tags (t1 int) tags (t1 int)
'''.format(stablename) '''.format(stablename)
) )
for i in range(tb_nums): for i in range(tb_nums):
sub_tbname = "sub_{}_{}".format(stablename,i) sub_tbname = "sub_{}_{}".format(stablename,i)
tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i)) tdSql.execute("create table {} using {} tags({})".format(sub_tbname, stablename ,i))
...@@ -162,11 +162,11 @@ class TDTestCase: ...@@ -162,11 +162,11 @@ class TDTestCase:
tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {sub_tbname} values ({ts}, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename)) tdLog.notice(" ==== stable {} insert rows execute end =====".format(stablename))
def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ): def append_rows_of_exists_tables(self,dbname ,stablename , tbname , append_nums ):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
for row_num in range(append_nums): for row_num in range(append_nums):
tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") tdSql.execute(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
# print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ") # print(f"insert into {tbname} values (now, {row_num} ,{row_num}, 10 ,1 ,{row_num} ,{row_num},true,'bin_{row_num}','nchar_{row_num}',now) ")
...@@ -176,7 +176,7 @@ class TDTestCase: ...@@ -176,7 +176,7 @@ class TDTestCase:
def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows): def check_insert_rows(self, dbname, stablename , tb_nums , row_nums, append_rows):
tdSql.execute("use {}".format(dbname)) tdSql.execute("use {}".format(dbname))
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
...@@ -184,8 +184,8 @@ class TDTestCase: ...@@ -184,8 +184,8 @@ class TDTestCase:
tdSql.query("select count(*) from {}.{}".format(dbname,stablename)) tdSql.query("select count(*) from {}.{}".format(dbname,stablename))
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups; '".format(dbname)) os.system("taos -s ' show {}.vgroups; '".format(dbname))
...@@ -199,14 +199,14 @@ class TDTestCase: ...@@ -199,14 +199,14 @@ class TDTestCase:
status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows) status_OK = self.mycheckData("select count(*) from {}.{}".format(dbname,stablename) ,0 , 0 , tb_nums*row_nums+append_rows)
tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname)) tdLog.notice(" ==== check insert rows first failed , this is {}_th retry check rows of database {}".format(count , dbname))
count += 1 count += 1
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
while not tdSql.queryResult: while not tdSql.queryResult:
time.sleep(0.1) time.sleep(0.1)
tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename)) tdSql.query("select distinct tbname from {}.{}".format(dbname,stablename))
status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums) status_OK = self.mycheckRows("select distinct tbname from {}.{}".format(dbname,stablename) ,tb_nums)
count = 0 count = 0
while not status_OK : while not status_OK :
if count > self.try_check_times: if count > self.try_check_times:
os.system("taos -s ' show {}.vgroups;'".format(dbname)) os.system("taos -s ' show {}.vgroups;'".format(dbname))
...@@ -225,7 +225,7 @@ class TDTestCase: ...@@ -225,7 +225,7 @@ class TDTestCase:
tdSql.query("show {}.vgroups".format(dbname)) tdSql.query("show {}.vgroups".format(dbname))
vgroup_infos = tdSql.queryResult vgroup_infos = tdSql.queryResult
for vgroup_info in vgroup_infos: for vgroup_info in vgroup_infos:
leader_infos = vgroup_info[3:-4] leader_infos = vgroup_info[3:-4]
# print(vgroup_info) # print(vgroup_info)
for ind ,role in enumerate(leader_infos): for ind ,role in enumerate(leader_infos):
if role =='follower': if role =='follower':
...@@ -237,7 +237,7 @@ class TDTestCase: ...@@ -237,7 +237,7 @@ class TDTestCase:
return self.stop_dnode_id return self.stop_dnode_id
def wait_stop_dnode_OK(self): def wait_stop_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
...@@ -250,7 +250,7 @@ class TDTestCase: ...@@ -250,7 +250,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="offline": while status !="offline":
...@@ -260,7 +260,7 @@ class TDTestCase: ...@@ -260,7 +260,7 @@ class TDTestCase:
tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id)) tdLog.notice("==== stop_dnode has stopped , id is {}".format(self.stop_dnode_id))
def wait_start_dnode_OK(self): def wait_start_dnode_OK(self):
def _get_status(): def _get_status():
newTdSql=tdCom.newTdSql() newTdSql=tdCom.newTdSql()
status = "" status = ""
...@@ -272,7 +272,7 @@ class TDTestCase: ...@@ -272,7 +272,7 @@ class TDTestCase:
if id == self.stop_dnode_id: if id == self.stop_dnode_id:
status = dnode_status status = dnode_status
break break
return status return status
status = _get_status() status = _get_status()
while status !="ready": while status !="ready":
...@@ -366,7 +366,7 @@ class TDTestCase: ...@@ -366,7 +366,7 @@ class TDTestCase:
tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) tdLog.info("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
check_status = False check_status = False
return check_status return check_status
def sync_run_case(self): def sync_run_case(self):
# stop follower and insert datas , update tables and create new stables # stop follower and insert datas , update tables and create new stables
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
...@@ -376,19 +376,19 @@ class TDTestCase: ...@@ -376,19 +376,19 @@ class TDTestCase:
self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1) self.create_database(dbname = db_name ,replica_num= self.replica , vgroup_nums= 1)
self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = stablename , tb_nums= 10 ,row_nums= 10 )
self.stop_dnode_id = self._get_stop_dnode_id(db_name) self.stop_dnode_id = self._get_stop_dnode_id(db_name)
# check rows of datas # check rows of datas
self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,stablename ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin stop dnode # begin stop dnode
start = time.time() start = time.time()
tdDnodes[self.stop_dnode_id-1].forcestop() tdDnodes[self.stop_dnode_id-1].forcestop()
self.wait_stop_dnode_OK() self.wait_stop_dnode_OK()
# append rows of stablename when dnode stop # append rows of stablename when dnode stop
tbname = "sub_{}_{}".format(stablename , 0) tbname = "sub_{}_{}".format(stablename , 0)
tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id)) tdLog.notice(" ==== begin append rows of exists table {} when dnode {} offline ====".format(tbname , self.stop_dnode_id))
self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 ) self.append_rows_of_exists_tables(db_name ,stablename , tbname , 100 )
...@@ -401,20 +401,20 @@ class TDTestCase: ...@@ -401,20 +401,20 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# begin start dnode # begin start dnode
tdDnodes[self.stop_dnode_id-1].starttaosd() tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end -start) time_cost = int(end -start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb2' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
def unsync_run_case(self): def unsync_run_case(self):
def _restart_dnode_of_db_unsync(dbname): def _restart_dnode_of_db_unsync(dbname):
...@@ -425,26 +425,26 @@ class TDTestCase: ...@@ -425,26 +425,26 @@ class TDTestCase:
time.sleep(0.5) time.sleep(0.5)
self.stop_dnode_id = self._get_stop_dnode_id(dbname) self.stop_dnode_id = self._get_stop_dnode_id(dbname)
# begin restart dnode # begin restart dnode
# force stop taosd by kill -9 # force stop taosd by kill -9
self.force_stop_dnode(self.stop_dnode_id) self.force_stop_dnode(self.stop_dnode_id)
self.wait_stop_dnode_OK() self.wait_stop_dnode_OK()
tdDnodes[self.stop_dnode_id-1].starttaosd() tdDnodes[self.stop_dnode_id-1].starttaosd()
self.wait_start_dnode_OK() self.wait_start_dnode_OK()
end = time.time() end = time.time()
time_cost = int(end-start) time_cost = int(end-start)
if time_cost > self.max_restart_time: if time_cost > self.max_restart_time:
tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id)) tdLog.exit(" ==== restart dnode {} cost too much time , please check ====".format(self.stop_dnode_id))
def _create_threading(dbname): def _create_threading(dbname):
self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,)) self.current_thread = threading.Thread(target=_restart_dnode_of_db_unsync, args=(dbname,))
return self.current_thread return self.current_thread
''' '''
in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive in this mode , it will be extra threading control start or stop dnode , insert will always going with not care follower online or alive
''' '''
tdDnodes=cluster.dnodes tdDnodes=cluster.dnodes
for loop in range(self.loop_restart_times): for loop in range(self.loop_restart_times):
...@@ -455,7 +455,7 @@ class TDTestCase: ...@@ -455,7 +455,7 @@ class TDTestCase:
tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name)) tdLog.notice(" ===== restart dnode of database {} in an unsync threading ===== ".format(db_name))
# create sync threading and start it # create sync threading and start it
self.current_thread = _create_threading(db_name) self.current_thread = _create_threading(db_name)
self.current_thread.start() self.current_thread.start()
...@@ -474,7 +474,7 @@ class TDTestCase: ...@@ -474,7 +474,7 @@ class TDTestCase:
tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} offline ====".format('new_stb1' , self.stop_dnode_id))
self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0) self.check_insert_rows(db_name ,'new_stb1' ,tb_nums=10 , row_nums= 10 ,append_rows=0)
# create new stables again # create new stables again
tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== create new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 ) self.create_stable_insert_datas(dbname = db_name , stablename = 'new_stb2' , tb_nums= 10 ,row_nums= 10 )
tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id)) tdLog.notice(" ==== check new stable {} when dnode {} restart ====".format('new_stb2' , self.stop_dnode_id))
...@@ -488,7 +488,7 @@ class TDTestCase: ...@@ -488,7 +488,7 @@ class TDTestCase:
port = None port = None
for dnode_info in tdSql.queryResult: for dnode_info in tdSql.queryResult:
if dnode_id == dnode_info[0]: if dnode_id == dnode_info[0]:
port = dnode_info[1].split(":")[-1] port = dnode_info[1].split(":")[-1]
break break
else: else:
continue continue
...@@ -502,7 +502,7 @@ class TDTestCase: ...@@ -502,7 +502,7 @@ class TDTestCase:
os.system(ps_kill_taosd) os.system(ps_kill_taosd)
def run(self): def run(self):
# basic insert and check of cluster # basic insert and check of cluster
self.check_setup_cluster_status() self.check_setup_cluster_status()
...@@ -510,7 +510,7 @@ class TDTestCase: ...@@ -510,7 +510,7 @@ class TDTestCase:
# self.sync_run_case() # self.sync_run_case()
self.unsync_run_case() self.unsync_run_case()
def stop(self): def stop(self):
...@@ -518,4 +518,4 @@ class TDTestCase: ...@@ -518,4 +518,4 @@ class TDTestCase:
tdLog.success(f"{__file__} successfully executed") tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册