Skip to content

Commit

Permalink
Stabilize more tests (#7066)
Browse files Browse the repository at this point in the history
* cagg_watermark_concurrent_update is very dependent on the chunk
numbers, and should be ran first.
* telemetry_stats should do VACUUM and REINDEX before getting the
statistics, to avoid dependency on how the index was build
* cagg_migrate_function is missing some orderbys
  • Loading branch information
akuzm authored Jun 26, 2024
1 parent fb14771 commit 82ab09d
Show file tree
Hide file tree
Showing 15 changed files with 331 additions and 278 deletions.
11 changes: 9 additions & 2 deletions test/runner_isolation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ set -u
ISOLATIONTEST=$1
shift

# Note that removing the chunk numbers is not enough. The chunk numbers also
# influence the alignment of the EXPLAIN output, so not only we have to replace
# them, we also have to remove the "----"s and the trailing spaces. The aligned
# output format in isolation tester is hardcoded, we cannot change it. Moreover,
# the chunk numbers influence the names of indexes if they are long enough to be
# truncated, so the only way to get a stable explain output is to run such a test
# in a separate database.
$ISOLATIONTEST "$@" | \
sed -e 's!_[0-9]\{1,\}_[0-9]\{1,\}_chunk!_X_X_chunk!g' | \
sed -e 's!hypertable_[0-9]\{1,\}!hypertable_X!g'
sed -e 's!_[0-9]\{1,\}_[0-9]\{1,\}_chunk!_X_X_chunk!g' \
-e 's!hypertable_[0-9]\{1,\}!hypertable_X!g'

4 changes: 2 additions & 2 deletions tsl/test/expected/cagg_migrate_function-14.out
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 00:00:00'), sensor, avg(v
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_timestamp;
SELECT * FROM cagg_temp_ng_1week_timestamp ORDER BY time, sensor;
time | sensor | avg
--------------------------+--------+-----
Sat Dec 26 00:00:00 2009 | 1 | 101
Expand Down Expand Up @@ -1027,7 +1027,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 01:00:00+00'), sensor, av
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_date;
SELECT * FROM cagg_temp_ng_1week_date ORDER BY time, sensor;
time | sensor | avg
------------+--------+-----
12-26-2009 | 1 | 101
Expand Down
4 changes: 2 additions & 2 deletions tsl/test/expected/cagg_migrate_function-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 00:00:00'), sensor, avg(v
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_timestamp;
SELECT * FROM cagg_temp_ng_1week_timestamp ORDER BY time, sensor;
time | sensor | avg
--------------------------+--------+-----
Sat Dec 26 00:00:00 2009 | 1 | 101
Expand Down Expand Up @@ -1027,7 +1027,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 01:00:00+00'), sensor, av
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_date;
SELECT * FROM cagg_temp_ng_1week_date ORDER BY time, sensor;
time | sensor | avg
------------+--------+-----
12-26-2009 | 1 | 101
Expand Down
4 changes: 2 additions & 2 deletions tsl/test/expected/cagg_migrate_function-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 00:00:00'), sensor, avg(v
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_timestamp;
SELECT * FROM cagg_temp_ng_1week_timestamp ORDER BY time, sensor;
time | sensor | avg
--------------------------+--------+-----
Sat Dec 26 00:00:00 2009 | 1 | 101
Expand Down Expand Up @@ -1027,7 +1027,7 @@ SELECT time_bucket('1 week', time, origin=>'2000-01-01 01:00:00+00'), sensor, av
(4 rows)

-- Even the CAgg now uses time_bucket, we should see buckets of the same alignment
SELECT * FROM cagg_temp_ng_1week_date;
SELECT * FROM cagg_temp_ng_1week_date ORDER BY time, sensor;
time | sensor | avg
------------+--------+-----
12-26-2009 | 1 | 101
Expand Down
43 changes: 27 additions & 16 deletions tsl/test/expected/telemetry_stats.out
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,13 @@ SELECT * FROM normal;
INSERT INTO part
SELECT * FROM normal;
CALL refresh_continuous_aggregate('contagg', NULL, NULL);
-- Reindex to avoid the dependency on the way the index is built (e.g. the caggs
-- might get their rows inserted in different order during the refresh based on
-- the underlying aggregation plan, and the index will be built differently,
-- which can influence its size).
REINDEX DATABASE :TEST_DBNAME;
-- ANALYZE to get updated reltuples stats
ANALYZE normal, hyper, part;
VACUUM ANALYZE;
SELECT count(c) FROM show_chunks('hyper') c;
count
-------
Expand All @@ -185,14 +190,14 @@ SELECT jsonb_pretty(rels) AS relations FROM relations;
"num_relations": 2 +
}, +
"tables": { +
"heap_size": 65536, +
"heap_size": 73728, +
"toast_size": 8192, +
"indexes_size": 0, +
"num_relations": 2, +
"num_reltuples": 697 +
}, +
"hypertables": { +
"heap_size": 163840, +
"heap_size": 475136, +
"toast_size": 0, +
"compression": { +
"compressed_heap_size": 0, +
Expand All @@ -207,19 +212,19 @@ SELECT jsonb_pretty(rels) AS relations FROM relations;
"num_compressed_hypertables": 0, +
"compressed_row_count_frozen_immediately": 0+
}, +
"indexes_size": 286720, +
"indexes_size": 270336, +
"num_children": 11, +
"num_relations": 2, +
"num_reltuples": 697 +
"num_reltuples": 1394 +
}, +
"materialized_views": { +
"toast_size": 8192, +
"indexes_size": 0, +
"num_relations": 1, +
"num_reltuples": 0 +
"num_reltuples": 1 +
}, +
"partitioned_tables": { +
"heap_size": 98304, +
"heap_size": 180224, +
"toast_size": 0, +
"indexes_size": 0, +
"num_children": 6, +
Expand Down Expand Up @@ -260,7 +265,7 @@ SELECT (SELECT count(*) FROM normal) num_inserted_rows,
(SELECT rels -> 'partitioned_tables' -> 'num_reltuples' FROM relations) part_reltuples;
num_inserted_rows | normal_reltuples | hyper_reltuples | part_reltuples
-------------------+------------------+-----------------+----------------
697 | 697 | 697 | 697
697 | 697 | 1394 | 697
(1 row)

-- Add compression
Expand Down Expand Up @@ -290,7 +295,13 @@ FROM show_chunks('contagg') c ORDER BY c LIMIT 1;

-- Turn of real-time aggregation
ALTER MATERIALIZED VIEW contagg SET (timescaledb.materialized_only = true);
ANALYZE normal, hyper, part;
-- Reindex to avoid the dependency on the way the index is built (e.g. the caggs
-- might get their rows inserted in different order during the refresh based on
-- the underlying aggregation plan, and the index will be built differently,
-- which can influence its size).
REINDEX DATABASE :TEST_DBNAME;
-- ANALYZE to get updated reltuples stats
VACUUM ANALYZE;
REFRESH MATERIALIZED VIEW telemetry_report;
SELECT jsonb_pretty(rels) AS relations FROM relations;
relations
Expand All @@ -300,41 +311,41 @@ SELECT jsonb_pretty(rels) AS relations FROM relations;
"num_relations": 2 +
}, +
"tables": { +
"heap_size": 65536, +
"heap_size": 73728, +
"toast_size": 8192, +
"indexes_size": 0, +
"num_relations": 2, +
"num_reltuples": 697 +
}, +
"hypertables": { +
"heap_size": 196608, +
"heap_size": 368640, +
"toast_size": 40960, +
"compression": { +
"compressed_heap_size": 114688, +
"compressed_row_count": 14, +
"compressed_toast_size": 40960, +
"num_compressed_chunks": 5, +
"uncompressed_heap_size": 81920, +
"uncompressed_heap_size": 221184, +
"uncompressed_row_count": 736, +
"compressed_indexes_size": 16384, +
"uncompressed_toast_size": 0, +
"uncompressed_indexes_size": 147456, +
"uncompressed_indexes_size": 131072, +
"num_compressed_hypertables": 2, +
"compressed_row_count_frozen_immediately": 14+
}, +
"indexes_size": 204800, +
"num_children": 11, +
"num_relations": 2, +
"num_reltuples": 413 +
"num_reltuples": 658 +
}, +
"materialized_views": { +
"toast_size": 8192, +
"indexes_size": 0, +
"num_relations": 1, +
"num_reltuples": 0 +
"num_reltuples": 1 +
}, +
"partitioned_tables": { +
"heap_size": 98304, +
"heap_size": 180224, +
"toast_size": 0, +
"indexes_size": 0, +
"num_children": 6, +
Expand Down
Loading

0 comments on commit 82ab09d

Please sign in to comment.