-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adds sqlness test for TTL (#5063)
* test: adds sqlness test for TTL * chore: restart cluster * fix: typo * test: adds database TTL with metric engine tables
- Loading branch information
1 parent
a518538
commit ff4c153
Showing
10 changed files
with
660 additions
and
0 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
tests/cases/standalone/common/ttl/alter_table_ttl.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT, PRIMARY KEY(val)) WITH (ttl = '1 day'); | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1), | ||
(now(), 2), | ||
(now(), 3); | ||
|
||
Affected Rows: 3 | ||
|
||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
| 2 | | ||
| 3 | | ||
+-----+ | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
+-------------------------------+ | ||
| ADMIN flush_table('test_ttl') | | ||
+-------------------------------+ | ||
| 0 | | ||
+-------------------------------+ | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
| 2 | | ||
| 3 | | ||
+-----+ | ||
|
||
ALTER TABLE test_ttl SET ttl = '1 second'; | ||
|
||
Affected Rows: 0 | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
SELECT val from test_ttl; | ||
|
||
++ | ||
++ | ||
|
||
ALTER TABLE test_ttl SET ttl = '1 minute'; | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1), | ||
(now(), 2), | ||
(now(), 3); | ||
|
||
Affected Rows: 3 | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
+-------------------------------+ | ||
| ADMIN flush_table('test_ttl') | | ||
+-------------------------------+ | ||
| 0 | | ||
+-------------------------------+ | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
| 2 | | ||
| 3 | | ||
+-----+ | ||
|
||
DROP TABLE test_ttl; | ||
|
||
Affected Rows: 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT, PRIMARY KEY(val)) WITH (ttl = '1 day'); | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1), | ||
(now(), 2), | ||
(now(), 3); | ||
|
||
SELECT val from test_ttl; | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
SELECT val from test_ttl; | ||
|
||
ALTER TABLE test_ttl SET ttl = '1 second'; | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN compact_table('test_ttl'); | ||
|
||
SELECT val from test_ttl; | ||
|
||
ALTER TABLE test_ttl SET ttl = '1 minute'; | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1), | ||
(now(), 2), | ||
(now(), 3); | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
|
||
SELECT val from test_ttl; | ||
|
||
|
||
DROP TABLE test_ttl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT) WITH (ttl = '1 second'); | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
Affected Rows: 1 | ||
|
||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
+-----+ | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
+-------------------------------+ | ||
| ADMIN flush_table('test_ttl') | | ||
+-------------------------------+ | ||
| 0 | | ||
+-------------------------------+ | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
SELECT val from test_ttl; | ||
|
||
++ | ||
++ | ||
|
||
DROP TABLE test_ttl; | ||
|
||
Affected Rows: 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT) WITH (ttl = '1 second'); | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
SELECT val from test_ttl; | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
SELECT val from test_ttl; | ||
|
||
DROP TABLE test_ttl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
CREATE DATABASE test_ttl_db WITH (ttl = '1 second'); | ||
|
||
Affected Rows: 1 | ||
|
||
USE test_ttl_db; | ||
|
||
Affected Rows: 0 | ||
|
||
-- It will use the database TTL setting -- | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT); | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
Affected Rows: 1 | ||
|
||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
+-----+ | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
+-------------------------------+ | ||
| ADMIN flush_table('test_ttl') | | ||
+-------------------------------+ | ||
| 0 | | ||
+-------------------------------+ | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
-- Must be expired -- | ||
SELECT val from test_ttl; | ||
|
||
++ | ||
++ | ||
|
||
ALTER DATABASE test_ttl_db SET ttl = '1 day'; | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
Affected Rows: 1 | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
+-------------------------------+ | ||
| ADMIN flush_table('test_ttl') | | ||
+-------------------------------+ | ||
| 0 | | ||
+-------------------------------+ | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
+---------------------------------+ | ||
| ADMIN compact_table('test_ttl') | | ||
+---------------------------------+ | ||
| 0 | | ||
+---------------------------------+ | ||
|
||
-- Must not be expired -- | ||
SELECT val from test_ttl; | ||
|
||
+-----+ | ||
| val | | ||
+-----+ | ||
| 1 | | ||
+-----+ | ||
|
||
DROP TABLE test_ttl; | ||
|
||
Affected Rows: 0 | ||
|
||
USE public; | ||
|
||
Affected Rows: 0 | ||
|
||
DROP DATABASE test_ttl_db; | ||
|
||
Affected Rows: 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CREATE DATABASE test_ttl_db WITH (ttl = '1 second'); | ||
|
||
USE test_ttl_db; | ||
|
||
-- It will use the database TTL setting -- | ||
CREATE TABLE test_ttl(ts TIMESTAMP TIME INDEX, val INT); | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
SELECT val from test_ttl; | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
-- Must be expired -- | ||
SELECT val from test_ttl; | ||
|
||
ALTER DATABASE test_ttl_db SET ttl = '1 day'; | ||
|
||
INSERT INTO test_ttl VALUES | ||
(now(), 1); | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('test_ttl'); | ||
|
||
ADMIN compact_table('test_ttl'); | ||
|
||
-- Must not be expired -- | ||
SELECT val from test_ttl; | ||
|
||
DROP TABLE test_ttl; | ||
|
||
|
||
USE public; | ||
|
||
DROP DATABASE test_ttl_db; |
Oops, something went wrong.