Skip to content

Commit

Permalink
Update client test to do a basic fs_pool test on btrfs and zfs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsonck92 committed Jul 28, 2020
1 parent 2867726 commit 2370167
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion client
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ path = '/targetrpc'
id_num = 1
ssl = False
pool = 'vg-targetd/thin_pool'

fs_pools = ['/mnt/btrfs','zfs_targetd/fs_pool']

def jsonrequest(method, params=None):
print("%s %s" % ("+" * 20, method))
Expand Down Expand Up @@ -150,3 +150,65 @@ try:
finally:
jsonrequest("vol_destroy", dict(pool=pool, name="test2"))
print("done")

failed = False
# ZFS fs tests
for fs_pool in fs_pools:
fs_uuid = None

print("testing {0}".format(fs_pool))
try:
jsonrequest('fs_create', dict(pool_name=fs_pool, name="test-fs", size_bytes=0))

results = jsonrequest('fs_list')
for fs in results:
print("{pool}: {uuid} -> {name}".format(**fs))
if fs['pool'] != fs_pool:
failed = True
raise Exception("unrecognized pool filesystem")
fs_uuid = fs['uuid']

ss_uuid = None

try:
jsonrequest('fs_snapshot', dict(fs_uuid=fs_uuid, dest_ss_name="test-snapshot"))

ss_results = jsonrequest('ss_list', dict(fs_uuid=fs_uuid))

for ss in ss_results:
print("{uuid} -> {name} ({timestamp})".format(**ss))
if ss['name'] != "test-snapshot":
failed = True
raise Exception("unrecognized snapshot")

ss_uuid = ss['uuid']

clone_uuid = None

try:
jsonrequest("fs_clone", dict(fs_uuid=fs_uuid, dest_fs_name="test-clone", snapshot_id=ss_uuid))

clone_results = jsonrequest('fs_list')

has_clone = False
for result in clone_results:
print("{pool}: {uuid} -> {name}".format(**result))
if result['name'] == 'test-clone':
clone_uuid = result['uuid']
has_clone = True
if not has_clone:
failed = True
raise Exception("test-clone not found")
finally:
if clone_uuid is not None:
jsonrequest("fs_destroy",dict(uuid=clone_uuid))
finally:
if ss_uuid is not None:
jsonrequest("fs_snapshot_delete", dict(fs_uuid=fs_uuid, ss_uuid=ss_uuid))
finally:
if fs_uuid is not None:
jsonrequest("fs_destroy", dict(uuid=fs_uuid))

if failed:
print("Test failed")
exit(1)

0 comments on commit 2370167

Please sign in to comment.