Skip to content

Commit 3f0e786

Browse files
committed
meson: Add 'running' test setup, as a replacement for installcheck
To run all tests that support running against existing server: $ meson test --setup running To run just the main pg_regress tests against existing server: $ meson test --setup running regress-running/regress To ensure the 'running' setup continues to work, test it as part of the freebsd CI task. Discussion: https://postgr.es/m/CAH2-Wz=XDQcmLoo7RR_i6FKQdDmcyb9q5gStnfuuQXrOGhB2sQ@mail.gmail.com
1 parent 8305629 commit 3f0e786

File tree

17 files changed

+132
-15
lines changed

17 files changed

+132
-15
lines changed

.cirrus.yml

+15
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,21 @@ task:
195195
meson test $MTEST_ARGS --num-processes ${TEST_JOBS}
196196
EOF
197197
198+
# test runningcheck, freebsd chosen because it's currently fast enough
199+
test_running_script: |
200+
su postgres <<-EOF
201+
set -e
202+
ulimit -c unlimited
203+
meson test $MTEST_ARGS --quiet --suite setup
204+
export LD_LIBRARY_PATH="$(pwd)/build/tmp_install/usr/local/pgsql/lib/:$LD_LIBRARY_PATH"
205+
mkdir -p build/testrun
206+
build/tmp_install/usr/local/pgsql/bin/initdb -N build/runningcheck --no-instructions -A trust
207+
echo "include '$(pwd)/src/tools/ci/pg_ci_base.conf'" >> build/runningcheck/postgresql.conf
208+
build/tmp_install/usr/local/pgsql/bin/pg_ctl -c -o '-c fsync=off' -D build/runningcheck -l build/testrun/runningcheck.log start
209+
meson test $MTEST_ARGS --num-processes ${TEST_JOBS} --setup running
210+
build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop
211+
EOF
212+
198213
on_failure:
199214
<<: *on_failure_meson
200215
cores_script: src/tools/ci/cores_backtrace.sh freebsd /tmp/cores

contrib/basic_archive/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ tests += {
2525
'regress_args': [
2626
'--temp-config', files('basic_archive.conf'),
2727
],
28+
# Disabled because these tests require "shared_preload_libraries=basic_archive",
29+
# which typical runningcheck users do not have (e.g. buildfarm clients).
30+
'runningcheck': false,
2831
},
2932
}

contrib/pg_freespacemap/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ tests += {
3333
'regress_args': [
3434
'--temp-config', files('pg_freespacemap.conf')
3535
],
36+
# Disabled because these tests require "autovacuum=off", which
37+
# typical runningcheck users do not have (e.g. buildfarm clients).
38+
'runningcheck': false,
3639
},
3740
}

contrib/pg_stat_statements/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@ tests += {
4141
'pg_stat_statements',
4242
],
4343
'regress_args': ['--temp-config', files('pg_stat_statements.conf')],
44+
# Disabled because these tests require
45+
# "shared_preload_libraries=pg_stat_statements", which typical
46+
# runningcheck users do not have (e.g. buildfarm clients).
47+
'runningcheck': false,
4448
},
4549
}

contrib/pg_walinspect/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ tests += {
2828
'sql': [
2929
'pg_walinspect',
3030
],
31+
# Disabled because these tests require "wal_level=replica", which
32+
# some runningcheck users do not have (e.g. buildfarm clients).
3133
'regress_args': ['--temp-config', files('walinspect.conf')],
34+
'runningcheck': false,
3235
},
3336
}

contrib/test_decoding/meson.build

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ tests += {
4343
'regress_args': [
4444
'--temp-config', files('logical.conf'),
4545
],
46+
# Disabled because these tests require "wal_level=logical", which
47+
# typical runningcheck users do not have (e.g. buildfarm clients).
48+
'runningcheck': false,
4649
},
4750
'isolation': {
4851
'specs': [
@@ -61,6 +64,8 @@ tests += {
6164
'regress_args': [
6265
'--temp-config', files('logical.conf'),
6366
],
67+
# see above
68+
'runningcheck': false,
6469
},
6570
'tap': {
6671
'tests': [

doc/src/sgml/installation.sgml

+6
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,12 @@ ninja
21082108
detailed information about interpreting the test results. You can
21092109
repeat this test at any later time by issuing the same command.
21102110
</para>
2111+
2112+
<para>
2113+
To run pg_regress and pg_isolation_regress tests against a running
2114+
postgres instance, specify <userinput>--setup running</userinput> as an
2115+
argument to <userinput>meson test</userinput>.
2116+
</para>
21112117
</step>
21122118

21132119
<step id="meson-install">

meson.build

+77-14
Original file line numberDiff line numberDiff line change
@@ -2920,14 +2920,27 @@ endif
29202920
# Test Generation
29212921
###############################################################
29222922

2923+
# When using a meson version understanding exclude_suites, define a
2924+
# 'tmp_install' test setup (the default) that excludes tests running against a
2925+
# pre-existing install and a 'running' setup that conflicts with creation of
2926+
# the temporary installation and tap tests (which don't support running
2927+
# against a running server).
2928+
2929+
running_suites = []
2930+
install_suites = []
2931+
if meson.version().version_compare('>=0.57')
2932+
runningcheck = true
2933+
else
2934+
runningcheck = false
2935+
endif
2936+
29232937
testwrap = files('src/tools/testwrap')
29242938

29252939
foreach test_dir : tests
29262940
testwrap_base = [
29272941
testwrap,
29282942
'--basedir', meson.build_root(),
29292943
'--srcdir', test_dir['sd'],
2930-
'--testgroup', test_dir['name'],
29312944
]
29322945

29332946
foreach kind, v : test_dir
@@ -2940,55 +2953,94 @@ foreach test_dir : tests
29402953
if kind in ['regress', 'isolation', 'ecpg']
29412954
if kind == 'regress'
29422955
runner = pg_regress
2956+
fallback_dbname = 'regression_@0@'
29432957
elif kind == 'isolation'
29442958
runner = pg_isolation_regress
2959+
fallback_dbname = 'isolation_regression_@0@'
29452960
elif kind == 'ecpg'
29462961
runner = pg_regress_ecpg
2962+
fallback_dbname = 'ecpg_regression_@0@'
29472963
endif
29482964

2949-
test_output = test_result_dir / test_dir['name'] / kind
2965+
test_group = test_dir['name']
2966+
test_group_running = test_dir['name'] + '-running'
29502967

2951-
test_command = [
2968+
test_output = test_result_dir / test_group / kind
2969+
test_output_running = test_result_dir / test_group_running/ kind
2970+
2971+
# Unless specified by the test, choose a non-conflicting database name,
2972+
# to avoid conflicts when running against existing server.
2973+
dbname = t.get('dbname',
2974+
fallback_dbname.format(test_dir['name']))
2975+
2976+
test_command_base = [
29522977
runner.full_path(),
29532978
'--inputdir', t.get('inputdir', test_dir['sd']),
29542979
'--expecteddir', t.get('expecteddir', test_dir['sd']),
2955-
'--outputdir', test_output,
2956-
'--temp-instance', test_output / 'tmp_check',
29572980
'--bindir', '',
29582981
'--dlpath', test_dir['bd'],
29592982
'--max-concurrent-tests=20',
2960-
'--port', testport.to_string(),
2983+
'--dbname', dbname,
29612984
] + t.get('regress_args', [])
29622985

2986+
test_selection = []
29632987
if t.has_key('schedule')
2964-
test_command += ['--schedule', t['schedule'],]
2988+
test_selection += ['--schedule', t['schedule'],]
29652989
endif
29662990

29672991
if kind == 'isolation'
2968-
test_command += t.get('specs', [])
2992+
test_selection += t.get('specs', [])
29692993
else
2970-
test_command += t.get('sql', [])
2994+
test_selection += t.get('sql', [])
29712995
endif
29722996

29732997
env = test_env
29742998
env.prepend('PATH', temp_install_bindir, test_dir['bd'])
29752999

29763000
test_kwargs = {
2977-
'suite': [test_dir['name']],
29783001
'priority': 10,
29793002
'timeout': 1000,
29803003
'depends': test_deps + t.get('deps', []),
29813004
'env': env,
29823005
} + t.get('test_kwargs', {})
29833006

2984-
test(test_dir['name'] / kind,
3007+
test(test_group / kind,
29853008
python,
2986-
args: testwrap_base + [
3009+
args: [
3010+
testwrap_base,
3011+
'--testgroup', test_group,
29873012
'--testname', kind,
2988-
'--', test_command,
3013+
'--',
3014+
test_command_base,
3015+
'--outputdir', test_output,
3016+
'--temp-instance', test_output / 'tmp_check',
3017+
'--port', testport.to_string(),
3018+
test_selection,
29893019
],
3020+
suite: test_group,
29903021
kwargs: test_kwargs,
29913022
)
3023+
install_suites += test_group
3024+
3025+
# some tests can't support running against running DB
3026+
if runningcheck and t.get('runningcheck', true)
3027+
test(test_group_running / kind,
3028+
python,
3029+
args: [
3030+
testwrap_base,
3031+
'--testgroup', test_group_running,
3032+
'--testname', kind,
3033+
'--',
3034+
test_command_base,
3035+
'--outputdir', test_output_running,
3036+
test_selection,
3037+
],
3038+
is_parallel: t.get('runningcheck-parallel', true),
3039+
suite: test_group_running,
3040+
kwargs: test_kwargs,
3041+
)
3042+
running_suites += test_group_running
3043+
endif
29923044

29933045
testport += 1
29943046
elif kind == 'tap'
@@ -3011,9 +3063,10 @@ foreach test_dir : tests
30113063
env.set(name, value)
30123064
endforeach
30133065

3066+
test_group = test_dir['name']
30143067
test_kwargs = {
30153068
'protocol': 'tap',
3016-
'suite': [test_dir['name']],
3069+
'suite': test_group,
30173070
'timeout': 1000,
30183071
'depends': test_deps + t.get('deps', []),
30193072
'env': env,
@@ -3033,12 +3086,14 @@ foreach test_dir : tests
30333086
python,
30343087
kwargs: test_kwargs,
30353088
args: testwrap_base + [
3089+
'--testgroup', test_dir['name'],
30363090
'--testname', onetap_p,
30373091
'--', test_command,
30383092
test_dir['sd'] / onetap,
30393093
],
30403094
)
30413095
endforeach
3096+
install_suites += test_group
30423097
else
30433098
error('unknown kind @0@ of test in @1@'.format(kind, test_dir['sd']))
30443099
endif
@@ -3047,6 +3102,14 @@ foreach test_dir : tests
30473102

30483103
endforeach # directories with tests
30493104

3105+
# repeat condition so meson realizes version dependency
3106+
if meson.version().version_compare('>=0.57')
3107+
add_test_setup('tmp_install',
3108+
is_default: true,
3109+
exclude_suites: running_suites)
3110+
add_test_setup('running',
3111+
exclude_suites: ['setup'] + install_suites)
3112+
endif
30503113

30513114

30523115
###############################################################

src/interfaces/ecpg/test/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ tests += {
8484
'test_kwargs': {
8585
'depends': ecpg_test_dependencies,
8686
},
87+
'dbname': 'ecpg1_regression,ecpg2_regression',
8788
'regress_args': ecpg_regress_args,
8889
},
8990
}

src/test/isolation/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ tests += {
6767
'priority': 40,
6868
'timeout': 1000,
6969
},
70+
'dbname': 'isolation_regression',
7071
},
7172
}

src/test/modules/commit_ts/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ tests += {
66
'sql': [
77
'commit_timestamp',
88
],
9+
# Disabled because these tests require "track_commit_timestamp = on",
10+
# which typical runningcheck users do not have (e.g. buildfarm clients).
11+
'runningcheck': false,
912
},
1013
'tap': {
1114
'tests': [

src/test/modules/snapshot_too_old/meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ tests += {
1010
'sto_using_hash_index',
1111
],
1212
'regress_args': ['--temp-config', files('sto.conf')],
13+
# Disabled because these tests require "old_snapshot_threshold" >= 0, which
14+
# typical runningcheck users do not have (e.g. buildfarm clients).
15+
'runningcheck': false,
1316
},
1417
}

src/test/modules/test_oat_hooks/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ tests += {
2525
'test_oat_hooks',
2626
],
2727
'regress_args': ['--no-locale', '--encoding=UTF8'],
28+
'runningcheck': false,
2829
},
2930
}

src/test/modules/test_pg_dump/meson.build

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tests += {
1313
'sql': [
1414
'test_pg_dump',
1515
],
16+
# doesn't delete its user
17+
'runningcheck': false,
1618
},
1719
'tap': {
1820
'tests': [

src/test/modules/test_slru/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ tests += {
3131
'test_slru',
3232
],
3333
'regress_args': ['--temp-config', files('test_slru.conf')],
34+
'runningcheck': false,
3435
},
3536
}

src/test/modules/worker_spi/meson.build

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ tests += {
3030
'sql': [
3131
'worker_spi',
3232
],
33-
'regress_args': ['--temp-config', files('dynamic.conf'), '--dbname=contrib_regression'],
33+
'dbname': 'contrib_regression',
34+
'regress_args': ['--temp-config', files('dynamic.conf')],
35+
'runningcheck': false,
3436
},
3537
}

src/test/regress/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ tests += {
7575
'priority': 50,
7676
'timeout': 1000,
7777
},
78+
'dbname': 'regression',
7879
},
7980
}

0 commit comments

Comments
 (0)