Improve stability of explain regression test.
authorFujii Masao <fujii@postgresql.org>
Fri, 3 Apr 2020 16:25:44 +0000 (01:25 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 3 Apr 2020 16:26:39 +0000 (01:26 +0900)
The explain regression test runs EXPLAIN commands via the function
that filters unstable outputs. To produce more stable test output,
this commit improves the function so that it also filters out text-mode
Buffers lines. This is necessary because text-mode Buffers lines vary
depending the system state.

This improvement will get rid of the regression test failure that
the commit ed7a509571 caused on the buildfarm members prion and
dory because of the instability of Buffers lines.

Author: Fujii Masao
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/20200403025751.GB1759@paquier.xyz

src/test/regress/expected/explain.out
src/test/regress/sql/explain.sql

index 8f31c308c6054904e98ef0bd56224602724f74a0..3ec66ceda3c2a10459dfc1e4cad84b338da4b8d3 100644 (file)
@@ -20,8 +20,9 @@ begin
         ln := regexp_replace(ln, '\m\d+\M', 'N', 'g');
         -- In sort output, the above won't match units-suffixed numbers
         ln := regexp_replace(ln, '\m\d+kB', 'NkB', 'g');
-        -- Text-mode buffers output varies depending on the system state
-        ln := regexp_replace(ln, '^( +Buffers: shared)( hit=N)?( read=N)?', '\1 [read]');
+        -- Ignore text-mode buffers output because it varies depending
+        -- on the system state
+        CONTINUE WHEN (ln ~ ' +Buffers: .*');
         return next ln;
     end loop;
 end;
@@ -71,10 +72,9 @@ select explain_filter('explain (analyze, buffers, format text) select * from int
                                         explain_filter                                         
 -----------------------------------------------------------------------------------------------
  Seq Scan on int8_tbl i8  (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N)
-   Buffers: shared [read]
  Planning Time: N.N ms
  Execution Time: N.N ms
-(4 rows)
+(3 rows)
 
 select explain_filter('explain (analyze, buffers, format json) select * from int8_tbl i8');
            explain_filter           
index e09371f97b8ae95d2791183f0c40a4a527981aa0..dce2a34207246a5cc99e0b4b6f923321757dd2f1 100644 (file)
@@ -22,8 +22,9 @@ begin
         ln := regexp_replace(ln, '\m\d+\M', 'N', 'g');
         -- In sort output, the above won't match units-suffixed numbers
         ln := regexp_replace(ln, '\m\d+kB', 'NkB', 'g');
-        -- Text-mode buffers output varies depending on the system state
-        ln := regexp_replace(ln, '^( +Buffers: shared)( hit=N)?( read=N)?', '\1 [read]');
+        -- Ignore text-mode buffers output because it varies depending
+        -- on the system state
+        CONTINUE WHEN (ln ~ ' +Buffers: .*');
         return next ln;
     end loop;
 end;