From 458a72c66ad15c2997ab3aa319688de11b1307e4 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sun, 29 Dec 2024 13:45:59 +0800 Subject: [PATCH] test: add test case for auto compact --- source/dnode/mnode/impl/src/mndDb.c | 20 ++------------------ tests/system-test/0-others/compact_auto.py | 10 ++-------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 47d9ab12fc..43abc842f4 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1445,14 +1445,6 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) { cfgRsp->compactInterval = pDb->cfg.compactInterval; cfgRsp->compactStartTime = pDb->cfg.compactStartTime; cfgRsp->compactEndTime = pDb->cfg.compactEndTime; - if (cfgRsp->compactInterval > 0) { - if (cfgRsp->compactStartTime == 0) { - cfgRsp->compactStartTime = -cfgRsp->daysToKeep2; - } - if (cfgRsp->compactEndTime == 0) { - cfgRsp->compactEndTime = -cfgRsp->daysPerFile; - } - } cfgRsp->compactTimeOffset = pDb->cfg.compactTimeOffset; } @@ -2601,16 +2593,8 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, TAOS_CHECK_GOTO(colDataSetVal(pColInfo, rows, (const char *)durationVstr, false), &lino, _OVER); } - 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)); + len = formatDurationOrKeep(durationStr, sizeof(durationStr), pDb->cfg.compactStartTime); + TAOS_UNUSED(formatDurationOrKeep(durationVstr, sizeof(durationVstr), pDb->cfg.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 c6ef169c8c..dbf050e00a 100644 --- a/tests/system-test/0-others/compact_auto.py +++ b/tests/system-test/0-others/compact_auto.py @@ -74,7 +74,6 @@ class TDTestCase: tdLog.info("alter db compact options separately") compact_separate_options = [["db100", "0m", "-0d,0", "0", "0d", "0d,0d", "0h"], ["db101", "10m", "-2d,-1", "1", "10m", "-2d,-1d", "1h"]] - index = 0 for item in compact_separate_options: tdSql.execute(f'create database {item[0]} duration 1d') tdSql.query(f'select * from information_schema.ins_databases where name = "{item[0]}"') @@ -93,13 +92,9 @@ 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]}') + self.checkShowCreateWithTimeout(item[0], f'COMPACT_INTERVAL {item[4]} COMPACT_TIME_RANGE {self.default_compact_options[1]} 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]}"') tdSql.checkEqual(tdSql.queryResult[0][34], item[4]) @@ -112,7 +107,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]}') - index += 1 for item in compact_separate_options: tdSql.execute(f'drop database {item[0]}', queryTimes=10)