summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Lawson <big.tedde@gmail.com>2023-07-24 14:54:47 -0700
committerGitHub <noreply@github.com>2023-07-24 23:54:47 +0200
commit2e59a702f6e65007b45338a792288dfb6b967edb (patch)
tree833ff67ae154cd73cfc93c714b8c9e43fc45e567 /src
parente1cd38a0df6ea2b7eb81c88886d81bc2374873a7 (diff)
`cmd` function now creates repo_location argument (#7734)
f'repo={repo_location}' moved to 'cmd' function
Diffstat (limited to 'src')
-rw-r--r--src/borg/testsuite/archiver/__init__.py49
-rw-r--r--src/borg/testsuite/archiver/argparsing.py20
-rw-r--r--src/borg/testsuite/archiver/benchmark_cmd.py4
-rw-r--r--src/borg/testsuite/archiver/bypass_lock_option.py80
-rw-r--r--src/borg/testsuite/archiver/check_cmd.py158
-rw-r--r--src/borg/testsuite/archiver/checks.py308
-rw-r--r--src/borg/testsuite/archiver/config_cmd.py32
-rw-r--r--src/borg/testsuite/archiver/corruption.py55
-rw-r--r--src/borg/testsuite/archiver/create_cmd.py630
-rw-r--r--src/borg/testsuite/archiver/debug_cmds.py107
-rw-r--r--src/borg/testsuite/archiver/delete_cmd.py80
-rw-r--r--src/borg/testsuite/archiver/diff_cmd.py84
-rw-r--r--src/borg/testsuite/archiver/extract_cmd.py335
-rw-r--r--src/borg/testsuite/archiver/info_cmd.py27
-rw-r--r--src/borg/testsuite/archiver/key_cmds.py168
-rw-r--r--src/borg/testsuite/archiver/list_cmd.py62
-rw-r--r--src/borg/testsuite/archiver/lock_cmds.py12
-rw-r--r--src/borg/testsuite/archiver/mount_cmds.py85
-rw-r--r--src/borg/testsuite/archiver/prune_cmd.py119
-rw-r--r--src/borg/testsuite/archiver/rcompress_cmd.py24
-rw-r--r--src/borg/testsuite/archiver/rcreate_cmd.py31
-rw-r--r--src/borg/testsuite/archiver/rdelete_cmd.py27
-rw-r--r--src/borg/testsuite/archiver/recreate_cmd.py288
-rw-r--r--src/borg/testsuite/archiver/rename_cmd.py34
-rw-r--r--src/borg/testsuite/archiver/rinfo_cmd.py39
-rw-r--r--src/borg/testsuite/archiver/rlist_cmd.py80
-rw-r--r--src/borg/testsuite/archiver/tar_cmds.py150
-rw-r--r--src/borg/testsuite/archiver/transfer_cmd.py54
28 files changed, 1283 insertions, 1859 deletions
diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py
index 470665259..2804ad44f 100644
--- a/src/borg/testsuite/archiver/__init__.py
+++ b/src/borg/testsuite/archiver/__init__.py
@@ -147,7 +147,9 @@ def cmd(archiver, *args, **kw):
binary_output = kw.get("binary_output", False)
if fork is None:
fork = archiver.FORK_DEFAULT
- ret, output = exec_cmd(*args, archiver=archiver.archiver, fork=fork, exe=archiver.EXE, **kw)
+ ret, output = exec_cmd(
+ f"--repo={archiver.repository_location}", *args, archiver=archiver.archiver, fork=fork, exe=archiver.EXE, **kw
+ )
if ret != exit_code:
print(output)
assert ret == exit_code
@@ -160,11 +162,10 @@ def cmd(archiver, *args, **kw):
def create_src_archive(archiver, name, ts=None):
- repo_location, source_dir = archiver.repository_location, src_dir
if ts:
- cmd(archiver, f"--repo={repo_location}", "create", "--compression=lz4", f"--timestamp={ts}", name, source_dir)
+ cmd(archiver, "create", "--compression=lz4", f"--timestamp={ts}", name, src_dir)
else:
- cmd(archiver, f"--repo={repo_location}", "create", "--compression=lz4", name, source_dir)
+ cmd(archiver, "create", "--compression=lz4", name, src_dir)
def open_archive(repo_path, name):
@@ -270,8 +271,7 @@ def _set_repository_id(repo_path, id):
def _extract_hardlinks_setup(archiver):
- repo_location, input_path = archiver.repository_location, archiver.input_path
-
+ input_path = archiver.input_path
os.mkdir(os.path.join(input_path, "dir1"))
os.mkdir(os.path.join(input_path, "dir1/subdir"))
@@ -283,13 +283,13 @@ def _extract_hardlinks_setup(archiver):
create_regular_file(input_path, "dir1/source2")
os.link(os.path.join(input_path, "dir1/source2"), os.path.join(input_path, "dir1/aaaa"))
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
- cmd(archiver, f"--repo={repo_location}", "create", "test", "input")
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "create", "test", "input")
def _create_test_caches(archiver):
- repo_location, input_path = archiver.repository_location, archiver.input_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ input_path = archiver.input_path
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_regular_file(input_path, "file1", size=1024 * 80)
create_regular_file(input_path, "cache1/%s" % CACHE_TAG_NAME, contents=CACHE_TAG_CONTENTS + b" extra stuff")
create_regular_file(input_path, "cache2/%s" % CACHE_TAG_NAME, contents=b"invalid signature")
@@ -297,35 +297,34 @@ def _create_test_caches(archiver):
if are_hardlinks_supported():
os.link("input/cache1/%s" % CACHE_TAG_NAME, "input/cache3/%s" % CACHE_TAG_NAME)
else:
- create_regular_file(
- archiver.input_path, "cache3/%s" % CACHE_TAG_NAME, contents=CACHE_TAG_CONTENTS + b" extra stuff"
- )
+ create_regular_file(input_path, "cache3/%s" % CACHE_TAG_NAME, contents=CACHE_TAG_CONTENTS + b" extra stuff")
def _assert_test_caches(archiver):
with changedir("output"):
- cmd(archiver, f"--repo={archiver.repository_location}", "extract", "test")
+ cmd(archiver, "extract", "test")
assert sorted(os.listdir("output/input")) == ["cache2", "file1"]
assert sorted(os.listdir("output/input/cache2")) == [CACHE_TAG_NAME]
def _create_test_tagged(archiver):
- cmd(archiver, f"--repo={archiver.repository_location}", "rcreate", RK_ENCRYPTION)
- create_regular_file(archiver.input_path, "file1", size=1024 * 80)
- create_regular_file(archiver.input_path, "tagged1/.NOBACKUP")
- create_regular_file(archiver.input_path, "tagged2/00-NOBACKUP")
- create_regular_file(archiver.input_path, "tagged3/.NOBACKUP/file2", size=1024)
+ input_path = archiver.input_path
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
+ create_regular_file(input_path, "file1", size=1024 * 80)
+ create_regular_file(input_path, "tagged1/.NOBACKUP")
+ create_regular_file(input_path, "tagged2/00-NOBACKUP")
+ create_regular_file(input_path, "tagged3/.NOBACKUP/file2", size=1024)
def _assert_test_tagged(archiver):
with changedir("output"):
- cmd(archiver, f"--repo={archiver.repository_location}", "extract", "test")
+ cmd(archiver, "extract", "test")
assert sorted(os.listdir("output/input")) == ["file1"]
def _create_test_keep_tagged(archiver):
input_path = archiver.input_path
- cmd(archiver, f"--repo={archiver.repository_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_regular_file(input_path, "file0", size=1024)
create_regular_file(input_path, "tagged1/.NOBACKUP1")
create_regular_file(input_path, "tagged1/file1", size=1024)
@@ -341,7 +340,7 @@ def _create_test_keep_tagged(archiver):
def _assert_test_keep_tagged(archiver):
with changedir("output"):
- cmd(archiver, f"--repo={archiver.repository_location}", "extract", "test")
+ cmd(archiver, "extract", "test")
assert sorted(os.listdir("output/input")), ["file0", "tagged1", "tagged2", "tagged3", "taggedall"]
assert os.listdir("output/input/tagged1"), [".NOBACKUP1"]
assert os.listdir("output/input/tagged2"), [".NOBACKUP2"]
@@ -351,7 +350,7 @@ def _assert_test_keep_tagged(archiver):
def check_cache(archiver):
# First run a regular borg check
- cmd(archiver, f"--repo={archiver.repository_location}", "check")
+ cmd(archiver, "check")
# Then check that the cache on disk matches exactly what's in the repo.
with open_repository(archiver) as repository:
manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK)
@@ -483,7 +482,7 @@ def wait_for_mountstate(mountpoint, *, mounted, timeout=5):
@contextmanager
-def fuse_mount(archiver, location, mountpoint=None, *options, fork=True, os_fork=False, **kwargs):
+def fuse_mount(archiver, mountpoint=None, *options, fork=True, os_fork=False, **kwargs):
# For a successful mount, `fork = True` is required for
# the borg mount daemon to work properly or the tests
# will just freeze. Therefore, if argument `fork` is not
@@ -502,7 +501,7 @@ def fuse_mount(archiver, location, mountpoint=None, *options, fork=True, os_fork
mountpoint = tempfile.mkdtemp()
else:
os.mkdir(mountpoint)
- args = [f"--repo={location}", "mount", mountpoint] + list(options)
+ args = ["mount", mountpoint] + list(options)
if os_fork:
# Do not spawn, but actually (OS) fork.
if os.fork() == 0:
diff --git a/src/borg/testsuite/archiver/argparsing.py b/src/borg/testsuite/archiver/argparsing.py
index 296ba214d..05d9ec5fa 100644
--- a/src/borg/testsuite/archiver/argparsing.py
+++ b/src/borg/testsuite/archiver/argparsing.py
@@ -6,28 +6,24 @@ from . import Archiver, RK_ENCRYPTION, cmd
def test_bad_filters(archiver):
- repo_location = archiver.repository_location
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
- cmd(archiver, f"--repo={repo_location}", "create", "test", "input")
- cmd(archiver, f"--repo={repo_location}", "delete", "--first", "1", "--last", "1", fork=True, exit_code=2)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "create", "test", "input")
+ cmd(archiver, "delete", "--first", "1", "--last", "1", fork=True, exit_code=2)
def test_highlander(archiver):
- repo_location = archiver.repository_location
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
- cmd(archiver, f"--repo={repo_location}", "create", "--comment", "comment 1", "test-1", __file__)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "create", "--comment", "comment 1", "test-1", __file__)
error_msg = "There can be only one"
# Default umask value is 0077
# Test that it works with a one time specified default or custom value
- output_default = cmd(archiver, f"--repo={repo_location}", "--umask", "0077", "rlist")
+ output_default = cmd(archiver, "--umask", "0077", "rlist")
assert error_msg not in output_default
- output_custom = cmd(archiver, f"--repo={repo_location}", "--umask", "0007", "rlist")
+ output_custom = cmd(archiver, "--umask", "0007", "rlist")
assert error_msg not in output_custom
# Test that all combinations of custom and default values fail
for first, second in [("0007", "0007"), ("0007", "0077"), ("0077", "0007"), ("0077", "0077")]:
- output_custom = cmd(
- archiver, f"--repo={repo_location}", "--umask", first, "--umask", second, "rlist", exit_code=2
- )
+ output_custom = cmd(archiver, "--umask", first, "--umask", second, "rlist", exit_code=2)
assert error_msg in output_custom
diff --git a/src/borg/testsuite/archiver/benchmark_cmd.py b/src/borg/testsuite/archiver/benchmark_cmd.py
index eeb833986..1ac424874 100644
--- a/src/borg/testsuite/archiver/benchmark_cmd.py
+++ b/src/borg/testsuite/archiver/benchmark_cmd.py
@@ -4,6 +4,6 @@ from . import cmd, RK_ENCRYPTION
def test_benchmark_crud(archiver):
- cmd(archiver, f"--repo={archiver.repository_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
with environment_variable(_BORG_BENCHMARK_CRUD_TEST="YES"):
- cmd(archiver, f"--repo={archiver.repository_location}", "benchmark", "crud", archiver.input_path)
+ cmd(archiver, "benchmark", "crud", archiver.input_path)
diff --git a/src/borg/testsuite/archiver/bypass_lock_option.py b/src/borg/testsuite/archiver/bypass_lock_option.py
index dab1cd3ae..8ddeb6762 100644
--- a/src/borg/testsuite/archiver/bypass_lock_option.py
+++ b/src/borg/testsuite/archiver/bypass_lock_option.py
@@ -9,132 +9,122 @@ from . import cmd, create_src_archive, RK_ENCRYPTION, read_only, fuse_mount
def test_readonly_check(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "check", "--verify-data", exit_code=EXIT_ERROR)
+ cmd(archiver, "check", "--verify-data", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "check", "--verify-data")
+ cmd(archiver, "check", "--verify-data")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "check", "--verify-data", "--bypass-lock")
+ cmd(archiver, "check", "--verify-data", "--bypass-lock")
def test_readonly_diff(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "a")
create_src_archive(archiver, "b")
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "diff", "a", "b", exit_code=EXIT_ERROR)
+ cmd(archiver, "diff", "a", "b", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "diff", "a", "b")
+ cmd(archiver, "diff", "a", "b")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "diff", "a", "b", "--bypass-lock")
+ cmd(archiver, "diff", "a", "b", "--bypass-lock")
def test_readonly_export_tar(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "export-tar", "test", "test.tar", exit_code=EXIT_ERROR)
+ cmd(archiver, "export-tar", "test", "test.tar", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "export-tar", "test", "test.tar")
+ cmd(archiver, "export-tar", "test", "test.tar")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "export-tar", "test", "test.tar", "--bypass-lock")
+ cmd(archiver, "export-tar", "test", "test.tar", "--bypass-lock")
def test_readonly_extract(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "extract", "test", exit_code=EXIT_ERROR)
+ cmd(archiver, "extract", "test", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "extract", "test")
+ cmd(archiver, "extract", "test")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "extract", "test", "--bypass-lock")
+ cmd(archiver, "extract", "test", "--bypass-lock")
def test_readonly_info(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
-
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "rinfo", exit_code=EXIT_ERROR)
+ cmd(archiver, "rinfo", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "rinfo")
+ cmd(archiver, "rinfo")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "rinfo", "--bypass-lock")
+ cmd(archiver, "rinfo", "--bypass-lock")
def test_readonly_list(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
-
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- cmd(archiver, f"--repo={repo_location}", "rlist", exit_code=EXIT_ERROR)
+ cmd(archiver, "rlist", exit_code=EXIT_ERROR)
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
- cmd(archiver, f"--repo={repo_location}", "rlist")
+ cmd(archiver, "rlist")
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- cmd(archiver, f"--repo={repo_location}", "rlist", "--bypass-lock")
+ cmd(archiver, "rlist", "--bypass-lock")
@pytest.mark.skipif(not llfuse, reason="llfuse not installed")
def test_readonly_mount(archiver):
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "test")
-
- with read_only(repo_path):
+ with read_only(archiver.repository_path):
# verify that command normally doesn't work with read-only repo
if archiver.FORK_DEFAULT:
- with fuse_mount(archiver, repo_location, exit_code=EXIT_ERROR):
+ with fuse_mount(archiver, exit_code=EXIT_ERROR):
pass
else:
with pytest.raises((LockFailed, RemoteRepository.RPCError)) as excinfo:
# self.fuse_mount always assumes fork=True, so for this test we have to set fork=False manually
- with fuse_mount(archiver, repo_location, fork=False):
+ with fuse_mount(archiver, fork=False):
pass
if isinstance(excinfo.value, RemoteRepository.RPCError):
assert excinfo.value.exception_class == "LockFailed"
# verify that command works with read-only repo when using --bypass-lock
- with fuse_mount(archiver, repo_location, None, "--bypass-lock"):
+ with fuse_mount(archiver, None, "--bypass-lock"):
pass
diff --git a/src/borg/testsuite/archiver/check_cmd.py b/src/borg/testsuite/archiver/check_cmd.py
index d38cf3fcf..b5db32538 100644
--- a/src/borg/testsuite/archiver/check_cmd.py
+++ b/src/borg/testsuite/archiver/check_cmd.py
@@ -16,7 +16,7 @@ pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds
def check_cmd_setup(archiver):
with patch.object(ChunkBuffer, "BUFFER_SIZE", 10):
- cmd(archiver, f"--repo={archiver.repository_location}", "rcreate", RK_ENCRYPTION)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
create_src_archive(archiver, "archive1")
create_src_archive(archiver, "archive2")
@@ -24,32 +24,29 @@ def check_cmd_setup(archiver):
def test_check_usage(archivers, request):
archiver = request.getfixturevalue(archivers)
check_cmd_setup(archiver)
- repo_location = archiver.repository_location
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--progress", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--progress", exit_code=0)
assert "Starting repository check" in output
assert "Starting archive consistency check" in output
assert "Checking segments" in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--repository-only", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--repository-only", exit_code=0)
assert "Starting repository check" in output
assert "Starting archive consistency check" not in output
assert "Checking segments" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", exit_code=0)
assert "Starting repository check" not in output
assert "Starting archive consistency check" in output
- output = cmd(
- archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--match-archives=archive2", exit_code=0
- )
+ output = cmd(archiver, "check", "-v", "--archives-only", "--match-archives=archive2", exit_code=0)
assert "archive1" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--first=1", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--first=1", exit_code=0)
assert "archive1" in output
assert "archive2" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--last=1", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--last=1", exit_code=0)
assert "archive1" not in output
assert "archive2" in output
@@ -57,49 +54,47 @@ def test_check_usage(archivers, request):
def test_date_matching(archivers, request):
archiver = request.getfixturevalue(archivers)
check_cmd_setup(archiver)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
- shutil.rmtree(repo_path)
- cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+ shutil.rmtree(archiver.repository_path)
+ cmd(archiver, "rcreate", RK_ENCRYPTION)
earliest_ts = "2022-11-20T23:59:59"
ts_in_between = "2022-12-18T23:59:59"
create_src_archive(archiver, "archive1", ts=earliest_ts)
create_src_archive(archiver, "archive2", ts=ts_in_between)
create_src_archive(archiver, "archive3")
- cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--oldest=23e", exit_code=2)
+ cmd(archiver, "check", "-v", "--archives-only", "--oldest=23e", exit_code=2)
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--oldest=1m", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--oldest=1m", exit_code=0)
assert "archive1" in output
assert "archive2" in output
assert "archive3" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--newest=1m", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--newest=1m", exit_code=0)
assert "archive3" in output
assert "archive2" not in output
assert "archive1" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--newer=1d", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--newer=1d", exit_code=0)
assert "archive3" in output
assert "archive1" not in output
assert "archive2" not in output
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--older=1d", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--older=1d", exit_code=0)
assert "archive1" in output
assert "archive2" in output
assert "archive3" not in output
# check for output when timespan older than the earliest archive is given. Issue #1711
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--archives-only", "--older=9999m", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--archives-only", "--older=9999m", exit_code=0)
for archive in ("archive1", "archive2", "archive3"):
assert archive not in output
def test_missing_file_chunk(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
for item in archive.iter_items():
@@ -112,17 +107,17 @@ def test_missing_file_chunk(archivers, request):
pytest.fail("should not happen") # convert 'fail'
repository.commit(compact=False)
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- output = cmd(archiver, f"--repo={repo_location}", "check", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ output = cmd(archiver, "check", "--repair", exit_code=0)
assert "New missing file chunk detected" in output
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=0)
- output = cmd(archiver, f"--repo={repo_location}", "list", "archive1", "--format={health}#{path}{NL}", exit_code=0)
+ cmd(archiver, "check", exit_code=0)
+ output = cmd(archiver, "list", "archive1", "--format={health}#{path}{NL}", exit_code=0)
assert "broken#" in output
# check that the file in the old archives has now a different chunk list without the killed chunk
for archive_name in ("archive1", "archive2"):
- archive, repository = open_archive(repo_path, archive_name)
+ archive, repository = open_archive(archiver.repository_path, archive_name)
with repository:
for item in archive.iter_items():
if item.path.endswith(src_file):
@@ -137,13 +132,13 @@ def test_missing_file_chunk(archivers, request):
create_src_archive(archiver, "archive3")
# check should be able to heal the file now:
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--repair", exit_code=0)
+ output = cmd(archiver, "check", "-v", "--repair", exit_code=0)
assert "Healed previously missing file chunk" in output
assert f"{src_file}: Completely healed previously damaged file!" in output
# check that the file in the old archives has the correct chunks again
for archive_name in ("archive1", "archive2"):
- archive, repository = open_archive(repo_path, archive_name)
+ archive, repository = open_archive(archiver.repository_path, archive_name)
with repository:
for item in archive.iter_items():
if item.path.endswith(src_file):
@@ -153,82 +148,68 @@ def test_missing_file_chunk(archivers, request):
pytest.fail("should not happen")
# list is also all-healthy again
- output = cmd(archiver, f"--repo={repo_location}", "list", "archive1", "--format={health}#{path}{NL}", exit_code=0)
+ output = cmd(archiver, "list", "archive1", "--format={health}#{path}{NL}", exit_code=0)
assert "broken#" not in output
def test_missing_archive_item_chunk(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
-
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
repository.delete(archive.metadata.items[0])
repository.commit(compact=False)
-
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- cmd(archiver, f"--repo={repo_location}", "check", "--repair", exit_code=0)
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ cmd(archiver, "check", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=0)
def test_missing_archive_metadata(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
-
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
repository.delete(archive.id)
repository.commit(compact=False)
-
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- cmd(archiver, f"--repo={repo_location}", "check", "--repair", exit_code=0)
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ cmd(archiver, "check", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=0)
def test_missing_manifest(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
-
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
repository.delete(Manifest.MANIFEST_ID)
repository.commit(compact=False)
-
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ output = cmd(archiver, "check", "-v", "--repair", exit_code=0)
assert "archive1" in output
assert "archive2" in output
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=0)
+ cmd(archiver, "check", exit_code=0)
def test_corrupted_manifest(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
-
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
manifest = repository.get(Manifest.MANIFEST_ID)
corrupted_manifest = manifest + b"corrupted!"
repository.put(Manifest.MANIFEST_ID, corrupted_manifest)
repository.commit(compact=False)
-
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ output = cmd(archiver, "check", "-v", "--repair", exit_code=0)
assert "archive1" in output
assert "archive2" in output
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=0)
+ cmd(archiver, "check", exit_code=0)
def test_manifest_rebuild_corrupted_chunk(archivers, request):
archiver = request.getfixturevalue(archivers)
- repo_location, repo_path = archiver.repository_location, archiver.repository_path
check_cmd_setup(archiver)
- archive, repository = open_archive(repo_path, "archive1")
-
+ archive, repository = open_archive(archiver.repository_path, "archive1")
with repository:
manifest = repository.get(Manifest.MANIFEST_ID)
corrupted_manifest = manifest + b"corrupted!"
@@ -237,20 +218,17 @@ def test_manifest_rebuild_corrupted_chunk(archivers, request):
corrupted_chunk = chunk + b"corrupted!"
repository.put(archive.id, corrupted_chunk)
repository.commit(compact=False)
-
- cmd(archiver, f"--repo={repo_location}", "check", exit_code=1)
- output = cmd(archiver, f"--repo={repo_location}", "check", "-v", "--repair", exit_code=0)
+ cmd(archiver, "check", exit_code=1)
+ output = cmd(archiver, "check", "-v", "--repair", exit_code=0)
assert "archive2" in output
- cmd(archiver, f"--repo={