Skip to content

Commit

Permalink
test: test backup preservation failures
Browse files Browse the repository at this point in the history
Make sure write errors fail without killing the entire backup process.
  • Loading branch information
kmichel-aiven committed Dec 22, 2022
1 parent 50171ab commit d219971
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,31 @@ def test_object_store_cancel_backup_preservation(tmp_path: Path) -> None:
store.cancel_backup_preservation(request_name)
requests = storage.list_path("site_name/preservation_request")
assert len(requests) == 0


def test_object_store_try_request_backup_preservation_returns_none_on_failure(tmp_path: Path) -> None:
storage_dir = tmp_path / "storage"
storage_dir.mkdir()
storage_dir.chmod(0o000)
try:
storage = LocalTransfer(directory=str(storage_dir))
store = ObjectStore(storage, prefix="site_name", site=None, pgdata=str(tmp_path / "pgdata"))
preserve_until = datetime.datetime(2022, 12, 18, 10, 20, 30, 123456, tzinfo=datetime.timezone.utc)
request_name = store.try_request_backup_preservation("2022_12_10", preserve_until=preserve_until)
assert request_name is None
finally:
storage_dir.chmod(0o700)


def test_object_store_try_cancel_backup_preservation_silently_fails(tmp_path: Path) -> None:
storage_dir = tmp_path / "storage"
storage_dir.mkdir()
storage = LocalTransfer(directory=str(storage_dir))
store = ObjectStore(storage, prefix="site_name", site=None, pgdata=str(tmp_path / "pgdata"))
preserve_until = datetime.datetime(2022, 12, 18, 10, 20, 30, 123456, tzinfo=datetime.timezone.utc)
request_name = store.request_backup_preservation("2022_12_10", preserve_until=preserve_until)
storage_dir.chmod(0o000)
try:
store.try_cancel_backup_preservation(request_name)
finally:
storage_dir.chmod(0o700)

0 comments on commit d219971

Please sign in to comment.