From da88217fd86fd0bd9a81b55e23cca1b889882f3b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 6 Feb 2022 20:19:20 -0800 Subject: [PATCH] Fixed test style --- .editorconfig | 2 +- test/t/001_wal.pl | 7 ++++--- test/t/003_recall.pl | 32 ++++++++++++++++---------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0cf6f7f..6ce05d9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,6 @@ root = true -[*.{c,h}] +[*.{c,h,pl}] indent_style = tab indent_size = tab tab_width = 4 diff --git a/test/t/001_wal.pl b/test/t/001_wal.pl index 4e9b21c..15ca3d4 100644 --- a/test/t/001_wal.pl +++ b/test/t/001_wal.pl @@ -34,9 +34,10 @@ sub test_index_replay my $r2 = rand(); my $r3 = rand(); - my $queries = qq(SET enable_seqscan=off; -SELECT * FROM tst ORDER BY v <-> '[$r1,$r2,$r3]' LIMIT 10; -); + my $queries = qq( + SET enable_seqscan = off; + SELECT * FROM tst ORDER BY v <-> '[$r1,$r2,$r3]' LIMIT 10; + ); # Run test queries and compare their result my $primary_result = $node_primary->safe_psql("postgres", $queries); diff --git a/test/t/003_recall.pl b/test/t/003_recall.pl index 44e421f..5d7387a 100644 --- a/test/t/003_recall.pl +++ b/test/t/003_recall.pl @@ -10,24 +10,24 @@ my @expected_ids; # TODO Run more queries to prevent flakiness sub test_recall { - my ($probes, $min) = @_; + my ($probes, $min) = @_; - my $actual = $node->safe_psql("postgres", qq( -SET enable_seqscan = off; -SET ivfflat.probes = $probes; -SELECT i FROM tst ORDER BY v <-> '[0.5,0.5,0.5]' LIMIT 10; -)); - my @actual_ids = split("\n", $actual); - my %actual_set = map { $_ => 1 } @actual_ids; + my $actual = $node->safe_psql("postgres", qq( + SET enable_seqscan = off; + SET ivfflat.probes = $probes; + SELECT i FROM tst ORDER BY v <-> '[0.5,0.5,0.5]' LIMIT 10; + )); + my @actual_ids = split("\n", $actual); + my %actual_set = map { $_ => 1 } @actual_ids; - my $count = 0; - for my $el (@expected_ids) { - if (exists($actual_set{$el})) { - $count++; - } - } + my $count = 0; + for my $el (@expected_ids) { + if (exists($actual_set{$el})) { + $count++; + } + } - cmp_ok($count, ">=", $min); + cmp_ok($count, ">=", $min); } # Initialize node @@ -39,7 +39,7 @@ $node->start; $node->safe_psql("postgres", "CREATE EXTENSION vector;"); $node->safe_psql("postgres", "CREATE TABLE tst (i int4, v vector(3));"); $node->safe_psql("postgres", - "INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1,100000) i;" + "INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1,100000) i;" ); # Get exact results