Browse Source

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

Dan Helfman 2 năm trước cách đây
mục cha
commit
5962fd473e

+ 1 - 1
.drone.yml

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

+ 0 - 1
NEWS

@@ -7,7 +7,6 @@
    commands with arguments.
  * #678: Fix calls to psql in PostgreSQL hook to ignore "~/.psqlrc", whose settings can break
    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.
  * #684: Rename "master" development branch to "main" to use more inclusive language. You'll need to
    update your development checkouts accordingly.

+ 1 - 5
borgmatic/hooks/postgresql.py

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

+ 0 - 1
tests/end-to-end/docker-compose.yaml

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

+ 3 - 3
tests/end-to-end/test_database.py

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

+ 6 - 2
tests/unit/hooks/test_postgresql.py

@@ -656,7 +656,11 @@ def test_restore_database_dump_runs_psql_for_all_database_dump():
     flexmock(module).should_receive('make_dump_path')
     flexmock(module.dump).should_receive('make_database_dump_filename')
     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],
         output_log_level=logging.DEBUG,
         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.dump).should_receive('make_database_dump_filename')
     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],
         output_log_level=logging.DEBUG,
         input_file=extract_process.stdout,