From 524ebca16a2dea8bfe1b5a45d5940defbd8d4853 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 11:35:08 +0800 Subject: [PATCH 1/8] coverage: add schUtil.c and schedulerTest --- source/libs/scheduler/src/schUtil.c | 2 ++ source/libs/scheduler/test/schedulerTests.cpp | 10 ++++++++++ source/libs/stream/test/CMakeLists.txt | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/libs/scheduler/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index 39c54ea731..47e6d53b46 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -263,6 +263,7 @@ void schCloseJobRef(void) { uint64_t schGenTaskId(void) { return atomic_add_fetch_64(&schMgmt.taskId, 1); } +#ifdef BUILD_NO_CALL uint64_t schGenUUID(void) { static uint64_t hashId = 0; static int32_t requestSerialId = 0; @@ -284,6 +285,7 @@ uint64_t schGenUUID(void) { uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } +#endif void schFreeRpcCtxVal(const void *arg) { if (NULL == arg) { diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index 5605a4b842..a62080c385 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -1005,6 +1005,16 @@ TEST(multiThread, forceFree) { taosSsleep(3); } +TEST(otherTest, otherCase) { + // excpet test + schReleaseJob(0); + schFreeRpcCtx(NULL); + + EXPECT_EQ(schDumpEpSet(NULL), NULL); + EXPECT_EQ(schGetOpStr(SCH_OP_NULL), "NULL"); + EXPECT_EQ(schGetOpStr((SCH_OP_TYPE)100, "UNKNOWN"); +} + int main(int argc, char **argv) { taosSeedRand(taosGetTimestampSec()); testing::InitGoogleTest(&argc, argv); diff --git a/source/libs/stream/test/CMakeLists.txt b/source/libs/stream/test/CMakeLists.txt index c11d8fe3e6..c90e05bcf6 100644 --- a/source/libs/stream/test/CMakeLists.txt +++ b/source/libs/stream/test/CMakeLists.txt @@ -34,7 +34,7 @@ add_test( COMMAND streamUpdateTest ) -# add_test( -# NAME checkpointTest -# COMMAND checkpointTest -# ) \ No newline at end of file +add_test( + NAME checkpointTest + COMMAND checkpointTest +) \ No newline at end of file From dfd1b5ccaff100f747da4a45eeafbaf328651f22 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 14:57:29 +0800 Subject: [PATCH 2/8] fix: build error for schedularTests --- source/libs/scheduler/test/schedulerTests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index a62080c385..793bc20024 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -1010,9 +1010,9 @@ TEST(otherTest, otherCase) { schReleaseJob(0); schFreeRpcCtx(NULL); - EXPECT_EQ(schDumpEpSet(NULL), NULL); - EXPECT_EQ(schGetOpStr(SCH_OP_NULL), "NULL"); - EXPECT_EQ(schGetOpStr((SCH_OP_TYPE)100, "UNKNOWN"); + ASSERT_EQ(schDumpEpSet(NULL), (char*)NULL); + ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 0); + ASSERT_EQ(strcmp(schGetOpStr((SCH_OP_TYPE)100), "UNKNOWN"), 0); } int main(int argc, char **argv) { From b3a6fa9c129a48ccaeeed0da4d65c7b71ecc18c6 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 19:36:35 +0800 Subject: [PATCH 3/8] coverage: add explain.c --- source/dnode/mnode/impl/src/mndConsumer.c | 2 ++ source/dnode/vnode/src/vnd/vnodeAsync.c | 2 ++ tests/system-test/2-query/explain.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 753076f1f3..c7f3da767d 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -540,12 +540,14 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj static void *topicNameDup(void *p) { return taosStrdup((char *)p); } +#ifdef BUILD_NO_CALL static void freeItem(void *param) { void *pItem = *(void **)param; if (pItem != NULL) { taosMemoryFree(pItem); } } +#endif int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 66668b60df..313603b19f 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -433,10 +433,12 @@ static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { return 0; } +#ifdef BUILD_NO_CALL int32_t vnodeAsync(SVAsync *async, EVAPriority priority, int32_t (*execute)(void *), void (*complete)(void *), void *arg, int64_t *taskId) { return vnodeAsyncC(async, 0, priority, execute, complete, arg, taskId); } +#endif int32_t vnodeAsyncC(SVAsync *async, int64_t channelId, EVAPriority priority, int32_t (*execute)(void *), void (*complete)(void *), void *arg, int64_t *taskId) { diff --git a/tests/system-test/2-query/explain.py b/tests/system-test/2-query/explain.py index f164d3aedf..92cd28a929 100644 --- a/tests/system-test/2-query/explain.py +++ b/tests/system-test/2-query/explain.py @@ -400,6 +400,9 @@ class TDTestCase: self.explain_check() + # coverage explain.c add + tdSql.query(f"explain verbose true select * from {dbname}.stb1 partition by c1 order by c2") + def __test_error(self, dbname=DBNAME): ratio = random.uniform(0.001,1) From 6dec22c1c26ccacfa1d2d2d7f332187f51d2cfa9 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 20:51:49 +0800 Subject: [PATCH 4/8] coverage: add tglobal.c --- source/dnode/mnode/impl/src/mndConsumer.c | 2 - tests/army/community/cluster/incSnapshot.py | 3 ++ tests/army/community/cluster/snapshot.py | 7 +++- .../community/cluster/splitVgroupByLearner.py | 3 ++ tests/army/community/cmdline/fullopt.py | 37 ++++++++++++++++++- tests/army/community/query/fill/fill_desc.py | 3 ++ tests/army/community/query/query_basic.py | 6 ++- 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index c7f3da767d..753076f1f3 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -540,14 +540,12 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj static void *topicNameDup(void *p) { return taosStrdup((char *)p); } -#ifdef BUILD_NO_CALL static void freeItem(void *param) { void *pItem = *(void **)param; if (pItem != NULL) { taosMemoryFree(pItem); } } -#endif int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; diff --git a/tests/army/community/cluster/incSnapshot.py b/tests/army/community/cluster/incSnapshot.py index d309bae72c..6bcf547136 100644 --- a/tests/army/community/cluster/incSnapshot.py +++ b/tests/army/community/cluster/incSnapshot.py @@ -18,6 +18,9 @@ from frame.autogen import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"query" + } def init(self, conn, logSql, replicaVar=3): super(TDTestCase, self).init(conn, logSql, replicaVar=3, db="snapshot", checkColName="c1") diff --git a/tests/army/community/cluster/snapshot.py b/tests/army/community/cluster/snapshot.py index b4c4d3c4c8..1cd7c1b2f6 100644 --- a/tests/army/community/cluster/snapshot.py +++ b/tests/army/community/cluster/snapshot.py @@ -33,8 +33,13 @@ class TDTestCase(TBase): "lossyColumns" : "float,double", "fPrecision" : "0.000000001", "dPrecision" : "0.00000000000000001", - "ifAdtFse" : "1" + "ifAdtFse" : "1", + 'slowLogScope' : "insert" } + updatecfgDict = { + + } + def insertData(self): tdLog.info(f"insert data.") diff --git a/tests/army/community/cluster/splitVgroupByLearner.py b/tests/army/community/cluster/splitVgroupByLearner.py index 5f75db2db5..c2025a331d 100644 --- a/tests/army/community/cluster/splitVgroupByLearner.py +++ b/tests/army/community/cluster/splitVgroupByLearner.py @@ -31,6 +31,9 @@ from frame.srvCtl import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope' : "others" + } def init(self, conn, logSql, replicaVar=1): tdLog.debug(f"start to init {__file__}") diff --git a/tests/army/community/cmdline/fullopt.py b/tests/army/community/cmdline/fullopt.py index c0ce709801..68b8f8ea01 100644 --- a/tests/army/community/cmdline/fullopt.py +++ b/tests/army/community/cmdline/fullopt.py @@ -33,7 +33,8 @@ class TDTestCase(TBase): 'totalMemoryKB': '1G', #'rpcQueueMemoryAllowed': '1T', #'mndLogRetention': '1P', - 'streamBufferSize':'2G' + 'streamBufferSize':'2G', + 'slowLogScope':"invalid" } def insertData(self): @@ -47,8 +48,42 @@ class TDTestCase(TBase): # taosBenchmark run etool.benchMark(command = f"-d {self.db} -t {self.childtable_count} -n {self.insert_rows} -v 2 -y") + def checkQueryOK(self, rets): + if rets[-1][:9] != "Query OK,": + tdLog.exit(f"check taos -s return unecpect: {rets}") + def doTaos(self): tdLog.info(f"check taos command options...") + + # local command + options = [ + "DebugFlag 143", + "enableCoreFile 1", + "fqdn 127.0.0.1", + "firstEp 127.0.0.1", + "locale ENG", + "metaCacheMaxSize 10000", + "minimalTmpDirGB 5", + "minimalDataDirGB 4", + "minimalLogDirGB 1", + "secondEp 127.0.0.2", + "smlChildTableName smltbname", + "smlAutoChildTableNameDelimiter autochild", + "smlTagName tagname", + "smlTsDefaultName tsdef", + "serverPort 6030", + "slowLogScope insert", + "timezone tz", + "tempDir /var/tmp", + "telemetryServer telserver" + ] + # exec + for option in options: + rets = etool.runBinFile("taos", f"-s \"alter local '{option}'\";") + self.checkQueryOK(rets) + # error + etool.runBinFile("taos", f"-s \"alter local 'nocmd check'\";") + # help rets = etool.runBinFile("taos", "--help") self.checkListNotEmpty(rets) diff --git a/tests/army/community/query/fill/fill_desc.py b/tests/army/community/query/fill/fill_desc.py index bec29c49fd..02e316a4fb 100644 --- a/tests/army/community/query/fill/fill_desc.py +++ b/tests/army/community/query/fill/fill_desc.py @@ -8,6 +8,9 @@ from frame.caseBase import * from frame import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"all" + } def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) diff --git a/tests/army/community/query/query_basic.py b/tests/army/community/query/query_basic.py index bfe88e483e..d2e0201860 100644 --- a/tests/army/community/query/query_basic.py +++ b/tests/army/community/query/query_basic.py @@ -29,9 +29,11 @@ from frame import * class TDTestCase(TBase): updatecfgDict = { - "keepColumnName" : "1", + "keepColumnName" : "1", "ttlChangeOnWrite" : "1", - "querySmaOptimize": "1" + "querySmaOptimize" : "1", + "slowLogScope" : "none", + "queryBufferSize" : 10240 } From 85bfc7ceb4f75409b706fc549dac99ac4ae96b64 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 21:20:02 +0800 Subject: [PATCH 5/8] coverage: remove tglobal.c client no use option --- source/common/src/tglobal.c | 8 -------- tests/army/community/cmdline/fullopt.py | 13 +++++-------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 444a4c0ccc..9ddf22ca49 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1601,10 +1601,6 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { tsTempSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); uInfo("%s set to %" PRId64, name, tsTempSpace.reserved); matched = true; - } else if (strcasecmp("minimalDataDirGB", name) == 0) { - tsDataSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); - uInfo("%s set to %" PRId64, name, tsDataSpace.reserved); - matched = true; } else if (strcasecmp("minimalLogDirGB", name) == 0) { tsLogSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); uInfo("%s set to %" PRId64, name, tsLogSpace.reserved); @@ -1675,10 +1671,6 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { return -1; } matched = true; - } else if (strcasecmp("telemetryServer", name) == 0) { - uInfo("%s set from %s to %s", name, pItem->str, tsTelemServer); - tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN); - matched = true; } break; } diff --git a/tests/army/community/cmdline/fullopt.py b/tests/army/community/cmdline/fullopt.py index 68b8f8ea01..0a870c52b5 100644 --- a/tests/army/community/cmdline/fullopt.py +++ b/tests/army/community/cmdline/fullopt.py @@ -31,11 +31,10 @@ class TDTestCase(TBase): 'queryMaxConcurrentTables': '2K', 'streamMax': '1M', 'totalMemoryKB': '1G', - #'rpcQueueMemoryAllowed': '1T', - #'mndLogRetention': '1P', - 'streamBufferSize':'2G', - 'slowLogScope':"invalid" - } + 'streamMax': '1P', + 'streamBufferSize':'1T', + 'slowLogScope':"query" + } def insertData(self): tdLog.info(f"insert data.") @@ -64,7 +63,6 @@ class TDTestCase(TBase): "locale ENG", "metaCacheMaxSize 10000", "minimalTmpDirGB 5", - "minimalDataDirGB 4", "minimalLogDirGB 1", "secondEp 127.0.0.2", "smlChildTableName smltbname", @@ -74,8 +72,7 @@ class TDTestCase(TBase): "serverPort 6030", "slowLogScope insert", "timezone tz", - "tempDir /var/tmp", - "telemetryServer telserver" + "tempDir /var/tmp" ] # exec for option in options: From 72a8fb15b747b8b972725ff3acf6369bbc28f9a0 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 18 Feb 2024 21:21:41 +0800 Subject: [PATCH 6/8] fix: fullopt.py index error --- tests/army/community/cmdline/fullopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/army/community/cmdline/fullopt.py b/tests/army/community/cmdline/fullopt.py index 0a870c52b5..c03ba428a1 100644 --- a/tests/army/community/cmdline/fullopt.py +++ b/tests/army/community/cmdline/fullopt.py @@ -48,7 +48,7 @@ class TDTestCase(TBase): etool.benchMark(command = f"-d {self.db} -t {self.childtable_count} -n {self.insert_rows} -v 2 -y") def checkQueryOK(self, rets): - if rets[-1][:9] != "Query OK,": + if rets[-2][:9] != "Query OK,": tdLog.exit(f"check taos -s return unecpect: {rets}") def doTaos(self): From 3a45a3b1354073b2693dbb918196a54dc491217a Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 19 Feb 2024 12:10:58 +0800 Subject: [PATCH 7/8] fix: always return zero --- tests/army/community/cluster/snapshot.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/army/community/cluster/snapshot.py b/tests/army/community/cluster/snapshot.py index 1cd7c1b2f6..b21cbb1ad8 100644 --- a/tests/army/community/cluster/snapshot.py +++ b/tests/army/community/cluster/snapshot.py @@ -36,10 +36,6 @@ class TDTestCase(TBase): "ifAdtFse" : "1", 'slowLogScope' : "insert" } - updatecfgDict = { - - } - def insertData(self): tdLog.info(f"insert data.") @@ -61,7 +57,7 @@ class TDTestCase(TBase): sql = f"select * from {self.db}.{self.stb} where fc!=100" tdSql.query(sql) tdSql.checkRows(0) - sql = f"select count(*) from {self.db}.{self.stb} where dc!=200" + sql = f"select * from {self.db}.{self.stb} where dc!=200" tdSql.query(sql) tdSql.checkRows(0) sql = f"select avg(fc) from {self.db}.{self.stb}" From 1f8680fdfdff18310f6e6816885478c4246079ec Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 19 Feb 2024 16:10:08 +0800 Subject: [PATCH 8/8] coverage: add unit test schedularTest --- source/libs/scheduler/test/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/libs/scheduler/test/CMakeLists.txt b/source/libs/scheduler/test/CMakeLists.txt index 703bd5932b..9605cc7a1c 100644 --- a/source/libs/scheduler/test/CMakeLists.txt +++ b/source/libs/scheduler/test/CMakeLists.txt @@ -25,4 +25,9 @@ IF(NOT TD_DARWIN) PUBLIC "${TD_SOURCE_DIR}/include/libs/scheduler/" PRIVATE "${TD_SOURCE_DIR}/source/libs/scheduler/inc" ) + add_test( + NAME schedulerTest + COMMAND schedulerTest + ) + ENDIF() \ No newline at end of file