Skip to content

Commit 30fa477

Browse files
committed
Create new database clusuters on every test run
The cost of running initdb, especially without fsync, is not very big on modern computers and version of PostgreSQL so the optimization of reusing the same database cluster between test runs is just a potential footgun no longer worth the benefits. It might still be worth caching the generated TLS certificates but for now let's not do that to keep the code simple.
1 parent 642ec32 commit 30fa477

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

spec/helpers.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ def initialize(name, port: 23456, postgresql_conf: '')
251251

252252
def create_test_db
253253
trace "Creating the test DB"
254-
log_and_run @logfile, pg_bin_path('psql'), '-p', @port.to_s, '-e', '-c', 'DROP DATABASE IF EXISTS test', 'postgres'
255254
log_and_run @logfile, pg_bin_path('createdb'), '-p', @port.to_s, '-e', 'test'
256255
end
257256

@@ -276,12 +275,10 @@ def ca_file
276275
private
277276

278277
def setup_cluster(postgresql_conf)
279-
return if (@pgdata+"ruby-pg-server-cert").exist?
280-
281278
FileUtils.rm_rf(@pgdata, verbose: $DEBUG)
282279

283280
trace "Running initdb"
284-
log_and_run @logfile, pg_bin_path('initdb'), '-E', 'UTF8', '--no-locale', '-D', @pgdata.to_s
281+
log_and_run @logfile, pg_bin_path('initdb'), '-E', 'UTF8', '--no-locale', '--no-sync', '-D', @pgdata.to_s
285282

286283
trace "Enable SSL"
287284
# Enable SSL in server config

0 commit comments

Comments
 (0)