Add an additional end-to-end database test.
This commit is contained in:
parent
de478f6ff7
commit
048a9ebb52
4 changed files with 41 additions and 4 deletions
2
NEWS
2
NEWS
|
@ -1,4 +1,4 @@
|
||||||
1.5.4.dev0
|
1.5.4
|
||||||
* #310: Fix legitimate database dump command errors (exit code 1) not being treated as errors by
|
* #310: Fix legitimate database dump command errors (exit code 1) not being treated as errors by
|
||||||
borgmatic.
|
borgmatic.
|
||||||
* For database dumps, replace the named pipe on every borgmatic run. This prevent hangs on stale
|
* For database dumps, replace the named pipe on every borgmatic run. This prevent hangs on stale
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.5.4.dev0'
|
VERSION = '1.5.4'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -68,7 +68,7 @@ def test_borgmatic_command():
|
||||||
extracted_config_path = os.path.join(extract_path, config_path)
|
extracted_config_path = os.path.join(extract_path, config_path)
|
||||||
assert open(extracted_config_path).read() == open(config_path).read()
|
assert open(extracted_config_path).read() == open(config_path).read()
|
||||||
|
|
||||||
# Exercise the info flag.
|
# Exercise the info action.
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
'borgmatic --config {} info --json'.format(config_path).split(' ')
|
'borgmatic --config {} info --json'.format(config_path).split(' ')
|
||||||
).decode(sys.stdout.encoding)
|
).decode(sys.stdout.encoding)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def write_configuration(config_path, repository_path, borgmatic_source_directory):
|
def write_configuration(config_path, repository_path, borgmatic_source_directory):
|
||||||
'''
|
'''
|
||||||
|
@ -67,7 +69,7 @@ def test_database_dump_and_restore():
|
||||||
'borgmatic -v 2 --config {} init --encryption repokey'.format(config_path).split(' ')
|
'borgmatic -v 2 --config {} init --encryption repokey'.format(config_path).split(' ')
|
||||||
)
|
)
|
||||||
|
|
||||||
# Run borgmatic to generate a backup archive including a database dump
|
# Run borgmatic to generate a backup archive including a database dump.
|
||||||
subprocess.check_call('borgmatic create --config {} -v 2'.format(config_path).split(' '))
|
subprocess.check_call('borgmatic create --config {} -v 2'.format(config_path).split(' '))
|
||||||
|
|
||||||
# Get the created archive name.
|
# Get the created archive name.
|
||||||
|
@ -89,3 +91,38 @@ def test_database_dump_and_restore():
|
||||||
finally:
|
finally:
|
||||||
os.chdir(original_working_directory)
|
os.chdir(original_working_directory)
|
||||||
shutil.rmtree(temporary_directory)
|
shutil.rmtree(temporary_directory)
|
||||||
|
|
||||||
|
|
||||||
|
def test_database_dump_with_error_causes_borgmatic_to_exit():
|
||||||
|
# Create a Borg repository.
|
||||||
|
temporary_directory = tempfile.mkdtemp()
|
||||||
|
repository_path = os.path.join(temporary_directory, 'test.borg')
|
||||||
|
borgmatic_source_directory = os.path.join(temporary_directory, '.borgmatic')
|
||||||
|
|
||||||
|
original_working_directory = os.getcwd()
|
||||||
|
|
||||||
|
try:
|
||||||
|
config_path = os.path.join(temporary_directory, 'test.yaml')
|
||||||
|
write_configuration(config_path, repository_path, borgmatic_source_directory)
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
'borgmatic -v 2 --config {} init --encryption repokey'.format(config_path).split(' ')
|
||||||
|
)
|
||||||
|
|
||||||
|
# Run borgmatic with a config override such that the database dump fails.
|
||||||
|
with pytest.raises(subprocess.CalledProcessError):
|
||||||
|
subprocess.check_call(
|
||||||
|
[
|
||||||
|
'borgmatic',
|
||||||
|
'create',
|
||||||
|
'--config',
|
||||||
|
config_path,
|
||||||
|
'-v',
|
||||||
|
'2',
|
||||||
|
'--override',
|
||||||
|
"hooks.postgresql_databases=[{'name': 'nope'}]",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
os.chdir(original_working_directory)
|
||||||
|
shutil.rmtree(temporary_directory)
|
||||||
|
|
Loading…
Reference in a new issue