Merge branch 'main' into merge/mainto3.0
This commit is contained in:
commit
d8dfe9532c
|
@ -6,7 +6,7 @@ description: 对表的各种管理操作
|
|||
|
||||
## 创建表
|
||||
|
||||
`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表。
|
||||
`CREATE TABLE` 语句用于创建普通表和以超级表为模板创建子表(也可以通过指定 TAGS 字段创建超级表)。
|
||||
|
||||
```sql
|
||||
CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definition] ...) [table_options]
|
||||
|
|
|
@ -46,7 +46,7 @@ static FORCE_INLINE bool mJoinBlkReachThreshold(SMJoinOperatorInfo* pInfo, int64
|
|||
return blkRows >= pInfo->ctx.mergeCtx.blkThreshold;
|
||||
}
|
||||
|
||||
return (pInfo->execInfo.resRows + blkRows) >= pInfo->ctx.mergeCtx.limit;
|
||||
return (pInfo->execInfo.resRows + blkRows) >= pInfo->ctx.mergeCtx.limit || blkRows >= pInfo->ctx.mergeCtx.blkThreshold;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,10 +44,10 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval);
|
|||
static int tfileWriteFooter(TFileWriter* write);
|
||||
|
||||
// handle file corrupt later
|
||||
static int tfileReaderLoadHeader(TFileReader* reader);
|
||||
static int tfileReaderLoadHeader(TFileReader* reader);
|
||||
static int32_t tfileReaderLoadFst(TFileReader* reader);
|
||||
static int tfileReaderVerify(TFileReader* reader);
|
||||
static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* result);
|
||||
static int tfileReaderVerify(TFileReader* reader);
|
||||
static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* result);
|
||||
|
||||
static int32_t tfileGetFileList(const char* path, SArray** pResult);
|
||||
static int tfileRmExpireFile(SArray* result);
|
||||
|
@ -106,6 +106,11 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) {
|
|||
|
||||
SArray* files = NULL;
|
||||
int32_t code = tfileGetFileList(path, &files);
|
||||
if (code != 0) {
|
||||
indexError("failed to get file list since %s", tstrerror(code));
|
||||
goto End;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < taosArrayGetSize(files); i++) {
|
||||
char* file = taosArrayGetP(files, i);
|
||||
|
||||
|
@ -1182,7 +1187,6 @@ _exception:
|
|||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
if (files != NULL) {
|
||||
taosArrayDestroyEx(files, tfileDestroyFileName);
|
||||
taosArrayDestroy(files);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ int32_t walLoadMeta(SWal* pWal);
|
|||
int32_t walSaveMeta(SWal* pWal);
|
||||
int32_t walRemoveMeta(SWal* pWal);
|
||||
int32_t walRollFileInfo(SWal* pWal);
|
||||
|
||||
int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, int64_t* lastVer);
|
||||
int32_t walCheckAndRepairMeta(SWal* pWal);
|
||||
|
||||
int32_t walCheckAndRepairIdx(SWal* pWal);
|
||||
|
|
|
@ -46,7 +46,7 @@ static FORCE_INLINE int walBuildTmpMetaName(SWal* pWal, char* buf) {
|
|||
return snprintf(buf, WAL_FILE_LEN, "%s/meta-ver.tmp", pWal->path);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, int64_t* lastVer) {
|
||||
FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, int64_t* lastVer) {
|
||||
int32_t code = 0, lino = 0;
|
||||
int32_t sz = taosArrayGetSize(pWal->fileInfoSet);
|
||||
int64_t retVer = -1;
|
||||
|
|
|
@ -127,7 +127,7 @@ class WalRetentionEnv : public ::testing::Test {
|
|||
SWalCfg cfg;
|
||||
cfg.rollPeriod = -1;
|
||||
cfg.segSize = -1;
|
||||
cfg.committed =-1;
|
||||
cfg.committed = -1;
|
||||
cfg.retentionPeriod = -1;
|
||||
cfg.retentionSize = 0;
|
||||
cfg.rollPeriod = 0;
|
||||
|
@ -146,6 +146,83 @@ class WalRetentionEnv : public ::testing::Test {
|
|||
const char* pathName = TD_TMP_DIR_PATH "wal_test";
|
||||
};
|
||||
|
||||
class WalSkipLevel : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
int code = walInit(NULL);
|
||||
ASSERT(code == 0);
|
||||
}
|
||||
|
||||
static void TearDownTestCase() { walCleanUp(); }
|
||||
|
||||
void walResetEnv() {
|
||||
TearDown();
|
||||
taosRemoveDir(pathName);
|
||||
SetUp();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
SWalCfg cfg;
|
||||
cfg.rollPeriod = -1;
|
||||
cfg.segSize = -1;
|
||||
cfg.committed = -1;
|
||||
cfg.retentionPeriod = -1;
|
||||
cfg.retentionSize = 0;
|
||||
cfg.rollPeriod = 0;
|
||||
cfg.vgId = 1;
|
||||
cfg.level = TAOS_WAL_SKIP;
|
||||
pWal = walOpen(pathName, &cfg);
|
||||
ASSERT(pWal != NULL);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
walClose(pWal);
|
||||
pWal = NULL;
|
||||
}
|
||||
|
||||
SWal* pWal = NULL;
|
||||
const char* pathName = TD_TMP_DIR_PATH "wal_test";
|
||||
};
|
||||
|
||||
class WalEncrypted : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
int code = walInit(NULL);
|
||||
ASSERT(code == 0);
|
||||
}
|
||||
|
||||
static void TearDownTestCase() { walCleanUp(); }
|
||||
|
||||
void walResetEnv() {
|
||||
TearDown();
|
||||
taosRemoveDir(pathName);
|
||||
SetUp();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
SWalCfg cfg;
|
||||
cfg.rollPeriod = -1;
|
||||
cfg.segSize = -1;
|
||||
cfg.committed = -1;
|
||||
cfg.retentionPeriod = -1;
|
||||
cfg.retentionSize = 0;
|
||||
cfg.rollPeriod = 0;
|
||||
cfg.vgId = 0;
|
||||
cfg.level = TAOS_WAL_FSYNC;
|
||||
cfg.encryptAlgorithm = 1;
|
||||
pWal = walOpen(pathName, &cfg);
|
||||
ASSERT(pWal != NULL);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
walClose(pWal);
|
||||
pWal = NULL;
|
||||
}
|
||||
|
||||
SWal* pWal = NULL;
|
||||
const char* pathName = TD_TMP_DIR_PATH "wal_test";
|
||||
};
|
||||
|
||||
TEST_F(WalCleanEnv, createNew) {
|
||||
walRollFileInfo(pWal);
|
||||
ASSERT(pWal->fileInfoSet != NULL);
|
||||
|
@ -373,6 +450,183 @@ TEST_F(WalKeepEnv, readHandleRead) {
|
|||
walCloseReader(pRead);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walLogExist) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
SWalReader* pRead = walOpenReader(pWal, NULL, 0);
|
||||
ASSERT(pRead != NULL);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, newStr, len);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
walLogExist(pWal, 0);
|
||||
ASSERT_EQ(code, 0);
|
||||
walCloseReader(pRead);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walScanLogGetLastVerHeadMissMatch) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
do {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, 0, 0, syncMeta, newStr, len);
|
||||
} while (0);
|
||||
|
||||
int i = 0;
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
int64_t offset = walGetCurFileOffset(pWal);
|
||||
SWalFileInfo* pFileInfo = walGetCurFileInfo(pWal);
|
||||
|
||||
pWal->writeHead.head.version = i;
|
||||
pWal->writeHead.head.bodyLen = len;
|
||||
pWal->writeHead.head.msgType = 0;
|
||||
pWal->writeHead.head.ingestTs = taosGetTimestampUs();
|
||||
|
||||
pWal->writeHead.head.syncMeta = syncMeta;
|
||||
|
||||
pWal->writeHead.cksumHead = 1;
|
||||
pWal->writeHead.cksumBody = walCalcBodyCksum(newStr, len);
|
||||
taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead));
|
||||
taosWriteFile(pWal->pLogFile, newStr, len);
|
||||
|
||||
int64_t lastVer = 0;
|
||||
code = walScanLogGetLastVer(pWal, 0, &lastVer);
|
||||
ASSERT_EQ(code, TSDB_CODE_WAL_CHKSUM_MISMATCH);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walScanLogGetLastVerBodyMissMatch) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
do {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, 0, 0, syncMeta, newStr, len);
|
||||
} while (0);
|
||||
|
||||
int i = 0;
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
int64_t offset = walGetCurFileOffset(pWal);
|
||||
SWalFileInfo* pFileInfo = walGetCurFileInfo(pWal);
|
||||
|
||||
pWal->writeHead.head.version = i;
|
||||
pWal->writeHead.head.bodyLen = len;
|
||||
pWal->writeHead.head.msgType = 0;
|
||||
pWal->writeHead.head.ingestTs = taosGetTimestampUs();
|
||||
|
||||
pWal->writeHead.head.syncMeta = syncMeta;
|
||||
|
||||
pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead);
|
||||
pWal->writeHead.cksumBody = 1;
|
||||
taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead));
|
||||
taosWriteFile(pWal->pLogFile, newStr, len);
|
||||
|
||||
int64_t lastVer = 0;
|
||||
code = walScanLogGetLastVer(pWal, 0, &lastVer);
|
||||
ASSERT_EQ(code, TSDB_CODE_WAL_CHKSUM_MISMATCH);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walCheckAndRepairIdxFile) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
do {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
sprintf(newStr, "%s-%d", ranStr, 0);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, 0, 0, syncMeta, newStr, len);
|
||||
} while (0);
|
||||
SWalFileInfo* pFileInfo = walGetCurFileInfo(pWal);
|
||||
for (int i = 1; i < 100; i++) {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
pWal->writeHead.head.version = i;
|
||||
pWal->writeHead.head.bodyLen = len;
|
||||
pWal->writeHead.head.msgType = 0;
|
||||
pWal->writeHead.head.ingestTs = taosGetTimestampUs();
|
||||
pWal->writeHead.head.syncMeta = syncMeta;
|
||||
pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead);
|
||||
pWal->writeHead.cksumBody = walCalcBodyCksum(newStr, len);
|
||||
taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead));
|
||||
taosWriteFile(pWal->pLogFile, newStr, len);
|
||||
}
|
||||
pWal->vers.lastVer = 99;
|
||||
pFileInfo->lastVer = 99;
|
||||
code = walCheckAndRepairIdx(pWal);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walRestoreFromSnapshot1) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, newStr, len);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
code = walRestoreFromSnapshot(pWal, 50);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walRestoreFromSnapshot2) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, newStr, len);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
SWalRef* ref = walOpenRef(pWal);
|
||||
ref->refVer = 10;
|
||||
code = walRestoreFromSnapshot(pWal, 99);
|
||||
ASSERT_EQ(code, -1);
|
||||
}
|
||||
|
||||
TEST_F(WalKeepEnv, walRollback) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 100; i++) {
|
||||
char newStr[100];
|
||||
sprintf(newStr, "%s-%d", ranStr, i);
|
||||
int len = strlen(newStr);
|
||||
code = walAppendLog(pWal, i, 0, syncMeta, newStr, len);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
code = walRollback(pWal, -1);
|
||||
ASSERT_EQ(code, TSDB_CODE_WAL_INVALID_VER);
|
||||
pWal->vers.lastVer = 50;
|
||||
pWal->vers.commitVer = 40;
|
||||
pWal->vers.snapshotVer = 40;
|
||||
SWalFileInfo* fileInfo = walGetCurFileInfo(pWal);
|
||||
|
||||
code = walRollback(pWal, 48);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
TEST_F(WalRetentionEnv, repairMeta1) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
|
@ -456,44 +710,6 @@ TEST_F(WalRetentionEnv, repairMeta1) {
|
|||
walCloseReader(pRead);
|
||||
}
|
||||
|
||||
class WalSkipLevel : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
int code = walInit(NULL);
|
||||
ASSERT(code == 0);
|
||||
}
|
||||
|
||||
static void TearDownTestCase() { walCleanUp(); }
|
||||
|
||||
void walResetEnv() {
|
||||
TearDown();
|
||||
taosRemoveDir(pathName);
|
||||
SetUp();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
SWalCfg cfg;
|
||||
cfg.rollPeriod = -1;
|
||||
cfg.segSize = -1;
|
||||
cfg.committed =-1;
|
||||
cfg.retentionPeriod = -1;
|
||||
cfg.retentionSize = 0;
|
||||
cfg.rollPeriod = 0;
|
||||
cfg.vgId = 1;
|
||||
cfg.level = TAOS_WAL_SKIP;
|
||||
pWal = walOpen(pathName, &cfg);
|
||||
ASSERT(pWal != NULL);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
walClose(pWal);
|
||||
pWal = NULL;
|
||||
}
|
||||
|
||||
SWal* pWal = NULL;
|
||||
const char* pathName = TD_TMP_DIR_PATH "wal_test";
|
||||
};
|
||||
|
||||
TEST_F(WalSkipLevel, restart) {
|
||||
walResetEnv();
|
||||
int code;
|
||||
|
@ -534,3 +750,14 @@ TEST_F(WalSkipLevel, roll) {
|
|||
code = walEndSnapshot(pWal);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
||||
|
||||
TEST_F(WalEncrypted, write) {
|
||||
int code;
|
||||
for (int i = 0; i < 100; i++) {
|
||||
code = walAppendLog(pWal, i, i + 1, syncMeta, (void*)ranStr, ranStrLen);
|
||||
ASSERT_EQ(code, 0);
|
||||
ASSERT_EQ(pWal->vers.lastVer, i);
|
||||
}
|
||||
code = walSaveMeta(pWal);
|
||||
ASSERT_EQ(code, 0);
|
||||
}
|
|
@ -519,7 +519,7 @@ int32_t cfgSetItemVal(SConfigItem *pItem, const char *name, const char *value, E
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (pItem == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_INVALID_CFG);
|
||||
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
|
||||
}
|
||||
switch (pItem->dtype) {
|
||||
case CFG_DTYPE_BOOL: {
|
||||
|
@ -629,6 +629,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
|||
cfgUnLock(pCfg);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if ((pItem->category == CFG_CATEGORY_GLOBAL) && alterType == CFG_ALTER_DNODE) {
|
||||
uError("failed to config:%s, not support update global config on only one dnode", name);
|
||||
cfgUnLock(pCfg);
|
||||
|
|
|
@ -908,12 +908,6 @@ const char* tstrerror(int32_t err) {
|
|||
(void)taosThreadOnce(&tsErrorInit, tsSortError);
|
||||
|
||||
// this is a system errno
|
||||
if ((err & 0x00ff0000) == 0x00ff0000) {
|
||||
int32_t code = err & 0x0000ffff;
|
||||
// strerror can handle any invalid code
|
||||
// invalid code return Unknown error
|
||||
return strerror(code);
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
if ((err & 0x01ff0000) == 0x01ff0000) {
|
||||
snprintf(WinAPIErrDesc, 256, "windows api error, code: 0x%08x", err & 0x0000ffff);
|
||||
|
@ -923,6 +917,13 @@ const char* tstrerror(int32_t err) {
|
|||
return WinAPIErrDesc;
|
||||
}
|
||||
#endif
|
||||
if ((err & 0x00ff0000) == 0x00ff0000) {
|
||||
int32_t code = err & 0x0000ffff;
|
||||
// strerror can handle any invalid code
|
||||
// invalid code return Unknown error
|
||||
return strerror(code);
|
||||
}
|
||||
|
||||
int32_t s = 0;
|
||||
int32_t e = sizeof(errors) / sizeof(errors[0]);
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "tconfig.h"
|
||||
|
||||
#ifndef WINDOWS
|
||||
#include "osFile.h"
|
||||
#endif
|
||||
|
||||
class CfgTest : public ::testing::Test {
|
||||
protected:
|
||||
static void SetUpTestSuite() {}
|
||||
|
@ -35,6 +39,9 @@ TEST_F(CfgTest, 01_Str) {
|
|||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ENV_CMD), "env_cmd");
|
||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_APOLLO_URL), "apollo_url");
|
||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ARG_LIST), "arg_list");
|
||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_TAOS_OPTIONS), "taos_options");
|
||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ALTER_CLIENT_CMD), "alter_client_cmd");
|
||||
EXPECT_STREQ(cfgStypeStr(CFG_STYPE_ALTER_SERVER_CMD), "alter_server_cmd");
|
||||
EXPECT_STREQ(cfgStypeStr(ECfgSrcType(1024)), "invalid");
|
||||
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_NONE), "none");
|
||||
|
@ -47,6 +54,10 @@ TEST_F(CfgTest, 01_Str) {
|
|||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DIR), "dir");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_DOUBLE), "double");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_LOCALE), "locale");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_CHARSET), "charset");
|
||||
EXPECT_STREQ(cfgDtypeStr(CFG_DTYPE_TIMEZONE), "timezone");
|
||||
EXPECT_STREQ(cfgDtypeStr(ECfgDataType(1024)), "invalid");
|
||||
}
|
||||
|
||||
|
@ -57,24 +68,30 @@ TEST_F(CfgTest, 02_Basic) {
|
|||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", TD_TMP_DIR_PATH, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 6, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 21, 0, 16, 0, 1, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0, 1, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 21, 0, 16, 0, 2, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0, 2, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 21, 0, 16, 0, 6, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0, 6, 0), 0);
|
||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0, 6, 0), 0);
|
||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", TD_TMP_DIR_PATH, 0, 6, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgGetSize(pConfig), 6);
|
||||
|
||||
int32_t size = cfgGetSize(pConfig);
|
||||
|
||||
SConfigItem* pItem = NULL;
|
||||
SConfigItem *pItem = NULL;
|
||||
SConfigIter *pIter = NULL;
|
||||
code = cfgCreateIter(pConfig, &pIter);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pIter, nullptr);
|
||||
|
||||
while((pItem = cfgNextIter(pIter)) != NULL) {
|
||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||
switch (pItem->dtype) {
|
||||
case CFG_DTYPE_BOOL:
|
||||
printf("index:%d, cfg:%s value:%d\n", size, pItem->name, pItem->bval);
|
||||
|
@ -115,12 +132,16 @@ TEST_F(CfgTest, 02_Basic) {
|
|||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT32);
|
||||
EXPECT_STREQ(pItem->name, "test_int32");
|
||||
EXPECT_EQ(pItem->i32, 1);
|
||||
code = cfgSetItem(pConfig, "test_int32", "21", CFG_STYPE_DEFAULT, true);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
pItem = cfgGetItem(pConfig, "test_int64");
|
||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_INT64);
|
||||
EXPECT_STREQ(pItem->name, "test_int64");
|
||||
EXPECT_EQ(pItem->i64, 2);
|
||||
code = cfgSetItem(pConfig, "test_int64", "21", CFG_STYPE_DEFAULT, true);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
pItem = cfgGetItem(pConfig, "test_float");
|
||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||
|
@ -140,5 +161,213 @@ TEST_F(CfgTest, 02_Basic) {
|
|||
EXPECT_STREQ(pItem->name, "test_dir");
|
||||
EXPECT_STREQ(pItem->str, TD_TMP_DIR_PATH);
|
||||
|
||||
code = cfgGetAndSetItem(pConfig, &pItem, "err_cfg", "err_val", CFG_STYPE_DEFAULT, true);
|
||||
ASSERT_EQ(code, TSDB_CODE_CFG_NOT_FOUND);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_int32", "4", false, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_INVALID_CFG);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_int64", "4", true, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_INVALID_CFG);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_bool", "3", false, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_int32", "74", true, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_int64", "74", false, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
code = cfgCheckRangeForDynUpdate(pConfig, "test_float", "74", false, CFG_ALTER_LOCAL);
|
||||
ASSERT_EQ(code, TSDB_CODE_OUT_OF_RANGE);
|
||||
|
||||
cfgCleanup(pConfig);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, initWithArray) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0, 0, 0), 0);
|
||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", TD_TMP_DIR_PATH, 0, 0, 0), 0);
|
||||
|
||||
SArray *pArgs = taosArrayInit(6, sizeof(SConfigPair));
|
||||
SConfigPair *pPair = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair->name = "test_bool";
|
||||
pPair->value = "1";
|
||||
taosArrayPush(pArgs, pPair);
|
||||
SConfigPair *pPair1 = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair1->name = "test_int32";
|
||||
pPair1->value = "2";
|
||||
taosArrayPush(pArgs, pPair1);
|
||||
SConfigPair *pPair2 = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair2->name = "test_int64";
|
||||
pPair2->value = "3";
|
||||
taosArrayPush(pArgs, pPair2);
|
||||
SConfigPair *pPair3 = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair3->name = "test_float";
|
||||
pPair3->value = "4";
|
||||
taosArrayPush(pArgs, pPair3);
|
||||
SConfigPair *pPair4 = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair4->name = "test_string";
|
||||
pPair4->value = "5";
|
||||
taosArrayPush(pArgs, pPair4);
|
||||
SConfigPair *pPair5 = (SConfigPair *)taosMemoryMalloc(sizeof(SConfigPair));
|
||||
pPair5->name = "test_dir";
|
||||
pPair5->value = TD_TMP_DIR_PATH;
|
||||
taosArrayPush(pArgs, pPair5);
|
||||
code = cfgLoadFromArray(pConfig, pArgs);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, cfgDumpItemCategory) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 6, 100), 0);
|
||||
|
||||
SConfigItem *pItem = NULL;
|
||||
pItem = cfgGetItem(pConfig, "test_bool");
|
||||
EXPECT_EQ(pItem->stype, CFG_STYPE_DEFAULT);
|
||||
EXPECT_EQ(pItem->dtype, CFG_DTYPE_BOOL);
|
||||
EXPECT_STREQ(pItem->name, "test_bool");
|
||||
EXPECT_EQ(pItem->bval, 0);
|
||||
|
||||
EXPECT_EQ(cfgDumpItemCategory(pItem, NULL, 0, 0), TSDB_CODE_INVALID_CFG);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, cfgDumpCfgS3) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
cfgAddInt32(pConfig, "s3MigrateIntervalSec", 60 * 60, 600, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,
|
||||
CFG_CATEGORY_GLOBAL);
|
||||
cfgAddBool(pConfig, "s3MigrateEnabled", 60 * 60, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER, CFG_CATEGORY_GLOBAL);
|
||||
cfgAddString(pConfig, "s3Accesskey", "", CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER_LAZY, CFG_CATEGORY_GLOBAL);
|
||||
cfgAddString(pConfig, "s3Endpoint", "", CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER_LAZY, CFG_CATEGORY_GLOBAL);
|
||||
cfgAddString(pConfig, "s3BucketName", "", CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER_LAZY, CFG_CATEGORY_GLOBAL);
|
||||
cfgAddInt32(pConfig, "s3PageCacheSize", 10, 4, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER_LAZY,
|
||||
CFG_CATEGORY_GLOBAL);
|
||||
cfgAddInt32(pConfig, "s3UploadDelaySec", 10, 1, 60 * 60 * 24 * 30, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER,
|
||||
CFG_CATEGORY_GLOBAL);
|
||||
cfgAddDir(pConfig, "scriptDir", configDir, CFG_SCOPE_BOTH, CFG_DYN_NONE, CFG_CATEGORY_LOCAL);
|
||||
|
||||
cfgDumpCfgS3(pConfig, false, false);
|
||||
|
||||
cfgDumpCfgS3(pConfig, true, true);
|
||||
|
||||
cfgDumpCfgS3(pConfig, false, true);
|
||||
|
||||
cfgDumpCfgS3(pConfig, true, false);
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
TEST_F(CfgTest, cfgLoadFromEnvVar) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 6, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 21, 0, 16, 0, 1, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0, 1, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 21, 0, 16, 0, 2, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0, 2, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 21, 0, 16, 0, 6, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0, 6, 0), 0);
|
||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0, 6, 0), 0);
|
||||
EXPECT_EQ(cfgAddDir(pConfig, "test_dir", TD_TMP_DIR_PATH, 0, 6, 0), 0);
|
||||
|
||||
setenv("test_bool", "1", 1);
|
||||
setenv("test_int32", "2", 1);
|
||||
setenv("test_int64", "3", 1);
|
||||
setenv("test_float", "4", 1);
|
||||
setenv("test_string", "5", 1);
|
||||
setenv("test_dir", TD_TMP_DIR_PATH, 1);
|
||||
|
||||
ASSERT_EQ(cfgLoad(pConfig, CFG_STYPE_ENV_VAR, "test_bool"), TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, cfgLoadFromEnvCmd) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
EXPECT_EQ(cfgAddBool(pConfig, "test_bool", 0, 0, 6, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 21, 0, 16, 0, 1, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt32(pConfig, "test_int32", 1, 0, 16, 0, 1, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 21, 0, 16, 0, 2, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddInt64(pConfig, "test_int64", 2, 0, 16, 0, 2, 0), 0);
|
||||
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 21, 0, 16, 0, 6, 0), TSDB_CODE_OUT_OF_RANGE);
|
||||
EXPECT_EQ(cfgAddFloat(pConfig, "test_float", 3, 0, 16, 0, 6, 0), 0);
|
||||
EXPECT_EQ(cfgAddString(pConfig, "test_string", "4", 0, 6, 0), 0);
|
||||
|
||||
const char *envCmd[] = {"test_bool=1", "test_int32=2", "test_int64=3", "test_float=4", "test_string=5", NULL};
|
||||
|
||||
ASSERT_EQ(cfgLoad(pConfig, CFG_STYPE_ENV_CMD, envCmd), TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, cfgLoadFromEnvFile) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
TdFilePtr envFile = NULL;
|
||||
const char *envFilePath = TD_TMP_DIR_PATH "envFile";
|
||||
envFile = taosOpenFile(envFilePath, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||
const char *buf = "test_bool=1\ntest_int32=2\ntest_int64=3\ntest_float=4\ntest_string=5\n";
|
||||
taosWriteFile(envFile, buf, strlen(buf));
|
||||
taosCloseFile(&envFile);
|
||||
ASSERT_EQ(cfgLoad(pConfig, CFG_STYPE_ENV_FILE, envFilePath), TSDB_CODE_SUCCESS);
|
||||
|
||||
taosRemoveFile(envFilePath);
|
||||
}
|
||||
|
||||
TEST_F(CfgTest, cfgLoadFromApollUrl) {
|
||||
SConfig *pConfig = NULL;
|
||||
int32_t code = cfgInit(&pConfig);
|
||||
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
ASSERT_NE(pConfig, nullptr);
|
||||
|
||||
TdFilePtr jsonFile = NULL;
|
||||
const char *jsonFilePath = TD_TMP_DIR_PATH "envJson.json";
|
||||
jsonFile = taosOpenFile(jsonFilePath, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||
const char *buf =
|
||||
"{\"test_bool\":\"1\",\"test_int32\":\"2\",\"test_int64\":\"3\",\"test_float\":\"4\",\"test_string\":\"5\"}";
|
||||
taosWriteFile(jsonFile, buf, strlen(buf));
|
||||
taosCloseFile(&jsonFile);
|
||||
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "jsonFile:%s", jsonFilePath);
|
||||
ASSERT_EQ(cfgLoad(pConfig, CFG_STYPE_APOLLO_URL, str), 0);
|
||||
|
||||
taosRemoveFile(jsonFilePath);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -248,6 +248,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 4
|
||||
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-32548.py
|
||||
,,n,system-test,python3 ./test.py -f 2-query/large_data.py
|
||||
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stddev_test.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stddev_test.py -Q 2
|
||||
|
@ -780,6 +781,7 @@
|
|||
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/compactDBConflict.py -N 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/mnodeEncrypt.py 3
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 2
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 2
|
||||
|
|
|
@ -19,6 +19,7 @@ import inspect
|
|||
import importlib
|
||||
import traceback
|
||||
from util.log import *
|
||||
import platform
|
||||
|
||||
|
||||
class TDCase:
|
||||
|
@ -146,5 +147,42 @@ class TDCases:
|
|||
|
||||
tdLog.notice("total %d Cluster test case(s) executed" % (runNum))
|
||||
|
||||
def getTaosBenchmarkPath(self, tool="taosBenchmark"):
|
||||
if (platform.system().lower() == 'windows'):
|
||||
tool = tool + ".exe"
|
||||
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
if "community" in selfPath:
|
||||
projPath = selfPath[: selfPath.find("community")]
|
||||
else:
|
||||
projPath = selfPath[: selfPath.find("tests")]
|
||||
|
||||
paths = []
|
||||
for root, dirs, files in os.walk(projPath):
|
||||
if (tool) in files:
|
||||
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||
if "packaging" not in rootRealPath:
|
||||
paths.append(os.path.join(root, tool))
|
||||
break
|
||||
if len(paths) == 0:
|
||||
tdLog.exit("taosBenchmark not found!")
|
||||
return
|
||||
else:
|
||||
tdLog.info("taosBenchmark found in %s" % paths[0])
|
||||
return paths[0]
|
||||
|
||||
def taosBenchmarkExec(self, param):
|
||||
buildPath = tdCases.getTaosBenchmarkPath()
|
||||
|
||||
if (platform.system().lower() == 'windows'):
|
||||
cmdStr1 = ' mintty -h never %s %s '%(buildPath, param)
|
||||
tdLog.info(cmdStr1)
|
||||
os.system(cmdStr1)
|
||||
else:
|
||||
cmdStr1 = '%s %s &'%(buildPath, param)
|
||||
tdLog.info(cmdStr1)
|
||||
os.system(cmdStr1)
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
tdCases = TDCases()
|
||||
|
|
|
@ -78,9 +78,34 @@ class TDTestCase:
|
|||
tdSql.error(f'create table {sql} (ts timestamp,c0 int)')
|
||||
tdSql.execute(f'trim database `{dbname}`')
|
||||
tdSql.execute(f'drop database `{dbname}`')
|
||||
|
||||
def tb_name_len_check(self):
|
||||
dbname = tdCom.getLongName(10)
|
||||
tdSql.execute(f'create database if not exists `{dbname}` vgroups 1 replica 1')
|
||||
tdSql.execute(f'use `{dbname}`')
|
||||
tdSql.execute(f'CREATE STABLE `test_csv` (`ts` TIMESTAMP, `c1` VARCHAR(2000), `c2` VARCHAR(2000)) TAGS (`c3` VARCHAR(2000))')
|
||||
tbname = "test_csv_a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012"
|
||||
tdSql.execute(f"INSERT INTO `{tbname}`\
|
||||
using `test_csv` (`c3`) tags('a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890')\
|
||||
(`ts`,`c1`,`c2`) values(1591060628000,'a','1');")
|
||||
tdSql.query(f'select * from {tbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'drop table {tbname}')
|
||||
|
||||
tdSql.execute(f"INSERT INTO `{dbname}`.`{tbname}`\
|
||||
using `{dbname}`.`test_csv` (`c3`) tags('a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890')\
|
||||
(`ts`,`c1`,`c2`) values(1591060628000,'a','1');")
|
||||
tdSql.query(f'select * from {tbname}')
|
||||
tdSql.checkRows(1)
|
||||
tdSql.execute(f'drop table {tbname}')
|
||||
|
||||
tdSql.execute(f'trim database `{dbname}`')
|
||||
tdSql.execute(f'drop database `{dbname}`')
|
||||
|
||||
def run(self):
|
||||
self.db_name_check()
|
||||
self.tb_name_check()
|
||||
self.tb_name_len_check()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
self.replicaVar = int(replicaVar)
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
|
||||
def prepare_data(self):
|
||||
tdSql.execute("drop database if exists test;")
|
||||
|
||||
tdCases.taosBenchmarkExec("-t 2 -n 1000000 -b int,float,nchar -y")
|
||||
|
||||
while True:
|
||||
tdSql.query("select ts from test.d0;")
|
||||
num1 = tdSql.queryRows
|
||||
tdSql.query("select ts from test.d1;")
|
||||
num2 = tdSql.queryRows
|
||||
if num1 == 1000000 and num2 == 1000000:
|
||||
break
|
||||
tdLog.info(f"waiting for data ready, d0: {num1}, d1: {num2}")
|
||||
time.sleep(1)
|
||||
|
||||
def ts5803(self):
|
||||
tdSql.query("select d0.ts,d0.c1,d0.c2 from test.d0 join test.d1 on d0.ts=d1.ts;")
|
||||
num1 = tdSql.queryRows
|
||||
|
||||
tdSql.query("select d0.ts,d0.c1,d0.c2 from test.d0 join test.d1 on d0.ts=d1.ts limit 1000000;")
|
||||
tdSql.checkRows(num1)
|
||||
|
||||
tdSql.query("select d0.ts from test.d0 join test.d1 on d0.ts=d1.ts limit 1000000;")
|
||||
tdSql.checkRows(num1)
|
||||
|
||||
tdSql.query("select d0.ts,d0.c1,d0.c2 from test.d0 left join test.d1 on d0.ts=d1.ts;")
|
||||
num1 = tdSql.queryRows
|
||||
|
||||
tdSql.query("select d0.ts,d0.c1,d0.c2 from test.d0 left join test.d1 on d0.ts=d1.ts limit 1000000;")
|
||||
tdSql.checkRows(num1)
|
||||
|
||||
tdSql.query("select d0.ts from test.d0 left join test.d1 on d0.ts=d1.ts limit 1000000;")
|
||||
tdSql.checkRows(num1)
|
||||
|
||||
def run(self):
|
||||
self.prepare_data()
|
||||
self.ts5803()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,69 @@
|
|||
from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
|
||||
from numpy import row_stack
|
||||
import taos
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import TDDnodes
|
||||
from util.dnodes import TDDnode
|
||||
from util.cluster import *
|
||||
sys.path.append("./6-cluster")
|
||||
from clusterCommonCreate import *
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
|
||||
import time
|
||||
import socket
|
||||
import subprocess
|
||||
from multiprocessing import Process
|
||||
import threading
|
||||
import time
|
||||
import inspect
|
||||
import ctypes
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql, replicaVar=1):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
self.TDDnodes = None
|
||||
tdSql.init(conn.cursor())
|
||||
self.host = socket.gethostname()
|
||||
|
||||
|
||||
def run(self):
|
||||
tdSql.execute('create database if not exists db');
|
||||
tdSql.execute('use db')
|
||||
tdSql.execute('create table st (ts timestamp, i int, j float, k double) tags(a int)')
|
||||
|
||||
for i in range(0, 2):
|
||||
tdSql.execute("create table if not exists db.t%d using db.st tags(%d)" % (i, i))
|
||||
|
||||
|
||||
for i in range(2, 4):
|
||||
tdSql.execute("create table if not exists db.t%d using db.st tags(%d)" % (i, i))
|
||||
|
||||
sql = "show db.tables"
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(4)
|
||||
|
||||
timestamp = 1530374400000
|
||||
for i in range (4) :
|
||||
val = i
|
||||
sql = "insert into db.t%d values(%d, %d, %d, %d)" % (i, timestamp, val, val, val)
|
||||
tdSql.execute(sql)
|
||||
|
||||
for i in range ( 4) :
|
||||
val = i
|
||||
sql = "select * from db.t%d" % (i)
|
||||
tdSql.query(sql)
|
||||
tdSql.checkRows(1)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -70,10 +70,10 @@ require (
|
|||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/arch v0.7.0 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
golang.org/x/sys v0.24.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
|
|
|
@ -424,8 +424,8 @@ golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm
|
|||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
|
@ -573,8 +573,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
@ -583,8 +583,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
Loading…
Reference in New Issue