From 078367d29f529d8ddba3cb7c7d54772baab5b346 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sat, 28 Dec 2024 20:52:22 +0800 Subject: [PATCH] test: add test case for auto compact --- include/libs/nodes/cmdnodes.h | 2 +- source/libs/parser/src/parTranslater.c | 2 +- tests/system-test/0-others/compact_auto.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 0f736e7068..7252929e3b 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -112,7 +112,7 @@ typedef struct SDatabaseOptions { int8_t s3Compact; int8_t withArbitrator; // for auto-compact - int8_t compactTimeOffset; // hours + int32_t compactTimeOffset; // hours int32_t compactInterval; // minutes int32_t compactStartTime; // minutes int32_t compactEndTime; // minutes diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index abd0efa2d8..2c43059ba0 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -7810,7 +7810,7 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int64_t val, int64_t minVal, int64_t maxVal, int8_t unit, bool skipUndef) { - if (skipUndef ? ((val >= 0) && (val < minVal || val > maxVal)) : (val < minVal || val > maxVal)) { + if (skipUndef ? ((val >= 0 || val < -2) && (val < minVal || val > maxVal)) : (val < minVal || val > maxVal)) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Invalid option %s: %" PRId64 "%c, valid range: [%" PRId64 "%c, %" PRId64 "%c]", pName, val, unit, minVal, unit, maxVal, unit); diff --git a/tests/system-test/0-others/compact_auto.py b/tests/system-test/0-others/compact_auto.py index 615c2bba5b..ea812b3ab7 100644 --- a/tests/system-test/0-others/compact_auto.py +++ b/tests/system-test/0-others/compact_auto.py @@ -76,10 +76,13 @@ class TDTestCase: ["compact_time_range -60,-1440h", "Invalid option compact_time_range: -86400m,-86400m, start time should be less than end time"], ["compact_time_range -60d,-61d", "Invalid option compact_time_range: -86400m,-87840m, start time should be less than end time"], ["compact_time_range -5256001m,-1", "Invalid option compact_time_range: -5256001m, start time should be in range: [-5256000m, -14400m]"], + ["compact_time_range -199999999999m,-199999999998m", "start time should be in range: [-5256000m, -14400m]"], + ["compact_time_range -99999999999999999999m,-99999999999999999998m", "Invalid value type: -99999999999999999999"], ["compact_time_range -60d,-1", "Invalid option compact_time_range: -1440m, end time should be in range: [-5256000m, -14400m]"], ["compact_interval 24h compact_time_range -60,61", "Invalid option compact_time_range: 87840m, end time should be in range: [-5256000m, -14400m]"], ["compact_interval 100 compact_time_range -60d,61d", "Invalid option compact_time_range: 87840m, end time should be in range: [-5256000m, -14400m]"], ["compact_time_range -60d,87840m", "Invalid option compact_time_range: 87840m, end time should be in range: [-5256000m, -14400m]"], + ["compact_time_range -100,-90s", "Invalid option compact_time_range end unit: s, only m, h, d allowed"], ["compact_interval 10m compact_time_range -120d,-14400m compact_time_offset -1", "syntax error near"], ["compact_time_range -100,-99d compact_interval -1", "syntax error near"], ["compact_time_range 0", "Invalid option compact_time_range, should have 2 value"], @@ -89,13 +92,19 @@ class TDTestCase: ["compact_time_range -100:-90", "syntax error near"], ["compact_time_range -100 -90", "syntax error near"], ["compact_interval 1m", "Invalid option compact_interval: 1m, valid range: [10m, 5256000m]"], + ["compact_interval 199999999999m", "valid range: [10m, 5256000m]"], + ["compact_interval 9999999999999m", "Invalid option compact_interval: 9999999999999m, valid range: [10m, 5256000m]"], ["compact_interval 5256001m", "Invalid option compact_interval: 5256001m, valid range: [10m, 5256000m]"], ["compact_interval 3651", "Invalid option compact_interval: 5257440m, valid range: [10m, 5256000m]"], + ["compact_interval 86400s", "Invalid option compact_interval unit: s, only m, h, d allowed"], ["compact_interval -1", "syntax error near"], ["compact_time_offset -1", "syntax error near"], + ["compact_time_offset 3600s", "Invalid option compact_time_offset unit: s, only h allowed"], ["compact_time_offset 1d", "Invalid option compact_time_offset unit: d, only h allowed"], ["compact_time_offset 24", "Invalid option compact_time_offset: 24h, valid range: [0h, 23h]"], ["compact_time_offset 24h", "Invalid option compact_time_offset: 24h, valid range: [0h, 23h]"], + ["compact_time_offset 9999999999999", "valid range: [0h, 23h]"], + ["compact_time_offset 199999999999", "valid range: [0h, 23h]"], ["compact_time_offset 1d", "Invalid option compact_time_offset unit: d, only h allowed"], ["compact_interval 10m compact_time_range -120d,-60 compact_time_offset 1d", "Invalid option compact_time_offset unit: d, only h allowed"], ] @@ -103,6 +112,7 @@ class TDTestCase: for item in compact_err_list: tdSql.error(f"create database db {item[0]}", expectErrInfo=item[1], fullMatched=False) tdSql.error(f"alter database db {item[0]}", expectErrInfo=item[1], fullMatched=False) + tdSql.execute('drop database db') def run(self): self.create_db_compact()