TD-10431 tsim compile
This commit is contained in:
parent
89f4a7adc6
commit
8e68fa6e4d
|
@ -26,6 +26,7 @@ if(${BUILD_TEST})
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
add_subdirectory(docs)
|
add_subdirectory(docs)
|
||||||
|
|
|
@ -6,7 +6,7 @@ target_link_libraries(
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
PUBLIC cJson
|
PUBLIC cjson
|
||||||
)
|
)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
tsim
|
tsim
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SIM_H__
|
#ifndef _TD_SIM_H_
|
||||||
#define __SIM_H__
|
#define _TD_SIM_H_
|
||||||
|
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -150,7 +150,6 @@ extern int32_t simScriptPos;
|
||||||
extern int32_t simScriptSucced;
|
extern int32_t simScriptSucced;
|
||||||
extern int32_t simDebugFlag;
|
extern int32_t simDebugFlag;
|
||||||
extern char tsScriptDir[];
|
extern char tsScriptDir[];
|
||||||
extern bool simAsyncQuery;
|
|
||||||
extern bool abortExecution;
|
extern bool abortExecution;
|
||||||
|
|
||||||
SScript *simParseScript(char *fileName);
|
SScript *simParseScript(char *fileName);
|
||||||
|
@ -178,4 +177,4 @@ bool simExecuteLineInsertCmd(SScript *script, char *option);
|
||||||
bool simExecuteLineInsertErrorCmd(SScript *script, char *option);
|
bool simExecuteLineInsertErrorCmd(SScript *script, char *option);
|
||||||
void simVisuallizeOption(SScript *script, char *src, char *dst);
|
void simVisuallizeOption(SScript *script, char *src, char *dst);
|
||||||
|
|
||||||
#endif
|
#endif /*_TD_SIM_H_*/
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SIM_PARSE_H__
|
#ifndef _TD_SIM_PARSE_H_
|
||||||
#define __SIM_PARSE_H__
|
#define _TD_SIM_PARSE_H_
|
||||||
|
|
||||||
#define MAX_NUM_CMD 64
|
#define MAX_NUM_CMD 64
|
||||||
#define MAX_NUM_LABLES 100
|
#define MAX_NUM_LABLES 100
|
||||||
|
@ -52,4 +52,4 @@ typedef struct {
|
||||||
|
|
||||||
bool simParseExpression(char *token, int32_t lineNum);
|
bool simParseExpression(char *token, int32_t lineNum);
|
||||||
|
|
||||||
#endif
|
#endif /*_TD_SIM_PARSE_H_*/
|
|
@ -14,14 +14,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "../../../include/client/taos.h"
|
#include "taos.h"
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "sim.h"
|
#include "sim.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#undef TAOS_MEM_CHECK
|
#include "ttypes.h"
|
||||||
|
|
||||||
void simLogSql(char *sql, bool useSharp) {
|
void simLogSql(char *sql, bool useSharp) {
|
||||||
static FILE *fp = NULL;
|
static FILE *fp = NULL;
|
||||||
|
@ -466,10 +466,6 @@ void simVisuallizeOption(SScript *script, char *src, char *dst) {
|
||||||
strcpy(dst + dstLen, src);
|
strcpy(dst + dstLen, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void simCloseRestFulConnect(SScript *script) {
|
|
||||||
memset(script->auth, 0, sizeof(script->auth));
|
|
||||||
}
|
|
||||||
|
|
||||||
void simCloseNativeConnect(SScript *script) {
|
void simCloseNativeConnect(SScript *script) {
|
||||||
if (script->taos == NULL) return;
|
if (script->taos == NULL) return;
|
||||||
|
|
||||||
|
@ -480,166 +476,7 @@ void simCloseNativeConnect(SScript *script) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void simCloseTaosdConnect(SScript *script) {
|
void simCloseTaosdConnect(SScript *script) {
|
||||||
if (simAsyncQuery) {
|
simCloseNativeConnect(script);
|
||||||
simCloseRestFulConnect(script);
|
|
||||||
} else {
|
|
||||||
simCloseNativeConnect(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}
|
|
||||||
// {"status":"succ","head":["affected_rows"],"data":[[1]],"rows":1}
|
|
||||||
// {"status":"succ","head":["ts","i"],"data":[["2017-12-25 21:28:41.022",1],["2017-12-25 21:28:42.022",2],["2017-12-25 21:28:43.022",3],["2017-12-25 21:28:44.022",4],["2017-12-25 21:28:45.022",5],["2017-12-25 21:28:46.022",6],["2017-12-25 21:28:47.022",7],["2017-12-25 21:28:48.022",8],["2017-12-25 21:28:49.022",9],["2017-12-25 21:28:50.022",10]],"rows":10}
|
|
||||||
int32_t simParseHttpCommandResult(SScript *script, char *command) {
|
|
||||||
cJSON* root = cJSON_Parse(command);
|
|
||||||
if (root == NULL) {
|
|
||||||
simError("script:%s, failed to parse json, response:%s", script->fileName, command);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *status = cJSON_GetObjectItem(root, "status");
|
|
||||||
if (status == NULL) {
|
|
||||||
simError("script:%s, failed to parse json, status is null, response:%s", script->fileName, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status->valuestring == NULL || strlen(status->valuestring) == 0) {
|
|
||||||
simError("script:%s, failed to parse json, status value is null, response:%s", script->fileName, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(status->valuestring, "succ") != 0) {
|
|
||||||
cJSON *code = cJSON_GetObjectItem(root, "code");
|
|
||||||
if (code == NULL) {
|
|
||||||
simError("script:%s, failed to parse json, code is null, response:%s", script->fileName, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int32_t retcode = (int32_t)code->valueint;
|
|
||||||
if (retcode != 1017) {
|
|
||||||
simError("script:%s, json:status:%s not equal to succ, response:%s", script->fileName, status->valuestring,
|
|
||||||
command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return retcode;
|
|
||||||
} else {
|
|
||||||
simDebug("script:%s, json:status:%s not equal to succ, but code is %d, response:%s", script->fileName,
|
|
||||||
status->valuestring, retcode, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *desc = cJSON_GetObjectItem(root, "desc");
|
|
||||||
if (desc != NULL) {
|
|
||||||
if (desc->valuestring == NULL || strlen(desc->valuestring) == 0) {
|
|
||||||
simError("script:%s, failed to parse json, desc value is null, response:%s", script->fileName, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
strcpy(script->auth, desc->valuestring);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *data = cJSON_GetObjectItem(root, "data");
|
|
||||||
if (data == NULL) {
|
|
||||||
simError("script:%s, failed to parse json, data is null, response:%s", script->fileName, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t rowsize = cJSON_GetArraySize(data);
|
|
||||||
if (rowsize < 0) {
|
|
||||||
simError("script:%s, failed to parse json:data, data size %d, response:%s", script->fileName, rowsize, command);
|
|
||||||
cJSON_Delete(root);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t rowIndex = 0;
|
|
||||||
sprintf(script->rows, "%d", rowsize);
|
|
||||||
for (int32_t r = 0; r < rowsize; ++r) {
|
|
||||||
cJSON *row = cJSON_GetArrayItem(data, r);
|
|
||||||
if (row == NULL) continue;
|
|
||||||
if (rowIndex++ >= 10) break;
|
|
||||||
|
|
||||||
int32_t colsize = cJSON_GetArraySize(row);
|
|
||||||
if (colsize < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
colsize = MIN(10, colsize);
|
|
||||||
for (int32_t c = 0; c < colsize; ++c) {
|
|
||||||
cJSON *col = cJSON_GetArrayItem(row, c);
|
|
||||||
if (col->valuestring != NULL) {
|
|
||||||
strcpy(script->data[r][c], col->valuestring);
|
|
||||||
} else {
|
|
||||||
if (col->numberstring[0] == 0) {
|
|
||||||
strcpy(script->data[r][c], "null");
|
|
||||||
} else {
|
|
||||||
strcpy(script->data[r][c], col->numberstring);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t simExecuteRestFulCommand(SScript *script, char *command) {
|
|
||||||
char buf[5000] = {0};
|
|
||||||
sprintf(buf, "%s 2>/dev/null", command);
|
|
||||||
|
|
||||||
FILE *fp = popen(buf, "r");
|
|
||||||
if (fp == NULL) {
|
|
||||||
simError("failed to execute %s", buf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t mallocSize = 2000;
|
|
||||||
int32_t alreadyReadSize = 0;
|
|
||||||
char * content = malloc(mallocSize);
|
|
||||||
|
|
||||||
while (!feof(fp)) {
|
|
||||||
int32_t availSize = mallocSize - alreadyReadSize;
|
|
||||||
int32_t len = (int32_t)fread(content + alreadyReadSize, 1, availSize, fp);
|
|
||||||
if (len >= availSize) {
|
|
||||||
alreadyReadSize += len;
|
|
||||||
mallocSize *= 2;
|
|
||||||
content = realloc(content, mallocSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pclose(fp);
|
|
||||||
|
|
||||||
return simParseHttpCommandResult(script, content);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
|
|
||||||
char command[4096];
|
|
||||||
sprintf(command, "curl 127.0.0.1:6041/rest/login/%s/%s", user, pass);
|
|
||||||
|
|
||||||
bool success = false;
|
|
||||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
|
||||||
success = simExecuteRestFulCommand(script, command) == 0;
|
|
||||||
if (!success) {
|
|
||||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
|
||||||
attempt);
|
|
||||||
taosMsleep(1000);
|
|
||||||
} else {
|
|
||||||
simDebug("script:%s, user:%s connect taosd successed, attempt:%d", script->fileName, user, attempt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
sprintf(script->error, "lineNum:%d. connect taosd failed:%s", script->lines[script->linePos].lineNum,
|
|
||||||
taos_errstr(NULL));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
simDebug("script:%s, connect taosd successed, auth:%p", script->fileName, script->auth);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
||||||
|
@ -651,7 +488,7 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort);
|
taos = taos_connect(NULL, user, pass, NULL, 0);
|
||||||
if (taos == NULL) {
|
if (taos == NULL) {
|
||||||
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
simDebug("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL),
|
||||||
attempt);
|
attempt);
|
||||||
|
@ -684,11 +521,7 @@ bool simCreateTaosdConnect(SScript *script, char *rest) {
|
||||||
user = token;
|
user = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simAsyncQuery) {
|
return simCreateNativeConnect(script, user, TSDB_DEFAULT_PASS);
|
||||||
return simCreateRestFulConnect(script, user, TSDB_DEFAULT_PASS);
|
|
||||||
} else {
|
|
||||||
return simCreateNativeConnect(script, user, TSDB_DEFAULT_PASS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
|
@ -710,7 +543,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
pSql = taos_query(script->taos, rest);
|
pSql = taos_query(script->taos, rest);
|
||||||
ret = taos_errno(pSql);
|
ret = taos_errno(pSql);
|
||||||
|
|
||||||
if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
if (ret == TSDB_CODE_MND_STB_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
||||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
||||||
tstrerror(ret));
|
tstrerror(ret));
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -877,41 +710,6 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simExecuteRestFulSqlCommand(SScript *script, char *rest) {
|
|
||||||
SCmdLine *line = &script->lines[script->linePos];
|
|
||||||
char command[4096];
|
|
||||||
sprintf(command, "curl -H 'Authorization: Taosd %s' -d \"%s\" 127.0.0.1:6041/rest/sql", script->auth, rest);
|
|
||||||
|
|
||||||
int32_t ret = -1;
|
|
||||||
for (int32_t attempt = 0; attempt < 10; ++attempt) {
|
|
||||||
ret = simExecuteRestFulCommand(script, command);
|
|
||||||
if (ret == TSDB_CODE_MND_TABLE_ALREADY_EXIST || ret == TSDB_CODE_MND_DB_ALREADY_EXIST) {
|
|
||||||
simDebug("script:%s, taos:%p, %s success, ret:%d:%s", script->fileName, script->taos, rest, ret & 0XFFFF,
|
|
||||||
tstrerror(ret));
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
} else if (ret != 0) {
|
|
||||||
simDebug("script:%s, taos:%p, %s failed, ret:%d", script->fileName, script->taos, rest, ret);
|
|
||||||
|
|
||||||
if (line->errorJump == SQL_JUMP_TRUE) {
|
|
||||||
script->linePos = line->jump;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
taosMsleep(1000);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
sprintf(script->error, "lineNum:%d. sql:%s failed, ret:%d", line->lineNum, rest, ret);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
script->linePos++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
|
bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
|
||||||
char buf[3000];
|
char buf[3000];
|
||||||
SCmdLine *line = &script->lines[script->linePos];
|
SCmdLine *line = &script->lines[script->linePos];
|
||||||
|
@ -935,7 +733,7 @@ bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!simAsyncQuery && script->taos == NULL) || (simAsyncQuery && script->auth[0] == 0)) {
|
if (script->taos == NULL) {
|
||||||
if (!simCreateTaosdConnect(script, "connect root")) {
|
if (!simCreateTaosdConnect(script, "connect root")) {
|
||||||
if (line->errorJump == SQL_JUMP_TRUE) {
|
if (line->errorJump == SQL_JUMP_TRUE) {
|
||||||
script->linePos = line->jump;
|
script->linePos = line->jump;
|
||||||
|
@ -951,11 +749,7 @@ bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simAsyncQuery) {
|
return simExecuteNativeSqlCommand(script, rest, isSlow);
|
||||||
return simExecuteRestFulSqlCommand(script, rest);
|
|
||||||
} else {
|
|
||||||
return simExecuteNativeSqlCommand(script, rest, isSlow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simExecuteSqlCmd(SScript *script, char *rest) {
|
bool simExecuteSqlCmd(SScript *script, char *rest) {
|
||||||
|
@ -1009,6 +803,7 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
|
||||||
return simExecuteSystemCmd(script, cmd);
|
return simExecuteSystemCmd(script, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
||||||
char buf[3000];
|
char buf[3000];
|
||||||
SCmdLine *line = &script->lines[script->linePos];
|
SCmdLine *line = &script->lines[script->linePos];
|
||||||
|
@ -1032,7 +827,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!simAsyncQuery && script->taos == NULL) || (simAsyncQuery && script->auth[0] == 0)) {
|
if (script->taos == NULL) {
|
||||||
if (!simCreateTaosdConnect(script, "connect root")) {
|
if (!simCreateTaosdConnect(script, "connect root")) {
|
||||||
if (line->errorJump == SQL_JUMP_TRUE) {
|
if (line->errorJump == SQL_JUMP_TRUE) {
|
||||||
script->linePos = line->jump;
|
script->linePos = line->jump;
|
||||||
|
@ -1048,17 +843,9 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret;
|
TAOS_RES *pSql = pSql = taos_query(script->taos, rest);
|
||||||
TAOS_RES *pSql = NULL;
|
int32_t ret = taos_errno(pSql);
|
||||||
if (simAsyncQuery) {
|
taos_free_result(pSql);
|
||||||
char command[4096];
|
|
||||||
sprintf(command, "curl -H 'Authorization: Taosd %s' -d '%s' 127.0.0.1:6041/rest/sql", script->auth, rest);
|
|
||||||
ret = simExecuteRestFulCommand(script, command);
|
|
||||||
} else {
|
|
||||||
pSql = taos_query(script->taos, rest);
|
|
||||||
ret = taos_errno(pSql);
|
|
||||||
taos_free_result(pSql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
simDebug("script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s", script->fileName, script->taos,
|
simDebug("script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s", script->fileName, script->taos,
|
||||||
|
@ -1084,7 +871,11 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) {
|
||||||
simInfo("script:%s, %s", script->fileName, rest);
|
simInfo("script:%s, %s", script->fileName, rest);
|
||||||
simLogSql(buf, true);
|
simLogSql(buf, true);
|
||||||
char * lines[] = {rest};
|
char * lines[] = {rest};
|
||||||
|
#if 0
|
||||||
int32_t ret = taos_insert_lines(script->taos, lines, 1);
|
int32_t ret = taos_insert_lines(script->taos, lines, 1);
|
||||||
|
#else
|
||||||
|
int32_t ret = 0;
|
||||||
|
#endif
|
||||||
if (ret == TSDB_CODE_SUCCESS) {
|
if (ret == TSDB_CODE_SUCCESS) {
|
||||||
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
|
simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest);
|
||||||
script->linePos++;
|
script->linePos++;
|
||||||
|
@ -1107,7 +898,11 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) {
|
||||||
simInfo("script:%s, %s", script->fileName, rest);
|
simInfo("script:%s, %s", script->fileName, rest);
|
||||||
simLogSql(buf, true);
|
simLogSql(buf, true);
|
||||||
char * lines[] = {rest};
|
char * lines[] = {rest};
|
||||||
|
#if 0
|
||||||
int32_t ret = taos_insert_lines(script->taos, lines, 1);
|
int32_t ret = taos_insert_lines(script->taos, lines, 1);
|
||||||
|
#else
|
||||||
|
int32_t ret = 0;
|
||||||
|
#endif
|
||||||
if (ret == TSDB_CODE_SUCCESS) {
|
if (ret == TSDB_CODE_SUCCESS) {
|
||||||
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
|
sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest);
|
||||||
script->linePos++;
|
script->linePos++;
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "sim.h"
|
#include "sim.h"
|
||||||
#undef TAOS_MEM_CHECK
|
|
||||||
|
|
||||||
bool simAsyncQuery = false;
|
|
||||||
bool simExecSuccess = false;
|
bool simExecSuccess = false;
|
||||||
bool abortExecution = false;
|
bool abortExecution = false;
|
||||||
|
|
||||||
|
@ -38,8 +36,6 @@ int32_t main(int32_t argc, char *argv[]) {
|
||||||
tstrncpy(configDir, argv[++i], 128);
|
tstrncpy(configDir, argv[++i], 128);
|
||||||
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
} else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) {
|
||||||
strcpy(scriptFile, argv[++i]);
|
strcpy(scriptFile, argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-a") == 0) {
|
|
||||||
simAsyncQuery = true;
|
|
||||||
} else {
|
} else {
|
||||||
printf("usage: %s [options] \n", argv[0]);
|
printf("usage: %s [options] \n", argv[0]);
|
||||||
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
#include "sim.h"
|
#include "sim.h"
|
||||||
#include "simParse.h"
|
#include "simParse.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#undef TAOS_MEM_CHECK
|
|
||||||
|
|
||||||
static SCommand *cmdHashList[MAX_NUM_CMD];
|
static SCommand *cmdHashList[MAX_NUM_CMD];
|
||||||
static SCmdLine cmdLine[MAX_CMD_LINES];
|
static SCmdLine cmdLine[MAX_CMD_LINES];
|
||||||
|
|
|
@ -14,15 +14,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "../../../include/client/taos.h"
|
#include "taos.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "sim.h"
|
#include "sim.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tsocket.h"
|
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#undef TAOS_MEM_CHECK
|
|
||||||
|
|
||||||
SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
|
SScript *simScriptList[MAX_MAIN_SCRIPT_NUM];
|
||||||
SCommand simCmdList[SIM_CMD_END];
|
SCommand simCmdList[SIM_CMD_END];
|
||||||
|
@ -81,9 +79,6 @@ char *simParseHostName(char *varName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool simSystemInit() {
|
bool simSystemInit() {
|
||||||
if (taos_init()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
taosGetFqdn(simHostName);
|
taosGetFqdn(simHostName);
|
||||||
simInitsimCmdList();
|
simInitsimCmdList();
|
||||||
memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM);
|
memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM);
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __COMMAND_STRUCT__
|
#ifndef _TD_SHELL_COMMAND_H_
|
||||||
#define __COMMAND_STRUCT__
|
#define _TD_SHELL_COMMAND_H_
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue