diff --git a/documentation20/webdocs/markdowndocs/connector-java-ch.md b/documentation20/webdocs/markdowndocs/connector-java-ch.md
index cd88e093aa15eec49bf8fcab0e8a0678b713f18d..62c1f11baba7b113749e99537585dc910cfdef15 100644
--- a/documentation20/webdocs/markdowndocs/connector-java-ch.md
+++ b/documentation20/webdocs/markdowndocs/connector-java-ch.md
@@ -339,9 +339,10 @@ conn.close();
config.setUsername("root");
config.setPassword("taosdata");
// connection pool configurations
- config.setMinimumIdle(3); //minimum number of idle connection
+ config.setMinimumIdle(10); //minimum number of idle connection
config.setMaximumPoolSize(10); //maximum number of connection in the pool
config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool
+ config.setMaxLifetime(0); // maximum life time for each connection
config.setIdleTimeout(0); // max idle time for recycle idle connection
config.setConnectionTestQuery("select server_status()"); //validation query
@@ -375,24 +376,22 @@ conn.close();
* 使用示例如下:
```java
public static void main(String[] args) throws Exception {
- Properties properties = new Properties();
+
+ DruidDataSource dataSource = new DruidDataSource();
// jdbc properties
- properties.put("driverClassName","com.taosdata.jdbc.TSDBDriver");
- properties.put("url","jdbc:TAOS://127.0.0.1:6030/log");
- properties.put("username","root");
- properties.put("password","taosdata");
+ dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
+ dataSource.setUrl(url);
+ dataSource.setUsername("root");
+ dataSource.setPassword("taosdata");
// pool configurations
- properties.put("maxActive","10"); //maximum number of connection in the pool
- properties.put("initialSize","3"); //initial number of connection
- properties.put("minIdle","3"); //minimum number of connection in the pool
- properties.put("maxWait","30000"); //maximum wait milliseconds for get connection from pool
- properties.put("validationQuery","select server_status()"); //validation query
-
- //create druid datasource
- DataSource ds = DruidDataSourceFactory.createDataSource(properties);
- Connection connection = ds.getConnection(); // get connection
+ dataSource.setInitialSize(10);
+ dataSource.setMinIdle(10);
+ dataSource.setMaxActive(10);
+ dataSource.setMaxWait(30000);
+ dataSource.setValidationQuery("select server_status()");
+
+ Connection connection = dataSource.getConnection(); // get connection
Statement statement = connection.createStatement(); // get statement
-
//query or insert
// ...
@@ -419,7 +418,7 @@ Query OK, 1 row(s) in set (0.000141s)
## 与框架使用
* Spring JdbcTemplate 中使用 taos-jdbcdriver,可参考 [SpringJdbcTemplate][11]
-* Springboot + Mybatis 中使用,可参考 [springbootdemo
+* Springboot + Mybatis 中使用,可参考 [springbootdemo][12]
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index 0b419a330566601727c440587d5eac4961baf23d..a5906f5539a8d40b055f580933feb4b1184331f1 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -905,6 +905,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return tscInvalidSQLErrMsg(pCmd->payload, "keyword TAGS expected", sToken.z);
}
+ index = 0;
+ sToken = tStrGetToken(sql, &index, false, 0, NULL);
+ sql += index;
+ if (sToken.type != TK_LP) {
+ return tscInvalidSQLErrMsg(pCmd->payload, NULL, sToken.z);
+ }
+
SKVRowBuilder kvRowBuilder = {0};
if (tdInitKVRowBuilder(&kvRowBuilder) < 0) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
@@ -1554,6 +1561,7 @@ void tscImportDataFromFile(SSqlObj *pSql) {
tscError("%p failed to open file %s to load data from file, code:%s", pSql, pCmd->payload, tstrerror(pSql->res.code));
tfree(pSupporter);
+ taos_free_result(pNew);
tscAsyncResultOnError(pSql);
return;
}
diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c
index 67fd3d24bdc33ae6cbfb2a57aacad6b7fc65b9a2..d1136ca4de973c89918d7109e8b5adebf9ff2134 100644
--- a/src/client/src/tscSubquery.c
+++ b/src/client/src/tscSubquery.c
@@ -1991,7 +1991,22 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
* current query failed, and the retry count is less than the available
* count, retry query clear previous retrieved data, then launch a new sub query
*/
-static int32_t tscReissueSubquery(SRetrieveSupport *trsupport, SSqlObj *pSql, int32_t code) {
+static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32_t code) {
+ SRetrieveSupport *trsupport = malloc(sizeof(SRetrieveSupport));
+ if (trsupport == NULL) {
+ return TSDB_CODE_TSC_OUT_OF_MEMORY;
+ }
+
+ memcpy(trsupport, oriTrs, sizeof(*trsupport));
+
+ const uint32_t nBufferSize = (1u << 16u); // 64KB
+ trsupport->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage));
+ if (trsupport->localBuffer == NULL) {
+ tscError("%p failed to malloc buffer for local buffer, reason:%s", pSql, strerror(errno));
+ tfree(trsupport);
+ return TSDB_CODE_TSC_OUT_OF_MEMORY;
+ }
+
SSqlObj *pParentSql = trsupport->pParentSql;
int32_t subqueryIndex = trsupport->subqueryIndex;
diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c
index d045000e24485f27d9cbde89ff76e794d12b2c32..824fff574e2fd1160eaa2cef1d6edc0869ea2a67 100644
--- a/src/client/src/tscUtil.c
+++ b/src/client/src/tscUtil.c
@@ -2127,7 +2127,11 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables);
} else { // transfer the ownership of pTableMeta to the newly create sql object.
STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0);
-
+ if (pPrevInfo->pTableMeta && pPrevInfo->pTableMeta->tableType < 0) {
+ terrno = TSDB_CODE_TSC_APP_ERROR;
+ goto _error;
+ }
+
STableMeta* pPrevTableMeta = tscTableMetaDup(pPrevInfo->pTableMeta);
SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList;
pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList,
diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c
index 1da1486dda3723a31d8d71c4e1ccfc5a663512ee..4caece16612353155886ff20055433878ec7411c 100644
--- a/src/dnode/src/dnodeTelemetry.c
+++ b/src/dnode/src/dnodeTelemetry.c
@@ -31,12 +31,16 @@
#include "mnodeAcct.h"
#include "dnodeTelemetry.h"
-static tsem_t tsExitSem;
+// sem_timedwait is NOT implemented on MacOSX
+// thus, we use pthread_mutex_t/pthread_cond_t to simulate
+static pthread_mutex_t tsExitLock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t tsExitCond = PTHREAD_COND_INITIALIZER;
+static volatile int tsExit = 0;
static pthread_t tsTelemetryThread;
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_PORT 80
-#define REPORT_INTERVAL 86400
+#define REPORT_INTERVAL 86400
static void beginObject(SBufferWriter* bw) {
tbufWriteChar(bw, '{');
@@ -172,8 +176,8 @@ static void addMemoryInfo(SBufferWriter* bw) {
static void addVersionInfo(SBufferWriter* bw) {
addStringField(bw, "version", version);
addStringField(bw, "buildInfo", buildinfo);
- addStringField(bw, "gitInfo", gitinfo);
- addStringField(bw, "email", tsEmail);
+ addStringField(bw, "gitInfo", gitinfo);
+ addStringField(bw, "email", tsEmail);
}
static void addRuntimeInfo(SBufferWriter* bw) {
@@ -236,24 +240,19 @@ static void sendTelemetryReport() {
taosCloseSocket(fd);
}
-#ifdef __APPLE__
-static int sem_timedwait(tsem_t *sem, struct timespec *to) {
- fprintf(stderr, "%s[%d]%s(): not implemented yet!\n", basename(__FILE__), __LINE__, __func__);
- abort();
-}
-#endif // __APPLE__
-
static void* telemetryThread(void* param) {
struct timespec end = {0};
clock_gettime(CLOCK_REALTIME, &end);
end.tv_sec += 300; // wait 5 minutes before send first report
- while (1) {
- if (sem_timedwait(&tsExitSem, &end) == 0) {
- break;
- } else if (errno != ETIMEDOUT) {
- continue;
- }
+ while (!tsExit) {
+ int r = 0;
+ struct timespec ts = end;
+ pthread_mutex_lock(&tsExitLock);
+ r = pthread_cond_timedwait(&tsExitCond, &tsExitLock, &ts);
+ pthread_mutex_unlock(&tsExitLock);
+ if (r==0) break;
+ if (r!=ETIMEDOUT) continue;
if (sdbIsMaster()) {
sendTelemetryReport();
@@ -269,12 +268,12 @@ static void dnodeGetEmail(char* filepath) {
if (fd < 0) {
return;
}
-
+
if (taosRead(fd, (void *)tsEmail, TSDB_FQDN_LEN) < 0) {
dError("failed to read %d bytes from file %s since %s", TSDB_FQDN_LEN, filepath, strerror(errno));
- }
+ }
- taosClose(fd);
+ taosClose(fd);
}
int32_t dnodeInitTelemetry() {
@@ -282,13 +281,7 @@ int32_t dnodeInitTelemetry() {
return 0;
}
- dnodeGetEmail("/usr/local/taos/email");
-
- if (tsem_init(&tsExitSem, 0, 0) == -1) {
- // just log the error, it is ok for telemetry to fail
- dTrace("failed to create semaphore for telemetry, reason:%s", strerror(errno));
- return 0;
- }
+ dnodeGetEmail("/usr/local/taos/email");
pthread_attr_t attr;
pthread_attr_init(&attr);
@@ -310,8 +303,11 @@ void dnodeCleanupTelemetry() {
}
if (taosCheckPthreadValid(tsTelemetryThread)) {
- tsem_post(&tsExitSem);
+ pthread_mutex_lock(&tsExitLock);
+ tsExit = 1;
+ pthread_cond_signal(&tsExitCond);
+ pthread_mutex_unlock(&tsExitLock);
+
pthread_join(tsTelemetryThread, NULL);
- tsem_destroy(&tsExitSem);
}
}
diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h
index 43ac666f7043dcd148b678dbe9976a391363cfd4..429304c7449e1a5541e0a231512c292172af95f4 100644
--- a/src/inc/taoserror.h
+++ b/src/inc/taoserror.h
@@ -258,6 +258,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "Query shou
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_IN_EXEC, 0, 0x0709, "Multiple retrieval of this query")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW, 0, 0x070A, "Too many time window in query")
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_ENOUGH_BUFFER, 0, 0x070B, "Query buffer limit has reached")
+TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INCONSISTAN, 0, 0x070C, "File inconsistance in replica")
+
// grant
TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "License expired")
diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c
index 9eb30ccdccc60d9b975236036b7f3aab0675b196..a8f457377dd0b150f8e0938e08a81f6d79d911d6 100644
--- a/src/kit/shell/src/shellLinux.c
+++ b/src/kit/shell/src/shellLinux.c
@@ -47,7 +47,7 @@ static struct argp_option options[] = {
{"thread", 'T', "THREADNUM", 0, "Number of threads when using multi-thread to import data."},
{"database", 'd', "DATABASE", 0, "Database to use when connecting to the server."},
{"timezone", 't', "TIMEZONE", 0, "Time zone of the shell, default is local."},
- {"netrole", 'n', "NETROLE", 0, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup."},
+ {"netrole", 'n', "NETROLE", 0, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync."},
{"pktlen", 'l', "PKTLEN", 0, "Packet length used for net test, default is 1000 bytes."},
{0}};
diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c
index 73216f9ca3aa3d29c9b83ee12c1ec661b10311ca..56021d9c34a812fcf96f2ca902ee97e9f6dd88af 100644
--- a/src/kit/shell/src/shellWindows.c
+++ b/src/kit/shell/src/shellWindows.c
@@ -52,7 +52,7 @@ void printHelp() {
printf("%s%s\n", indent, "-t");
printf("%s%s%s\n", indent, indent, "Time zone of the shell, default is local.");
printf("%s%s\n", indent, "-n");
- printf("%s%s%s\n", indent, indent, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup.");
+ printf("%s%s%s\n", indent, indent, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync.");
printf("%s%s\n", indent, "-l");
printf("%s%s%s\n", indent, indent, "Packet length used for net test, default is 1000 bytes.");
printf("%s%s\n", indent, "-V");
diff --git a/src/os/src/detail/osSysinfo.c b/src/os/src/detail/osSysinfo.c
index 247aee56c835f7b7eb33c738c3cdd0267aff7e27..25b0edae72a2a043eb8d993afe8644d8c9775e6e 100644
--- a/src/os/src/detail/osSysinfo.c
+++ b/src/os/src/detail/osSysinfo.c
@@ -248,7 +248,7 @@ static void taosGetSystemLocale() { // get and set default locale
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
locale = setlocale(LC_CTYPE, "");
if (locale == NULL) {
- uError("can't get locale from system, set it to en_US.UTF-8");
+ uError("can't get locale from system, set it to en_US.UTF-8 since error:%d:%s", errno, strerror(errno));
strcpy(tsLocale, "en_US.UTF-8");
} else {
tstrncpy(tsLocale, locale, TSDB_LOCALE_LEN);
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index 6140b9824c0688b423397682578c16fe872eb031..6e1945407cc0e7682a884a99ea0095bdc27c7b2c 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -1398,13 +1398,13 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) {
if (key < elem.ts) {
return TS_JOIN_TS_NOT_EQUALS;
} else if (key > elem.ts) {
- assert(false);
+ longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_INCONSISTAN);
}
} else {
if (key > elem.ts) {
return TS_JOIN_TS_NOT_EQUALS;
} else if (key < elem.ts) {
- assert(false);
+ longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_INCONSISTAN);
}
}
@@ -3828,6 +3828,11 @@ void scanOneTableDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, TSKEY start) {
setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
pRuntimeEnv->scanFlag = REPEAT_SCAN;
+ if (pRuntimeEnv->pTsBuf) {
+ bool ret = tsBufNextPos(pRuntimeEnv->pTsBuf);
+ assert(ret);
+ }
+
qDebug("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%"PRId64"-%"PRId64, pQInfo,
cond.twindow.skey, cond.twindow.ekey);
}
diff --git a/src/sync/inc/syncMsg.h b/src/sync/inc/syncMsg.h
index 5724927daf94df793ced6f9def6a0d25acab647c..85ac9c78affa5282d5ca703caffc1bc5c24461bb 100644
--- a/src/sync/inc/syncMsg.h
+++ b/src/sync/inc/syncMsg.h
@@ -37,7 +37,8 @@ typedef enum {
TAOS_SMSG_SETUP_RSP = 12,
TAOS_SMSG_SYNC_FILE = 13,
TAOS_SMSG_SYNC_FILE_RSP = 14,
- TAOS_SMSG_END = 15,
+ TAOS_SMSG_TEST = 15,
+ TAOS_SMSG_END = 16
} ESyncMsgType;
typedef enum {
@@ -128,6 +129,7 @@ void syncBuildSyncReqMsg(SSyncMsg *pMsg, int32_t vgId);
void syncBuildSyncDataMsg(SSyncMsg *pMsg, int32_t vgId);
void syncBuildSyncSetupMsg(SSyncMsg *pMsg, int32_t vgId);
void syncBuildPeersStatus(SPeersStatus *pMsg, int32_t vgId);
+void syncBuildSyncTestMsg(SSyncMsg *pMsg, int32_t vgId);
void syncBuildFileAck(SFileAck *pMsg, int32_t vgId);
void syncBuildFileVersion(SFileVersion *pMsg, int32_t vgId);
diff --git a/src/sync/src/syncArbitrator.c b/src/sync/src/syncArbitrator.c
index 9fb6b0ddb78e1f7c34daa5c3417b62750d7d5c2d..fdbef4c9f827d77bdc1ce1874dc2b368a7467ca1 100644
--- a/src/sync/src/syncArbitrator.c
+++ b/src/sync/src/syncArbitrator.c
@@ -27,6 +27,7 @@
#include "syncInt.h"
#include "syncTcp.h"
+extern void syncProcessTestMsg(SSyncMsg *pMsg, SOCKET connFd);
static void arbSignalHandler(int32_t signum, void *sigInfo, void *context);
static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp);
static void arbProcessBrokenLink(int64_t rid);
@@ -118,6 +119,11 @@ static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
return;
}
+ if (msg.head.type == TAOS_SMSG_TEST) {
+ syncProcessTestMsg(&msg, connFd);
+ return;
+ }
+
SNodeConn *pNode = calloc(sizeof(SNodeConn), 1);
if (pNode == NULL) {
sError("failed to allocate memory since %s", strerror(errno));
diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c
index 049a2b3ca89882f46bef6aeda1bdc4102de61634..0f7fb77da87ff7fd336d32c36c6fa846fbafeca1 100644
--- a/src/sync/src/syncMain.c
+++ b/src/sync/src/syncMain.c
@@ -1182,6 +1182,20 @@ static void syncCreateRestoreDataThread(SSyncPeer *pPeer) {
}
}
+void syncProcessTestMsg(SSyncMsg *pMsg, SOCKET connFd) {
+ sInfo("recv sync test msg");
+
+ SSyncMsg rsp;
+ syncBuildSyncTestMsg(&rsp, -1);
+ if (taosWriteMsg(connFd, &rsp, sizeof(SSyncMsg)) != sizeof(SSyncMsg)) {
+ sInfo("failed to send sync test rsp since %s", strerror(errno));
+ }
+
+ sInfo("send sync test rsp");
+ taosMsleep(1000);
+ taosCloseSocket(connFd);
+}
+
static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
char ipstr[24];
int32_t i;
@@ -1203,6 +1217,11 @@ static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
return;
}
+ if (msg.head.type == TAOS_SMSG_TEST) {
+ syncProcessTestMsg(&msg, connFd);
+ return;
+ }
+
int32_t vgId = msg.head.vgId;
SSyncNode **ppNode = taosHashGet(tsVgIdHash, &vgId, sizeof(int32_t));
if (ppNode == NULL || *ppNode == NULL) {
diff --git a/src/sync/src/syncMsg.c b/src/sync/src/syncMsg.c
index e16b9f5b4ae87dff72448adb2cfae2ea9132d3f5..3348f1ec337e1b7c292d231360765c914936625c 100644
--- a/src/sync/src/syncMsg.c
+++ b/src/sync/src/syncMsg.c
@@ -86,6 +86,7 @@ static void syncBuildMsg(SSyncMsg *pMsg, int32_t vgId, ESyncMsgType type) {
void syncBuildSyncReqMsg(SSyncMsg *pMsg, int32_t vgId) { syncBuildMsg(pMsg, vgId, TAOS_SMSG_SYNC_REQ); }
void syncBuildSyncDataMsg(SSyncMsg *pMsg, int32_t vgId) { syncBuildMsg(pMsg, vgId, TAOS_SMSG_SYNC_DATA); }
void syncBuildSyncSetupMsg(SSyncMsg *pMsg, int32_t vgId) { syncBuildMsg(pMsg, vgId, TAOS_SMSG_SETUP); }
+void syncBuildSyncTestMsg(SSyncMsg *pMsg, int32_t vgId) { syncBuildMsg(pMsg, vgId, TAOS_SMSG_TEST); }
void syncBuildPeersStatus(SPeersStatus *pMsg, int32_t vgId) {
pMsg->head.type = TAOS_SMSG_STATUS;
diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt
index b4ec8c7007c850567e3b4501d27769fb5782f10c..95b618507a0fd0ae3601f04c86f47a1a3eb98cc1 100644
--- a/src/util/CMakeLists.txt
+++ b/src/util/CMakeLists.txt
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(TDengine)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc)
+INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/sync/inc)
AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(tutil ${SRC})
TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4 z)
diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c
index fe6dfb493d3b8293ad6cbdcf42b0122f991e36a2..28abad356c156182b23feebd8d2e80ea4c914e52 100644
--- a/src/util/src/tnettest.c
+++ b/src/util/src/tnettest.c
@@ -23,6 +23,8 @@
#include "tsocket.h"
#include "trpc.h"
#include "rpcHead.h"
+#include "tchecksum.h"
+#include "syncMsg.h"
#define MAX_PKG_LEN (64 * 1000)
#define BUFFER_SIZE (MAX_PKG_LEN + 1024)
@@ -408,13 +410,51 @@ static void taosNetTestStartup(char *host, int32_t port) {
free(pStep);
}
+static void taosNetCheckSync(char *host, int32_t port) {
+ uint32_t ip = taosGetIpv4FromFqdn(host);
+ if (ip == 0xffffffff) {
+ uError("failed to get IP address from %s since %s", host, strerror(errno));
+ return;
+ }
+
+ SOCKET connFd = taosOpenTcpClientSocket(ip, (uint16_t)port, 0);
+ if (connFd < 0) {
+ uError("failed to create socket while test port:%d since %s", port, strerror(errno));
+ return;
+ }
+
+ SSyncMsg msg;
+ memset(&msg, 0, sizeof(SSyncMsg));
+ SSyncHead *pHead = &msg.head;
+ pHead->type = TAOS_SMSG_TEST;
+ pHead->protocol = SYNC_PROTOCOL_VERSION;
+ pHead->signature = SYNC_SIGNATURE;
+ pHead->code = 0;
+ pHead->cId = 0;
+ pHead->vgId = -1;
+ pHead->len = sizeof(SSyncMsg) - sizeof(SSyncHead);
+ taosCalcChecksumAppend(0, (uint8_t *)pHead, sizeof(SSyncHead));
+
+ if (taosWriteMsg(connFd, &msg, sizeof(SSyncMsg)) != sizeof(SSyncMsg)) {
+ uError("failed to test port:%d while send msg since %s", port, strerror(errno));
+ return;
+ }
+
+ if (taosReadMsg(connFd, &msg, sizeof(SSyncMsg)) != sizeof(SSyncMsg)) {
+ uError("failed to test port:%d while recv msg since %s", port, strerror(errno));
+ }
+
+ uInfo("successed to test TCP port:%d", port);
+ taosCloseSocket(connFd);
+}
+
static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
- int32_t endPort = startPort + 9;
+ int32_t endPort = startPort + TSDB_PORT_SYNC;
char spi = 0;
uInfo("check rpc, host:%s startPort:%d endPort:%d pkgLen:%d\n", host, startPort, endPort, pkgLen);
-
- for (uint16_t port = startPort; port <= endPort; port++) {
+
+ for (uint16_t port = startPort; port < endPort; port++) {
int32_t sendpkgLen;
if (pkgLen <= tsRpcMaxUdpSize) {
sendpkgLen = tsRpcMaxUdpSize + 1000;
@@ -442,6 +482,9 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
uInfo("successed to test UDP port:%d", port);
}
}
+
+ taosNetCheckSync(host, startPort + TSDB_PORT_SYNC);
+ taosNetCheckSync(host, startPort + TSDB_PORT_ARBITRATOR);
}
static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
@@ -508,6 +551,8 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen) {
taosNetTestServer(host, port, pkgLen);
} else if (0 == strcmp("rpc", role)) {
taosNetTestRpc(host, port, pkgLen);
+ } else if (0 == strcmp("sync", role)) {
+ taosNetCheckSync(host, port);
} else if (0 == strcmp("startup", role)) {
taosNetTestStartup(host, port);
} else {
diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml
index d075fc8f2ad480535075b79efc15c55d9bb799a5..27a03911a298f6c5a966c16bb5cbc47d1985fa61 100644
--- a/tests/examples/JDBC/JDBCDemo/pom.xml
+++ b/tests/examples/JDBC/JDBCDemo/pom.xml
@@ -9,6 +9,14 @@
SNAPSHOT
jar
+
+
+ com.taosdata.jdbc
+ taos-jdbcdriver
+ 2.0.18
+
+
+
@@ -48,12 +56,4 @@
-
-
- com.taosdata.jdbc
- taos-jdbcdriver
- 2.0.15
-
-
-
diff --git a/tests/examples/JDBC/JDBCDemo/readme.md b/tests/examples/JDBC/JDBCDemo/readme.md
index da638a0bcc485cb3d73f75b59348ec260cc871d2..94844420859a2cc56842e95e4ac8c664c8ffa2e7 100644
--- a/tests/examples/JDBC/JDBCDemo/readme.md
+++ b/tests/examples/JDBC/JDBCDemo/readme.md
@@ -11,12 +11,12 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-
## Run jdbcDemo using mvn plugin
run command:
```
-mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"
+mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo"
```
and run with your customed args
```
-mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"
+mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo" -Dexec.args="-host [HOSTNAME]"
```
## Compile the Demo Code and Run It
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
index 0fa0059805e54893a3c25a4dbd7a0f4d67207b57..07a21e79d1cd188528fbbc7548e35fac78c65600 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
@@ -5,7 +5,6 @@ import java.util.Properties;
public class JDBCDemo {
private static String host;
- private static String driverType = "jni";
private static final String dbName = "test";
private static final String tbName = "weather";
private Connection connection;
@@ -14,17 +13,10 @@ public class JDBCDemo {
for (int i = 0; i < args.length; i++) {
if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1)
host = args[++i];
- if ("-driverType".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- driverType = args[++i];
- if (!"jni".equalsIgnoreCase(driverType) && !"restful".equalsIgnoreCase(driverType))
- printHelp();
- }
}
-
if (host == null) {
printHelp();
}
-
JDBCDemo demo = new JDBCDemo();
demo.init();
demo.createDatabase();
@@ -38,15 +30,10 @@ public class JDBCDemo {
}
private void init() {
+ final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
// get connection
try {
- String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
- if (driverType.equals("restful")) {
- Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
- url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata";
- } else {
- Class.forName("com.taosdata.jdbc.TSDBDriver");
- }
+ Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties();
properties.setProperty("charset", "UTF-8");
properties.setProperty("locale", "en_US.UTF-8");
@@ -70,11 +57,39 @@ public class JDBCDemo {
exuete(sql);
}
+ private void dropTable() {
+ final String sql = "drop table if exists " + dbName + "." + tbName + "";
+ exuete(sql);
+ }
+
+ private void createTable() {
+ final String sql = "create table if not exists " + dbName + "." + tbName + " (ts timestamp, temperature float, humidity int)";
+ exuete(sql);
+ }
+
+ private void insert() {
+ final String sql = "insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)";
+ exuete(sql);
+ }
+
private void select() {
final String sql = "select * from test.weather";
executeQuery(sql);
}
+ private void close() {
+ try {
+ if (connection != null) {
+ this.connection.close();
+ System.out.println("connection closed.");
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /************************************************************************/
+
private void executeQuery(String sql) {
try (Statement statement = connection.createStatement()) {
long start = System.currentTimeMillis();
@@ -99,15 +114,6 @@ public class JDBCDemo {
}
}
- private void insert() {
- final String sql = "insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)";
- exuete(sql);
- }
-
- private void createTable() {
- final String sql = "create table if not exists " + dbName + "." + tbName + " (ts timestamp, temperature float, humidity int)";
- exuete(sql);
- }
private void printSql(String sql, boolean succeed, long cost) {
System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql);
@@ -125,24 +131,8 @@ public class JDBCDemo {
}
}
- private void close() {
- try {
- if (connection != null) {
- this.connection.close();
- System.out.println("connection closed.");
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- private void dropTable() {
- final String sql = "drop table if exists " + dbName + "." + tbName + "";
- exuete(sql);
- }
-
private static void printHelp() {
- System.out.println("Usage: java -jar JdbcDemo.jar -host -driverType ");
+ System.out.println("Usage: java -jar JDBCDemo.jar -host ");
System.exit(0);
}
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
index 91639e85f3b488a5ded5e1253b429fa874b091e2..eedb0ba166da50f21577296ad6fa1cd3f838ac32 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java
@@ -14,9 +14,9 @@ public class JdbcRestfulDemo {
String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata";
Properties properties = new Properties();
-// properties.setProperty("charset", "UTF-8");
-// properties.setProperty("locale", "en_US.UTF-8");
-// properties.setProperty("timezone", "UTC-8");
+ properties.setProperty("charset", "UTF-8");
+ properties.setProperty("locale", "en_US.UTF-8");
+ properties.setProperty("timezone", "UTC-8");
Connection conn = DriverManager.getConnection(url, properties);
Statement stmt = conn.createStatement();
diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java
index bb3712a3024de84aea1dba0e71b47dec5e2405a5..def4c649027034028d222bfedb71e37d82b99380 100644
--- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java
+++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java
@@ -6,75 +6,70 @@ import com.taosdata.jdbc.TSDBResultSet;
import com.taosdata.jdbc.TSDBSubscribe;
import java.sql.DriverManager;
+import java.sql.ResultSetMetaData;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
public class SubscribeDemo {
+ private static final String usage = "java -jar SubscribeDemo.jar -host -database -topic -sql ";
- public static TSDBConnection getConnection(String host, String database) throws Exception {
- Class.forName("com.taosdata.jdbc.TSDBDriver");
- Properties properties = new Properties();
- properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
- properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
- properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
- properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
-
- String cs = String.format("jdbc:TAOS://%s:0/%s", host, database);
- return (TSDBConnection) DriverManager.getConnection(cs, properties);
- }
-
- public static void main(String[] args) throws Exception {
- String usage = "java -Djava.ext.dirs=../ TestTSDBSubscribe [-host host] <-db database> <-topic topic> <-sql sql>";
- if (args.length < 2) {
- System.err.println(usage);
- return;
- }
-
- String host = "localhost", database = "", topic = "", sql = "";
+ public static void main(String[] args) {
+ // parse args from command line
+ String host = "", database = "", topic = "", sql = "";
for (int i = 0; i < args.length; i++) {
- if ("-db".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ host = args[++i];
+ }
+ if ("-database".equalsIgnoreCase(args[i]) && i < args.length - 1) {
database = args[++i];
}
if ("-topic".equalsIgnoreCase(args[i]) && i < args.length - 1) {
topic = args[++i];
}
- if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- host = args[++i];
- }
if ("-sql".equalsIgnoreCase(args[i]) && i < args.length - 1) {
sql = args[++i];
}
}
- if (database.isEmpty() || topic.isEmpty() || sql.isEmpty()) {
- System.err.println(usage);
+ if (host.isEmpty() || database.isEmpty() || topic.isEmpty() || sql.isEmpty()) {
+ System.out.println(usage);
return;
}
-
- TSDBConnection connection = null;
- TSDBSubscribe sub = null;
+ /*********************************************************************************************/
try {
- connection = getConnection(host, database);
- sub = ((TSDBConnection) connection).subscribe(topic, sql, false);
+ Class.forName("com.taosdata.jdbc.TSDBDriver");
+ Properties properties = new Properties();
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
+ final String url = "jdbc:TAOS://" + host + ":6030/" + database + "?user=root&password=taosdata";
+ // get TSDBConnection
+ TSDBConnection connection = (TSDBConnection) DriverManager.getConnection(url, properties);
+ // create TSDBSubscribe
+ TSDBSubscribe sub = connection.subscribe(topic, sql, false);
int total = 0;
while (true) {
TSDBResultSet rs = sub.consume();
int count = 0;
+ ResultSetMetaData meta = rs.getMetaData();
while (rs.next()) {
+ for (int i = 1; i <= meta.getColumnCount(); i++) {
+ System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
+ }
+ System.out.println();
count++;
}
total += count;
- System.out.printf("%d rows consumed, total %d\n", count, total);
- Thread.sleep(900);
+// System.out.printf("%d rows consumed, total %d\n", count, total);
+ if (total >= 10)
+ break;
+ TimeUnit.SECONDS.sleep(1);
}
+ sub.close(false);
+ connection.close();
} catch (Exception e) {
+ System.out.println("host: " + host + ", database: " + database + ", topic: " + topic + ", sql: " + sql);
e.printStackTrace();
- } finally {
- if (null != sub) {
- sub.close(true);
- }
- if (null != connection) {
- connection.close();
- }
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/examples/JDBC/calciteDemo/pom.xml b/tests/examples/JDBC/calciteDemo/pom.xml
deleted file mode 100644
index a7d47837d9ba407f3959a00d522a9cd26b5622db..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/calciteDemo/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
- 4.0.0
-
- com.taosdata.example.calcite
- calciteDemo
- 1.0-SNAPSHOT
-
-
-
-
- org.slf4j
- slf4j-simple
- 1.7.25
- compile
-
-
-
- org.apache.calcite
- calcite-core
- 1.23.0
-
-
- org.apache.commons
- commons-dbcp2
- 2.7.0
-
-
- org.apache.calcite.avatica
- avatica-core
- 1.17.0
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.47
-
-
-
-
- com.taosdata.jdbc
- taos-jdbcdriver
- 2.0.8
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java b/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java
deleted file mode 100644
index 7e97956b7879c26056b9b0e27cce4786284ff96c..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/calciteDemo/src/main/java/com/taosdata/example/calcite/CalciteDemo.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.taosdata.example.calcite;
-
-import org.apache.calcite.adapter.jdbc.JdbcSchema;
-import org.apache.calcite.jdbc.CalciteConnection;
-import org.apache.calcite.schema.Schema;
-import org.apache.calcite.schema.SchemaPlus;
-import org.apache.calcite.sql.parser.SqlParseException;
-import org.apache.commons.dbcp2.BasicDataSource;
-
-import java.sql.*;
-import java.util.Properties;
-
-public class CalciteDemo {
-
- private static String url_taos = "jdbc:TAOS://192.168.236.135:6030/test";
- private static String url_mysql = "jdbc:mysql://master:3306/test?useSSL=false&useUnicode=true&characterEncoding=UTF-8";
-
- public static void main(String[] args) throws SqlParseException, ClassNotFoundException, SQLException {
- Class.forName("org.apache.calcite.jdbc.Driver");
- Properties info = new Properties();
- info.setProperty("caseSensitive", "false");
-
- Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
- CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
-
- SchemaPlus rootSchema = calciteConnection.getRootSchema();
-
- //这里hdb是在tdengine中创建的数据库名
- Schema schema = mysqlTest(rootSchema);
-// Schema schema = tdengineTest(rootSchema);
-
- //创建新的schema自动映射到原来的hdb数据库
- rootSchema.add("test", schema);
-
- Statement stmt = calciteConnection.createStatement();
- //查询schema test中的表,表名是tdengine中的表
- ResultSet rs = stmt.executeQuery("select * from test.t");
- ResultSetMetaData metaData = rs.getMetaData();
- while (rs.next()) {
- for (int i = 1; i <= metaData.getColumnCount(); i++) {
- System.out.println(metaData.getColumnLabel(i) + " : " + rs.getString(i));
- }
- }
- }
-
-
- private static Schema tdengineTest(SchemaPlus rootSchema) throws ClassNotFoundException {
- Class.forName("com.taosdata.jdbc.TSDBDriver");
- BasicDataSource dataSource = new BasicDataSource();
- dataSource.setUrl(url_taos);
- dataSource.setUsername("root");
- dataSource.setPassword("taosdata");
-
- return JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null);
- }
-
- private static Schema mysqlTest(SchemaPlus rootSchema) throws ClassNotFoundException {
- Class.forName("com.mysql.jdbc.Driver");
- BasicDataSource dataSource = new BasicDataSource();
- dataSource.setUrl(url_mysql);
- dataSource.setUsername("root");
- dataSource.setPassword("123456");
-
- //Schema schema = JdbcSchema.create(rootSchema, "test", dataSource, "hdb", null);
- return JdbcSchema.create(rootSchema, "test", dataSource, "test", null);
- }
-}
diff --git a/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties b/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties
deleted file mode 100644
index 1a77ec520cd3e727ac51acb4b8f647b7cf188d97..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/calciteDemo/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-log4j.rootLogger=info,stdout
-
-#console
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern= [%d{yyyy-MM-dd HH:mm:ss a}]:%p %l%m%n
\ No newline at end of file
diff --git a/tests/examples/JDBC/connectionPools/README-cn.md b/tests/examples/JDBC/connectionPools/README-cn.md
index 761596dfc55a3e2c9f449ed34fd72ac96c277512..9b26df3c2eb2c23171a673643891a292af4c920c 100644
--- a/tests/examples/JDBC/connectionPools/README-cn.md
+++ b/tests/examples/JDBC/connectionPools/README-cn.md
@@ -1,23 +1,25 @@
这个example中,我们适配了java常见的连接池:
-* c3p0
-* dbcp
+* HikariCP(默认)
* druid
-* HikariCP
+* dbcp
+* c3p0
### 说明
ConnectionPoolDemo的程序逻辑:
1. 创建到host的connection连接池
2. 创建名称为pool_test的database,创建表超级weather,创建tableSize个子表
-3. 不断向所有子表进行插入。
+3. 总共插入totalNumber条数据。
### 如何运行这个例子:
+
```shell script
-# mvn exec:java -Dexec.mainClass="com.taosdata.demo.ConnectionPoolDemo" -Dexec.args="-host localhost"
+mvn clean package assembly:single
+java -jar target/connectionPools-1.0-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
```
使用mvn运行ConnectionPoolDemo的main方法,可以指定参数
```shell script
Usage:
-mvn exec:java -Dexec.mainClass="com.taosdata.demo.ConnectionPoolDemo" -Dexec.args=""
+java -jar target/connectionPools-1.0-SNAPSHOT-jar-with-dependencies.jar
-host : hostname
-poolType
-poolSize
@@ -26,8 +28,5 @@ mvn exec:java -Dexec.mainClass="com.taosdata.demo.ConnectionPoolDemo" -Dexec.arg
-sleep : 每次插入任务提交后的
```
-### 如何停止程序:
-ConnectionPoolDemo不会自己停止,会一直执行插入,需要手动Ctrl+C运行。
-
### 日志
使用log4j,将日志和错误分别输出到了debug.log和error.log中
\ No newline at end of file
diff --git a/tests/examples/JDBC/connectionPools/pom.xml b/tests/examples/JDBC/connectionPools/pom.xml
index fbee256067dcc3dec5e5888384d5ca36d3b66066..84467003f905c454bb285088e56bcd26465a3e5e 100644
--- a/tests/examples/JDBC/connectionPools/pom.xml
+++ b/tests/examples/JDBC/connectionPools/pom.xml
@@ -12,7 +12,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.17
+ 2.0.18
@@ -50,6 +50,35 @@
log4j
1.2.17
-
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.1.0
+
+
+
+ com.taosdata.example.ConnectionPoolDemo
+
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/common/InsertTask.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/common/InsertTask.java
deleted file mode 100644
index ed86acd6e9f8bfb8c862c1764e39f541d3f054eb..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/common/InsertTask.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.taosdata.demo.common;
-
-import org.apache.log4j.Logger;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Random;
-
-public class InsertTask implements Runnable {
- private final Random random = new Random(System.currentTimeMillis());
- private static final Logger logger = Logger.getLogger(InsertTask.class);
-
- private final DataSource ds;
- private final int batchSize;
- private final String dbName;
- private final int tableSize;
-
- public InsertTask(DataSource ds, String dbName, int tableSize, int batchSize) {
- this.ds = ds;
- this.dbName = dbName;
- this.tableSize = tableSize;
- this.batchSize = batchSize;
- }
-
- @Override
- public void run() {
- Connection conn = null;
- Statement stmt = null;
- int affectedRows = 0;
-
- long start = System.currentTimeMillis();
- try {
- conn = ds.getConnection();
- stmt = conn.createStatement();
-
- for (int tb_index = 1; tb_index <= tableSize; tb_index++) {
- StringBuilder sb = new StringBuilder();
- sb.append("insert into ");
- sb.append(dbName);
- sb.append(".t_");
- sb.append(tb_index);
- sb.append("(ts, temperature, humidity) values ");
- for (int i = 0; i < batchSize; i++) {
- sb.append("(");
- sb.append(start + i);
- sb.append(", ");
- sb.append(random.nextFloat() * 30);
- sb.append(", ");
- sb.append(random.nextInt(70));
- sb.append(") ");
- }
- logger.info("SQL >>> " + sb.toString());
- affectedRows += stmt.executeUpdate(sb.toString());
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- logger.info(">>> affectedRows:" + affectedRows + " TimeCost:" + (System.currentTimeMillis() - start) + " ms");
- }
- }
-}
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java
similarity index 54%
rename from tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java
rename to tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java
index 4e33b75bc57aa18ebc0cae166e84401d4357d614..bd57d138b21034f45569ab3dcfc8e1ad5b39263d 100644
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java
@@ -1,10 +1,10 @@
-package com.taosdata.demo;
+package com.taosdata.example;
-import com.taosdata.demo.common.InsertTask;
-import com.taosdata.demo.pool.C3p0Builder;
-import com.taosdata.demo.pool.DbcpBuilder;
-import com.taosdata.demo.pool.DruidPoolBuilder;
-import com.taosdata.demo.pool.HikariCpBuilder;
+import com.taosdata.example.common.InsertTask;
+import com.taosdata.example.pool.C3p0Builder;
+import com.taosdata.example.pool.DbcpBuilder;
+import com.taosdata.example.pool.DruidPoolBuilder;
+import com.taosdata.example.pool.HikariCpBuilder;
import org.apache.log4j.Logger;
import javax.sql.DataSource;
@@ -20,44 +20,43 @@ public class ConnectionPoolDemo {
private static Logger logger = Logger.getLogger(DruidPoolBuilder.class);
private static final String dbName = "pool_test";
- private static int batchSize = 10;
- private static int sleep = 1000;
- private static int poolSize = 50;
- private static int tableSize = 1000;
- private static int threadCount = 50;
private static String poolType = "hikari";
+ private static long totalSize = 1_000_000l;
+ private static long tableSize = 1;
+ private static long batchSize = 1;
+ private static int poolSize = 50;
+ private static int threadCount = 50;
+ private static int sleep = 0;
- public static void main(String[] args) throws InterruptedException {
+ public static void main(String[] args) {
String host = null;
for (int i = 0; i < args.length; i++) {
if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) {
host = args[++i];
}
- if ("-batchSize".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- batchSize = Integer.parseInt(args[++i]);
- }
- if ("-sleep".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- sleep = Integer.parseInt(args[++i]);
+ if ("-poolType".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ poolType = args[++i];
}
- if ("-poolSize".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- poolSize = Integer.parseInt(args[++i]);
+ if ("-recordNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ totalSize = Long.parseLong(args[++i]);
}
- if ("-tableSize".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- tableSize = Integer.parseInt(args[++i]);
+ if ("-tableNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ tableSize = Long.parseLong(args[++i]);
}
- if ("-poolType".equalsIgnoreCase(args[i]) && i < args.length - 1) {
- poolType = args[++i];
+ if ("-batchNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) {
+ batchSize = Long.parseLong(args[++i]);
}
+
}
if (host == null) {
- System.out.println("Usage: java -jar XXX.jar " +
- "-host " +
- "-batchSize " +
- "-sleep " +
- "-poolSize " +
- "-tableSize " +
- "-poolType ");
+ System.out.println("Usage: java -jar XXX.jar -host " +
+ "-poolType " +
+ "-recordNumber " +
+ "-tableNumber " +
+ "-batchNumber " +
+ "-sleep "
+ );
return;
}
@@ -79,30 +78,35 @@ public class ConnectionPoolDemo {
}
logger.info(">>>>>>>>>>>>>> connection pool Type: " + poolType);
-
init(dataSource);
- try {
- Connection connection = dataSource.getConnection();
- Statement statement = connection.createStatement();
- String sql = "insert into " + dbName + ".t_1 values('2020-01-01 00:00:00.000',12.12,111)";
- int affectRows = statement.executeUpdate(sql);
- System.out.println("affectRows >>> " + affectRows);
- affectRows = statement.executeUpdate(sql);
- System.out.println("affectRows >>> " + affectRows);
- statement.close();
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
+// try {
+// Connection connection = dataSource.getConnection();
+// Statement statement = connection.createStatement();
+// String sql = "insert into " + dbName + ".t_1 values('2020-01-01 00:00:00.000',12.12,111)";
+// int affectRows = statement.executeUpdate(sql);
+// System.out.println("affectRows >>> " + affectRows);
+// affectRows = statement.executeUpdate(sql);
+// System.out.println("affectRows >>> " + affectRows);
+// statement.close();
+// connection.close();
+// } catch (SQLException e) {
+// e.printStackTrace();
+// }
+ ExecutorService executor = Executors.newFixedThreadPool(threadCount);
+ for (long i = 0; i < totalSize / tableSize / batchSize; i++) {
+ executor.execute(new InsertTask(dataSource, dbName, tableSize, batchSize));
+ // sleep few seconds
+ try {
+ if (sleep > 0)
+ TimeUnit.MILLISECONDS.sleep(sleep);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ executor.shutdown();
-// ExecutorService executor = Executors.newFixedThreadPool(threadCount);
-// while (true) {
-// executor.execute(new InsertTask(dataSource, dbName, tableSize, batchSize));
-// if (sleep > 0)
-// TimeUnit.MILLISECONDS.sleep(sleep);
-// }
}
private static void init(DataSource dataSource) {
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..da7c9a22b5b3e7f5d877a3a1489d55f439bff883
--- /dev/null
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java
@@ -0,0 +1,46 @@
+package com.taosdata.example.common;
+
+import org.apache.log4j.Logger;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Random;
+
+public class InsertTask implements Runnable {
+ private final Random random = new Random(System.currentTimeMillis());
+ private static final Logger logger = Logger.getLogger(InsertTask.class);
+
+ private final DataSource ds;
+ private final String dbName;
+ private final long tableSize;
+ private final long batchSize;
+
+ public InsertTask(DataSource ds, String dbName, long tableSize, long batchSize) {
+ this.ds = ds;
+ this.dbName = dbName;
+ this.tableSize = tableSize;
+ this.batchSize = batchSize;
+ }
+
+ @Override
+ public void run() {
+ int affectedRows = 0;
+ long start = System.currentTimeMillis();
+ try (Connection conn = ds.getConnection(); Statement stmt = conn.createStatement()) {
+ for (int tb_index = 1; tb_index <= tableSize; tb_index++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("insert into ").append(dbName).append(".t_").append(tb_index).append("(ts, temperature, humidity) values ");
+ for (int i = 0; i < batchSize; i++) {
+ sb.append("(").append(start + i).append(", ").append(random.nextFloat() * 30).append(", ").append(random.nextInt(70)).append(") ");
+ }
+ logger.info("SQL >>> " + sb.toString());
+ affectedRows += stmt.executeUpdate(sb.toString());
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ logger.info(">>> affectedRows:" + affectedRows + " TimeCost:" + (System.currentTimeMillis() - start) + " ms");
+ }
+}
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/C3p0Builder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java
similarity index 89%
rename from tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/C3p0Builder.java
rename to tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java
index 587f417410f96f43be2ced5a4820cd49cdb99a17..235db0bb796ee507b2d93838c8e7bfa7de870fcd 100644
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/C3p0Builder.java
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java
@@ -1,7 +1,6 @@
-package com.taosdata.demo.pool;
+package com.taosdata.example.pool;
import com.mchange.v2.c3p0.ComboPooledDataSource;
-import org.apache.commons.dbcp.BasicDataSource;
import javax.sql.DataSource;
import java.beans.PropertyVetoException;
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DbcpBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java
similarity index 93%
rename from tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DbcpBuilder.java
rename to tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java
index 3c34a32532f595bf3134942094e96e952bd09dbb..3aa9e4ebcf2d07ba1e6a51a2dae216cf44e88486 100644
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DbcpBuilder.java
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java
@@ -1,4 +1,4 @@
-package com.taosdata.demo.pool;
+package com.taosdata.example.pool;
import org.apache.commons.dbcp.BasicDataSource;
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DruidPoolBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java
similarity index 66%
rename from tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DruidPoolBuilder.java
rename to tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java
index a03e9758b6cb62b0f16a80cbf569feab036508aa..500f0e9e97cc09c2c5e9990234f051d0bbc72044 100644
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/DruidPoolBuilder.java
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java
@@ -1,4 +1,4 @@
-package com.taosdata.demo.pool;
+package com.taosdata.example.pool;
import com.alibaba.druid.pool.DruidDataSource;
@@ -11,19 +11,17 @@ public class DruidPoolBuilder {
DruidDataSource dataSource = new DruidDataSource();
// jdbc properties
- dataSource.setUrl(url);
dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
+ dataSource.setUrl(url);
dataSource.setUsername("root");
dataSource.setPassword("taosdata");
-
// pool configurations
- dataSource.setInitialSize(poolSize);//初始连接数,默认0
- dataSource.setMinIdle(poolSize);//最小闲置数
- dataSource.setMaxActive(poolSize);//最大连接数,默认8
- dataSource.setMaxWait(30000);//获取连接的最大等待时间,单位毫秒
+ dataSource.setInitialSize(poolSize);
+ dataSource.setMinIdle(poolSize);
+ dataSource.setMaxActive(poolSize);
+ dataSource.setMaxWait(30000);
dataSource.setValidationQuery("select server_status()");
return dataSource;
}
-
}
diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/HikariCpBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java
similarity index 74%
rename from tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/HikariCpBuilder.java
rename to tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java
index 2e50dcacffc5f27c449f1e2a3a97284c85d86b99..7e151de3e052495b3ce50ffe042732717fcc38f4 100644
--- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/pool/HikariCpBuilder.java
+++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java
@@ -1,4 +1,4 @@
-package com.taosdata.demo.pool;
+package com.taosdata.example.pool;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@@ -15,9 +15,10 @@ public class HikariCpBuilder {
config.setUsername("root");
config.setPassword("taosdata");
// pool configurations
- config.setMinimumIdle(3); //minimum number of idle connection
- config.setMaximumPoolSize(10); //maximum number of connection in the pool
+ config.setMinimumIdle(poolSize); //minimum number of idle connection
+ config.setMaximumPoolSize(poolSize); //maximum number of connection in the pool
config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool
+ config.setMaxLifetime(0); // maximum life time for each connection
config.setIdleTimeout(0); // max idle time for recycle idle connection
config.setConnectionTestQuery("select server_status()"); //validation query
diff --git a/tests/examples/JDBC/mybatisplus-demo/pom.xml b/tests/examples/JDBC/mybatisplus-demo/pom.xml
index e59b915d2cba0c53bfcea36782ba25f4fa19c37b..a83d0a00e69bdcffff2db8b17c763959dc67365b 100644
--- a/tests/examples/JDBC/mybatisplus-demo/pom.xml
+++ b/tests/examples/JDBC/mybatisplus-demo/pom.xml
@@ -47,15 +47,9 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.14
+ 2.0.18
-
-
- mysql
- mysql-connector-java
- 5.1.47
-
org.springframework.boot
spring-boot-starter-web
diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
index 71e518602e8f68b9f6691cba60cb6ad0de247bfe..38180c6d75a620a63bcaab9ec350d97e65f9dd16 100644
--- a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
+++ b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
@@ -1,19 +1,15 @@
spring:
datasource:
driver-class-name: com.taosdata.jdbc.TSDBDriver
- url: jdbc:TAOS://localhost:6030/mp_test
+ url: jdbc:TAOS://localhost:6030/mp_test?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
user: root
password: taosdata
- charset: UTF-8
- locale: en_US.UTF-8
- timezone: UTC-8
druid:
initial-size: 5
min-idle: 5
max-active: 5
-
mybatis-plus:
configuration:
map-underscore-to-camel-case: false
diff --git a/tests/examples/JDBC/springbootdemo/pom.xml b/tests/examples/JDBC/springbootdemo/pom.xml
index 881ea0d6bf485891a29427853bd1bbf9b294c2d8..52fb8caa90b1ee8ef0566ee7e87aae5199b6ea73 100644
--- a/tests/examples/JDBC/springbootdemo/pom.xml
+++ b/tests/examples/JDBC/springbootdemo/pom.xml
@@ -8,7 +8,7 @@
2.2.1.RELEASE
- com.taosdata.jdbc
+ com.taosdata.example
springbootdemo
0.0.1-SNAPSHOT
springbootdemo
@@ -63,7 +63,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.4
+ 2.0.18
@@ -71,8 +71,6 @@
druid-spring-boot-starter
1.1.17
-
-
diff --git a/tests/examples/JDBC/springbootdemo/readme.md b/tests/examples/JDBC/springbootdemo/readme.md
index ac3bb44ef95c251e25c664cd50414494e19f6820..67a28947d2dfb8fc069bf94fd139a7006d35a22b 100644
--- a/tests/examples/JDBC/springbootdemo/readme.md
+++ b/tests/examples/JDBC/springbootdemo/readme.md
@@ -47,7 +47,7 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
* 插入单条记录
```xml
-
+
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
```
@@ -67,9 +67,9 @@ logging.level.com.taosdata.jdbc.springbootdemo.dao=debug
-
+
-
+
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
similarity index 66%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
index f693214567fb3e8780e8ee1a867cf765de0ec8d7..8066126d62b195d3a5c16f3c580d6ff07fe32648 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplication.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
@@ -1,15 +1,13 @@
-package com.taosdata.jdbc.springbootdemo;
+package com.taosdata.example.springbootdemo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-@MapperScan(basePackages = {"com.taosdata.jdbc.springbootdemo.dao"})
+@MapperScan(basePackages = {"com.taosdata.example.springbootdemo.dao"})
@SpringBootApplication
-public class cd {
-
+public class SpringbootdemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootdemoApplication.class, args);
}
-
}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
similarity index 87%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
index 56a58fbb4d9a783a34989eae00369ff7b307acaf..4a4109dcf326bd82067e3ab7153547f926e9f5ae 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
@@ -1,7 +1,7 @@
-package com.taosdata.jdbc.springbootdemo.controller;
+package com.taosdata.example.springbootdemo.controller;
-import com.taosdata.jdbc.springbootdemo.domain.Weather;
-import com.taosdata.jdbc.springbootdemo.service.WeatherService;
+import com.taosdata.example.springbootdemo.domain.Weather;
+import com.taosdata.example.springbootdemo.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -45,7 +45,6 @@ public class WeatherController {
*/
@PostMapping("/{temperature}/{humidity}")
public int saveWeather(@PathVariable int temperature, @PathVariable float humidity) {
-
return weatherService.save(temperature, humidity);
}
@@ -57,7 +56,6 @@ public class WeatherController {
*/
@PostMapping("/batch")
public int batchSaveWeather(@RequestBody List weatherList) {
-
return weatherService.save(weatherList);
}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
similarity index 74%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
index 1e3db1f49106606c412851c0a74ad382adea68fb..cae1a1aec03297d79bd8b7deb7ef1c387f81d740 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
@@ -1,6 +1,6 @@
-package com.taosdata.jdbc.springbootdemo.dao;
+package com.taosdata.example.springbootdemo.dao;
-import com.taosdata.jdbc.springbootdemo.domain.Weather;
+import com.taosdata.example.springbootdemo.domain.Weather;
import org.apache.ibatis.annotations.Param;
import java.util.List;
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
similarity index 84%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
index e894f9a6583d271d8ce526e9afe79528f0fd5490..a9bcda0b00ca73f133b2f31622e5d6e0b034e5bf 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
@@ -1,9 +1,9 @@
-
+
-
+
@@ -34,7 +34,7 @@
-
+
insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT})
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
similarity index 93%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
index cd7de447eade4a126c86c38c703d6a4de444c557..60565448ad7d66bb713e46ca5f62b41bbe905893 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
@@ -1,4 +1,4 @@
-package com.taosdata.jdbc.springbootdemo.domain;
+package com.taosdata.example.springbootdemo.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
similarity index 82%
rename from tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java
rename to tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
index b950a9a4e42e306320415c7be556ba78c2f25a27..31ce8f1dd96b7f4d006b0b10acf722f262afda33 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
@@ -1,7 +1,7 @@
-package com.taosdata.jdbc.springbootdemo.service;
+package com.taosdata.example.springbootdemo.service;
-import com.taosdata.jdbc.springbootdemo.dao.WeatherMapper;
-import com.taosdata.jdbc.springbootdemo.domain.Weather;
+import com.taosdata.example.springbootdemo.dao.WeatherMapper;
+import com.taosdata.example.springbootdemo.domain.Weather;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
deleted file mode 100644
index 844ac21bb8855de06edcc586deb713bcad686385..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.controller;
-
-
-import com.taosdata.jdbc.springbootdemo.domain.Rainfall;
-import com.taosdata.jdbc.springbootdemo.service.RainStationService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-@RestController
-@RequestMapping("/rainstation")
-public class RainStationController {
-
- @Autowired
- private RainStationService service;
-
- @GetMapping("/init")
- public boolean init() {
- service.init();
- service.createTable();
- return true;
- }
-
- @PostMapping("/insert")
- public int insert(@RequestBody Rainfall rainfall){
- return service.insert(rainfall);
- }
-
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
deleted file mode 100644
index a9266acb3028c453062ce6e56ccade53c405f742..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.dao;
-
-import java.util.Map;
-
-public interface DatabaseMapper {
-
- int createDatabase(String dbname);
-
- int dropDatabase(String dbname);
-
- int creatDatabaseWithParameters(Map map);
-
- int useDatabase(String dbname);
-
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
deleted file mode 100644
index 329f75b582a276bed522e671d0c9f868b837c172..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
- create database if not exists ${dbname}
-
-
-
- DROP database if exists ${dbname}
-
-
-
-
- CREATE database if not EXISTS ${dbname}
-
- KEEP ${keep}
-
-
- DAYS ${days}
-
-
- REPLICA ${replica}
-
-
- cache ${cache}
-
-
- blocks ${blocks}
-
-
- minrows ${minrows}
-
-
- maxrows ${maxrows}
-
-
-
-
- use ${dbname}
-
-
-
\ No newline at end of file
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
deleted file mode 100644
index f0efbf40ba477d9b8f410e0806be38701d274394..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.dao;
-
-import java.util.Map;
-
-public interface RainfallMapper {
-
-
- int save(Map map);
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
deleted file mode 100644
index 319b4f397434f1b7623c31250c8ba798c0499d86..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
- INSERT INTO ${table} using ${dbname}.${stable} tags(#{values.station_code}, #{values.station_name}) (ts, name, code, rainfall) values (#{values.ts}, #{values.name}, #{values.code}, #{values.rainfall})
-
-
-
-
\ No newline at end of file
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
deleted file mode 100644
index 7601bf974c7c727b2a46171b145bdcec662dc258..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.dao;
-
-import com.taosdata.jdbc.springbootdemo.domain.TableMetadata;
-
-public interface TableMapper {
-
- boolean createSTable(TableMetadata tableMetadata);
-}
\ No newline at end of file
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
deleted file mode 100644
index 5a272eadb4abd7637735a834ec445c822073486f..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
- create table if not exists ${dbname}.${tablename}
-
- ${field.name} ${field.type}
-
- TAGS
-
- ${tag.name} ${tag.type}
-
-
-
-
- drop ${tablename}
-
-
-
\ No newline at end of file
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
deleted file mode 100644
index 619b5a303d715132d6a428770a27d069a9b9dcaa..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.domain;
-
-public class FieldMetadata {
-
- private String name;
- private String type;
-
- public FieldMetadata(String name, String type) {
- this.name = name;
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
deleted file mode 100644
index 93e199d7e66582e7f8d771994b358a2c58f5dae2..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.domain;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import java.sql.Timestamp;
-
-public class Rainfall {
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
- private Timestamp ts;
- private String name;
- private String code;
- private float rainfall;
- private String station_code;
- private String station_name;
-
- public Timestamp getTs() {
- return ts;
- }
-
- public void setTs(Timestamp ts) {
- this.ts = ts;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public float getRainfall() {
- return rainfall;
- }
-
- public void setRainfall(float rainfall) {
- this.rainfall = rainfall;
- }
-
- public String getStation_code() {
- return station_code;
- }
-
- public void setStation_code(String station_code) {
- this.station_code = station_code;
- }
-
- public String getStation_name() {
- return station_name;
- }
-
- public void setStation_name(String station_name) {
- this.station_name = station_name;
- }
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
deleted file mode 100644
index 74bb434f08484af6c244dd884570c974ab93e634..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.domain;
-
-import java.util.List;
-
-public class TableMetadata {
-
- private String dbname;
- private String tablename;
- private List fields;
- private List tags;
-
- public String getDbname() {
- return dbname;
- }
-
- public void setDbname(String dbname) {
- this.dbname = dbname;
- }
-
- public String getTablename() {
- return tablename;
- }
-
- public void setTablename(String tablename) {
- this.tablename = tablename;
- }
-
- public List getFields() {
- return fields;
- }
-
- public void setFields(List fields) {
- this.fields = fields;
- }
-
- public List getTags() {
- return tags;
- }
-
- public void setTags(List tags) {
- this.tags = tags;
- }
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
deleted file mode 100644
index 755ecc0075506c4ba2c99eafa47593a69a50bd84..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.domain;
-
-public class TagMetadata {
- private String name;
- private String type;
-
- public TagMetadata(String name, String type) {
- this.name = name;
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
deleted file mode 100644
index 3ea63c1760d4aef9e11a076eaff0c19df3a3a73c..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.taosdata.jdbc.springbootdemo.service;
-
-import com.taosdata.jdbc.springbootdemo.dao.DatabaseMapper;
-import com.taosdata.jdbc.springbootdemo.dao.RainfallMapper;
-import com.taosdata.jdbc.springbootdemo.dao.TableMapper;
-import com.taosdata.jdbc.springbootdemo.domain.FieldMetadata;
-import com.taosdata.jdbc.springbootdemo.domain.Rainfall;
-import com.taosdata.jdbc.springbootdemo.domain.TableMetadata;
-import com.taosdata.jdbc.springbootdemo.domain.TagMetadata;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@Service
-public class RainStationService {
-
- @Autowired
- private DatabaseMapper databaseMapper;
- @Autowired
- private TableMapper tableMapper;
- @Autowired
- private RainfallMapper rainfallMapper;
-
- public boolean init() {
- databaseMapper.dropDatabase("rainstation");
-
- Map map = new HashMap<>();
- map.put("dbname", "rainstation");
- map.put("keep", "36500");
- map.put("days", "30");
- map.put("blocks", "4");
- databaseMapper.creatDatabaseWithParameters(map);
-
- databaseMapper.useDatabase("rainstation");
- return true;
- }
-
- public boolean createTable() {
- TableMetadata tableMetadata = new TableMetadata();
- tableMetadata.setDbname("rainstation");
- tableMetadata.setTablename("monitoring");
-
- List fields = new ArrayList<>();
- fields.add(new FieldMetadata("ts", "timestamp"));
- fields.add(new FieldMetadata("name", "NCHAR(10)"));
- fields.add(new FieldMetadata("code", " BINARY(8)"));
- fields.add(new FieldMetadata("rainfall", "float"));
- tableMetadata.setFields(fields);
-
- List tags = new ArrayList<>();
- tags.add(new TagMetadata("station_code", "BINARY(8)"));
- tags.add(new TagMetadata("station_name", "NCHAR(10)"));
- tableMetadata.setTags(tags);
-
- tableMapper.createSTable(tableMetadata);
- return true;
- }
-
-
- public int insert(Rainfall rainfall) {
- Map map = new HashMap<>();
- map.put("dbname", "rainstation");
- map.put("table", "S_53646");
- map.put("stable", "monitoring");
- map.put("values", rainfall);
- return rainfallMapper.save(map);
- }
-}
\ No newline at end of file
diff --git a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
index 683884fcdd852fd1a72c685b40c6a8517ed92ff4..4fb68758c454b923c0a19e2e723a86c8b56ed88d 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
+++ b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
@@ -1,24 +1,18 @@
-# datasource config
+# datasource config - JDBC-JNI
spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
-spring.datasource.url=jdbc:TAOS://localhost:6030/log
+spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username=root
spring.datasource.password=taosdata
+# datasource config - JDBC-RESTful
+#spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
+#spring.datasource.url=jdbc:TAOS-RS://master:6041/test?user=root&password=taosdata
+
spring.datasource.druid.initial-size=5
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-active=5
-# max wait time for get connection, ms
-spring.datasource.druid.max-wait=60000
-
+spring.datasource.druid.max-wait=30000
spring.datasource.druid.validation-query=select server_status();
-spring.datasource.druid.validation-query-timeout=5000
-spring.datasource.druid.test-on-borrow=false
-spring.datasource.druid.test-on-return=false
-spring.datasource.druid.test-while-idle=true
-spring.datasource.druid.time-between-eviction-runs-millis=60000
-spring.datasource.druid.min-evictable-idle-time-millis=600000
-spring.datasource.druid.max-evictable-idle-time-millis=900000
-
#mybatis
mybatis.mapper-locations=classpath:mapper/*.xml
diff --git a/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java b/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java
deleted file mode 100644
index 23a7420dab24a15d9d24341839ba58caa9acb4b9..0000000000000000000000000000000000000000
--- a/tests/examples/JDBC/springbootdemo/src/test/java/com/taosdata/jdbc/springbootdemo/SpringbootdemoApplicationTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.taosdata.jdbc.springbootdemo;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class SpringbootdemoApplicationTests {
-
- @Test
- void contextLoads() {
- }
-
-}
diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml
index 15f868a117238956e79d58222809140e2a098144..a6cbe4615e0ec132f789a1edcc63fdde6fb0ad9c 100644
--- a/tests/examples/JDBC/taosdemo/pom.xml
+++ b/tests/examples/JDBC/taosdemo/pom.xml
@@ -67,7 +67,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.17
+ 2.0.18
diff --git a/tests/pytest/cluster/clusterEnvSetup/basic.py b/tests/pytest/cluster/clusterEnvSetup/basic.py
new file mode 100644
index 0000000000000000000000000000000000000000..10ba91ab06704f9373b7c7a4c1d2cab72287d0dd
--- /dev/null
+++ b/tests/pytest/cluster/clusterEnvSetup/basic.py
@@ -0,0 +1,26 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import os
+import random
+
+class ClusterTestcase:
+
+
+ def run(self):
+ os.system("./buildClusterEnv.sh -n 3 -v 2.0.14.1")
+ os.system("yes|taosdemo -h 172.27.0.7 -n 100 -t 100 -x")
+ os.system("python3 ../../concurrent_inquiry.py -H 172.27.0.7 -T 4 -t 4 -l 10")
+
+clusterTest = ClusterTestcase()
+clusterTest.run()
\ No newline at end of file
diff --git a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
index e0788ef329b6d513bce52ea0261c1b770c9352bc..973d000a0ad582d3aba90fc1f7ff8f7d88812473 100755
--- a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
+++ b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh
@@ -85,18 +85,18 @@ function clusterUp {
cd $DOCKER_DIR
if [ $NUM_OF_NODES -eq 3 ]; then
- PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION docker-compose up -d
+ PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose up -d
fi
if [ $NUM_OF_NODES -eq 4 ]; then
- PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION docker-compose -f docker-compose.yml -f node4.yml up -d
+ PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node4.yml up -d
fi
if [ $NUM_OF_NODES -eq 5 ]; then
- PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION docker-compose -f docker-compose.yml -f node4.yml -f node5.yml up -d
+ PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node4.yml -f node5.yml up -d
fi
}
cleanEnv
-# prepareBuild
-# clusterUp
\ No newline at end of file
+prepareBuild
+clusterUp
\ No newline at end of file
diff --git a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml
index c8498b36d4a0f15ad70b0d258c37546ea6aec55c..c45a09582b5cd46a20ce052f3f535def67c46232 100644
--- a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml
+++ b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml
@@ -7,7 +7,7 @@ services:
args:
- PACKAGE=${PACKAGE}
- EXTRACTDIR=${DIR}
- image: 'tdengine:2.0.13.1'
+ image: 'tdengine:${VERSION}'
container_name: 'td2.0-node1'
cap_add:
- ALL
@@ -34,7 +34,8 @@ services:
target: /etc/taos
- type: bind
source: /data
- target: /root
+ target: /root
+ hostname: node1
networks:
taos_update_net:
ipv4_address: 172.27.0.7
@@ -46,7 +47,7 @@ services:
args:
- PACKAGE=${PACKAGE}
- EXTRACTDIR=${DIR}
- image: 'tdengine:2.0.13.1'
+ image: 'tdengine:${VERSION}'
container_name: 'td2.0-node2'
cap_add:
- ALL
@@ -85,7 +86,7 @@ services:
args:
- PACKAGE=${PACKAGE}
- EXTRACTDIR=${DIR}
- image: 'tdengine:2.0.13.1'
+ image: 'tdengine:${VERSION}'
container_name: 'td2.0-node3'
cap_add:
- ALL
diff --git a/tests/pytest/multilevel/fileDistributionSameLevel.py b/tests/pytest/multilevel/fileDistributionSameLevel.py
index 88a7216b8e6a6388d8d65bf8bd6ca530e662327f..83ce85671771c4d2627541e80262ef8c764e45c3 100644
--- a/tests/pytest/multilevel/fileDistributionSameLevel.py
+++ b/tests/pytest/multilevel/fileDistributionSameLevel.py
@@ -18,18 +18,36 @@ from util.cases import *
from util.sql import *
from util.dnodes import *
-
+dataDir = ['data00','data01','data02','data03','data04']
+dataDict = {'data00':0,'data01':0,'data02':0,'data03':0,'data04':0}
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
+ def getfiles(self,ospath):
+ try:
+ files = os.listdir(ospath)
+ for f in files:
+ path = os.path.join(ospath, f)
+ if os.path.isfile(path):
+ if path.endswith('.data'):
+ for i in dataDir:
+ if i in path:
+ dataDict[i] = dataDict[i] + 1
+ print(path)
+ if os.path.isdir(path):
+ self.getfiles(path)
+ except Exception as e :
+ print(str(e))
+
def run(self):
self.ntables = 1000
self.ts = 1520000010000
tdDnodes.stop(1)
# Test1 1 dataDir
+ tdLog.info("================= step1")
cfg={
'10' : 'maxVgroupsPerDb',
'100' : 'maxTablesPerVnode',
@@ -55,15 +73,33 @@ class TDTestCase:
for i in range(self.ntables):
tdSql.execute("create table tb%d using stb tags(%d)" %(i, i))
- tdSql.execute("insert into tb%d values(%d, 1)" % (self.ts + int (i / 100) * 86400000))
-
+ tdSql.execute("insert into tb%d values(%d, 1)" % (i,self.ts + int (i / 100) * 86400000))
+
+ tdLog.info("================= step2")
tdDnodes.stop(1)
tdDnodes.start(1)
tdSql.query("select * from test.stb")
tdSql.checkRows(1000)
-
+ tdLog.info("================= step3")
+ tdSql.execute('drop database test')
+ for i in range(50):
+ tdSql.execute("create database test%d days 1" %(i))
+ tdSql.execute("use test%d" %(i))
+ tdSql.execute("create table tb (ts timestamp,i int)")
+ for j in range(10):
+ tdSql.execute("insert into tb values(%d, 1)" % (self.ts + int (i / 100) * 86400000))
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+ flag = True
+ for i in range(4):
+ if dataDict[dataDir[i]] == dataDict[dataDir[i+1]]:
+ flag = flag & True
+ else:
+ flag = flag & False
+ break
+ if not flag : tdLog.exit("%s failed, expect not occured" % (sys.argv[0]))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
diff --git a/tests/pytest/stream/stream3.py b/tests/pytest/stream/stream3.py
new file mode 100644
index 0000000000000000000000000000000000000000..9a5c6c9aeca08bff1c94861255919255eef89100
--- /dev/null
+++ b/tests/pytest/stream/stream3.py
@@ -0,0 +1,108 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+import time
+import taos
+from util.log import tdLog
+from util.cases import tdCases
+from util.sql import tdSql
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug("start to execute %s" % __file__)
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ ts = 1500000000000
+ tbNum = 10
+ rowNum = 20
+
+ tdSql.prepare()
+
+ tdLog.info("===== step1 =====")
+ tdSql.execute(
+ "create table stb0(ts timestamp, col1 binary(20), col2 nchar(20)) tags(tgcol int)")
+ for i in range(tbNum):
+ tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i))
+ for j in range(rowNum):
+ tdSql.execute(
+ "insert into tb%d values (%d, 'binary%d', 'nchar%d')" %
+ (i, ts + 60000 * j, j, j))
+ tdSql.execute("insert into tb0 values(%d, null, null)" % (ts + 10000000))
+ time.sleep(0.1)
+
+ tdLog.info("===== step2 =====")
+ tdSql.query(
+ "select count(*), count(col1), count(col2) from stb0 interval(1d)")
+ tdSql.checkData(0, 1, rowNum * tbNum + 1)
+ tdSql.checkData(0, 2, rowNum * tbNum)
+ tdSql.checkData(0, 3, rowNum * tbNum)
+
+ tdSql.query("show tables")
+ tdSql.checkRows(tbNum)
+ tdSql.execute(
+ "create table s0 as select count(*), count(col1), count(col2) from stb0 interval(1d)")
+ tdSql.query("show tables")
+ tdSql.checkRows(tbNum + 1)
+
+ tdLog.info("===== step3 =====")
+ tdSql.waitedQuery("select * from s0", 1, 120)
+ try:
+ tdSql.checkData(0, 1, rowNum * tbNum + 1)
+ tdSql.checkData(0, 2, rowNum * tbNum)
+ tdSql.checkData(0, 3, rowNum * tbNum)
+ except Exception as e:
+ tdLog.info(repr(e))
+
+ tdLog.info("===== step4 =====")
+ tdSql.execute("drop table s0")
+ tdSql.query("show tables")
+ tdSql.checkRows(tbNum)
+
+ tdLog.info("===== step5 =====")
+ tdSql.error("select * from s0")
+
+ tdLog.info("===== step6 =====")
+ time.sleep(0.1)
+ tdSql.execute(
+ "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)")
+ tdSql.query("show tables")
+ tdSql.checkRows(tbNum + 1)
+
+ tdLog.info("===== step7 =====")
+ tdSql.waitedQuery("select * from s0", 1, 120)
+ try:
+ tdSql.checkData(0, 1, rowNum + 1)
+ tdSql.checkData(0, 2, rowNum)
+ tdSql.checkData(0, 3, rowNum)
+ except Exception as e:
+ tdLog.info(repr(e))
+
+ tdLog.info("===== step8 =====")
+ tdSql.query(
+ "select count(*), count(col1), count(col2) from stb0 interval(1d)")
+ tdSql.checkData(0, 1, rowNum * tbNum + 1)
+ tdSql.checkData(0, 2, rowNum * tbNum)
+ tdSql.checkData(0, 3, rowNum * tbNum)
+ tdSql.query("show tables")
+ tdSql.checkRows(tbNum + 1)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success("%s successfully executed" % __file__)
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt
index b5f608f3d33da7a34c9eb3b62457fe3a6eebdb70..4f42d043d93a76e6e0435c80ee92d4b5f022f02a 100644
--- a/tests/script/jenkins/basic.txt
+++ b/tests/script/jenkins/basic.txt
@@ -196,6 +196,7 @@ cd ../../../debug; make
./test.sh -f general/table/table.sim
./test.sh -f general/table/tinyint.sim
./test.sh -f general/table/vgroup.sim
+./test.sh -f general/table/createmulti.sim
./test.sh -f general/tag/3.sim
./test.sh -f general/tag/4.sim
diff --git a/tests/script/jenkins/basic_1.txt b/tests/script/jenkins/basic_1.txt
index c124b60f806ff2e082289fa7e98b896a77e9d3b9..7f7ef18368d7bcff536a0fdff19228fadbba8494 100644
--- a/tests/script/jenkins/basic_1.txt
+++ b/tests/script/jenkins/basic_1.txt
@@ -157,4 +157,4 @@
./test.sh -f general/table/table.sim
./test.sh -f general/table/tinyint.sim
./test.sh -f general/table/vgroup.sim
-
+./test.sh -f general/table/createmulti.sim
\ No newline at end of file
diff --git a/tests/script/jenkins/basic_2.txt b/tests/script/jenkins/basic_2.txt
index f35a0cd31dc33acc9aca77026ad33bc383162cd3..9b3b3f9b18dbf9520b0764f3a9299cb9c5d637db 100644
--- a/tests/script/jenkins/basic_2.txt
+++ b/tests/script/jenkins/basic_2.txt
@@ -10,7 +10,7 @@ cd ../../../debug; make
./test.sh -f general/tag/binary_binary.sim
./test.sh -f general/tag/binary.sim
./test.sh -f general/tag/bool_binary.sim
-#./test.sh -f general/tag/bool_int.sim
+./test.sh -f general/tag/bool_int.sim
./test.sh -f general/tag/bool.sim
./test.sh -f general/tag/change.sim
./test.sh -f general/tag/column.sim