From cc0cec9a6f357ff90aa7b42a3ba11a10e7fcb293 Mon Sep 17 00:00:00 2001 From: Konrad Bucheli Date: Tue, 22 May 2018 15:58:23 +0200 Subject: [PATCH 1/2] simplify imports --- influxdb-schema-updater | 3 --- 1 file changed, 3 deletions(-) diff --git a/influxdb-schema-updater b/influxdb-schema-updater index 46b4b9d..295ba24 100755 --- a/influxdb-schema-updater +++ b/influxdb-schema-updater @@ -18,14 +18,11 @@ use strict; use warnings; use InfluxDB::HTTP; - use Getopt::Long; use Pod::Usage qw(pod2usage); use IPC::Run qw(run); use JSON::MaybeXS; use File::Slurper qw(read_text); -use List::Util qw(sum0); - sub main { my $show_usage; From 273e6ac8251b4227ae6927594fb16149eb2c659e Mon Sep 17 00:00:00 2001 From: Anselme Goetschmann Date: Wed, 18 Jul 2018 17:17:17 +0200 Subject: [PATCH 2/2] Avoid detecting change when there isn't because of fill(null) --- influxdb-schema-updater | 1 + t/data/test06.2/cq/db1.ifql | 2 ++ t/data/test06.2/db/db1.ifql | 2 ++ t/influxdb-schema-updater.t | 5 +++++ 4 files changed, 10 insertions(+) create mode 100644 t/data/test06.2/cq/db1.ifql create mode 100644 t/data/test06.2/db/db1.ifql diff --git a/influxdb-schema-updater b/influxdb-schema-updater index 295ba24..5a49810 100755 --- a/influxdb-schema-updater +++ b/influxdb-schema-updater @@ -305,6 +305,7 @@ sub compare_cqs { $cq =~ s/;//g; $cq =~ s/"//g; $cq = lc $cq; + $cq =~ s/fill\(null\)//g; # since fill(null) doesn't change anything, influx doesn't store it } return $cq1 cmp $cq2; } diff --git a/t/data/test06.2/cq/db1.ifql b/t/data/test06.2/cq/db1.ifql new file mode 100644 index 0000000..27e2b8c --- /dev/null +++ b/t/data/test06.2/cq/db1.ifql @@ -0,0 +1,2 @@ +CREATE CONTINUOUS QUERY cq1 ON test RESAMPLE EVERY 5m FOR 10m BEGIN SELECT LAST(a) AS b, c INTO test.rp2.m FROM test.rp1.m GROUP BY time(5m) fill(null) END; +CREATE CONTINUOUS QUERY cq2 ON test RESAMPLE EVERY 5m FOR 10m BEGIN SELECT MAX(a) AS b, c INTO test.rp2.m FROM test.rp1.m GROUP BY time(5m) END; \ No newline at end of file diff --git a/t/data/test06.2/db/db1.ifql b/t/data/test06.2/db/db1.ifql new file mode 100644 index 0000000..f92da11 --- /dev/null +++ b/t/data/test06.2/db/db1.ifql @@ -0,0 +1,2 @@ +CREATE DATABASE test WITH DURATION 260w REPLICATION 1 SHARD DURATION 12w NAME rp2; +CREATE RETENTION POLICY rp1 ON test DURATION 100d REPLICATION 1 SHARD DURATION 2w; diff --git a/t/influxdb-schema-updater.t b/t/influxdb-schema-updater.t index 50b1527..dfa1656 100755 --- a/t/influxdb-schema-updater.t +++ b/t/influxdb-schema-updater.t @@ -85,6 +85,11 @@ sub test { run_updater($curdir, "$schemas_dir/test06", $port); is run_updater($curdir, "$schemas_dir/test06", $port, '--diff'), '' => 'CQ is updated'; + # check that fill(null) is ignored + run_updater($curdir, "$schemas_dir/test06.2", $port, '--force'); + is run_updater($curdir, "$schemas_dir/test06.2", $port, '--diff'), '' => 'fill(null) in CQ is ignored'; + run_updater($curdir, "$schemas_dir/test06", $port, '--force'); # reset + # remove a continuous query is run_updater($curdir, "$schemas_dir/test07", $port, '--diff'), "-- DROP CONTINUOUS QUERY cq2 ON test;\n" => 'CQ removal is detected';