This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add infrastructure for psql-based golden tests
This adds the infrastructure for simple golden file tests. Also add a simple golden file test for views.
- Loading branch information
Showing
7 changed files
with
269 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
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
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,85 @@ | ||
\set ON_ERROR_STOP 1 | ||
SELECT _prom_catalog.get_or_create_metric_table_name('cpu_usage'); | ||
psql:/testdata/sql/views.sql:4: NOTICE: adding not-null constraint to column "time" | ||
DETAIL: Time dimensions cannot have NULL values | ||
psql:/testdata/sql/views.sql:4: NOTICE: adding index _compressed_hypertable_2_series_id__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_2 USING BTREE(series_id, _ts_meta_sequence_num) | ||
get_or_create_metric_table_name | ||
--------------------------------- | ||
(1,cpu_usage) | ||
(1 row) | ||
|
||
SELECT _prom_catalog.get_or_create_metric_table_name('cpu_total'); | ||
psql:/testdata/sql/views.sql:5: NOTICE: adding not-null constraint to column "time" | ||
DETAIL: Time dimensions cannot have NULL values | ||
psql:/testdata/sql/views.sql:5: NOTICE: adding index _compressed_hypertable_4_series_id__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_4 USING BTREE(series_id, _ts_meta_sequence_num) | ||
get_or_create_metric_table_name | ||
--------------------------------- | ||
(2,cpu_total) | ||
(1 row) | ||
|
||
INSERT INTO prom_data.cpu_usage | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.1 + g, series_id('{"__name__": "cpu_usage", "namespace":"dev", "node": "brain"}') | ||
FROM generate_series(1,10) g; | ||
INSERT 0 10 | ||
INSERT INTO prom_data.cpu_usage | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.1 + g, series_id('{"__name__": "cpu_usage", "namespace":"production", "node": "pinky", "new_tag":"foo"}') | ||
FROM generate_series(1,10) g; | ||
INSERT 0 10 | ||
INSERT INTO prom_data.cpu_total | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.0, series_id('{"__name__": "cpu_total", "namespace":"dev", "node": "brain"}') | ||
FROM generate_series(1,10) g; | ||
INSERT 0 10 | ||
INSERT INTO prom_data.cpu_total | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.0, series_id('{"__name__": "cpu_total", "namespace":"production", "node": "pinky", "new_tag_2":"bar"}') | ||
FROM generate_series(1,10) g; | ||
INSERT 0 10 | ||
SELECT * FROM prom_info.label ORDER BY key; | ||
key | value_column_name | id_column_name | values | ||
-----------+-------------------+----------------+----------------------- | ||
__name__ | __name__ | __name___id | {cpu_total,cpu_usage} | ||
namespace | namespace | namespace_id | {dev,production} | ||
new_tag | new_tag | new_tag_id | {foo} | ||
new_tag_2 | new_tag_2 | new_tag_2_id | {bar} | ||
node | node | node_id | {brain,pinky} | ||
(5 rows) | ||
|
||
SELECT count(compress_chunk(i)) from show_chunks('prom_data.cpu_usage') i; | ||
count | ||
------- | ||
1 | ||
(1 row) | ||
|
||
SELECT * FROM prom_info.metric ORDER BY id; | ||
id | metric_name | table_name | retention_period | chunk_interval | label_keys | size | compression_ratio | total_chunks | compressed_chunks | ||
----+-------------+------------+------------------+----------------+-------------------------------------+-------+-------------------------+--------------+------------------- | ||
1 | cpu_usage | cpu_usage | 90 days | 08:00:00 | {__name__,namespace,new_tag,node} | 48 kB | 20.00000000000000000000 | 1 | 1 | ||
2 | cpu_total | cpu_total | 90 days | 08:00:00 | {__name__,namespace,new_tag_2,node} | 40 kB | | | | ||
(2 rows) | ||
|
||
SELECT * FROM cpu_usage ORDER BY time, series_id LIMIT 5; | ||
time | value | series_id | labels | node_id | namespace_id | new_tag_id | ||
------------------------+-------+-----------+-----------+---------+--------------+------------ | ||
2000-01-01 02:03:05+00 | 101.1 | 1 | {2,1,3} | 1 | 3 | | ||
2000-01-01 02:03:05+00 | 101.1 | 2 | {2,4,6,5} | 4 | 6 | 5 | ||
2000-01-01 02:03:06+00 | 102.1 | 1 | {2,1,3} | 1 | 3 | | ||
2000-01-01 02:03:06+00 | 102.1 | 2 | {2,4,6,5} | 4 | 6 | 5 | ||
2000-01-01 02:03:07+00 | 103.1 | 1 | {2,1,3} | 1 | 3 | | ||
(5 rows) | ||
|
||
SELECT time, value, jsonb(labels), val(namespace_id) FROM cpu_usage ORDER BY time, series_id LIMIT 5; | ||
time | value | jsonb | val | ||
------------------------+-------+-----------------------------------------------------------------------------------------+------------ | ||
2000-01-01 02:03:05+00 | 101.1 | {"node": "brain", "__name__": "cpu_usage", "namespace": "dev"} | dev | ||
2000-01-01 02:03:05+00 | 101.1 | {"node": "pinky", "new_tag": "foo", "__name__": "cpu_usage", "namespace": "production"} | production | ||
2000-01-01 02:03:06+00 | 102.1 | {"node": "brain", "__name__": "cpu_usage", "namespace": "dev"} | dev | ||
2000-01-01 02:03:06+00 | 102.1 | {"node": "pinky", "new_tag": "foo", "__name__": "cpu_usage", "namespace": "production"} | production | ||
2000-01-01 02:03:07+00 | 103.1 | {"node": "brain", "__name__": "cpu_usage", "namespace": "dev"} | dev | ||
(5 rows) | ||
|
||
SELECT * FROM prom_series.cpu_usage ORDER BY series_id; | ||
series_id | labels | node | namespace | new_tag | ||
-----------+-----------+-------+------------+--------- | ||
1 | {2,1,3} | brain | dev | | ||
2 | {2,4,6,5} | pinky | production | foo | ||
(2 rows) | ||
|
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,26 @@ | ||
\set ECHO all | ||
\set ON_ERROR_STOP 1 | ||
|
||
SELECT _prom_catalog.get_or_create_metric_table_name('cpu_usage'); | ||
SELECT _prom_catalog.get_or_create_metric_table_name('cpu_total'); | ||
INSERT INTO prom_data.cpu_usage | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.1 + g, series_id('{"__name__": "cpu_usage", "namespace":"dev", "node": "brain"}') | ||
FROM generate_series(1,10) g; | ||
INSERT INTO prom_data.cpu_usage | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.1 + g, series_id('{"__name__": "cpu_usage", "namespace":"production", "node": "pinky", "new_tag":"foo"}') | ||
FROM generate_series(1,10) g; | ||
INSERT INTO prom_data.cpu_total | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.0, series_id('{"__name__": "cpu_total", "namespace":"dev", "node": "brain"}') | ||
FROM generate_series(1,10) g; | ||
INSERT INTO prom_data.cpu_total | ||
SELECT timestamptz '2000-01-01 02:03:04'+(interval '1s' * g), 100.0, series_id('{"__name__": "cpu_total", "namespace":"production", "node": "pinky", "new_tag_2":"bar"}') | ||
FROM generate_series(1,10) g; | ||
|
||
SELECT * FROM prom_info.label ORDER BY key; | ||
|
||
SELECT count(compress_chunk(i)) from show_chunks('prom_data.cpu_usage') i; | ||
SELECT * FROM prom_info.metric ORDER BY id; | ||
|
||
SELECT * FROM cpu_usage ORDER BY time, series_id LIMIT 5; | ||
SELECT time, value, jsonb(labels), val(namespace_id) FROM cpu_usage ORDER BY time, series_id LIMIT 5; | ||
SELECT * FROM prom_series.cpu_usage ORDER BY series_id; |
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