Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/dmtest/blk_archive/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,28 @@
from dmtest.fs import Xfs
from dmtest.thin.utils import standard_pool

# Environment variable to override the blk-archive/blk-stash binary name
BLK_ARCHIVE_BIN = os.getenv("BLK_ARCHIVE_BIN", "blk-stash")


class BlkArchive:
def __init__(self, directory, block_size=4096):
self.dir = os.path.abspath(directory)
process.run(f"blk-archive create -a {self.dir} --block-size {block_size}")
process.run(f"{BLK_ARCHIVE_BIN} create -a {self.dir} --block-size {block_size}")

def pack(self, device_or_file):
stdout = process.run(f"blk-archive -j pack -a {self.dir} {device_or_file}")[1]
stdout = process.run(f"{BLK_ARCHIVE_BIN} pack -j -a {self.dir} {device_or_file}")[1]
result = json.loads(stdout)
return result["stream_id"]

def unpack(self, stream, dest):
process.run(f"blk-archive -j unpack -a {self.dir} -s {stream} {dest}")
process.run(f"{BLK_ARCHIVE_BIN} unpack -j -a {self.dir} -s {stream} {dest}")

def dump_stream(self, stream):
return process.run(f"blk-archive -j dump-stream -a {self.dir} -s {stream}")
return process.run(f"{BLK_ARCHIVE_BIN} dump-stream -j -a {self.dir} -s {stream}")

def pack_delta(self, old, old_id, new):
stdout = process.run(f"blk-archive -j pack -a {self.dir} {new} --delta-stream {old_id} --delta-device {old}")[1]
stdout = process.run(f"{BLK_ARCHIVE_BIN} pack -j -a {self.dir} {new} --delta-stream {old_id} --delta-device {old}")[1]
result = json.loads(stdout)
return result["stream_id"]

Expand All @@ -42,15 +45,15 @@ def verify(self, dev_or_file, stream=None):
if stream is None:
stream = self.get_stream_id(dev_or_file)
process.run(
f"blk-archive verify -a {self.dir} --stream {stream} {dev_or_file}"
f"{BLK_ARCHIVE_BIN} verify -a {self.dir} --stream {stream} {dev_or_file}"
)

def get_stream_id(self, dev_or_file):
if isinstance(dev_or_file, str):
name = os.path.basename(dev_or_file)
else:
name = os.path.basename(dev_or_file.path)
(code, stdout, stderr) = process.run(f"blk-archive -j list -a {self.dir}")
(code, stdout, stderr) = process.run(f"{BLK_ARCHIVE_BIN} list -j -a {self.dir}")
result = json.loads(stdout)

item = next((i for i in result if i["source"] == name), None)
Expand Down
2 changes: 1 addition & 1 deletion src/dmtest/blk_archive/rolling_snaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def t_rolling_snaps(fix):

def register(tests):
tests.register_batch(
"/blk-archive/",
"/blk-stash/",
[
("rolling-snaps", t_rolling_snaps, reg.check_linux_repo),
],
Expand Down
2 changes: 1 addition & 1 deletion src/dmtest/blk_archive/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def t_src_dest_combinations(fix):

def register(tests):
tests.register_batch(
"/blk-archive/unit",
"/blk-stash/unit",
[
("combinations", t_src_dest_combinations),
],
Expand Down
10 changes: 5 additions & 5 deletions test_dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ targets = [ "linear", "thin", "thin-pool",]
executables = [ "blockdev", "dd", "dmsetup", "thin_check",]
targets = [ "linear", "thin", "thin-pool",]

["/blk-archive/rolling-snaps"]
executables = [ "blk-archive", "blockdev", "dd", "dmsetup", "echo", "fsck.ext4", "git", "mkfs.ext4", "mount", "rm", "umount",]
["/blk-stash/rolling-snaps"]
executables = [ "blk-stash", "blockdev", "dd", "dmsetup", "echo", "fsck.ext4", "git", "mkfs.ext4", "mount", "rm", "umount",]
targets = [ "thin", "thin-pool",]

["/blk-archive/unit/hello"]
["/blk-stash/unit/hello"]
executables = [ "blockdev", "dd", "dmsetup",]
targets = [ "thin", "thin-pool",]

["/blk-archive/unit/combinations"]
executables = [ "blk-archive", "blockdev", "cmp", "dd", "dmsetup", "echo", "losetup", "mkfs.xfs", "mount", "umount", "xfs_repair",]
["/blk-stash/unit/combinations"]
executables = [ "blk-stash", "blockdev", "cmp", "dd", "dmsetup", "echo", "losetup", "mkfs.xfs", "mount", "umount", "xfs_repair",]
targets = [ "linear", "thin", "thin-pool",]

["/thin/fs-bench/fio/thick"]
Expand Down