未验证 提交 135a70e0 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Hotfix/sangshuduo/td 3197 taosdemo coverity scan for master (#8487)

* [TD-3197]<fix>: taosdemo and taosdump coverity scan issues.

* exit if read sample file failed.

* fix converity scan issue.

* fix coverity scan issue.

* fix coverity scan memory leak.

* fix resource leak reported by coverity scan.

* fix taosdemo coverity scan issue.

* fix tcsetattr and getchar return value determination bug.

* fix coverity scan issue.

* fix two more coverity scan issues.

* fix stmt batch coverity scan issue.

* change to portable format.

* fix coverity scan issue

* [TD-10578]<fix>: taosdemo rest interface slow.

* fix missed 200

* fix taosdemo coverity scan issue.

* fix taosdemo coverity scan issue.

* fix taosdemo testcase for restful result.

* make master taosdemo rest logic same as develop

* modify taosdemo param to reflect current tbname prefix.

* remove chmod to make script keep same mod.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 a89cb214
IF (TD_LINUX) IF (TD_LINUX)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})") INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})")
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS)
IF (TD_POWER) IF (TD_POWER)
SET(CMAKE_INSTALL_PREFIX C:/PowerDB) SET(CMAKE_INSTALL_PREFIX C:/PowerDB)
...@@ -41,6 +40,5 @@ ELSEIF (TD_WINDOWS) ...@@ -41,6 +40,5 @@ ELSEIF (TD_WINDOWS)
ELSEIF (TD_DARWIN) ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})") INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR} Darwin ${TD_VER_NUMBER})")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR} Darwin ${TD_VER_NUMBER})")
ENDIF () ENDIF ()
...@@ -3501,9 +3501,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -3501,9 +3501,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
char resEncodingChunk[] = "Encoding: chunked"; char resEncodingChunk[] = "Encoding: chunked";
char resHttp[] = "HTTP/1.1 "; char resHttp[] = "HTTP/1.1 ";
int resHttpLen = strlen(resHttp);
char resHttpOk[] = "HTTP/1.1 200 OK"; char resHttpOk[] = "HTTP/1.1 200 OK";
int resHttpOkLen = strlen(resHttpOk);
do { do {
#ifdef WINDOWS #ifdef WINDOWS
...@@ -3527,8 +3525,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -3527,8 +3525,8 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
__func__, __LINE__, received, resp_len, response_buf); __func__, __LINE__, received, resp_len, response_buf);
if (((NULL == strstr(response_buf, resEncodingChunk)) if (((NULL == strstr(response_buf, resEncodingChunk))
&& (0 == strncmp(response_buf, resHttp, resHttpLen))) && (NULL != strstr(response_buf, resHttp)))
|| ((0 == strncmp(response_buf, resHttpOk, resHttpOkLen)) || ((NULL != strstr(response_buf, resHttpOk))
&& (NULL != strstr(response_buf, "\"status\":")))) { && (NULL != strstr(response_buf, "\"status\":")))) {
debugPrint( debugPrint(
"%s() LN%d: received:%d resp_len:%d, response_buf:\n%s\n", "%s() LN%d: received:%d resp_len:%d, response_buf:\n%s\n",
......
...@@ -54,29 +54,36 @@ class TDTestCase: ...@@ -54,29 +54,36 @@ class TDTestCase:
binPath = buildPath + "/build/bin/" binPath = buildPath + "/build/bin/"
if(threadID == 0): if(threadID == 0):
print("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT -m t" % print("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" %
(binPath, self.numberOfTables, self.numberOfRecords)) (binPath, self.numberOfTables, self.numberOfRecords))
os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT -m t" % os.system("%staosdemo -y -t %d -n %d -b INT,INT,INT,INT" %
(binPath, self.numberOfTables, self.numberOfRecords)) (binPath, self.numberOfTables, self.numberOfRecords))
if(threadID == 1): if(threadID == 1):
time.sleep(2) time.sleep(2)
print("use test") print("use test")
while True: max_try = 100
count = 0
while (count < max_try):
try: try:
tdSql.execute("use test") tdSql.execute("use test")
break break
except Exception as e: except Exception as e:
tdLog.info("use database test failed") tdLog.info("use database test failed")
time.sleep(1) time.sleep(2)
count += 1
print("try %d times" % count)
continue continue
# check if all the tables have heen created # check if all the tables have heen created
while True: count = 0
while (count < max_try):
try: try:
tdSql.query("show tables") tdSql.query("show tables")
except Exception as e: except Exception as e:
tdLog.info("show tables test failed") tdLog.info("show tables test failed")
time.sleep(1) time.sleep(2)
count += 1
print("try %d times" % count)
continue continue
rows = tdSql.queryRows rows = tdSql.queryRows
...@@ -85,13 +92,17 @@ class TDTestCase: ...@@ -85,13 +92,17 @@ class TDTestCase:
break break
time.sleep(1) time.sleep(1)
# check if there are any records in the last created table # check if there are any records in the last created table
while True: count = 0
while (count < max_try):
print("query started") print("query started")
print("try %d times" % count)
try: try:
tdSql.query("select * from test.t7") tdSql.query("select * from test.d7")
except Exception as e: except Exception as e:
tdLog.info("select * test failed") tdLog.info("select * test failed")
time.sleep(2) time.sleep(2)
count += 1
print("try %d times" % count)
continue continue
rows = tdSql.queryRows rows = tdSql.queryRows
...@@ -102,8 +113,8 @@ class TDTestCase: ...@@ -102,8 +113,8 @@ class TDTestCase:
print("alter table test.meters add column c10 int") print("alter table test.meters add column c10 int")
tdSql.execute("alter table test.meters add column c10 int") tdSql.execute("alter table test.meters add column c10 int")
print("insert into test.t7 values (now, 1, 2, 3, 4, 0)") print("insert into test.d7 values (now, 1, 2, 3, 4, 0)")
tdSql.execute("insert into test.t7 values (now, 1, 2, 3, 4, 0)") tdSql.execute("insert into test.d7 values (now, 1, 2, 3, 4, 0)")
def run(self): def run(self):
tdSql.prepare() tdSql.prepare()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册