From 33d28d2217df648eb528fa0dca902d7233d2626d Mon Sep 17 00:00:00 2001 From: Matvey Arye Date: Tue, 11 Jun 2019 15:24:54 -0400 Subject: [PATCH] Test continuous aggs with extension updates Add a v3 update test that makes sure that continuous aggregates continue to work after extensions are updated. --- scripts/test_updates_pg10.sh | 18 +++++- scripts/test_updates_with_constraints.sh | 17 ++++- test/sql/updates/post.continuous_aggs.sql | 15 +++++ test/sql/updates/post.v3.sql | 7 +++ test/sql/updates/setup.continuous_aggs.sql | 73 ++++++++++++++++++++++ test/sql/updates/setup.v3.sql | 7 +++ 6 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 test/sql/updates/post.continuous_aggs.sql create mode 100644 test/sql/updates/post.v3.sql create mode 100644 test/sql/updates/setup.continuous_aggs.sql create mode 100644 test/sql/updates/setup.v3.sql diff --git a/scripts/test_updates_pg10.sh b/scripts/test_updates_pg10.sh index 41ff51a77..0c1ebad6c 100755 --- a/scripts/test_updates_pg10.sh +++ b/scripts/test_updates_pg10.sh @@ -5,7 +5,21 @@ set -o pipefail SCRIPT_DIR=$(dirname $0) -TAGS="0.7.0-pg10 0.7.1-pg10 0.8.0-pg10 0.9.0-pg10 0.9.1-pg10 0.9.2-pg10 0.10.0-pg10 0.10.1-pg10 0.11.0-pg10 0.12.0-pg10 1.0.0-pg10 1.0.1-pg10 1.1.0-pg10 1.1.1-pg10 1.2.0-pg10 1.2.1-pg10 1.2.2-pg10 1.3.0-pg10 1.3.1-pg10" +TAGS="0.7.0-pg10 0.7.1-pg10 0.8.0-pg10 0.9.0-pg10 0.9.1-pg10 0.9.2-pg10 0.10.0-pg10 0.10.1-pg10 0.11.0-pg10 0.12.0-pg10 1.0.0-pg10 1.0.1-pg10 1.1.0-pg10 1.1.1-pg10 1.2.0-pg10 1.2.1-pg10 1.2.2-pg10" TEST_VERSION="v2" -. ${SCRIPT_DIR}/test_updates.sh +TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + exit $EXIT_CODE +fi + + +TAGS="1.3.0-pg10 1.3.1-pg10" +TEST_VERSION="v3" + +TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + exit $EXIT_CODE +fi diff --git a/scripts/test_updates_with_constraints.sh b/scripts/test_updates_with_constraints.sh index 3552a01f7..014cd7fc1 100755 --- a/scripts/test_updates_with_constraints.sh +++ b/scripts/test_updates_with_constraints.sh @@ -12,7 +12,20 @@ set -o pipefail SCRIPT_DIR=$(dirname $0) -TAGS="0.5.0 0.6.0 0.6.1 0.7.0-pg9.6 0.7.1-pg9.6 0.8.0-pg9.6 0.9.0-pg9.6 0.9.1-pg9.6 0.9.2-pg9.6 0.10.0-pg9.6 0.10.1-pg9.6 0.11.0-pg9.6 0.12.0-pg9.6 1.0.0-pg9.6 1.0.1-pg9.6 1.1.0-pg9.6 1.1.1-pg9.6 1.2.0-pg9.6 1.2.1-pg9.6 1.2.2-pg9.6 1.3.0-pg9.6 1.3.1-pg9.6" +TAGS="0.5.0 0.6.0 0.6.1 0.7.0-pg9.6 0.7.1-pg9.6 0.8.0-pg9.6 0.9.0-pg9.6 0.9.1-pg9.6 0.9.2-pg9.6 0.10.0-pg9.6 0.10.1-pg9.6 0.11.0-pg9.6 0.12.0-pg9.6 1.0.0-pg9.6 1.0.1-pg9.6 1.1.0-pg9.6 1.1.1-pg9.6 1.2.0-pg9.6 1.2.1-pg9.6 1.2.2-pg9.6" TEST_VERSION="v2" -. ${SCRIPT_DIR}/test_updates.sh +TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + exit $EXIT_CODE +fi + +TAGS="1.3.0-pg9.6 1.3.1-pg9.6" +TEST_VERSION="v3" + +TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + exit $EXIT_CODE +fi diff --git a/test/sql/updates/post.continuous_aggs.sql b/test/sql/updates/post.continuous_aggs.sql new file mode 100644 index 000000000..1629b0fd2 --- /dev/null +++ b/test/sql/updates/post.continuous_aggs.sql @@ -0,0 +1,15 @@ +-- 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. + +SELECT * FROM mat_before; + +INSERT INTO conditions_before +SELECT generate_series('2018-12-01 00:00'::timestamp, '2018-12-31 00:00'::timestamp, '1 day'), 'POR', 165, 75, 40, 70, NULL, (1,2)::custom_type, 2, true; + +SELECT * FROM mat_before; + +REFRESH MATERIALIZED VIEW mat_before; + +--the max of the temp for the POR should now be 165 +SELECT * FROM mat_before; diff --git a/test/sql/updates/post.v3.sql b/test/sql/updates/post.v3.sql new file mode 100644 index 000000000..54493ce95 --- /dev/null +++ b/test/sql/updates/post.v3.sql @@ -0,0 +1,7 @@ +-- 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. + +\ir post.v2.sql + +\ir post.continuous_aggs.sql diff --git a/test/sql/updates/setup.continuous_aggs.sql b/test/sql/updates/setup.continuous_aggs.sql new file mode 100644 index 000000000..8a7e1ce31 --- /dev/null +++ b/test/sql/updates/setup.continuous_aggs.sql @@ -0,0 +1,73 @@ +-- 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. + +CREATE TYPE custom_type AS (high int, low int); + +CREATE TABLE conditions_before ( + timec TIMESTAMPTZ NOT NULL, + location TEXT NOT NULL, + temperature DOUBLE PRECISION NULL, + humidity DOUBLE PRECISION NULL, + lowp double precision NULL, + highp double precision null, + allnull double precision null, + highlow custom_type null, + bit_int smallint, + good_life boolean + ); + +SELECT table_name FROM create_hypertable( 'conditions_before', 'timec'); + +INSERT INTO conditions_before +SELECT generate_series('2018-12-01 00:00'::timestamp, '2018-12-31 00:00'::timestamp, '1 day'), 'POR', 55, 75, 40, 70, NULL, (1,2)::custom_type, 2, true; +INSERT INTO conditions_before +SELECT generate_series('2018-11-01 00:00'::timestamp, '2018-12-31 00:00'::timestamp, '1 day'), 'NYC', 35, 45, 50, 40, NULL, (3,4)::custom_type, 4, false; +INSERT INTO conditions_before +SELECT generate_series('2018-11-01 00:00'::timestamp, '2018-12-15 00:00'::timestamp, '1 day'), 'LA', 73, 55, NULL, 28, NULL, NULL, 8, true; + +CREATE VIEW mat_before +WITH ( timescaledb.continuous, timescaledb.refresh_lag='-30 day') +AS + SELECT time_bucket('1week', timec) as bucket, + location, + min(allnull) as min_allnull, + max(temperature) as max_temp, + sum(temperature)+sum(humidity) as agg_sum_expr, + avg(humidity), + stddev(humidity), + bit_and(bit_int), + bit_or(bit_int), + bool_and(good_life), + every(temperature > 0), + bool_or(good_life), + count(*) as count_rows, + count(temperature) as count_temp, + count(allnull) as count_zero, + corr(temperature, humidity), + covar_pop(temperature, humidity), + covar_samp(temperature, humidity), + regr_avgx(temperature, humidity), + regr_avgy(temperature, humidity), + regr_count(temperature, humidity), + regr_intercept(temperature, humidity), + regr_r2(temperature, humidity), + regr_slope(temperature, humidity), + regr_sxx(temperature, humidity), + regr_sxy(temperature, humidity), + regr_syy(temperature, humidity), + stddev(temperature) as stddev_temp, + stddev_pop(temperature), + stddev_samp(temperature), + variance(temperature), + var_pop(temperature), + var_samp(temperature), + last(temperature, timec) as last_temp, + last(highlow, timec) as last_hl, + first(highlow, timec) as first_hl, + histogram(temperature, 0, 100, 5) + FROM conditions_before + GROUP BY bucket, location + HAVING min(location) >= 'NYC' and avg(temperature) > 2; + + REFRESH MATERIALIZED VIEW mat_before; diff --git a/test/sql/updates/setup.v3.sql b/test/sql/updates/setup.v3.sql new file mode 100644 index 000000000..652dab363 --- /dev/null +++ b/test/sql/updates/setup.v3.sql @@ -0,0 +1,7 @@ +-- 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. + +\ir setup.v2.sql + +\ir setup.continuous_aggs.sql