-
Notifications
You must be signed in to change notification settings - Fork 5k
test: tidy up cases on main branch #33317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
9b268ee
662057c
1aee244
baa7b3d
e0f7e4d
82d1057
ff2a186
96ad0a4
8c2f5b6
56d2d64
dc481c0
4d9b90c
7720e5a
89dddc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,32 +1,15 @@ | ||||||
| from new_test_framework.utils import tdLog, tdSql, sc, clusterComCheck, clusterComCheck | ||||||
| from new_test_framework.utils import tdLog, tdSql, sc, clusterComCheck, clusterComCheck, etool | ||||||
|
|
||||||
|
|
||||||
| class TestDatabaseAlterOption: | ||||||
|
|
||||||
| def setup_class(cls): | ||||||
| tdLog.debug(f"start to execute {__file__}") | ||||||
|
|
||||||
| def test_database_alter_option(self): | ||||||
| """Alter all options | ||||||
|
|
||||||
| 1. Create database and inspect all option values. | ||||||
| 2. Attempt to alter database with invalid options (expect failure). | ||||||
| 3. Alter database with valid options and verify the changes. | ||||||
|
|
||||||
| Catalog: | ||||||
| - Database:Alter | ||||||
|
|
||||||
| Since: v3.0.0.0 | ||||||
|
|
||||||
| Labels: common,ci | ||||||
|
|
||||||
| Jira: None | ||||||
|
|
||||||
| History: | ||||||
| - 2025-4-30 Simon Guan Migrated from tsim/db/alter_option.sim | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
|
|
||||||
| # | ||||||
| # ----------------------- sim ------------------- | ||||||
| # | ||||||
| def do_sim_case(self): | ||||||
| clusterComCheck.checkDnodes(3) | ||||||
|
|
||||||
| tdLog.info(f"============= create database") | ||||||
|
|
@@ -314,3 +297,263 @@ def test_database_alter_option(self): | |||||
| tdSql.error(f"alter database db precision 'ns'") | ||||||
| tdSql.error(f"alter database db precision 'ys'") | ||||||
| tdSql.error(f"alter database db prec 'xs'") | ||||||
|
|
||||||
| print("do sim case ........................... [passed]") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
|
|
||||||
| # | ||||||
| # ----------------------- army ------------------- | ||||||
| # | ||||||
| def prepare_database(self): | ||||||
| tdLog.info(f"prepare database") | ||||||
| tdSql.execute("DROP DATABASE IF EXISTS test") | ||||||
| tdSql.execute("CREATE DATABASE IF NOT EXISTS test") | ||||||
| tdSql.execute("USE test") | ||||||
|
|
||||||
| def check_alter_buffer_size(self): | ||||||
| tdLog.info(f"check alter buffer size") | ||||||
| tdSql.execute("ALTER DATABASE test buffer 789") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 8, '789') | ||||||
| tdSql.error("ALTER DATABASE test buffer 0",expectErrInfo="Invalid option", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test buffer 16385",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_cache_model(self): | ||||||
| tdLog.info(f"check alter cache model") | ||||||
| tdSql.execute("ALTER DATABASE test cachemodel 'last_row'") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 18, "last_row") | ||||||
| tdSql.execute("ALTER DATABASE test cachemodel 'last_value'") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 18, "last_value") | ||||||
| tdSql.execute("ALTER DATABASE test cachemodel 'both'") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 18, "both") | ||||||
| tdSql.execute("ALTER DATABASE test cachemodel 'none'") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 18, "none") | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test cachemodel 'hash_value'",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_cache_size(self): | ||||||
| tdLog.info(f"check alter cache size") | ||||||
| tdSql.execute("ALTER DATABASE test cachesize 777") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 19, '777') | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test cachesize 0",expectErrInfo="Invalid option", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test cachesize 65537",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_min_rows(self): | ||||||
| tdLog.info(f"check alter min rows") | ||||||
| tdSql.execute("ALTER DATABASE test minrows 231") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 11, '231') | ||||||
| tdSql.error("ALTER DATABASE test minrows 5000",expectErrInfo="Invalid database options", fullMatched=False) | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test minrows 9",expectErrInfo="Invalid option", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test minrows 1000001",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_pages(self): | ||||||
| tdLog.info(f"check alter pages") | ||||||
| tdSql.execute("ALTER DATABASE test pages 256") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 10, '256') | ||||||
| tdSql.error("ALTER DATABASE test pages 0",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
|
|
||||||
| def check_alter_wal_level(self): | ||||||
| tdLog.info(f"check alter wal_level") | ||||||
| tdSql.execute("ALTER DATABASE test wal_level 1") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 20, '1') | ||||||
|
|
||||||
| tdSql.execute("ALTER DATABASE test wal_level 2") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 20, '2') | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test wal_level 3",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_fsync(self): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method name
Suggested change
|
||||||
| tdLog.info(f"check alter wal_fsync_period") | ||||||
| tdSql.execute("ALTER DATABASE test wal_fsync_period 1000") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 21, '1000') | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test wal_fsync_period 180001",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_stt_trigger(self): | ||||||
| tdLog.info(f"check alter stt_trigger") | ||||||
| tdSql.execute("ALTER DATABASE test stt_trigger 5") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 24, '5') | ||||||
|
|
||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test stt_trigger 18",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
| def check_alter_wal_retention_period(self): | ||||||
| tdLog.info(f"check alter wal_retention_period") | ||||||
| tdSql.execute("ALTER DATABASE test wal_retention_period 3600") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 22, '3600') | ||||||
|
|
||||||
|
|
||||||
| def check_alter_wal_retention_size(self): | ||||||
| tdLog.info(f"check alter wal_retention_size") | ||||||
| tdSql.execute("ALTER DATABASE test wal_retention_size 1000") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 23, '1000') | ||||||
|
|
||||||
| def check_alter_ss_keeplocal(self): | ||||||
| tdLog.info(f"check alter ss_keeplocal") | ||||||
| tdSql.execute("ALTER DATABASE test ss_keeplocal 2880m") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 30, '2880m') | ||||||
|
|
||||||
| def check_alter_ss_compact(self): | ||||||
| tdLog.info(f"check alter ss_compact") | ||||||
| tdSql.execute("ALTER DATABASE test ss_compact 1") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 31, '1') | ||||||
|
|
||||||
| tdSql.execute("ALTER DATABASE test ss_compact 0") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 31, '0') | ||||||
|
|
||||||
| tdSql.error("ALTER DATABASE test ss_compact 2",expectErrInfo="Invalid option", fullMatched=False) | ||||||
|
|
||||||
|
|
||||||
| def check_alter_keep_time_offset(self): | ||||||
| tdLog.info(f"check alter keep_time_offset") | ||||||
| tdSql.execute("ALTER DATABASE test keep_time_offset 22") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 28, '22') | ||||||
|
|
||||||
| def check_alter_compact_interval(self): | ||||||
| tdLog.info(f"check alter compact_interval") | ||||||
| tdSql.execute("ALTER DATABASE test compact_interval 1800d") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 34, '1800d') | ||||||
|
|
||||||
| tdSql.execute("ALTER DATABASE test compact_interval 1h") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 34, '1h') | ||||||
|
|
||||||
| def check_alter_compact_time_offset(self): | ||||||
| tdLog.info(f"check alter compact_time_offset") | ||||||
| tdSql.execute("ALTER DATABASE test compact_time_offset 18") | ||||||
| tdSql.query("select * from information_schema.ins_databases") | ||||||
| tdSql.checkData(2, 36, '18h') | ||||||
|
|
||||||
|
|
||||||
| def check_alter_unsupport_option(self): | ||||||
| tdLog.info(f"check alter unsupport option") | ||||||
| tdSql.error("ALTER DATABASE test COMP 1",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test DURATION 1",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test maxrows 1",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test encrypt_algorithm 'sm4'",expectErrInfo="Encryption is not allowed to be changed after database is created", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test vgroups 4",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test single_stable 1",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test schemaless 1",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test table_prefix 't'",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test table_suffix 't'",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test dnodes 'dnode1'",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test precision 'ms'",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test strict 'on'",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test pagesize 4096",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test tsdb_pagesize 4096",expectErrInfo="syntax error", fullMatched=False) | ||||||
| tdSql.error("ALTER DATABASE test retentions '1d:1d'",expectErrInfo="syntax error", fullMatched=False) | ||||||
|
|
||||||
| # run | ||||||
| def do_army_case(self): | ||||||
| tdLog.debug(f"start to excute {__file__}") | ||||||
|
|
||||||
| # prepare database | ||||||
| self.prepare_database() | ||||||
|
|
||||||
| # check alter buffer size | ||||||
| self.check_alter_buffer_size() | ||||||
|
|
||||||
| # check alter cache model | ||||||
| self.check_alter_cache_model() | ||||||
|
|
||||||
| # check alter cache size | ||||||
| self.check_alter_cache_size() | ||||||
|
|
||||||
| # check alter min rows | ||||||
| self.check_alter_min_rows() | ||||||
|
|
||||||
| # check alter pages | ||||||
| self.check_alter_pages() | ||||||
|
|
||||||
| # check alter wal_level | ||||||
| self.check_alter_wal_level() | ||||||
|
|
||||||
| # check alter wal_fsync_period | ||||||
| self.check_alter_fsync() | ||||||
|
|
||||||
| # check alter stt_trigger | ||||||
| self.check_alter_stt_trigger() | ||||||
|
|
||||||
| # check alter wal_retention_period | ||||||
| self.check_alter_wal_retention_period() | ||||||
|
|
||||||
| # check alter wal_retention_size | ||||||
| self.check_alter_wal_retention_size() | ||||||
|
|
||||||
| # check alter ss_keeplocal | ||||||
| self.check_alter_ss_keeplocal() | ||||||
|
|
||||||
| # check alter ss_compact | ||||||
| self.check_alter_ss_compact() | ||||||
|
|
||||||
| # check alter keep_time_offset | ||||||
| self.check_alter_keep_time_offset() | ||||||
|
|
||||||
| # check alter compact_interval | ||||||
| self.check_alter_compact_interval() | ||||||
|
|
||||||
| # check alter compact_time_offset | ||||||
| self.check_alter_compact_time_offset() | ||||||
|
|
||||||
| # check alter unsupport option | ||||||
| self.check_alter_unsupport_option() | ||||||
|
|
||||||
| print("do army case .......................... [passed]") | ||||||
|
DuanKuanJun marked this conversation as resolved.
|
||||||
|
|
||||||
| def test_db_alter_option(self): | ||||||
| """Alter all options | ||||||
|
|
||||||
| 1. Create database and inspect all option values. | ||||||
| 2. Attempt to alter database with invalid options (expect failure). | ||||||
| 3. Alter database with valid options and verify the changes. | ||||||
| 4. Check alter buffer size | ||||||
| 5. Check alter cache model | ||||||
| 6. Check alter cache size | ||||||
| 7. Check alter min rows | ||||||
| 8. Check alter pages | ||||||
| 9. Check alter wal_level | ||||||
| 10. Check alter wal_fsync_period | ||||||
| 11. Check alter stt_trigger | ||||||
| 12. Check alter wal_retention_period | ||||||
| 13. Check alter wal_retention_size | ||||||
| 14. Check alter ss_keeplocal | ||||||
| 15. Check alter ss_compact | ||||||
| 16. Check alter keep_time_offset | ||||||
| 17. Check alter compact_interval | ||||||
| 18. Check alter compact_time_offset | ||||||
| 19. Check alter unsupport option | ||||||
|
|
||||||
| Since: v3.0.0.0 | ||||||
|
|
||||||
| Labels: common,ci | ||||||
|
|
||||||
| Jira: None | ||||||
|
|
||||||
| History: | ||||||
| - 2025-10-20 Alex Duan Migrated from uncatalog/army/alter/test_alter_db_option.py | ||||||
| - 2025-04-30 Simon Guan Migrated from tsim/db/alter_option.sim | ||||||
|
|
||||||
| """ | ||||||
| self.do_sim_case() | ||||||
| self.do_army_case() | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.