提交 b73ce7ba 编写于 作者: S Shuaiqiang Chang

Merge branch 'develop' into hotfix/taos-tools

* develop:
  [modify for not pSql in taos obj ]
  [TD-476]fixbug: show correct info when user has no permission to open db
  make test case print message one by one.
  fix crash caused by double free
...@@ -487,7 +487,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -487,7 +487,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
code = tscGetTableMeta(pSql, pTableMetaInfo); code = tscGetTableMeta(pSql, pTableMetaInfo);
assert(code == TSDB_CODE_SUCCESS && pTableMetaInfo->pTableMeta != NULL); assert(code == TSDB_CODE_SUCCESS && pTableMetaInfo->pTableMeta != NULL);
(*pSql->fp)(pSql->param, NULL, code); (*pSql->fp)(pSql->param, pSql, code);
return; return;
} }
......
...@@ -494,7 +494,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { ...@@ -494,7 +494,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
tsem_init(&pSql->rspSem, 0, 0); tsem_init(&pSql->rspSem, 0, 0);
pSql->signature = pSql; pSql->signature = pSql;
pSql->pTscObj = pObj; pSql->pTscObj = pObj;
pSql->pTscObj->pSql = pSql; //pSql->pTscObj->pSql = pSql;
pSql->maxRetry = TSDB_MAX_REPLICA_NUM; pSql->maxRetry = TSDB_MAX_REPLICA_NUM;
pStmt->pSql = pSql; pStmt->pSql = pSql;
...@@ -515,7 +515,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { ...@@ -515,7 +515,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
//doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen); //doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen);
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
pSql->param = (void*)pStmt->taos; pSql->param = (void*)pSql;
pSql->fp = waitForQueryRsp; pSql->fp = waitForQueryRsp;
pSql->insertType = TSDB_QUERY_TYPE_STMT_INSERT; pSql->insertType = TSDB_QUERY_TYPE_STMT_INSERT;
...@@ -613,7 +613,12 @@ int taos_stmt_execute(TAOS_STMT* stmt) { ...@@ -613,7 +613,12 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
} else { } else {
tfree(pStmt->pSql->sqlstr); tfree(pStmt->pSql->sqlstr);
pStmt->pSql->sqlstr = sql; pStmt->pSql->sqlstr = sql;
ret = taos_query(pStmt->taos, pStmt->pSql->sqlstr); SSqlObj* pSql = taos_query((TAOS*)pStmt->taos, pStmt->pSql->sqlstr);
if (pSql != NULL) {
ret = pSql->res.code;
} else {
ret = terrno;
}
} }
} }
return ret; return ret;
......
...@@ -256,13 +256,7 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) { ...@@ -256,13 +256,7 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) {
} }
void waitForQueryRsp(void *param, TAOS_RES *tres, int code) { void waitForQueryRsp(void *param, TAOS_RES *tres, int code) {
assert(param != NULL); assert(tres != NULL);
SSqlObj *pSql = ((STscObj *)param)->pSql;
// valid error code is less than 0
if (code < 0) {
pSql->res.code = code;
}
SSqlObj *pSql = (SSqlObj *) tres; SSqlObj *pSql = (SSqlObj *) tres;
sem_post(&pSql->rspSem); sem_post(&pSql->rspSem);
......
...@@ -38,6 +38,7 @@ static void dnodeCheckDataDirOpenned(char *dir); ...@@ -38,6 +38,7 @@ static void dnodeCheckDataDirOpenned(char *dir);
static SDnodeRunStatus tsDnodeRunStatus = TSDB_DNODE_RUN_STATUS_STOPPED; static SDnodeRunStatus tsDnodeRunStatus = TSDB_DNODE_RUN_STATUS_STOPPED;
static int32_t dnodeInitComponents(); static int32_t dnodeInitComponents();
static void dnodeCleanupComponents(int32_t stepId); static void dnodeCleanupComponents(int32_t stepId);
static int dnodeCreateDir(const char *dir);
typedef struct { typedef struct {
const char *const name; const char *const name;
...@@ -59,6 +60,16 @@ static const SDnodeComponent SDnodeComponents[] = { ...@@ -59,6 +60,16 @@ static const SDnodeComponent SDnodeComponents[] = {
{"shell", dnodeInitShell, dnodeCleanupShell} {"shell", dnodeInitShell, dnodeCleanupShell}
}; };
static int dnodeCreateDir(const char *dir) {
struct stat dirstat;
if (stat(dir, &dirstat) < 0) {
if (mkdir(dir, 0755) != 0 && errno != EEXIST) {
return -1;
}
}
return 0;
}
static void dnodeCleanupComponents(int32_t stepId) { static void dnodeCleanupComponents(int32_t stepId) {
for (int32_t i = stepId; i >= 0; i--) { for (int32_t i = stepId; i >= 0; i--) {
SDnodeComponents[i].cleanup(); SDnodeComponents[i].cleanup();
...@@ -87,9 +98,9 @@ int32_t dnodeInitSystem() { ...@@ -87,9 +98,9 @@ int32_t dnodeInitSystem() {
taosSetCoreDump(); taosSetCoreDump();
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
struct stat dirstat; if (dnodeCreateDir(tsLogDir) < 0) {
if (stat(tsLogDir, &dirstat) < 0) { printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno));
mkdir(tsLogDir, 0755); return -1;
} }
char temp[TSDB_FILENAME_LEN]; char temp[TSDB_FILENAME_LEN];
...@@ -140,7 +151,11 @@ static void dnodeCheckDataDirOpenned(char *dir) { ...@@ -140,7 +151,11 @@ static void dnodeCheckDataDirOpenned(char *dir) {
char filepath[256] = {0}; char filepath[256] = {0};
sprintf(filepath, "%s/.running", dir); sprintf(filepath, "%s/.running", dir);
int32_t fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int fd = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) {
dError("failed to open lock file:%s, reason: %s, quit", filepath, strerror(errno));
exit(0);
}
int32_t ret = flock(fd, LOCK_EX | LOCK_NB); int32_t ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret != 0) { if (ret != 0) {
dError("failed to lock file:%s ret:%d, database may be running, quit", filepath, ret); dError("failed to lock file:%s ret:%d, database may be running, quit", filepath, ret);
...@@ -150,16 +165,28 @@ static void dnodeCheckDataDirOpenned(char *dir) { ...@@ -150,16 +165,28 @@ static void dnodeCheckDataDirOpenned(char *dir) {
} }
static int32_t dnodeInitStorage() { static int32_t dnodeInitStorage() {
struct stat dirstat; if (dnodeCreateDir(tsDataDir) < 0) {
if (stat(tsDataDir, &dirstat) < 0) { dError("failed to create dir: %s, reason: %s", tsDataDir, strerror(errno));
mkdir(tsDataDir, 0755); return -1;
} }
sprintf(tsMnodeDir, "%s/mnode", tsDataDir); sprintf(tsMnodeDir, "%s/mnode", tsDataDir);
sprintf(tsVnodeDir, "%s/vnode", tsDataDir); sprintf(tsVnodeDir, "%s/vnode", tsDataDir);
sprintf(tsDnodeDir, "%s/dnode", tsDataDir); sprintf(tsDnodeDir, "%s/dnode", tsDataDir);
mkdir(tsVnodeDir, 0755);
mkdir(tsDnodeDir, 0755); //TODO(dengyihao): no need to init here
if (dnodeCreateDir(tsMnodeDir) < 0) {
dError("failed to create dir: %s, reason: %s", tsMnodeDir, strerror(errno));
return -1;
}
//TODO(dengyihao): no need to init here
if (dnodeCreateDir(tsVnodeDir) < 0) {
dError("failed to create dir: %s, reason: %s", tsVnodeDir, strerror(errno));
return -1;
}
if (dnodeCreateDir(tsDnodeDir) < 0) {
dError("failed to create dir: %s, reason: %s", tsDnodeDir, strerror(errno));
return -1;
}
dnodeCheckDataDirOpenned(tsDnodeDir); dnodeCheckDataDirOpenned(tsDnodeDir);
......
...@@ -131,6 +131,6 @@ python3 ./test.py -f user/pass_len.py ...@@ -131,6 +131,6 @@ python3 ./test.py -f user/pass_len.py
#query #query
python3 ./test.py -f query/filter.py python3 ./test.py -f query/filter.py
python3 ./test.py $1 -f query/filterCombo.py python3 ./test.py -f query/filterCombo.py
python3 ./test.py $1 -f query/queryNormal.py python3 ./test.py -f query/queryNormal.py
python3 ./test.py $1 -f query/queryError.py python3 ./test.py -f query/queryError.py
#!/bin/bash #!/bin/bash
function runSimCaseOneByOne {
while read -r line; do
if [[ $line =~ ^run.* ]]; then
case=`echo $line | awk '{print $2}'`
./test.sh -f $case 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee -a out.log
fi
done < $1
}
function runPyCaseOneByOne {
while read -r line; do
if [[ $line =~ ^python.* ]]; then
$line 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee -a pytest-out.log
fi
done < $1
}
# Color setting # Color setting
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
...@@ -9,10 +26,13 @@ NC='\033[0m' ...@@ -9,10 +26,13 @@ NC='\033[0m'
echo "### run TSIM script ###" echo "### run TSIM script ###"
cd script cd script
[ -f out.log ] && rm -f out.log
if [ "$1" == "cron" ]; then if [ "$1" == "cron" ]; then
./test.sh -f fullGeneralSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.log runSimCaseOneByOne fullGeneralSuite.sim
else else
./test.sh -f basicSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.log runSimCaseOneByOne basicSuite.sim
fi fi
totalSuccess=`grep 'success' out.log | wc -l` totalSuccess=`grep 'success' out.log | wc -l`
...@@ -36,10 +56,12 @@ fi ...@@ -36,10 +56,12 @@ fi
echo "### run Python script ###" echo "### run Python script ###"
cd ../pytest cd ../pytest
[ -f pytest-out.log ] && rm -f pytest-out.log
if [ "$1" == "cron" ]; then if [ "$1" == "cron" ]; then
./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log runPyCaseOneByOne fulltest.sh
else else
./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log runPyCaseOneByOne smoketest.sh
fi fi
totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l` totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册