forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update test for repair table script
This commit creates an update repair test that breaks a few tables for pre-2.0 versions to ensure that the repair script actually fixes them. The integrity check for the update tests already contain a check that dimension slices are valid, so there is no need to add a test for that. Fixes timescale#2824
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- This file and its contents are licensed under the Apache License 2.0. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-APACHE for a copy of the license. | ||
|
||
-- Test file to check that the repair script works. It will create a | ||
-- bunch of tables and "break" them by removing dimension slices from | ||
-- the dimension slice table. The repair script should then repair all | ||
-- of them and there should be no dimension slices missing. | ||
|
||
CREATE TABLE chunk_test_int(time integer, temp float8, tag integer, color integer); | ||
CREATE TABLE chunk_test_timestamptz(time timestamptz, temp float8, tag integer, color integer); | ||
CREATE TABLE chunk_test_timestamp(time timestamp, temp float8, tag integer, color integer); | ||
CREATE TABLE chunk_test_date(time date, temp float8, tag integer, color integer); | ||
|
||
SELECT create_hypertable('chunk_test_int', 'time', 'tag', 2, chunk_time_interval => 3); | ||
SELECT create_hypertable('chunk_test_timestamptz', 'time', 'tag', 2, chunk_time_interval => '1 day'::interval); | ||
SELECT create_hypertable('chunk_test_timestamp', 'time', 'tag', 2, chunk_time_interval => '1 day'::interval); | ||
SELECT create_hypertable('chunk_test_date', 'time', 'tag', 2, chunk_time_interval => '1 day'::interval); | ||
|
||
-- These rows will create four constraints for each table. | ||
INSERT INTO chunk_test_int VALUES | ||
(4, 24.3, 1, 1), | ||
(4, 24.3, 2, 1), | ||
(10, 24.3, 2, 1); | ||
|
||
INSERT INTO chunk_test_timestamptz VALUES | ||
('2020-01-01 10:11:12', 24.3, 1, 1), | ||
('2020-01-01 10:11:13', 24.3, 2, 1), | ||
('2020-01-02 10:11:14', 24.3, 2, 1); | ||
|
||
INSERT INTO chunk_test_timestamp VALUES | ||
('2020-01-01 10:11:12', 24.3, 1, 1), | ||
('2020-01-01 10:11:13', 24.3, 2, 1), | ||
('2020-01-02 10:11:14', 24.3, 2, 1); | ||
|
||
INSERT INTO chunk_test_date VALUES | ||
('2020-01-01 10:11:12', 24.3, 1, 1), | ||
('2020-01-01 10:11:13', 24.3, 2, 1), | ||
('2020-01-02 10:11:14', 24.3, 2, 1); | ||
|
||
ALTER TABLE _timescaledb_catalog.chunk_constraint | ||
DROP CONSTRAINT chunk_constraint_dimension_slice_id_fkey; | ||
|
||
-- Break the first dimension on each table. It contain one of the | ||
-- time constraints. | ||
DELETE FROM _timescaledb_catalog.dimension_slice WHERE id IN (1, 5, 9, 13); | ||
|
||
-- Break the partition constraints on some of the tables. These look | ||
-- the same in all tables so we create a mix of tables with just one | ||
-- missing dimension slice and several missing dimension slices. | ||
DELETE FROM _timescaledb_catalog.dimension_slice WHERE id IN (6, 14, 15); |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
\ir setup.compression.sql | ||
\ir setup.policies.sql | ||
\ir setup.multinode.sql | ||
\ir setup.repair.sql |