From 0778a507de25c43f2e539b768abc6440f8d8636b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 11 Aug 2023 19:13:22 -0700 Subject: [PATCH] Use consistent style in TAP tests, part 2 [skip ci] --- test/t/001_ivfflat_wal.pl | 6 ++++-- test/t/003_ivfflat_recall.pl | 12 ++++++++---- test/t/010_hnsw_wal.pl | 3 ++- test/t/011_hnsw_vacuum.pl | 3 ++- test/t/012_hnsw_build_recall.pl | 16 +++++++++++----- test/t/013_hnsw_insert_recall.pl | 16 +++++++++++----- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/test/t/001_ivfflat_wal.pl b/test/t/001_ivfflat_wal.pl index 84760ad..34bcfab 100644 --- a/test/t/001_ivfflat_wal.pl +++ b/test/t/001_ivfflat_wal.pl @@ -53,11 +53,13 @@ my $array_sql = join(",", ('random()') x $dim); # Initialize primary node $node_primary = get_new_node('primary'); $node_primary->init(allows_streaming => 1); -if ($dim > 32) { +if ($dim > 32) +{ # TODO use wal_keep_segments for Postgres < 13 $node_primary->append_conf('postgresql.conf', qq(wal_keep_size = 1GB)); } -if ($dim > 1500) { +if ($dim > 1500) +{ $node_primary->append_conf('postgresql.conf', qq(maintenance_work_mem = 128MB)); } $node_primary->start; diff --git a/test/t/003_ivfflat_recall.pl b/test/t/003_ivfflat_recall.pl index 2086d7e..9a43ca0 100644 --- a/test/t/003_ivfflat_recall.pl +++ b/test/t/003_ivfflat_recall.pl @@ -22,7 +22,8 @@ sub test_recall )); like($explain, qr/Index Scan using idx on tst/); - for my $i (0 .. $#queries) { + for my $i (0 .. $#queries) + { my $actual = $node->safe_psql("postgres", qq( SET enable_seqscan = off; SET ivfflat.probes = $probes; @@ -33,8 +34,10 @@ sub test_recall my @expected_ids = split("\n", $expected[$i]); - foreach (@expected_ids) { - if (exists($actual_set{$_})) { + foreach (@expected_ids) + { + if (exists($actual_set{$_})) + { $correct++; } $total++; @@ -74,7 +77,8 @@ foreach (@operators) # Get exact results @expected = (); - foreach (@queries) { + foreach (@queries) + { my $res = $node->safe_psql("postgres", "SELECT i FROM tst ORDER BY v $operator '$_' LIMIT $limit;"); push(@expected, $res); } diff --git a/test/t/010_hnsw_wal.pl b/test/t/010_hnsw_wal.pl index d59a977..422a10b 100644 --- a/test/t/010_hnsw_wal.pl +++ b/test/t/010_hnsw_wal.pl @@ -26,7 +26,8 @@ sub test_index_replay or die "Timed out while waiting for replica 1 to catch up"; my @r = (); - for (1 .. $dim) { + for (1 .. $dim) + { push(@r, rand()); } my $sql = join(",", @r); diff --git a/test/t/011_hnsw_vacuum.pl b/test/t/011_hnsw_vacuum.pl index 53ba709..ff80e29 100644 --- a/test/t/011_hnsw_vacuum.pl +++ b/test/t/011_hnsw_vacuum.pl @@ -7,7 +7,8 @@ use Test::More; my $dim = 3; my @r = (); -for (1 .. $dim) { +for (1 .. $dim) +{ my $v = int(rand(1000)) + 1; push(@r, "i % $v"); } diff --git a/test/t/012_hnsw_build_recall.pl b/test/t/012_hnsw_build_recall.pl index a94601c..22dcac7 100644 --- a/test/t/012_hnsw_build_recall.pl +++ b/test/t/012_hnsw_build_recall.pl @@ -21,7 +21,8 @@ sub test_recall )); like($explain, qr/Index Scan/); - for my $i (0 .. $#queries) { + for my $i (0 .. $#queries) + { my $actual = $node->safe_psql("postgres", qq( SET enable_seqscan = off; SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit; @@ -31,8 +32,10 @@ sub test_recall my @expected_ids = split("\n", $expected[$i]); - foreach (@expected_ids) { - if (exists($actual_set{$_})) { + foreach (@expected_ids) + { + if (exists($actual_set{$_})) + { $correct++; } $total++; @@ -89,9 +92,12 @@ foreach (@operators) } $node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v $opclass);"); - if ($operator eq "<#>") { + if ($operator eq "<#>") + { test_recall(0.80, $operator); - } else { + } + else + { test_recall(0.99, $operator); } } diff --git a/test/t/013_hnsw_insert_recall.pl b/test/t/013_hnsw_insert_recall.pl index c77e2f7..6ef48d9 100644 --- a/test/t/013_hnsw_insert_recall.pl +++ b/test/t/013_hnsw_insert_recall.pl @@ -21,7 +21,8 @@ sub test_recall )); like($explain, qr/Index Scan/); - for my $i (0 .. $#queries) { + for my $i (0 .. $#queries) + { my $actual = $node->safe_psql("postgres", qq( SET enable_seqscan = off; SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit; @@ -31,8 +32,10 @@ sub test_recall my @expected_ids = split("\n", $expected[$i]); - foreach (@expected_ids) { - if (exists($actual_set{$_})) { + foreach (@expected_ids) + { + if (exists($actual_set{$_})) + { $correct++; } $total++; @@ -101,9 +104,12 @@ foreach (@operators) push(@expected, $res); } - if ($operator eq "<#>") { + if ($operator eq "<#>") + { test_recall(0.80, $operator); - } else { + } + else + { test_recall(0.99, $operator); }