Another try. Backing out psql error changes (#678).

This commit is contained in:
Dan Helfman 2023-04-21 10:34:50 -07:00
parent 7e64f415ba
commit 5962fd473e
6 changed files with 11 additions and 13 deletions

View File

@ -1,3 +1,4 @@
---
kind: pipeline kind: pipeline
name: python-3-8-alpine-3-13 name: python-3-8-alpine-3-13
@ -5,7 +6,6 @@ services:
- name: postgresql - name: postgresql
image: docker.io/postgres:13.1-alpine image: docker.io/postgres:13.1-alpine
environment: environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test POSTGRES_PASSWORD: test
POSTGRES_DB: test POSTGRES_DB: test
- name: mysql - name: mysql

1
NEWS
View File

@ -7,7 +7,6 @@
commands with arguments. commands with arguments.
* #678: Fix calls to psql in PostgreSQL hook to ignore "~/.psqlrc", whose settings can break * #678: Fix calls to psql in PostgreSQL hook to ignore "~/.psqlrc", whose settings can break
database dumping. database dumping.
* #678: Fix calls to psql in PostgreSQL hook to abort on error during a database restore.
* #682: Fix "source_directories_must_exist" option to expand globs and tildes in source directories. * #682: Fix "source_directories_must_exist" option to expand globs and tildes in source directories.
* #684: Rename "master" development branch to "main" to use more inclusive language. You'll need to * #684: Rename "master" development branch to "main" to use more inclusive language. You'll need to
update your development checkouts accordingly. update your development checkouts accordingly.

View File

@ -229,11 +229,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
restore_command = ( restore_command = (
tuple(psql_command if use_psql_command else pg_restore_command) tuple(psql_command if use_psql_command else pg_restore_command)
+ ('--no-password',) + ('--no-password',)
+ ( + (('--no-psqlrc',) if use_psql_command else ('--if-exists', '--exit-on-error', '--clean'))
('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
if use_psql_command
else ('--if-exists', '--exit-on-error', '--clean')
)
+ (('--dbname', database['name']) if not all_databases else ()) + (('--dbname', database['name']) if not all_databases else ())
+ (('--host', database['hostname']) if 'hostname' in database else ()) + (('--host', database['hostname']) if 'hostname' in database else ())
+ (('--port', str(database['port'])) if 'port' in database else ()) + (('--port', str(database['port'])) if 'port' in database else ())

View File

@ -3,7 +3,6 @@ services:
postgresql: postgresql:
image: docker.io/postgres:13.1-alpine image: docker.io/postgres:13.1-alpine
environment: environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test POSTGRES_PASSWORD: test
POSTGRES_DB: test POSTGRES_DB: test
mysql: mysql:

View File

@ -36,17 +36,17 @@ hooks:
postgresql_databases: postgresql_databases:
- name: test - name: test
hostname: postgresql hostname: postgresql
username: test username: postgres
password: test password: test
format: {postgresql_dump_format} format: {postgresql_dump_format}
- name: all - name: all
hostname: postgresql hostname: postgresql
username: test username: postgres
password: test password: test
- name: all - name: all
format: custom format: custom
hostname: postgresql hostname: postgresql
username: test username: postgres
password: test password: test
mysql_databases: mysql_databases:
- name: test - name: test

View File

@ -656,7 +656,11 @@ def test_restore_database_dump_runs_psql_for_all_database_dump():
flexmock(module).should_receive('make_dump_path') flexmock(module).should_receive('make_dump_path')
flexmock(module.dump).should_receive('make_database_dump_filename') flexmock(module.dump).should_receive('make_database_dump_filename')
flexmock(module).should_receive('execute_command_with_processes').with_args( flexmock(module).should_receive('execute_command_with_processes').with_args(
('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on'), (
'psql',
'--no-password',
'--no-psqlrc',
),
processes=[extract_process], processes=[extract_process],
output_log_level=logging.DEBUG, output_log_level=logging.DEBUG,
input_file=extract_process.stdout, input_file=extract_process.stdout,
@ -680,7 +684,7 @@ def test_restore_database_dump_runs_psql_for_plain_database_dump():
flexmock(module).should_receive('make_dump_path') flexmock(module).should_receive('make_dump_path')
flexmock(module.dump).should_receive('make_database_dump_filename') flexmock(module.dump).should_receive('make_database_dump_filename')
flexmock(module).should_receive('execute_command_with_processes').with_args( flexmock(module).should_receive('execute_command_with_processes').with_args(
('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on', '--dbname', 'foo'), ('psql', '--no-password', '--no-psqlrc', '--dbname', 'foo'),
processes=[extract_process], processes=[extract_process],
output_log_level=logging.DEBUG, output_log_level=logging.DEBUG,
input_file=extract_process.stdout, input_file=extract_process.stdout,