1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

use get_reset_ec to internally re-init ec/warnings

if we do multiple calls to Archiver.do_something(),
we need to reset the ec / warnings after each call,
otherwise they will keep growing (in severity, in length).
This commit is contained in:
Thomas Waldmann 2023-12-16 00:30:32 +01:00
parent b53c86cf4c
commit a0a07ab464
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 21 additions and 8 deletions

View file

@ -9,7 +9,7 @@
from ..crypto.key import FlexiKey
from ..helpers import format_file_size
from ..helpers import msgpack
from ..helpers import get_ec
from ..helpers import get_reset_ec
from ..item import Item
from ..platform import SyncFile
@ -22,7 +22,7 @@ def measurement_run(repo, path):
compression = "--compression=none"
# measure create perf (without files cache to always have it chunking)
t_start = time.monotonic()
rc = get_ec(
rc = get_reset_ec(
self.do_create(
self.parse_args(
[
@ -40,23 +40,27 @@ def measurement_run(repo, path):
dt_create = t_end - t_start
assert rc == 0
# now build files cache
rc1 = get_ec(
rc1 = get_reset_ec(
self.do_create(self.parse_args([f"--repo={repo}", "create", compression, "borg-benchmark-crud2", path]))
)
rc2 = get_ec(self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud2"])))
rc2 = get_reset_ec(
self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud2"]))
)
assert rc1 == rc2 == 0
# measure a no-change update (archive1 is still present)
t_start = time.monotonic()
rc1 = get_ec(
rc1 = get_reset_ec(
self.do_create(self.parse_args([f"--repo={repo}", "create", compression, "borg-benchmark-crud3", path]))
)
t_end = time.monotonic()
dt_update = t_end - t_start
rc2 = get_ec(self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud3"])))
rc2 = get_reset_ec(
self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud3"]))
)
assert rc1 == rc2 == 0
# measure extraction (dry-run: without writing result to disk)
t_start = time.monotonic()
rc = get_ec(
rc = get_reset_ec(
self.do_extract(self.parse_args([f"--repo={repo}", "extract", "borg-benchmark-crud1", "--dry-run"]))
)
t_end = time.monotonic()
@ -64,7 +68,9 @@ def measurement_run(repo, path):
assert rc == 0
# measure archive deletion (of LAST present archive with the data)
t_start = time.monotonic()
rc = get_ec(self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud1"])))
rc = get_reset_ec(
self.do_delete(self.parse_args([f"--repo={repo}", "delete", "-a", "borg-benchmark-crud1"]))
)
t_end = time.monotonic()
dt_delete = t_end - t_start
assert rc == 0

View file

@ -164,3 +164,10 @@ def get_ec(ec=None):
return rcs[0]
# there were different kinds of warnings
return EXIT_WARNING # generic warning rc, user has to look into the logs
def get_reset_ec(ec=None):
"""Like get_ec, but re-initialize ec/warnings afterwards."""
rc = get_ec(ec)
init_ec_warnings()
return rc