|
@@ -2509,20 +2509,6 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
assert log_message["levelname"] == "DEBUG" # there should only be DEBUG messages
|
|
assert log_message["levelname"] == "DEBUG" # there should only be DEBUG messages
|
|
assert isinstance(log_message["message"], str)
|
|
assert isinstance(log_message["message"], str)
|
|
|
|
|
|
- def test_debug_profile(self):
|
|
|
|
- self.create_test_files()
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test", "input", "--debug-profile=create.prof")
|
|
|
|
- self.cmd("debug", "convert-profile", "create.prof", "create.pyprof")
|
|
|
|
- stats = pstats.Stats("create.pyprof")
|
|
|
|
- stats.strip_dirs()
|
|
|
|
- stats.sort_stats("cumtime")
|
|
|
|
-
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test2", "input", "--debug-profile=create.pyprof")
|
|
|
|
- stats = pstats.Stats("create.pyprof") # Only do this on trusted data!
|
|
|
|
- stats.strip_dirs()
|
|
|
|
- stats.sort_stats("cumtime")
|
|
|
|
-
|
|
|
|
def test_common_options(self):
|
|
def test_common_options(self):
|
|
self.create_test_files()
|
|
self.create_test_files()
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
@@ -2870,45 +2856,6 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
# Undecorate
|
|
# Undecorate
|
|
borg.locking.Lock.migrate_lock = borg.locking.Lock.migrate_lock.__wrapped__
|
|
borg.locking.Lock.migrate_lock = borg.locking.Lock.migrate_lock.__wrapped__
|
|
|
|
|
|
- def test_debug_dump_archive_items(self):
|
|
|
|
- self.create_test_files()
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
|
|
|
|
- with changedir("output"):
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "dump-archive-items", "test")
|
|
|
|
- output_dir = sorted(os.listdir("output"))
|
|
|
|
- assert len(output_dir) > 0 and output_dir[0].startswith("000000_")
|
|
|
|
- assert "Done." in output
|
|
|
|
-
|
|
|
|
- def test_debug_dump_repo_objs(self):
|
|
|
|
- self.create_test_files()
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
|
|
|
|
- with changedir("output"):
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "dump-repo-objs")
|
|
|
|
- output_dir = sorted(os.listdir("output"))
|
|
|
|
- assert len(output_dir) > 0 and output_dir[0].startswith("00000000_")
|
|
|
|
- assert "Done." in output
|
|
|
|
-
|
|
|
|
- def test_debug_put_get_delete_obj(self):
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- data = b"some data"
|
|
|
|
- hexkey = sha256(data).hexdigest()
|
|
|
|
- self.create_regular_file("file", contents=data)
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "put-obj", "input/file")
|
|
|
|
- assert hexkey in output
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "get-obj", hexkey, "output/file")
|
|
|
|
- assert hexkey in output
|
|
|
|
- with open("output/file", "rb") as f:
|
|
|
|
- data_read = f.read()
|
|
|
|
- assert data == data_read
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "delete-obj", hexkey)
|
|
|
|
- assert "deleted" in output
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "delete-obj", hexkey)
|
|
|
|
- assert "not found" in output
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "delete-obj", "invalid")
|
|
|
|
- assert "is invalid" in output
|
|
|
|
-
|
|
|
|
def test_init_interrupt(self):
|
|
def test_init_interrupt(self):
|
|
def raise_eof(*args, **kwargs):
|
|
def raise_eof(*args, **kwargs):
|
|
raise EOFError
|
|
raise EOFError
|
|
@@ -3364,56 +3311,6 @@ id: 2 / e29442 3506da 4e1ea7 / 25f62a 5a3d41 - 02
|
|
typed_input = b"2 / e29442 3506da 4e1ea7 / 25f62a 5a3d41 - 02\n\ny\n"
|
|
typed_input = b"2 / e29442 3506da 4e1ea7 / 25f62a 5a3d41 - 02\n\ny\n"
|
|
self.cmd(f"--repo={self.repository_location}", "key", "import", "--paper", input=typed_input)
|
|
self.cmd(f"--repo={self.repository_location}", "key", "import", "--paper", input=typed_input)
|
|
|
|
|
|
- def test_debug_dump_manifest(self):
|
|
|
|
- self.create_regular_file("file1", size=1024 * 80)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
|
|
|
|
- dump_file = self.output_path + "/dump"
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "dump-manifest", dump_file)
|
|
|
|
- assert output == ""
|
|
|
|
- with open(dump_file) as f:
|
|
|
|
- result = json.load(f)
|
|
|
|
- assert "archives" in result
|
|
|
|
- assert "config" in result
|
|
|
|
- assert "item_keys" in result
|
|
|
|
- assert "timestamp" in result
|
|
|
|
- assert "version" in result
|
|
|
|
-
|
|
|
|
- def test_debug_dump_archive(self):
|
|
|
|
- self.create_regular_file("file1", size=1024 * 80)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
|
|
|
|
- dump_file = self.output_path + "/dump"
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "dump-archive", "test", dump_file)
|
|
|
|
- assert output == ""
|
|
|
|
- with open(dump_file) as f:
|
|
|
|
- result = json.load(f)
|
|
|
|
- assert "_name" in result
|
|
|
|
- assert "_manifest_entry" in result
|
|
|
|
- assert "_meta" in result
|
|
|
|
- assert "_items" in result
|
|
|
|
-
|
|
|
|
- def test_debug_refcount_obj(self):
|
|
|
|
- self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "refcount-obj", "0" * 64).strip()
|
|
|
|
- assert (
|
|
|
|
- output
|
|
|
|
- == "object 0000000000000000000000000000000000000000000000000000000000000000 not found [info from chunks cache]."
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- create_json = json.loads(self.cmd(f"--repo={self.repository_location}", "create", "--json", "test", "input"))
|
|
|
|
- archive_id = create_json["archive"]["id"]
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "refcount-obj", archive_id).strip()
|
|
|
|
- assert output == "object " + archive_id + " has 1 referrers [info from chunks cache]."
|
|
|
|
-
|
|
|
|
- # Invalid IDs do not abort or return an error
|
|
|
|
- output = self.cmd(f"--repo={self.repository_location}", "debug", "refcount-obj", "124", "xyza").strip()
|
|
|
|
- assert output == "object id 124 is invalid.\nobject id xyza is invalid."
|
|
|
|
-
|
|
|
|
- def test_debug_info(self):
|
|
|
|
- output = self.cmd("debug", "info")
|
|
|
|
- assert "Python" in output
|
|
|
|
-
|
|
|
|
def test_benchmark_crud(self):
|
|
def test_benchmark_crud(self):
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
with environment_variable(_BORG_BENCHMARK_CRUD_TEST="YES"):
|
|
with environment_variable(_BORG_BENCHMARK_CRUD_TEST="YES"):
|
|
@@ -3892,12 +3789,14 @@ class ManifestAuthenticationTest(ArchiverTestCaseBase):
|
|
self.cmd(f"--repo={self.repository_location}", "rlist")
|
|
self.cmd(f"--repo={self.repository_location}", "rlist")
|
|
|
|
|
|
|
|
|
|
-class RemoteArchiverTestCase(ArchiverTestCase):
|
|
|
|
|
|
+class RemoteArchiverTestCaseBase:
|
|
prefix = "ssh://__testsuite__"
|
|
prefix = "ssh://__testsuite__"
|
|
|
|
|
|
def open_repository(self):
|
|
def open_repository(self):
|
|
return RemoteRepository(Location(self.repository_location))
|
|
return RemoteRepository(Location(self.repository_location))
|
|
|
|
|
|
|
|
+
|
|
|
|
+class RemoteArchiverTestCase(RemoteArchiverTestCaseBase, ArchiverTestCase):
|
|
def test_remote_repo_restrict_to_path(self):
|
|
def test_remote_repo_restrict_to_path(self):
|
|
# restricted to repo directory itself:
|
|
# restricted to repo directory itself:
|
|
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", self.repository_path]):
|
|
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", self.repository_path]):
|
|
@@ -3930,10 +3829,6 @@ class RemoteArchiverTestCase(ArchiverTestCase):
|
|
with pytest.raises(PathNotAllowed):
|
|
with pytest.raises(PathNotAllowed):
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
|
|
|
|
|
- @unittest.skip("only works locally")
|
|
|
|
- def test_debug_put_get_delete_obj(self):
|
|
|
|
- pass
|
|
|
|
-
|
|
|
|
@unittest.skip("only works locally")
|
|
@unittest.skip("only works locally")
|
|
def test_config(self):
|
|
def test_config(self):
|
|
pass
|
|
pass
|