From f529339fb80f5ee4bc0ce6f8a0fe61fe6d27557f Mon Sep 17 00:00:00 2001 From: kailixu Date: Sun, 29 Dec 2024 13:26:40 +0800 Subject: [PATCH] test: add test case for auto compact --- source/dnode/mnode/impl/src/mndDb.c | 12 ++++++++++-- tests/system-test/0-others/compact_auto.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 3444b88807..47d9ab12fc 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -2601,8 +2601,16 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)durationVstr, false), &lino, _OVER); } - len = formatDurationOrKeep(durationStr, sizeof(durationStr), pDb->cfg.compactStartTime); - TAOS_UNUSED(formatDurationOrKeep(durationVstr, sizeof(durationVstr), pDb->cfg.compactEndTime)); + int32_t compactStartTime = pDb->cfg.compactStartTime; + int32_t compactEndTime = pDb->cfg.compactEndTime; + if(compactStartTime == 0 && pDb->cfg.compactInterval > 0) { + compactStartTime = -pDb->cfg.daysToKeep2; + } + if(compactEndTime == 0 && pDb->cfg.compactInterval > 0) { + compactEndTime = -pDb->cfg.daysPerFile; + } + len = formatDurationOrKeep(durationStr, sizeof(durationStr), compactStartTime); + TAOS_UNUSED(formatDurationOrKeep(durationVstr, sizeof(durationVstr), compactEndTime)); TAOS_UNUSED(snprintf(durationStr + len, sizeof(durationStr) - len, ",%s", durationVstr)); STR_WITH_MAXSIZE_TO_VARSTR(durationVstr, durationStr, sizeof(durationVstr)); if ((pColInfo = taosArrayGet(pBlock->pDataBlock, cols++))) { diff --git a/tests/system-test/0-others/compact_auto.py b/tests/system-test/0-others/compact_auto.py index 4cfeec5b62..c6ef169c8c 100644 --- a/tests/system-test/0-others/compact_auto.py +++ b/tests/system-test/0-others/compact_auto.py @@ -93,11 +93,12 @@ class TDTestCase: tdSql.execute(f'alter database {item[0]} compact_interval {item[1]}', queryTimes=10) tdSql.query(f'select * from information_schema.ins_databases where name = "{item[0]}"') tdSql.checkEqual(tdSql.queryResult[0][34], item[4]) - tdSql.checkEqual(tdSql.queryResult[0][35], self.default_compact_options[1]) tdSql.checkEqual(tdSql.queryResult[0][36], item[6]) if index == 0: + tdSql.checkEqual(tdSql.queryResult[0][35], item[5]) self.checkShowCreateWithTimeout(item[0], f'COMPACT_INTERVAL {item[4]} COMPACT_TIME_RANGE {self.default_compact_options[1]} COMPACT_TIME_OFFSET {item[6]}') else: + tdSql.checkEqual(tdSql.queryResult[0][35], "-3650d,-1d") self.checkShowCreateWithTimeout(item[0], f'COMPACT_INTERVAL {item[4]} COMPACT_TIME_RANGE -3650d,-1d COMPACT_TIME_OFFSET {item[6]}') tdSql.execute(f'alter database {item[0]} compact_time_range {item[2]}', queryTimes=10) tdSql.query(f'select * from information_schema.ins_databases where name = "{item[0]}"') @@ -105,7 +106,6 @@ class TDTestCase: tdSql.checkEqual(tdSql.queryResult[0][35], item[5]) tdSql.checkEqual(tdSql.queryResult[0][36], item[6]) self.checkShowCreateWithTimeout(item[0], f'COMPACT_INTERVAL {item[4]} COMPACT_TIME_RANGE {item[5]} COMPACT_TIME_OFFSET {item[6]}') - tdSql.execute(f'alter database {item[0]} compact_time_offset {item[3]}', queryTimes=10) tdSql.query(f'select * from information_schema.ins_databases where name = "{item[0]}"') tdSql.checkEqual(tdSql.queryResult[0][34], item[4])