-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adds database TTL with metric engine tables
- Loading branch information
1 parent
f21e46c
commit 62c985e
Showing
2 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
tests/cases/standalone/common/ttl/database_ttl_with_metric_engine.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,123 @@ | ||
CREATE DATABASE test_ttl_db WITH (ttl = '1 second'); | ||
|
||
Affected Rows: 1 | ||
|
||
USE test_ttl_db; | ||
|
||
Affected Rows: 0 | ||
|
||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = ""); | ||
|
||
Affected Rows: 0 | ||
|
||
-- It will use the database TTL setting -- | ||
CREATE TABLE test_ttl (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy"); | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl(ts, val, host) VALUES | ||
(now(), 1, 'host1'), | ||
(now(), 2, 'host2'), | ||
(now(), 3, 'host3'); | ||
|
||
Affected Rows: 3 | ||
|
||
SELECT val, host FROM test_ttl; | ||
|
||
+-----+-------+ | ||
| val | host | | ||
+-----+-------+ | ||
| 2.0 | host2 | | ||
| 3.0 | host3 | | ||
| 1.0 | host1 | | ||
+-----+-------+ | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('phy'); | ||
|
||
+--------------------------+ | ||
| ADMIN flush_table('phy') | | ||
+--------------------------+ | ||
| 0 | | ||
+--------------------------+ | ||
|
||
ADMIN compact_table('phy'); | ||
|
||
+----------------------------+ | ||
| ADMIN compact_table('phy') | | ||
+----------------------------+ | ||
| 0 | | ||
+----------------------------+ | ||
|
||
--- should be expired -- | ||
SELECT val, host FROM test_ttl; | ||
|
||
++ | ||
++ | ||
|
||
ALTER DATABASE test_ttl_db SET ttl = '1 day'; | ||
|
||
Affected Rows: 0 | ||
|
||
INSERT INTO test_ttl(ts, val, host) VALUES | ||
(now(), 1, 'host1'), | ||
(now(), 2, 'host2'), | ||
(now(), 3, 'host3'); | ||
|
||
Affected Rows: 3 | ||
|
||
ADMIN flush_table('phy'); | ||
|
||
+--------------------------+ | ||
| ADMIN flush_table('phy') | | ||
+--------------------------+ | ||
| 0 | | ||
+--------------------------+ | ||
|
||
ADMIN compact_table('phy'); | ||
|
||
+----------------------------+ | ||
| ADMIN compact_table('phy') | | ||
+----------------------------+ | ||
| 0 | | ||
+----------------------------+ | ||
|
||
--- should not be expired -- | ||
SELECT val, host FROM test_ttl; | ||
|
||
+-----+-------+ | ||
| val | host | | ||
+-----+-------+ | ||
| 2.0 | host2 | | ||
| 3.0 | host3 | | ||
| 1.0 | host1 | | ||
+-----+-------+ | ||
|
||
-- restart the db, ensure everything is ok | ||
-- SQLNESS ARG restart=true | ||
SELECT val, host FROM test_ttl; | ||
|
||
+-----+-------+ | ||
| val | host | | ||
+-----+-------+ | ||
| 2.0 | host2 | | ||
| 3.0 | host3 | | ||
| 1.0 | host1 | | ||
+-----+-------+ | ||
|
||
DROP TABLE test_ttl; | ||
|
||
Affected Rows: 0 | ||
|
||
DROP TABLE phy; | ||
|
||
Affected Rows: 0 | ||
|
||
USE public; | ||
|
||
Affected Rows: 0 | ||
|
||
DROP DATABASE test_ttl_db; | ||
|
||
Affected Rows: 0 | ||
|
50 changes: 50 additions & 0 deletions
50
tests/cases/standalone/common/ttl/database_ttl_with_metric_engine.sql
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,50 @@ | ||
CREATE DATABASE test_ttl_db WITH (ttl = '1 second'); | ||
|
||
USE test_ttl_db; | ||
|
||
CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = ""); | ||
|
||
-- It will use the database TTL setting -- | ||
CREATE TABLE test_ttl (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy"); | ||
|
||
|
||
INSERT INTO test_ttl(ts, val, host) VALUES | ||
(now(), 1, 'host1'), | ||
(now(), 2, 'host2'), | ||
(now(), 3, 'host3'); | ||
|
||
SELECT val, host FROM test_ttl; | ||
|
||
-- SQLNESS SLEEP 2s | ||
ADMIN flush_table('phy'); | ||
|
||
ADMIN compact_table('phy'); | ||
|
||
--- should be expired -- | ||
SELECT val, host FROM test_ttl; | ||
|
||
ALTER DATABASE test_ttl_db SET ttl = '1 day'; | ||
|
||
INSERT INTO test_ttl(ts, val, host) VALUES | ||
(now(), 1, 'host1'), | ||
(now(), 2, 'host2'), | ||
(now(), 3, 'host3'); | ||
|
||
ADMIN flush_table('phy'); | ||
|
||
ADMIN compact_table('phy'); | ||
|
||
--- should not be expired -- | ||
SELECT val, host FROM test_ttl; | ||
|
||
-- restart the db, ensure everything is ok | ||
-- SQLNESS ARG restart=true | ||
SELECT val, host FROM test_ttl; | ||
|
||
DROP TABLE test_ttl; | ||
|
||
DROP TABLE phy; | ||
|
||
USE public; | ||
|
||
DROP DATABASE test_ttl_db; |