Commit 83f3c211 authored by Hiro's avatar Hiro 🏄
Browse files

Add a test to check if for overlapping intervals we do not sum values

parent b86cd24f
Pipeline #40155 passed with stage
in 8 minutes and 37 seconds
......@@ -100,9 +100,9 @@
<target name="test-all-dbs"
depends="init"
description="Run all available database pgTAP tests." >
<antcall target="test-db">
<!-- <antcall target="test-db">
<param name="db2test" value="ipv6servers" />
</antcall>
</antcall> -->
<antcall target="test-db">
<param name="db2test" value="userstats" />
</antcall>
......
Subproject commit 8976cdd9be1bb70d3457bf2551971e12ee253ce1
Subproject commit 7b20f3bfc3525de4ed27f9fb0c84112d7a386df3
......@@ -22,9 +22,6 @@ SELECT has_table('imported');
SELECT has_column('imported', 'fingerprint');
SELECT col_type_is('imported', 'fingerprint', 'character(40)');
SELECT col_not_null('imported', 'fingerprint');
SELECT has_column('imported', 'nickname');
SELECT col_type_is('imported', 'nickname', 'character(40)');
SELECT col_not_null('imported', 'nickname');
SELECT has_column('imported', 'node');
SELECT col_type_is('imported', 'node', 'node');
SELECT col_not_null('imported', 'node');
......@@ -51,6 +48,9 @@ SELECT col_not_null('imported', 'stats_end');
SELECT has_column('imported', 'val');
SELECT col_type_is('imported', 'val', 'double precision');
SELECT col_not_null('imported', 'val');
SELECT has_column('imported', 'nickname');
SELECT col_type_is('imported', 'nickname', 'character(40)');
SELECT col_not_null('imported', 'nickname');
SELECT hasnt_pk('imported');
-- Make sure that the internally-used merged table is exactly as merge()
......@@ -62,9 +62,6 @@ SELECT col_is_pk('merged', 'id');
SELECT has_column('merged', 'fingerprint');
SELECT col_type_is('merged', 'fingerprint', 'character(40)');
SELECT col_not_null('merged', 'fingerprint');
SELECT has_column('merged', 'nickname');
SELECT col_type_is('merged', 'nickname', 'character(40)');
SELECT col_not_null('merged', 'nickname');
SELECT has_column('merged', 'node');
SELECT col_type_is('merged', 'node', 'node');
SELECT col_not_null('merged', 'node');
......@@ -91,7 +88,9 @@ SELECT col_not_null('merged', 'stats_end');
SELECT has_column('merged', 'val');
SELECT col_type_is('merged', 'val', 'double precision');
SELECT col_not_null('merged', 'val');
SELECT has_column('merged', 'nickname');
SELECT col_type_is('merged', 'nickname', 'character(40)');
SELECT col_not_null('merged', 'nickname');
-- Make sure that the internally-used aggregated table is exactly as
-- aggregate() expects it.
SELECT has_table('aggregated');
......@@ -205,6 +204,12 @@ PREPARE new_imported_nick(timestamp without time zone,
stats_end, val, nickname) VALUES ('1234567890123456789012345678901234567890',
'relay', 'status', '', '', '', $1, $2, 0, 'longclaw2');
PREPARE new_imported_check_value(timestamp without time zone,
timestamp without time zone) AS INSERT INTO imported
(fingerprint, node, metric, country, transport, version, stats_start,
stats_end, val, nickname) VALUES ('1234567890123456789012345678901234567890',
'relay', 'status', '', '', '', $1, $2, $3, 'longclaw');
EXECUTE new_imported('2013-04-11 14:00:00', '2013-04-11 15:00:00');
SELECT merge();
DROP TABLE merged_part;
......@@ -225,6 +230,26 @@ SELECT bag_eq('SELECT stats_end FROM merged',
DELETE FROM imported;
DELETE FROM merged;
EXECUTE new_imported_check_value('2022-05-08 05:10:35', '2022-05-09 05:10:35', 25);
EXECUTE new_imported_check_value('2022-05-08 05:10:35', '2022-05-09 05:10:35', 25);
SELECT merge();
DROP TABLE merged_part;
SELECT bag_eq('SELECT stats_end, val FROM merged',
$$VALUES ('2022-05-09 05:10:35'::timestamp without time zone, '25'::integer)$$,
'Should not sum values');
DELETE FROM imported;
DELETE FROM merged;
EXECUTE new_imported('2022-05-08 05:10:35', '2022-05-09 05:10:35');
EXECUTE new_imported('2022-05-08 05:10:35', '2022-05-09 05:10:35');
SELECT merge();
DROP TABLE merged_part;
SELECT bag_eq('SELECT stats_end FROM merged',
$$VALUES ('2022-05-09 05:10:35'::timestamp without time zone)$$,
'Should not insert two overlapping entries');
DELETE FROM imported;
DELETE FROM merged;
EXECUTE new_imported('2013-04-11 13:00:00', '2013-04-11 15:00:00');
EXECUTE new_imported('2013-04-11 15:00:00', '2013-04-11 17:00:00');
SELECT merge();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment