aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2019-01-04 10:50:39 -0800
committerBrian Behlendorf <[email protected]>2019-01-06 10:39:41 -0800
commit4b1c4062d050e2cfa609e1040384d1f3b5f04f52 (patch)
treefcda46eb0656d4ed553f3b1d30ea75adec10a80a
parente5fb1dc586e879f016ddba24372b731971dad20c (diff)
pyzfs: python3 support (unit tests)
* Updated unit tests to be compatbile with python 2 or 3. In most cases all that was required was to add the 'b' prefix to existing strings to convert them to type bytes for python 3 compatibility. * There were several places where the python version need to be checked to remain compatible with pythong 2 and 3. Some one more seasoned with Python may be able to find a way to rewrite these statements in a compatible fashion. Reviewed-by: John Ramsden <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Reviewed-by: loli10K <[email protected]> Signed-off-by: John Wren Kennedy <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #8096
-rw-r--r--contrib/pyzfs/libzfs_core/test/test_libzfs_core.py1668
-rw-r--r--contrib/pyzfs/libzfs_core/test/test_nvlist.py254
2 files changed, 978 insertions, 944 deletions
diff --git a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
index 65e177345..97fd36ce7 100644
--- a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
+++ b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py
@@ -33,6 +33,7 @@ import resource
import shutil
import stat
import subprocess
+import sys
import tempfile
import time
import uuid
@@ -168,7 +169,7 @@ def temp_file_in_fs(fs):
with zfs_mount(fs) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
yield f.name
@@ -177,7 +178,7 @@ def make_snapshots(fs, before, modified, after):
def _maybe_snap(snap):
if snap is not None:
if not snap.startswith(fs):
- snap = fs + '@' + snap
+ snap = fs + b'@' + snap
lzc.lzc_snapshot([snap])
return snap
@@ -206,16 +207,16 @@ def streams(fs, first, second):
@contextlib.contextmanager
def encrypted_filesystem():
- fs = ZFSTest.pool.getFilesystem("encrypted")
+ fs = ZFSTest.pool.getFilesystem(b"encrypted")
name = fs.getName()
filename = None
key = os.urandom(lzc.WRAPPING_KEY_LEN)
with tempfile.NamedTemporaryFile() as f:
filename = "file://" + f.name
props = {
- "encryption": lzc.zio_encrypt.ZIO_CRYPT_AES_256_CCM,
- "keylocation": filename,
- "keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW,
+ b"encryption": lzc.zio_encrypt.ZIO_CRYPT_AES_256_CCM,
+ b"keylocation": filename.encode(),
+ b"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW,
}
lzc.lzc_create(name, 'zfs', props=props, key=key)
yield (name, key)
@@ -273,7 +274,7 @@ def needs_support(function):
class ZFSTest(unittest.TestCase):
POOL_FILE_SIZE = 128 * 1024 * 1024
- FILESYSTEMS = ['fs1', 'fs2', 'fs1/fs']
+ FILESYSTEMS = [b'fs1', b'fs2', b'fs1/fs']
pool = None
misc_pool = None
@@ -323,17 +324,17 @@ class ZFSTest(unittest.TestCase):
self.assertExists(ZFSTest.readonly_pool.makeName())
def test_exists_failure(self):
- self.assertNotExists(ZFSTest.pool.makeName('nonexistent'))
+ self.assertNotExists(ZFSTest.pool.makeName(b'nonexistent'))
def test_create_fs(self):
- name = ZFSTest.pool.makeName("fs1/fs/test1")
+ name = ZFSTest.pool.makeName(b"fs1/fs/test1")
lzc.lzc_create(name)
self.assertExists(name)
def test_create_zvol(self):
- name = ZFSTest.pool.makeName("fs1/fs/zvol")
- props = {"volsize": 1024 * 1024}
+ name = ZFSTest.pool.makeName(b"fs1/fs/zvol")
+ props = {b"volsize": 1024 * 1024}
lzc.lzc_create(name, ds_type='zvol', props=props)
self.assertExists(name)
@@ -344,14 +345,14 @@ class ZFSTest(unittest.TestCase):
time.sleep(0.1)
def test_create_fs_with_prop(self):
- name = ZFSTest.pool.makeName("fs1/fs/test2")
- props = {"atime": 0}
+ name = ZFSTest.pool.makeName(b"fs1/fs/test2")
+ props = {b"atime": 0}
lzc.lzc_create(name, props=props)
self.assertExists(name)
def test_create_fs_wrong_ds_type(self):
- name = ZFSTest.pool.makeName("fs1/fs/test1")
+ name = ZFSTest.pool.makeName(b"fs1/fs/test1")
with self.assertRaises(lzc_exc.DatasetTypeInvalid):
lzc.lzc_create(name, ds_type='wrong')
@@ -359,15 +360,15 @@ class ZFSTest(unittest.TestCase):
# XXX: we should have a way to raise lzc_exc.WrongParent from lzc_create()
@unittest.expectedFailure
def test_create_fs_below_zvol(self):
- name = ZFSTest.pool.makeName("fs1/fs/zvol")
- props = {"volsize": 1024 * 1024}
+ name = ZFSTest.pool.makeName(b"fs1/fs/zvol")
+ props = {b"volsize": 1024 * 1024}
lzc.lzc_create(name, ds_type='zvol', props=props)
with self.assertRaises(lzc_exc.WrongParent):
- lzc.lzc_create(name + '/fs')
+ lzc.lzc_create(name + b'/fs')
def test_create_fs_duplicate(self):
- name = ZFSTest.pool.makeName("fs1/fs/test6")
+ name = ZFSTest.pool.makeName(b"fs1/fs/test6")
lzc.lzc_create(name)
@@ -375,83 +376,83 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_create(name)
def test_create_fs_in_ro_pool(self):
- name = ZFSTest.readonly_pool.makeName("fs")
+ name = ZFSTest.readonly_pool.makeName(b"fs")
with self.assertRaises(lzc_exc.ReadOnlyPool):
lzc.lzc_create(name)
def test_create_fs_without_parent(self):
- name = ZFSTest.pool.makeName("fs1/nonexistent/test")
+ name = ZFSTest.pool.makeName(b"fs1/nonexistent/test")
with self.assertRaises(lzc_exc.ParentNotFound):
lzc.lzc_create(name)
self.assertNotExists(name)
def test_create_fs_in_nonexistent_pool(self):
- name = "no-such-pool/fs"
+ name = b"no-such-pool/fs"
with self.assertRaises(lzc_exc.ParentNotFound):
lzc.lzc_create(name)
self.assertNotExists(name)
def test_create_fs_with_invalid_prop(self):
- name = ZFSTest.pool.makeName("fs1/fs/test3")
- props = {"BOGUS": 0}
+ name = ZFSTest.pool.makeName(b"fs1/fs/test3")
+ props = {b"BOGUS": 0}
with self.assertRaises(lzc_exc.PropertyInvalid):
lzc.lzc_create(name, 'zfs', props)
self.assertNotExists(name)
def test_create_fs_with_invalid_prop_type(self):
- name = ZFSTest.pool.makeName("fs1/fs/test4")
- props = {"recordsize": "128k"}
+ name = ZFSTest.pool.makeName(b"fs1/fs/test4")
+ props = {b"recordsize": b"128k"}
with self.assertRaises(lzc_exc.PropertyInvalid):
lzc.lzc_create(name, 'zfs', props)
self.assertNotExists(name)
def test_create_fs_with_invalid_prop_val(self):
- name = ZFSTest.pool.makeName("fs1/fs/test5")
- props = {"atime": 20}
+ name = ZFSTest.pool.makeName(b"fs1/fs/test5")
+ props = {b"atime": 20}
with self.assertRaises(lzc_exc.PropertyInvalid):
lzc.lzc_create(name, 'zfs', props)
self.assertNotExists(name)
def test_create_fs_with_invalid_name(self):
- name = ZFSTest.pool.makeName("@badname")
+ name = ZFSTest.pool.makeName(b"@badname")
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_create(name)
self.assertNotExists(name)
def test_create_fs_with_invalid_pool_name(self):
- name = "bad!pool/fs"
+ name = b"bad!pool/fs"
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_create(name)
self.assertNotExists(name)
def test_create_encrypted_fs(self):
- fs = ZFSTest.pool.getFilesystem("encrypted")
+ fs = ZFSTest.pool.getFilesystem(b"encrypted")
name = fs.getName()
filename = None
with tempfile.NamedTemporaryFile() as f:
filename = "file://" + f.name
props = {
- "encryption": lzc.zio_encrypt.ZIO_CRYPT_AES_256_CCM,
- "keylocation": filename,
- "keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW,
+ b"encryption": lzc.zio_encrypt.ZIO_CRYPT_AES_256_CCM,
+ b"keylocation": filename.encode(),
+ b"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW,
}
key = os.urandom(lzc.WRAPPING_KEY_LEN)
lzc.lzc_create(name, 'zfs', props=props, key=key)
- self.assertEqual(fs.getProperty("encryption"), "aes-256-ccm")
+ self.assertEqual(fs.getProperty("encryption"), b"aes-256-ccm")
self.assertEqual(fs.getProperty("encryptionroot"), name)
- self.assertEqual(fs.getProperty("keylocation"), filename)
- self.assertEqual(fs.getProperty("keyformat"), "raw")
+ self.assertEqual(fs.getProperty("keylocation"), filename.encode())
+ self.assertEqual(fs.getProperty("keyformat"), b"raw")
def test_snapshot(self):
- snapname = ZFSTest.pool.makeName("@snap")
+ snapname = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname]
lzc.lzc_snapshot(snaps)
@@ -461,17 +462,17 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([])
def test_snapshot_user_props(self):
- snapname = ZFSTest.pool.makeName("@snap")
+ snapname = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname]
- props = {"user:foo": "bar"}
+ props = {b"user:foo": b"bar"}
lzc.lzc_snapshot(snaps, props)
self.assertExists(snapname)
def test_snapshot_invalid_props(self):
- snapname = ZFSTest.pool.makeName("@snap")
+ snapname = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname]
- props = {"foo": "bar"}
+ props = {b"foo": b"bar"}
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
lzc.lzc_snapshot(snaps, props)
@@ -482,8 +483,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname)
def test_snapshot_ro_pool(self):
- snapname1 = ZFSTest.readonly_pool.makeName("@snap")
- snapname2 = ZFSTest.readonly_pool.makeName("fs1@snap")
+ snapname1 = ZFSTest.readonly_pool.makeName(b"@snap")
+ snapname2 = ZFSTest.readonly_pool.makeName(b"fs1@snap")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -497,7 +498,7 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_snapshot_nonexistent_pool(self):
- snapname = "no-such-pool@snap"
+ snapname = b"no-such-pool@snap"
snaps = [snapname]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -508,7 +509,7 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(e, lzc_exc.FilesystemNotFound)
def test_snapshot_nonexistent_fs(self):
- snapname = ZFSTest.pool.makeName("nonexistent@snap")
+ snapname = ZFSTest.pool.makeName(b"nonexistent@snap")
snaps = [snapname]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -519,8 +520,8 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(e, lzc_exc.FilesystemNotFound)
def test_snapshot_nonexistent_and_existent_fs(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.pool.makeName("nonexistent@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.pool.makeName(b"nonexistent@snap")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -533,8 +534,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_multiple_snapshots_nonexistent_fs(self):
- snapname1 = ZFSTest.pool.makeName("nonexistent@snap1")
- snapname2 = ZFSTest.pool.makeName("nonexistent@snap2")
+ snapname1 = ZFSTest.pool.makeName(b"nonexistent@snap1")
+ snapname2 = ZFSTest.pool.makeName(b"nonexistent@snap2")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -548,8 +549,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_multiple_snapshots_multiple_nonexistent_fs(self):
- snapname1 = ZFSTest.pool.makeName("nonexistent1@snap")
- snapname2 = ZFSTest.pool.makeName("nonexistent2@snap")
+ snapname1 = ZFSTest.pool.makeName(b"nonexistent1@snap")
+ snapname2 = ZFSTest.pool.makeName(b"nonexistent2@snap")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -562,7 +563,7 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_snapshot_already_exists(self):
- snapname = ZFSTest.pool.makeName("@snap")
+ snapname = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname]
lzc.lzc_snapshot(snaps)
@@ -575,8 +576,8 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(e, lzc_exc.SnapshotExists)
def test_multiple_snapshots_for_same_fs(self):
- snapname1 = ZFSTest.pool.makeName("@snap1")
- snapname2 = ZFSTest.pool.makeName("@snap2")
+ snapname1 = ZFSTest.pool.makeName(b"@snap1")
+ snapname2 = ZFSTest.pool.makeName(b"@snap2")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -589,8 +590,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_multiple_snapshots(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.pool.makeName("fs1@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@snap")
snaps = [snapname1, snapname2]
lzc.lzc_snapshot(snaps)
@@ -598,8 +599,8 @@ class ZFSTest(unittest.TestCase):
self.assertExists(snapname2)
def test_multiple_existing_snapshots(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.pool.makeName("fs1@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@snap")
snaps = [snapname1, snapname2]
lzc.lzc_snapshot(snaps)
@@ -612,9 +613,9 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(e, lzc_exc.SnapshotExists)
def test_multiple_new_and_existing_snapshots(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.pool.makeName("fs1@snap")
- snapname3 = ZFSTest.pool.makeName("fs2@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@snap")
+ snapname3 = ZFSTest.pool.makeName(b"fs2@snap")
snaps = [snapname1, snapname2]
more_snaps = snaps + [snapname3]
@@ -629,9 +630,9 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname3)
def test_snapshot_multiple_errors(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.pool.makeName("nonexistent@snap")
- snapname3 = ZFSTest.pool.makeName("fs1@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.pool.makeName(b"nonexistent@snap")
+ snapname3 = ZFSTest.pool.makeName(b"fs1@snap")
snaps = [snapname1]
more_snaps = [snapname1, snapname2, snapname3]
@@ -655,8 +656,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname3)
def test_snapshot_different_pools(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.misc_pool.makeName("@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.misc_pool.makeName(b"@snap")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -670,8 +671,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_snapshot_different_pools_ro_pool(self):
- snapname1 = ZFSTest.pool.makeName("@snap")
- snapname2 = ZFSTest.readonly_pool.makeName("@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@snap")
+ snapname2 = ZFSTest.readonly_pool.makeName(b"@snap")
snaps = [snapname1, snapname2]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -688,9 +689,9 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_snapshot_invalid_name(self):
- snapname1 = ZFSTest.pool.makeName("@bad&name")
- snapname2 = ZFSTest.pool.makeName("fs1@bad*name")
- snapname3 = ZFSTest.pool.makeName("fs2@snap")
+ snapname1 = ZFSTest.pool.makeName(b"@bad&name")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@bad*name")
+ snapname3 = ZFSTest.pool.makeName(b"fs2@snap")
snaps = [snapname1, snapname2, snapname3]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -703,9 +704,9 @@ class ZFSTest(unittest.TestCase):
self.assertIsNone(e.name)
def test_snapshot_too_long_complete_name(self):
- snapname1 = ZFSTest.pool.makeTooLongName("fs1@")
- snapname2 = ZFSTest.pool.makeTooLongName("fs2@")
- snapname3 = ZFSTest.pool.makeName("@snap")
+ snapname1 = ZFSTest.pool.makeTooLongName(b"fs1@")
+ snapname2 = ZFSTest.pool.makeTooLongName(b"fs2@")
+ snapname3 = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname1, snapname2, snapname3]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -717,9 +718,9 @@ class ZFSTest(unittest.TestCase):
self.assertIsNotNone(e.name)
def test_snapshot_too_long_snap_name(self):
- snapname1 = ZFSTest.pool.makeTooLongComponent("fs1@")
- snapname2 = ZFSTest.pool.makeTooLongComponent("fs2@")
- snapname3 = ZFSTest.pool.makeName("@snap")
+ snapname1 = ZFSTest.pool.makeTooLongComponent(b"fs1@")
+ snapname2 = ZFSTest.pool.makeTooLongComponent(b"fs2@")
+ snapname3 = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname1, snapname2, snapname3]
with self.assertRaises(lzc_exc.SnapshotFailure) as ctx:
@@ -732,18 +733,18 @@ class ZFSTest(unittest.TestCase):
self.assertIsNone(e.name)
def test_destroy_nonexistent_snapshot(self):
- lzc.lzc_destroy_snaps([ZFSTest.pool.makeName("@nonexistent")], False)
- lzc.lzc_destroy_snaps([ZFSTest.pool.makeName("@nonexistent")], True)
+ lzc.lzc_destroy_snaps([ZFSTest.pool.makeName(b"@nonexistent")], False)
+ lzc.lzc_destroy_snaps([ZFSTest.pool.makeName(b"@nonexistent")], True)
def test_destroy_snapshot_of_nonexistent_pool(self):
with self.assertRaises(lzc_exc.SnapshotDestructionFailure) as ctx:
- lzc.lzc_destroy_snaps(["no-such-pool@snap"], False)
+ lzc.lzc_destroy_snaps([b"no-such-pool@snap"], False)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.PoolNotFound)
with self.assertRaises(lzc_exc.SnapshotDestructionFailure) as ctx:
- lzc.lzc_destroy_snaps(["no-such-pool@snap"], True)
+ lzc.lzc_destroy_snaps([b"no-such-pool@snap"], True)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.PoolNotFound)
@@ -751,24 +752,24 @@ class ZFSTest(unittest.TestCase):
# NB: note the difference from the nonexistent pool test.
def test_destroy_snapshot_of_nonexistent_fs(self):
lzc.lzc_destroy_snaps(
- [ZFSTest.pool.makeName("nonexistent@snap")], False)
+ [ZFSTest.pool.makeName(b"nonexistent@snap")], False)
lzc.lzc_destroy_snaps(
- [ZFSTest.pool.makeName("nonexistent@snap")], True)
+ [ZFSTest.pool.makeName(b"nonexistent@snap")], True)
# Apparently the name is not checked for validity.
@unittest.expectedFailure
def test_destroy_invalid_snap_name(self):
with self.assertRaises(lzc_exc.SnapshotDestructionFailure):
lzc.lzc_destroy_snaps(
- [ZFSTest.pool.makeName("@non$&*existent")], False)
+ [ZFSTest.pool.makeName(b"@non$&*existent")], False)
with self.assertRaises(lzc_exc.SnapshotDestructionFailure):
lzc.lzc_destroy_snaps(
- [ZFSTest.pool.makeName("@non$&*existent")], True)
+ [ZFSTest.pool.makeName(b"@non$&*existent")], True)
# Apparently the full name is not checked for length.
@unittest.expectedFailure
def test_destroy_too_long_full_snap_name(self):
- snapname1 = ZFSTest.pool.makeTooLongName("fs1@")
+ snapname1 = ZFSTest.pool.makeTooLongName(b"fs1@")
snaps = [snapname1]
with self.assertRaises(lzc_exc.SnapshotDestructionFailure):
@@ -777,9 +778,9 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_destroy_snaps(snaps, True)
def test_destroy_too_long_short_snap_name(self):
- snapname1 = ZFSTest.pool.makeTooLongComponent("fs1@")
- snapname2 = ZFSTest.pool.makeTooLongComponent("fs2@")
- snapname3 = ZFSTest.pool.makeName("@snap")
+ snapname1 = ZFSTest.pool.makeTooLongComponent(b"fs1@")
+ snapname2 = ZFSTest.pool.makeTooLongComponent(b"fs2@")
+ snapname3 = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname1, snapname2, snapname3]
with self.assertRaises(lzc_exc.SnapshotDestructionFailure) as ctx:
@@ -803,8 +804,8 @@ class ZFSTest(unittest.TestCase):
# Since currently we can not destroy filesystems,
# it would be impossible to destroy the snapshot,
# so no point in attempting to clean it up.
- snapname = ZFSTest.pool.makeName("fs2@origin1")
- name = ZFSTest.pool.makeName("fs1/fs/clone1")
+ snapname = ZFSTest.pool.makeName(b"fs2@origin1")
+ name = ZFSTest.pool.makeName(b"fs1/fs/clone1")
lzc.lzc_snapshot([snapname])
@@ -812,8 +813,8 @@ class ZFSTest(unittest.TestCase):
self.assertExists(name)
def test_clone_nonexistent_snapshot(self):
- snapname = ZFSTest.pool.makeName("fs2@nonexistent")
- name = ZFSTest.pool.makeName("fs1/fs/clone2")
+ snapname = ZFSTest.pool.makeName(b"fs2@nonexistent")
+ name = ZFSTest.pool.makeName(b"fs1/fs/clone2")
# XXX The error should be SnapshotNotFound
# but limitations of C interface do not allow
@@ -823,8 +824,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_clone_nonexistent_parent_fs(self):
- snapname = ZFSTest.pool.makeName("fs2@origin3")
- name = ZFSTest.pool.makeName("fs1/nonexistent/clone3")
+ snapname = ZFSTest.pool.makeName(b"fs2@origin3")
+ name = ZFSTest.pool.makeName(b"fs1/nonexistent/clone3")
lzc.lzc_snapshot([snapname])
@@ -833,8 +834,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_clone_to_nonexistent_pool(self):
- snapname = ZFSTest.pool.makeName("fs2@snap")
- name = "no-such-pool/fs"
+ snapname = ZFSTest.pool.makeName(b"fs2@snap")
+ name = b"no-such-pool/fs"
lzc.lzc_snapshot([snapname])
@@ -845,8 +846,8 @@ class ZFSTest(unittest.TestCase):
def test_clone_invalid_snap_name(self):
# Use a valid filesystem name of filesystem that
# exists as a snapshot name
- snapname = ZFSTest.pool.makeName("fs1/fs")
- name = ZFSTest.pool.makeName("fs2/clone")
+ snapname = ZFSTest.pool.makeName(b"fs1/fs")
+ name = ZFSTest.pool.makeName(b"fs2/clone")
with self.assertRaises(lzc_exc.SnapshotNameInvalid):
lzc.lzc_clone(name, snapname)
@@ -855,16 +856,16 @@ class ZFSTest(unittest.TestCase):
def test_clone_invalid_snap_name_2(self):
# Use a valid filesystem name of filesystem that
# doesn't exist as a snapshot name
- snapname = ZFSTest.pool.makeName("fs1/nonexistent")
- name = ZFSTest.pool.makeName("fs2/clone")
+ snapname = ZFSTest.pool.makeName(b"fs1/nonexistent")
+ name = ZFSTest.pool.makeName(b"fs2/clone")
with self.assertRaises(lzc_exc.SnapshotNameInvalid):
lzc.lzc_clone(name, snapname)
self.assertNotExists(name)
def test_clone_invalid_name(self):
- snapname = ZFSTest.pool.makeName("fs2@snap")
- name = ZFSTest.pool.makeName("fs1/bad#name")
+ snapname = ZFSTest.pool.makeName(b"fs2@snap")
+ name = ZFSTest.pool.makeName(b"fs1/bad#name")
lzc.lzc_snapshot([snapname])
@@ -873,8 +874,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_clone_invalid_pool_name(self):
- snapname = ZFSTest.pool.makeName("fs2@snap")
- name = "bad!pool/fs1"
+ snapname = ZFSTest.pool.makeName(b"fs2@snap")
+ name = b"bad!pool/fs1"
lzc.lzc_snapshot([snapname])
@@ -883,8 +884,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_clone_across_pools(self):
- snapname = ZFSTest.pool.makeName("fs2@snap")
- name = ZFSTest.misc_pool.makeName("clone1")
+ snapname = ZFSTest.pool.makeName(b"fs2@snap")
+ name = ZFSTest.misc_pool.makeName(b"clone1")
lzc.lzc_snapshot([snapname])
@@ -893,8 +894,8 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_clone_across_pools_to_ro_pool(self):
- snapname = ZFSTest.pool.makeName("fs2@snap")
- name = ZFSTest.readonly_pool.makeName("fs1/clone1")
+ snapname = ZFSTest.pool.makeName(b"fs2@snap")
+ name = ZFSTest.readonly_pool.makeName(b"fs1/clone1")
lzc.lzc_snapshot([snapname])
@@ -904,9 +905,9 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(name)
def test_destroy_cloned_fs(self):
- snapname1 = ZFSTest.pool.makeName("fs2@origin4")
- snapname2 = ZFSTest.pool.makeName("fs1@snap")
- clonename = ZFSTest.pool.makeName("fs1/fs/clone4")
+ snapname1 = ZFSTest.pool.makeName(b"fs2@origin4")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@snap")
+ clonename = ZFSTest.pool.makeName(b"fs1/fs/clone4")
snaps = [snapname1, snapname2]
lzc.lzc_snapshot(snaps)
@@ -922,9 +923,9 @@ class ZFSTest(unittest.TestCase):
self.assertExists(snap)
def test_deferred_destroy_cloned_fs(self):
- snapname1 = ZFSTest.pool.makeName("fs2@origin5")
- snapname2 = ZFSTest.pool.makeName("fs1@snap")
- clonename = ZFSTest.pool.makeName("fs1/fs/clone5")
+ snapname1 = ZFSTest.pool.makeName(b"fs2@origin5")
+ snapname2 = ZFSTest.pool.makeName(b"fs1@snap")
+ clonename = ZFSTest.pool.makeName(b"fs1/fs/clone5")
snaps = [snapname1, snapname2]
lzc.lzc_snapshot(snaps)
@@ -936,17 +937,17 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(snapname2)
def test_rollback(self):
- name = ZFSTest.pool.makeName("fs1")
- snapname = name + "@snap"
+ name = ZFSTest.pool.makeName(b"fs1")
+ snapname = name + b"@snap"
lzc.lzc_snapshot([snapname])
ret = lzc.lzc_rollback(name)
self.assertEqual(ret, snapname)
def test_rollback_2(self):
- name = ZFSTest.pool.makeName("fs1")
- snapname1 = name + "@snap1"
- snapname2 = name + "@snap2"
+ name = ZFSTest.pool.makeName(b"fs1")
+ snapname1 = name + b"@snap1"
+ snapname2 = name + b"@snap2"
lzc.lzc_snapshot([snapname1])
lzc.lzc_snapshot([snapname2])
@@ -954,31 +955,31 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ret, snapname2)
def test_rollback_no_snaps(self):
- name = ZFSTest.pool.makeName("fs1")
+ name = ZFSTest.pool.makeName(b"fs1")
with self.assertRaises(lzc_exc.SnapshotNotFound):
lzc.lzc_rollback(name)
def test_rollback_non_existent_fs(self):
- name = ZFSTest.pool.makeName("nonexistent")
+ name = ZFSTest.pool.makeName(b"nonexistent")
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_rollback(name)
def test_rollback_invalid_fs_name(self):
- name = ZFSTest.pool.makeName("bad~name")
+ name = ZFSTest.pool.makeName(b"bad~name")
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_rollback(name)
def test_rollback_snap_name(self):
- name = ZFSTest.pool.makeName("fs1@snap")
+ name = ZFSTest.pool.makeName(b"fs1@snap")
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_rollback(name)
def test_rollback_snap_name_2(self):
- name = ZFSTest.pool.makeName("fs1@snap")
+ name = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([name])
with self.assertRaises(lzc_exc.NameInvalid):
@@ -991,28 +992,28 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_rollback(name)
def test_rollback_to_snap_name(self):
- name = ZFSTest.pool.makeName("fs1")
- snap = name + "@snap"
+ name = ZFSTest.pool.makeName(b"fs1")
+ snap = name + b"@snap"
lzc.lzc_snapshot([snap])
lzc.lzc_rollback_to(name, snap)
def test_rollback_to_not_latest(self):
- fsname = ZFSTest.pool.makeName('fs1')
- snap1 = fsname + "@snap1"
- snap2 = fsname + "@snap2"
+ fsname = ZFSTest.pool.makeName(b'fs1')
+ snap1 = fsname + b"@snap1"
+ snap2 = fsname + b"@snap2"
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
with self.assertRaises(lzc_exc.SnapshotNotLatest):
- lzc.lzc_rollback_to(fsname, fsname + "@snap1")
+ lzc.lzc_rollback_to(fsname, fsname + b"@snap1")
@skipUnlessBookmarksSupported
def test_bookmarks(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs1#bmark1'), ZFSTest.pool.makeName('fs2#bmark1')]
+ b'fs1#bmark1'), ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1021,9 +1022,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_2(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs1#bmark1'), ZFSTest.pool.makeName('fs2#bmark1')]
+ b'fs1#bmark1'), ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1036,8 +1037,8 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_mismatching_name(self):
- snaps = [ZFSTest.pool.makeName('fs1@snap1')]
- bmarks = [ZFSTest.pool.makeName('fs2#bmark1')]
+ snaps = [ZFSTest.pool.makeName(b'fs1@snap1')]
+ bmarks = [ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1049,8 +1050,8 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_invalid_name(self):
- snaps = [ZFSTest.pool.makeName('fs1@snap1')]
- bmarks = [ZFSTest.pool.makeName('fs1#bmark!')]
+ snaps = [ZFSTest.pool.makeName(b'fs1@snap1')]
+ bmarks = [ZFSTest.pool.makeName(b'fs1#bmark!')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1062,8 +1063,8 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_invalid_name_2(self):
- snaps = [ZFSTest.pool.makeName('fs1@snap1')]
- bmarks = [ZFSTest.pool.makeName('fs1@bmark')]
+ snaps = [ZFSTest.pool.makeName(b'fs1@snap1')]
+ bmarks = [ZFSTest.pool.makeName(b'fs1@bmark')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1075,8 +1076,8 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_too_long_name(self):
- snaps = [ZFSTest.pool.makeName('fs1@snap1')]
- bmarks = [ZFSTest.pool.makeTooLongName('fs1#')]
+ snaps = [ZFSTest.pool.makeName(b'fs1@snap1')]
+ bmarks = [ZFSTest.pool.makeTooLongName(b'fs1#')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1088,8 +1089,8 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_too_long_name_2(self):
- snaps = [ZFSTest.pool.makeName('fs1@snap1')]
- bmarks = [ZFSTest.pool.makeTooLongComponent('fs1#')]
+ snaps = [ZFSTest.pool.makeName(b'fs1@snap1')]
+ bmarks = [ZFSTest.pool.makeTooLongComponent(b'fs1#')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1102,9 +1103,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_mismatching_names(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs2#bmark1'), ZFSTest.pool.makeName('fs1#bmark1')]
+ b'fs2#bmark1'), ZFSTest.pool.makeName(b'fs1#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1117,9 +1118,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_partially_mismatching_names(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs2#bmark'), ZFSTest.pool.makeName('fs2#bmark1')]
+ b'fs2#bmark'), ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps)
@@ -1132,9 +1133,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_cross_pool(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.misc_pool.makeName('@snap1')]
+ b'fs1@snap1'), ZFSTest.misc_pool.makeName(b'@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs1#bmark1'), ZFSTest.misc_pool.makeName('#bmark1')]
+ b'fs1#bmark1'), ZFSTest.misc_pool.makeName(b'#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps[0:1])
@@ -1148,9 +1149,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_missing_snap(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs1#bmark1'), ZFSTest.pool.makeName('fs2#bmark1')]
+ b'fs1#bmark1'), ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
lzc.lzc_snapshot(snaps[0:1])
@@ -1163,9 +1164,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_missing_snaps(self):
snaps = [ZFSTest.pool.makeName(
- 'fs1@snap1'), ZFSTest.pool.makeName('fs2@snap1')]
+ b'fs1@snap1'), ZFSTest.pool.makeName(b'fs2@snap1')]
bmarks = [ZFSTest.pool.makeName(
- 'fs1#bmark1'), ZFSTest.pool.makeName('fs2#bmark1')]
+ b'fs1#bmark1'), ZFSTest.pool.makeName(b'fs2#bmark1')]
bmark_dict = {x: y for x, y in zip(bmarks, snaps)}
with self.assertRaises(lzc_exc.BookmarkFailure) as ctx:
@@ -1176,9 +1177,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_for_the_same_snap(self):
- snap = ZFSTest.pool.makeName('fs1@snap1')
- bmark1 = ZFSTest.pool.makeName('fs1#bmark1')
- bmark2 = ZFSTest.pool.makeName('fs1#bmark2')
+ snap = ZFSTest.pool.makeName(b'fs1@snap1')
+ bmark1 = ZFSTest.pool.makeName(b'fs1#bmark1')
+ bmark2 = ZFSTest.pool.makeName(b'fs1#bmark2')
bmark_dict = {bmark1: snap, bmark2: snap}
lzc.lzc_snapshot([snap])
@@ -1186,9 +1187,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_for_the_same_snap_2(self):
- snap = ZFSTest.pool.makeName('fs1@snap1')
- bmark1 = ZFSTest.pool.makeName('fs1#bmark1')
- bmark2 = ZFSTest.pool.makeName('fs1#bmark2')
+ snap = ZFSTest.pool.makeName(b'fs1@snap1')
+ bmark1 = ZFSTest.pool.makeName(b'fs1#bmark1')
+ bmark2 = ZFSTest.pool.makeName(b'fs1#bmark2')
bmark_dict1 = {bmark1: snap}
bmark_dict2 = {bmark2: snap}
@@ -1198,9 +1199,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_bookmarks_duplicate_name(self):
- snap1 = ZFSTest.pool.makeName('fs1@snap1')
- snap2 = ZFSTest.pool.makeName('fs1@snap2')
- bmark = ZFSTest.pool.makeName('fs1#bmark')
+ snap1 = ZFSTest.pool.makeName(b'fs1@snap1')
+ snap2 = ZFSTest.pool.makeName(b'fs1@snap2')
+ bmark = ZFSTest.pool.makeName(b'fs1#bmark')
bmark_dict1 = {bmark: snap1}
bmark_dict2 = {bmark: snap2}
@@ -1215,11 +1216,11 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_get_bookmarks(self):
- snap1 = ZFSTest.pool.makeName('fs1@snap1')
- snap2 = ZFSTest.pool.makeName('fs1@snap2')
- bmark = ZFSTest.pool.makeName('fs1#bmark')
- bmark1 = ZFSTest.pool.makeName('fs1#bmark1')
- bmark2 = ZFSTest.pool.makeName('fs1#bmark2')
+ snap1 = ZFSTest.pool.makeName(b'fs1@snap1')
+ snap2 = ZFSTest.pool.makeName(b'fs1@snap2')
+ bmark = ZFSTest.pool.makeName(b'fs1#bmark')
+ bmark1 = ZFSTest.pool.makeName(b'fs1#bmark1')
+ bmark2 = ZFSTest.pool.makeName(b'fs1#bmark2')
bmark_dict1 = {bmark1: snap1, bmark2: snap2}
bmark_dict2 = {bmark: snap2}
@@ -1229,34 +1230,34 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_bookmark(bmark_dict2)
lzc.lzc_destroy_snaps([snap1, snap2], defer=False)
- bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName('fs1'))
+ bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName(b'fs1'))
self.assertEqual(len(bmarks), 3)
- for b in 'bmark', 'bmark1', 'bmark2':
+ for b in b'bmark', b'bmark1', b'bmark2':
self.assertIn(b, bmarks)
self.assertIsInstance(bmarks[b], dict)
self.assertEqual(len(bmarks[b]), 0)
- bmarks = lzc.lzc_get_bookmarks(
- ZFSTest.pool.makeName('fs1'), ['guid', 'createtxg', 'creation'])
+ bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName(b'fs1'),
+ [b'guid', b'createtxg', b'creation'])
self.assertEqual(len(bmarks), 3)
- for b in 'bmark', 'bmark1', 'bmark2':
+ for b in b'bmark', b'bmark1', b'bmark2':
self.assertIn(b, bmarks)
self.assertIsInstance(bmarks[b], dict)
self.assertEqual(len(bmarks[b]), 3)
@skipUnlessBookmarksSupported
def test_get_bookmarks_invalid_property(self):
- snap = ZFSTest.pool.makeName('fs1@snap')
- bmark = ZFSTest.pool.makeName('fs1#bmark')
+ snap = ZFSTest.pool.makeName(b'fs1@snap')
+ bmark = ZFSTest.pool.makeName(b'fs1#bmark')
bmark_dict = {bmark: snap}
lzc.lzc_snapshot([snap])
lzc.lzc_bookmark(bmark_dict)
bmarks = lzc.lzc_get_bookmarks(
- ZFSTest.pool.makeName('fs1'), ['badprop'])
+ ZFSTest.pool.makeName(b'fs1'), [b'badprop'])
self.assertEqual(len(bmarks), 1)
- for b in ('bmark', ):
+ for b in (b'bmark', ):
self.assertIn(b, bmarks)
self.assertIsInstance(bmarks[b], dict)
self.assertEqual(len(bmarks[b]), 0)
@@ -1264,26 +1265,26 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_get_bookmarks_nonexistent_fs(self):
with self.assertRaises(lzc_exc.FilesystemNotFound):
- lzc.lzc_get_bookmarks(ZFSTest.pool.makeName('nonexistent'))
+ lzc.lzc_get_bookmarks(ZFSTest.pool.makeName(b'nonexistent'))
@skipUnlessBookmarksSupported
def test_destroy_bookmarks(self):
- snap = ZFSTest.pool.makeName('fs1@snap')
- bmark = ZFSTest.pool.makeName('fs1#bmark')
+ snap = ZFSTest.pool.makeName(b'fs1@snap')
+ bmark = ZFSTest.pool.makeName(b'fs1#bmark')
bmark_dict = {bmark: snap}
lzc.lzc_snapshot([snap])
lzc.lzc_bookmark(bmark_dict)
lzc.lzc_destroy_bookmarks(
- [bmark, ZFSTest.pool.makeName('fs1#nonexistent')])
- bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName('fs1'))
+ [bmark, ZFSTest.pool.makeName(b'fs1#nonexistent')])
+ bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName(b'fs1'))
self.assertEqual(len(bmarks), 0)
@skipUnlessBookmarksSupported
def test_destroy_bookmarks_invalid_name(self):
- snap = ZFSTest.pool.makeName('fs1@snap')
- bmark = ZFSTest.pool.makeName('fs1#bmark')
+ snap = ZFSTest.pool.makeName(b'fs1@snap')
+ bmark = ZFSTest.pool.makeName(b'fs1#bmark')
bmark_dict = {bmark: snap}
lzc.lzc_snapshot([snap])
@@ -1291,26 +1292,27 @@ class ZFSTest(unittest.TestCase):
with self.assertRaises(lzc_exc.BookmarkDestructionFailure) as ctx:
lzc.lzc_destroy_bookmarks(
- [bmark, ZFSTest.pool.makeName('fs1/nonexistent')])
+ [bmark, ZFSTest.pool.makeName(b'fs1/nonexistent')])
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameInvalid)
- bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName('fs1'))
+ bmarks = lzc.lzc_get_bookmarks(ZFSTest.pool.makeName(b'fs1'))
self.assertEqual(len(bmarks), 1)
- self.assertIn('bmark', bmarks)
+ self.assertIn(b'bmark', bmarks)
@skipUnlessBookmarksSupported
def test_destroy_bookmark_nonexistent_fs(self):
- lzc.lzc_destroy_bookmarks([ZFSTest.pool.makeName('nonexistent#bmark')])
+ lzc.lzc_destroy_bookmarks(
+ [ZFSTest.pool.makeName(b'nonexistent#bmark')])
@skipUnlessBookmarksSupported
def test_destroy_bookmarks_empty(self):
lzc.lzc_bookmark({})
def test_snaprange_space(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- snap3 = ZFSTest.pool.makeName("fs1@snap")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ snap3 = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1324,15 +1326,15 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(space, (int, int))
def test_snaprange_space_2(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- snap3 = ZFSTest.pool.makeName("fs1@snap")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ snap3 = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap1])
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap2])
lzc.lzc_snapshot([snap3])
@@ -1345,12 +1347,12 @@ class ZFSTest(unittest.TestCase):
self.assertGreater(space, 1024 * 1024)
def test_snaprange_space_same_snap(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap])
@@ -1359,8 +1361,8 @@ class ZFSTest(unittest.TestCase):
self.assertAlmostEqual(space, 1024 * 1024, delta=1024 * 1024 // 20)
def test_snaprange_space_wrong_order(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1369,8 +1371,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap2, snap1)
def test_snaprange_space_unrelated(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs2@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs2@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1379,8 +1381,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap1, snap2)
def test_snaprange_space_across_pools(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.misc_pool.makeName("@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.misc_pool.makeName(b"@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1389,8 +1391,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap1, snap2)
def test_snaprange_space_nonexistent(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
@@ -1403,8 +1405,8 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.name, snap1)
def test_snaprange_space_invalid_name(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@sn#p")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@sn#p")
lzc.lzc_snapshot([snap1])
@@ -1412,8 +1414,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap1, snap2)
def test_snaprange_space_not_snap(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1")
lzc.lzc_snapshot([snap1])
@@ -1423,8 +1425,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap2, snap1)
def test_snaprange_space_not_snap_2(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1#bmark")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1#bmark")
lzc.lzc_snapshot([snap1])
@@ -1434,9 +1436,9 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snaprange_space(snap2, snap1)
def test_send_space(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- snap3 = ZFSTest.pool.makeName("fs1@snap")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ snap3 = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1456,15 +1458,15 @@ class ZFSTest(unittest.TestCase):
self.assertIsInstance(space, (int, int))
def test_send_space_2(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- snap3 = ZFSTest.pool.makeName("fs1@snap")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ snap3 = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap1])
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap2])
lzc.lzc_snapshot([snap3])
@@ -1485,14 +1487,14 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(space, space_empty)
def test_send_space_same_snap(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
lzc.lzc_snapshot([snap1])
with self.assertRaises(lzc_exc.SnapshotMismatch):
lzc.lzc_send_space(snap1, snap1)
def test_send_space_wrong_order(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1501,8 +1503,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send_space(snap1, snap2)
def test_send_space_unrelated(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs2@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs2@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1511,8 +1513,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send_space(snap1, snap2)
def test_send_space_across_pools(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.misc_pool.makeName("@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.misc_pool.makeName(b"@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1521,8 +1523,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send_space(snap1, snap2)
def test_send_space_nonexistent(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs2@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs2@snap2")
lzc.lzc_snapshot([snap1])
@@ -1539,8 +1541,8 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.name, snap2)
def test_send_space_invalid_name(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@sn!p")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@sn!p")
lzc.lzc_snapshot([snap1])
@@ -1555,8 +1557,8 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.name, snap2)
def test_send_space_not_snap(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1")
lzc.lzc_snapshot([snap1])
@@ -1568,8 +1570,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send_space(snap2)
def test_send_space_not_snap_2(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1#bmark")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1#bmark")
lzc.lzc_snapshot([snap1])
@@ -1579,12 +1581,12 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send_space(snap2)
def test_send_full(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap])
@@ -1598,14 +1600,14 @@ class ZFSTest(unittest.TestCase):
self.assertAlmostEqual(st.st_size, estimate, delta=estimate // 20)
def test_send_incremental(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap2])
@@ -1620,7 +1622,7 @@ class ZFSTest(unittest.TestCase):
def test_send_flags(self):
flags = ['embedded_data', 'large_blocks', 'compress', 'raw']
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
for c in range(len(flags)):
@@ -1629,14 +1631,14 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap, None, fd, list(flag))
def test_send_unknown_flags(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
with dev_null() as fd:
with self.assertRaises(lzc_exc.UnknownStreamFeature):
lzc.lzc_send(snap, None, fd, ['embedded_data', 'UNKNOWN'])
def test_send_same_snap(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
lzc.lzc_snapshot([snap1])
with tempfile.TemporaryFile(suffix='.ztream') as output:
fd = output.fileno()
@@ -1644,8 +1646,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap1, snap1, fd)
def test_send_wrong_order(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1656,8 +1658,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap1, snap2, fd)
def test_send_unrelated(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs2@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs2@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1668,8 +1670,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap1, snap2, fd)
def test_send_across_pools(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.misc_pool.makeName("@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.misc_pool.makeName(b"@snap2")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1680,8 +1682,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap1, snap2, fd)
def test_send_nonexistent(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
lzc.lzc_snapshot([snap1])
@@ -1700,8 +1702,8 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.name, snap2)
def test_send_invalid_name(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@sn!p")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@sn!p")
lzc.lzc_snapshot([snap1])
@@ -1722,8 +1724,8 @@ class ZFSTest(unittest.TestCase):
# is taken at some time after the call is made and before the stream
# starts being produced.
def test_send_filesystem(self):
- snap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.makeName("fs1")
+ snap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.makeName(b"fs1")
lzc.lzc_snapshot([snap])
@@ -1733,8 +1735,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(fs, None, fd)
def test_send_from_filesystem(self):
- snap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.makeName("fs1")
+ snap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.makeName(b"fs1")
lzc.lzc_snapshot([snap])
@@ -1745,9 +1747,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_send_bookmark(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- bmark = ZFSTest.pool.makeName("fs1#bmark")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ bmark = ZFSTest.pool.makeName(b"fs1#bmark")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1763,9 +1765,9 @@ class ZFSTest(unittest.TestCase):
@skipUnlessBookmarksSupported
def test_send_from_bookmark(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- bmark = ZFSTest.pool.makeName("fs1#bmark")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ bmark = ZFSTest.pool.makeName(b"fs1#bmark")
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2])
@@ -1777,7 +1779,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_send(snap2, bmark, fd)
def test_send_bad_fd(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
with tempfile.TemporaryFile() as tmp:
@@ -1788,7 +1790,7 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.errno, errno.EBADF)
def test_send_bad_fd_2(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
with self.assertRaises(lzc_exc.StreamIOError) as ctx:
@@ -1796,7 +1798,7 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.errno, errno.EBADF)
def test_send_bad_fd_3(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
with tempfile.TemporaryFile() as tmp:
@@ -1809,32 +1811,46 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.errno, errno.EBADF)
def test_send_to_broken_pipe(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
- proc = subprocess.Popen(['true'], stdin=subprocess.PIPE)
- proc.wait()
- with self.assertRaises(lzc_exc.StreamIOError) as ctx:
- lzc.lzc_send(snap, None, proc.stdin.fileno())
- self.assertEqual(ctx.exception.errno, errno.EPIPE)
+ if sys.version_info < (3, 0):
+ proc = subprocess.Popen(['true'], stdin=subprocess.PIPE)
+ proc.wait()
+ with self.assertRaises(lzc_exc.StreamIOError) as ctx:
+ lzc.lzc_send(snap, None, proc.stdin.fileno())
+ self.assertEqual(ctx.exception.errno, errno.EPIPE)
+ else:
+ with subprocess.Popen(['true'], stdin=subprocess.PIPE) as proc:
+ proc.wait()
+ with self.assertRaises(lzc_exc.StreamIOError) as ctx:
+ lzc.lzc_send(snap, None, proc.stdin.fileno())
+ self.assertEqual(ctx.exception.errno, errno.EPIPE)
def test_send_to_broken_pipe_2(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
f.flush()
lzc.lzc_snapshot([snap])
- proc = subprocess.Popen(['sleep', '2'], stdin=subprocess.PIPE)
- with self.assertRaises(lzc_exc.StreamIOError) as ctx:
- lzc.lzc_send(snap, None, proc.stdin.fileno())
- self.assertTrue(ctx.exception.errno == errno.EPIPE or
- ctx.exception.errno == errno.EINTR)
+ if sys.version_info < (3, 0):
+ p = subprocess.Popen(['sleep', '2'], stdin=subprocess.PIPE)
+ with self.assertRaises(lzc_exc.StreamIOError) as ctx:
+ lzc.lzc_send(snap, None, p.stdin.fileno())
+ self.assertTrue(ctx.exception.errno == errno.EPIPE or
+ ctx.exception.errno == errno.EINTR)
+ else:
+ with subprocess.Popen(['sleep', '2'], stdin=subprocess.PIPE) as p:
+ with self.assertRaises(lzc_exc.StreamIOError) as ctx:
+ lzc.lzc_send(snap, None, p.stdin.fileno())
+ self.assertTrue(ctx.exception.errno == errno.EPIPE or
+ ctx.exception.errno == errno.EINTR)
def test_send_to_ro_file(self):
- snap = ZFSTest.pool.makeName("fs1@snap")
+ snap = ZFSTest.pool.makeName(b"fs1@snap")
lzc.lzc_snapshot([snap])
with tempfile.NamedTemporaryFile(
@@ -1849,10 +1865,10 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(ctx.exception.errno, errno.EBADF)
def test_recv_full(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dst = ZFSTest.pool.makeName("fs2/received-1@snap")
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dst = ZFSTest.pool.makeName(b"fs2/received-1@snap")
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")) as name:
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")) as name:
lzc.lzc_snapshot([src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -1867,13 +1883,13 @@ class ZFSTest(unittest.TestCase):
os.path.join(mnt1, name), os.path.join(mnt2, name), False))
def test_recv_incremental(self):
- src1 = ZFSTest.pool.makeName("fs1@snap1")
- src2 = ZFSTest.pool.makeName("fs1@snap2")
- dst1 = ZFSTest.pool.makeName("fs2/received-2@snap1")
- dst2 = ZFSTest.pool.makeName("fs2/received-2@snap2")
+ src1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ src2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ dst1 = ZFSTest.pool.makeName(b"fs2/received-2@snap1")
+ dst2 = ZFSTest.pool.makeName(b"fs2/received-2@snap2")
lzc.lzc_snapshot([src1])
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")) as name:
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")) as name:
lzc.lzc_snapshot([src2])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -1896,12 +1912,12 @@ class ZFSTest(unittest.TestCase):
# is applied to libzfs_core, otherwise it succeeds.
@unittest.skip("fails with unpatched libzfs_core")
def test_recv_without_explicit_snap_name(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-100")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-100")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dstfs, full.fileno())
@@ -1910,11 +1926,11 @@ class ZFSTest(unittest.TestCase):
self.assertExists(dst2)
def test_recv_clone(self):
- orig_src = ZFSTest.pool.makeName("fs2@send-origin")
- clone = ZFSTest.pool.makeName("fs1/fs/send-clone")
- clone_snap = clone + "@snap"
- orig_dst = ZFSTest.pool.makeName("fs1/fs/recv-origin@snap")
- clone_dst = ZFSTest.pool.makeName("fs1/fs/recv-clone@snap")
+ orig_src = ZFSTest.pool.makeName(b"fs2@send-origin")
+ clone = ZFSTest.pool.makeName(b"fs1/fs/send-clone")
+ clone_snap = clone + b"@snap"
+ orig_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-origin@snap")
+ clone_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-clone@snap")
lzc.lzc_snapshot([orig_src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -1930,11 +1946,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(clone_dst, stream.fileno(), origin=orig_dst)
def test_recv_full_already_existing_empty_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-3")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-3")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -1947,11 +1963,11 @@ class ZFSTest(unittest.TestCase):
def test_recv_full_into_root_empty_pool(self):
empty_pool = None
try:
- srcfs = ZFSTest.pool.makeName("fs1")
+ srcfs = ZFSTest.pool.makeName(b"fs1")
empty_pool = _TempPool()
- dst = empty_pool.makeName('@snap')
+ dst = empty_pool.makeName(b'@snap')
- with streams(srcfs, "snap", None) as (_, (stream, _)):
+ with streams(srcfs, b"snap", None) as (_, (stream, _)):
with self.assertRaises((
lzc_exc.DestinationModified, lzc_exc.DatasetExists)):
lzc.lzc_receive(dst, stream.fileno())
@@ -1960,19 +1976,19 @@ class ZFSTest(unittest.TestCase):
empty_pool.cleanUp()
def test_recv_full_into_ro_pool(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- dst = ZFSTest.readonly_pool.makeName('fs2/received@snap')
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ dst = ZFSTest.readonly_pool.makeName(b'fs2/received@snap')
- with streams(srcfs, "snap", None) as (_, (stream, _)):
+ with streams(srcfs, b"snap", None) as (_, (stream, _)):
with self.assertRaises(lzc_exc.ReadOnlyPool):
lzc.lzc_receive(dst, stream.fileno())
def test_recv_full_already_existing_modified_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-5")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-5")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
with temp_file_in_fs(dstfs):
@@ -1984,14 +2000,14 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno())
def test_recv_full_already_existing_with_snapshots(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-4")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-4")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
- lzc.lzc_snapshot([dstfs + "@snap1"])
+ lzc.lzc_snapshot([dstfs + b"@snap1"])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(src, None, stream.fileno())
stream.seek(0)
@@ -2000,11 +2016,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno())
def test_recv_full_already_existing_snapshot(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-6")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-6")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
lzc.lzc_snapshot([dst])
@@ -2015,10 +2031,10 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno())
def test_recv_full_missing_parent_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dst = ZFSTest.pool.makeName("fs2/nonexistent/fs@snap")
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dst = ZFSTest.pool.makeName(b"fs2/nonexistent/fs@snap")
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(src, None, stream.fileno())
@@ -2027,18 +2043,18 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno())
def test_recv_full_but_specify_origin(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src = srcfs + "@snap"
- dstfs = ZFSTest.pool.makeName("fs2/received-30")
- dst = dstfs + '@snap'
- origin1 = ZFSTest.pool.makeName("fs2@snap1")
- origin2 = ZFSTest.pool.makeName("fs2@snap2")
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src = srcfs + b"@snap"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-30")
+ dst = dstfs + b'@snap'
+ origin1 = ZFSTest.pool.makeName(b"fs2@snap1")
+ origin2 = ZFSTest.pool.makeName(b"fs2@snap2")
lzc.lzc_snapshot([origin1])
with streams(srcfs, src, None) as (_, (stream, _)):
lzc.lzc_receive(dst, stream.fileno(), origin=origin1)
- origin = ZFSTest.pool.getFilesystem("fs2/received-30").getProperty(
- 'origin')
+ origin = ZFSTest.pool.getFilesystem(
+ b"fs2/received-30").getProperty('origin')
self.assertEqual(origin, origin1)
stream.seek(0)
# because origin snap does not exist can't receive as a clone of it
@@ -2048,11 +2064,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), origin=origin2)
def test_recv_full_existing_empty_fs_and_origin(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src = srcfs + "@snap"
- dstfs = ZFSTest.pool.makeName("fs2/received-31")
- dst = dstfs + '@snap'
- origin = dstfs + '@dummy'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src = srcfs + b"@snap"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-31")
+ dst = dstfs + b'@snap'
+ origin = dstfs + b'@dummy'
lzc.lzc_create(dstfs)
with streams(srcfs, src, None) as (_, (stream, _)):
@@ -2072,12 +2088,12 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), origin=origin)
def test_recv_incremental_mounted_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-7")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-7")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2085,12 +2101,12 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno())
def test_recv_incremental_modified_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-15")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-15")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2099,12 +2115,12 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno())
def test_recv_incremental_snapname_used(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-8")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-8")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2113,13 +2129,13 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno())
def test_recv_incremental_more_recent_snap_with_no_changes(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-9")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-9")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2127,13 +2143,13 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno())
def test_recv_incremental_non_clone_but_set_origin(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-20")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-20")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2143,13 +2159,13 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno(), origin=dst1)
def test_recv_incremental_non_clone_but_set_random_origin(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-21")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-21")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2160,16 +2176,16 @@ class ZFSTest(unittest.TestCase):
lzc_exc.BadStream)):
lzc.lzc_receive(
dst2, incr.fileno(),
- origin=ZFSTest.pool.makeName("fs2/fs@snap"))
+ origin=ZFSTest.pool.makeName(b"fs2/fs@snap"))
def test_recv_incremental_more_recent_snap(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-10")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-10")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2179,13 +2195,13 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno())
def test_recv_incremental_duplicate(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-11")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-11")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2195,11 +2211,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst_snap, incr.fileno())
def test_recv_incremental_unrelated_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-12")
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-12")
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (_, incr)):
lzc.lzc_create(dstfs)
@@ -2207,32 +2223,32 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst_snap, incr.fileno())
def test_recv_incremental_nonexistent_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-13")
- dst_snap = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-13")
+ dst_snap = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (_, incr)):
with self.assertRaises(lzc_exc.DatasetNotFound):
lzc.lzc_receive(dst_snap, incr.fileno())
def test_recv_incremental_same_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- src_snap = srcfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ src_snap = srcfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (_, incr)):
with self.assertRaises(lzc_exc.DestinationModified):
lzc.lzc_receive(src_snap, incr.fileno())
def test_recv_clone_without_specifying_origin(self):
- orig_src = ZFSTest.pool.makeName("fs2@send-origin-2")
- clone = ZFSTest.pool.makeName("fs1/fs/send-clone-2")
- clone_snap = clone + "@snap"
- orig_dst = ZFSTest.pool.makeName("fs1/fs/recv-origin-2@snap")
- clone_dst = ZFSTest.pool.makeName("fs1/fs/recv-clone-2@snap")
+ orig_src = ZFSTest.pool.makeName(b"fs2@send-origin-2")
+ clone = ZFSTest.pool.makeName(b"fs1/fs/send-clone-2")
+ clone_snap = clone + b"@snap"
+ orig_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-origin-2@snap")
+ clone_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-clone-2@snap")
lzc.lzc_snapshot([orig_src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2249,11 +2265,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(clone_dst, stream.fileno())
def test_recv_clone_invalid_origin(self):
- orig_src = ZFSTest.pool.makeName("fs2@send-origin-3")
- clone = ZFSTest.pool.makeName("fs1/fs/send-clone-3")
- clone_snap = clone + "@snap"
- orig_dst = ZFSTest.pool.makeName("fs1/fs/recv-origin-3@snap")
- clone_dst = ZFSTest.pool.makeName("fs1/fs/recv-clone-3@snap")
+ orig_src = ZFSTest.pool.makeName(b"fs2@send-origin-3")
+ clone = ZFSTest.pool.makeName(b"fs1/fs/send-clone-3")
+ clone_snap = clone + b"@snap"
+ orig_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-origin-3@snap")
+ clone_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-clone-3@snap")
lzc.lzc_snapshot([orig_src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2269,15 +2285,15 @@ class ZFSTest(unittest.TestCase):
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_receive(
clone_dst, stream.fileno(),
- origin=ZFSTest.pool.makeName("fs1/fs"))
+ origin=ZFSTest.pool.makeName(b"fs1/fs"))
def test_recv_clone_wrong_origin(self):
- orig_src = ZFSTest.pool.makeName("fs2@send-origin-4")
- clone = ZFSTest.pool.makeName("fs1/fs/send-clone-4")
- clone_snap = clone + "@snap"
- orig_dst = ZFSTest.pool.makeName("fs1/fs/recv-origin-4@snap")
- clone_dst = ZFSTest.pool.makeName("fs1/fs/recv-clone-4@snap")
- wrong_origin = ZFSTest.pool.makeName("fs1/fs@snap")
+ orig_src = ZFSTest.pool.makeName(b"fs2@send-origin-4")
+ clone = ZFSTest.pool.makeName(b"fs1/fs/send-clone-4")
+ clone_snap = clone + b"@snap"
+ orig_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-origin-4@snap")
+ clone_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-clone-4@snap")
+ wrong_origin = ZFSTest.pool.makeName(b"fs1/fs@snap")
lzc.lzc_snapshot([orig_src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2296,12 +2312,12 @@ class ZFSTest(unittest.TestCase):
clone_dst, stream.fileno(), origin=wrong_origin)
def test_recv_clone_nonexistent_origin(self):
- orig_src = ZFSTest.pool.makeName("fs2@send-origin-5")
- clone = ZFSTest.pool.makeName("fs1/fs/send-clone-5")
- clone_snap = clone + "@snap"
- orig_dst = ZFSTest.pool.makeName("fs1/fs/recv-origin-5@snap")
- clone_dst = ZFSTest.pool.makeName("fs1/fs/recv-clone-5@snap")
- wrong_origin = ZFSTest.pool.makeName("fs1/fs@snap")
+ orig_src = ZFSTest.pool.makeName(b"fs2@send-origin-5")
+ clone = ZFSTest.pool.makeName(b"fs1/fs/send-clone-5")
+ clone_snap = clone + b"@snap"
+ orig_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-origin-5@snap")
+ clone_dst = ZFSTest.pool.makeName(b"fs1/fs/recv-clone-5@snap")
+ wrong_origin = ZFSTest.pool.makeName(b"fs1/fs@snap")
lzc.lzc_snapshot([orig_src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2319,11 +2335,11 @@ class ZFSTest(unittest.TestCase):
clone_dst, stream.fileno(), origin=wrong_origin)
def test_force_recv_full_existing_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-50")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-50")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
@@ -2336,11 +2352,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), force=True)
def test_force_recv_full_existing_modified_mounted_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-53")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-53")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
@@ -2351,7 +2367,7 @@ class ZFSTest(unittest.TestCase):
with zfs_mount(dstfs) as mntdir:
f = tempfile.NamedTemporaryFile(dir=mntdir, delete=False)
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
lzc.lzc_receive(dst, stream.fileno(), force=True)
# The temporary file dissappears and any access, even close(),
# results in EIO.
@@ -2363,17 +2379,17 @@ class ZFSTest(unittest.TestCase):
# at the moment it may fail with DatasetExists or StreamMismatch
# depending on the implementation.
def test_force_recv_full_already_existing_with_snapshots(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-51")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-51")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
with temp_file_in_fs(dstfs):
pass # enough to taint the fs
- lzc.lzc_snapshot([dstfs + "@snap1"])
+ lzc.lzc_snapshot([dstfs + b"@snap1"])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(src, None, stream.fileno())
@@ -2381,11 +2397,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), force=True)
def test_force_recv_full_already_existing_with_same_snap(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.makeName("fs2/received-52")
- dst = dstfs + '@snap'
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-52")
+ dst = dstfs + b'@snap'
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
lzc.lzc_create(dstfs)
@@ -2400,10 +2416,10 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), force=True)
def test_force_recv_full_missing_parent_fs(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dst = ZFSTest.pool.makeName("fs2/nonexistent/fs@snap")
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dst = ZFSTest.pool.makeName(b"fs2/nonexistent/fs@snap")
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")):
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")):
lzc.lzc_snapshot([src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(src, None, stream.fileno())
@@ -2412,12 +2428,12 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst, stream.fileno(), force=True)
def test_force_recv_incremental_modified_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-60")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-60")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2426,19 +2442,19 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno(), force=True)
def test_force_recv_incremental_modified_mounted_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-64")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-64")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
with zfs_mount(dstfs) as mntdir:
f = tempfile.NamedTemporaryFile(dir=mntdir, delete=False)
for i in range(1024):
- f.write('x' * 1024)
+ f.write(b'x' * 1024)
lzc.lzc_receive(dst2, incr.fileno(), force=True)
# The temporary file dissappears and any access, even close(),
# results in EIO.
@@ -2447,13 +2463,13 @@ class ZFSTest(unittest.TestCase):
f.close()
def test_force_recv_incremental_modified_fs_plus_later_snap(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-61")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst3 = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-61")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst3 = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2466,12 +2482,12 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(dst3)
def test_force_recv_incremental_modified_fs_plus_same_name_snap(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-62")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-62")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2482,13 +2498,13 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(dst2, incr.fileno(), force=True)
def test_force_recv_incremental_modified_fs_plus_held_snap(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-63")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst3 = dstfs + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-63")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst3 = dstfs + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2496,7 +2512,7 @@ class ZFSTest(unittest.TestCase):
pass # enough to taint the fs
lzc.lzc_snapshot([dst3])
with cleanup_fd() as cfd:
- lzc.lzc_hold({dst3: 'tag'}, cfd)
+ lzc.lzc_hold({dst3: b'tag'}, cfd)
with self.assertRaises(lzc_exc.DatasetBusy):
lzc.lzc_receive(dst2, incr.fileno(), force=True)
self.assertExists(dst1)
@@ -2504,14 +2520,14 @@ class ZFSTest(unittest.TestCase):
self.assertExists(dst3)
def test_force_recv_incremental_modified_fs_plus_cloned_snap(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-70")
- dst1 = dstfs + '@snap1'
- dst2 = dstfs + '@snap2'
- dst3 = dstfs + '@snap'
- cloned = ZFSTest.pool.makeName("fs2/received-cloned-70")
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-70")
+ dst1 = dstfs + b'@snap1'
+ dst2 = dstfs + b'@snap2'
+ dst3 = dstfs + b'@snap'
+ cloned = ZFSTest.pool.makeName(b"fs2/received-cloned-70")
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2526,13 +2542,13 @@ class ZFSTest(unittest.TestCase):
self.assertExists(dst3)
def test_recv_incremental_into_cloned_fs(self):
- srcfs = ZFSTest.pool.makeName("fs1")
- src1 = srcfs + "@snap1"
- src2 = srcfs + "@snap2"
- dstfs = ZFSTest.pool.makeName("fs2/received-71")
- dst1 = dstfs + '@snap1'
- cloned = ZFSTest.pool.makeName("fs2/received-cloned-71")
- dst2 = cloned + '@snap'
+ srcfs = ZFSTest.pool.makeName(b"fs1")
+ src1 = srcfs + b"@snap1"
+ src2 = srcfs + b"@snap2"
+ dstfs = ZFSTest.pool.makeName(b"fs2/received-71")
+ dst1 = dstfs + b'@snap1'
+ cloned = ZFSTest.pool.makeName(b"fs2/received-cloned-71")
+ dst2 = cloned + b'@snap'
with streams(srcfs, src1, src2) as (_, (full, incr)):
lzc.lzc_receive(dst1, full.fileno())
@@ -2547,10 +2563,10 @@ class ZFSTest(unittest.TestCase):
self.assertNotExists(dst2)
def test_recv_with_header_full(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dst = ZFSTest.pool.makeName("fs2/received")
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dst = ZFSTest.pool.makeName(b"fs2/received")
- with temp_file_in_fs(ZFSTest.pool.makeName("fs1")) as name:
+ with temp_file_in_fs(ZFSTest.pool.makeName(b"fs1")) as name:
lzc.lzc_snapshot([src])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2559,9 +2575,9 @@ class ZFSTest(unittest.TestCase):
(header, c_header) = lzc.receive_header(stream.fileno())
self.assertEqual(src, header['drr_toname'])
- snap = header['drr_toname'].split('@', 1)[1]
+ snap = header['drr_toname'].split(b'@', 1)[1]
lzc.lzc_receive_with_header(
- dst + '@' + snap, stream.fileno(), c_header)
+ dst + b'@' + snap, stream.fileno(), c_header)
name = os.path.basename(name)
with zfs_mount(src) as mnt1, zfs_mount(dst) as mnt2:
@@ -2570,42 +2586,42 @@ class ZFSTest(unittest.TestCase):
os.path.join(mnt1, name), os.path.join(mnt2, name), False))
def test_send_full_across_clone_branch_point(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-20", None)
+ origfs, b"snap1", b"send-origin-20", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-20")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-20")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(tosnap, None, stream.fileno())
def test_send_incr_across_clone_branch_point(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-21", None)
+ origfs, b"snap1", b"send-origin-21", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-21")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-21")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(tosnap, fromsnap, stream.fileno())
def test_send_resume_token_full(self):
- src = ZFSTest.pool.makeName("fs1@snap")
- dstfs = ZFSTest.pool.getFilesystem("fs2/received")
+ src = ZFSTest.pool.makeName(b"fs1@snap")
+ dstfs = ZFSTest.pool.getFilesystem(b"fs2/received")
dst = dstfs.getSnap()
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
for i in range(1, 10):
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
- f.write('x' * 1024 * i)
+ f.write(b'x' * 1024 * i)
f.flush()
lzc.lzc_snapshot([src])
@@ -2619,20 +2635,27 @@ class ZFSTest(unittest.TestCase):
# XXX: if used more than twice move this code into an external func
# format: <version>-<cksum>-<packed-size>-<compressed-payload>
token = dstfs.getProperty("receive_resume_token")
- self.assertNotEqual(token, '-')
- tokens = token.split('-')
+ self.assertNotEqual(token, b'-')
+ tokens = token.split(b'-')
self.assertEqual(len(tokens), 4)
version = tokens[0]
packed_size = int(tokens[2], 16)
compressed_nvs = tokens[3]
# Validate resume token
- self.assertEqual(version, '1') # ZFS_SEND_RESUME_TOKEN_VERSION
- payload = zlib.decompress(str(bytearray.fromhex(compressed_nvs)))
+ self.assertEqual(version, b'1') # ZFS_SEND_RESUME_TOKEN_VERSION
+ if sys.version_info < (3, 0):
+ payload = (
+ zlib.decompress(str(bytearray.fromhex(compressed_nvs)))
+ )
+ else:
+ payload = (
+ zlib.decompress(bytearray.fromhex(compressed_nvs.decode()))
+ )
self.assertEqual(len(payload), packed_size)
# Unpack
resume_values = packed_nvlist_out(payload, packed_size)
- resumeobj = resume_values.get('object')
- resumeoff = resume_values.get('offset')
+ resumeobj = resume_values.get(b'object')
+ resumeoff = resume_values.get(b'offset')
with tempfile.NamedTemporaryFile(suffix='.ztream') as rstream:
lzc.lzc_send_resume(
src, None, rstream.fileno(), None, resumeobj, resumeoff)
@@ -2640,9 +2663,9 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive_resumable(dst, rstream.fileno())
def test_send_resume_token_incremental(self):
- snap1 = ZFSTest.pool.makeName("fs1@snap1")
- snap2 = ZFSTest.pool.makeName("fs1@snap2")
- dstfs = ZFSTest.pool.getFilesystem("fs2/received")
+ snap1 = ZFSTest.pool.makeName(b"fs1@snap1")
+ snap2 = ZFSTest.pool.makeName(b"fs1@snap2")
+ dstfs = ZFSTest.pool.getFilesystem(b"fs2/received")
dst1 = dstfs.getSnap()
dst2 = dstfs.getSnap()
@@ -2652,10 +2675,10 @@ class ZFSTest(unittest.TestCase):
stream.seek(0)
lzc.lzc_receive(dst1, stream.fileno())
- with zfs_mount(ZFSTest.pool.makeName("fs1")) as mntdir:
+ with zfs_mount(ZFSTest.pool.makeName(b"fs1")) as mntdir:
for i in range(1, 10):
with tempfile.NamedTemporaryFile(dir=mntdir) as f:
- f.write('x' * 1024 * i)
+ f.write(b'x' * 1024 * i)
f.flush()
lzc.lzc_snapshot([snap2])
@@ -2669,19 +2692,26 @@ class ZFSTest(unittest.TestCase):
# format: <version>-<cksum>-<packed-size>-<compressed-payload>
token = dstfs.getProperty("receive_resume_token")
self.assertNotEqual(token, '-')
- tokens = token.split('-')
+ tokens = token.split(b'-')
self.assertEqual(len(tokens), 4)
version = tokens[0]
packed_size = int(tokens[2], 16)
compressed_nvs = tokens[3]
# Validate resume token
- self.assertEqual(version, '1') # ZFS_SEND_RESUME_TOKEN_VERSION
- payload = zlib.decompress(str(bytearray.fromhex(compressed_nvs)))
+ self.assertEqual(version, b'1') # ZFS_SEND_RESUME_TOKEN_VERSION
+ if sys.version_info < (3, 0):
+ payload = (
+ zlib.decompress(str(bytearray.fromhex(compressed_nvs)))
+ )
+ else:
+ payload = (
+ zlib.decompress(bytearray.fromhex(compressed_nvs.decode()))
+ )
self.assertEqual(len(payload), packed_size)
# Unpack
resume_values = packed_nvlist_out(payload, packed_size)
- resumeobj = resume_values.get('object')
- resumeoff = resume_values.get('offset')
+ resumeobj = resume_values.get(b'object')
+ resumeoff = resume_values.get(b'offset')
with tempfile.NamedTemporaryFile(suffix='.ztream') as rstream:
lzc.lzc_send_resume(
snap2, snap1, rstream.fileno(), None, resumeobj, resumeoff)
@@ -2689,26 +2719,26 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive_resumable(dst2, rstream.fileno())
def test_recv_full_across_clone_branch_point(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-30", None)
+ origfs, b"snap1", b"send-origin-30", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-30")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-30")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
- recvfs = ZFSTest.pool.makeName("fs1/recv-clone-30")
- recvsnap = recvfs + "@snap"
+ recvfs = ZFSTest.pool.makeName(b"fs1/recv-clone-30")
+ recvsnap = recvfs + b"@snap"
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(tosnap, None, stream.fileno())
stream.seek(0)
lzc.lzc_receive(recvsnap, stream.fileno())
def test_recv_one(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- tosnap = ZFSTest.pool.makeName("recv@snap1")
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ tosnap = ZFSTest.pool.makeName(b"recv@snap1")
lzc.lzc_snapshot([fromsnap])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2718,8 +2748,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive_one(tosnap, stream.fileno(), c_header)
def test_recv_one_size(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- tosnap = ZFSTest.pool.makeName("recv@snap1")
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ tosnap = ZFSTest.pool.makeName(b"recv@snap1")
lzc.lzc_snapshot([fromsnap])
with tempfile.TemporaryFile(suffix='.ztream') as stream:
@@ -2731,12 +2761,12 @@ class ZFSTest(unittest.TestCase):
self.assertAlmostEqual(read, size, delta=read * 0.05)
def test_recv_one_props(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.getFilesystem("recv")
- tosnap = fs.getName() + "@snap1"
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.getFilesystem(b"recv")
+ tosnap = fs.getName() + b"@snap1"
props = {
- "compression": 0x01,
- "ns:prop": "val"
+ b"compression": 0x01,
+ b"ns:prop": b"val"
}
lzc.lzc_snapshot([fromsnap])
@@ -2746,16 +2776,16 @@ class ZFSTest(unittest.TestCase):
(header, c_header) = lzc.receive_header(stream.fileno())
lzc.lzc_receive_one(tosnap, stream.fileno(), c_header, props=props)
self.assertExists(tosnap)
- self.assertEqual(fs.getProperty("compression", "received"), "on")
- self.assertEqual(fs.getProperty("ns:prop", "received"), "val")
+ self.assertEqual(fs.getProperty("compression", "received"), b"on")
+ self.assertEqual(fs.getProperty("ns:prop", "received"), b"val")
def test_recv_one_invalid_prop(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.getFilesystem("recv")
- tosnap = fs.getName() + "@snap1"
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.getFilesystem(b"recv")
+ tosnap = fs.getName() + b"@snap1"
props = {
- "exec": 0xff,
- "atime": 0x00
+ b"exec": 0xff,
+ b"atime": 0x00
}
lzc.lzc_snapshot([fromsnap])
@@ -2767,19 +2797,19 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive_one(
tosnap, stream.fileno(), c_header, props=props)
self.assertExists(tosnap)
- self.assertEqual(fs.getProperty("atime", "received"), "off")
+ self.assertEqual(fs.getProperty("atime", "received"), b"off")
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.PropertyInvalid)
- self.assertEqual(e.name, "exec")
+ self.assertEqual(e.name, b"exec")
def test_recv_with_cmdprops(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.getFilesystem("recv")
- tosnap = fs.getName() + "@snap1"
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.getFilesystem(b"recv")
+ tosnap = fs.getName() + b"@snap1"
props = {}
cmdprops = {
- "compression": 0x01,
- "ns:prop": "val"
+ b"compression": 0x01,
+ b"ns:prop": b"val"
}
lzc.lzc_snapshot([fromsnap])
@@ -2791,22 +2821,22 @@ class ZFSTest(unittest.TestCase):
tosnap, stream.fileno(), c_header, props=props,
cmdprops=cmdprops)
self.assertExists(tosnap)
- self.assertEqual(fs.getProperty("compression"), "on")
- self.assertEqual(fs.getProperty("ns:prop"), "val")
+ self.assertEqual(fs.getProperty("compression"), b"on")
+ self.assertEqual(fs.getProperty("ns:prop"), b"val")
def test_recv_with_cmdprops_and_recvprops(self):
- fromsnap = ZFSTest.pool.makeName("fs1@snap1")
- fs = ZFSTest.pool.getFilesystem("recv")
- tosnap = fs.getName() + "@snap1"
+ fromsnap = ZFSTest.pool.makeName(b"fs1@snap1")
+ fs = ZFSTest.pool.getFilesystem(b"recv")
+ tosnap = fs.getName() + b"@snap1"
props = {
- "atime": 0x01,
- "exec": 0x00,
- "ns:prop": "abc"
+ b"atime": 0x01,
+ b"exec": 0x00,
+ b"ns:prop": b"abc"
}
cmdprops = {
- "compression": 0x01,
- "ns:prop": "def",
- "exec": None,
+ b"compression": 0x01,
+ b"ns:prop": b"def",
+ b"exec": None,
}
lzc.lzc_snapshot([fromsnap])
@@ -2818,27 +2848,27 @@ class ZFSTest(unittest.TestCase):
tosnap, stream.fileno(), c_header, props=props,
cmdprops=cmdprops)
self.assertExists(tosnap)
- self.assertEqual(fs.getProperty("atime", True), "on")
- self.assertEqual(fs.getProperty("exec", True), "off")
- self.assertEqual(fs.getProperty("ns:prop", True), "abc")
- self.assertEqual(fs.getProperty("compression"), "on")
- self.assertEqual(fs.getProperty("ns:prop"), "def")
- self.assertEqual(fs.getProperty("exec"), "on")
+ self.assertEqual(fs.getProperty("atime", True), b"on")
+ self.assertEqual(fs.getProperty("exec", True), b"off")
+ self.assertEqual(fs.getProperty("ns:prop", True), b"abc")
+ self.assertEqual(fs.getProperty("compression"), b"on")
+ self.assertEqual(fs.getProperty("ns:prop"), b"def")
+ self.assertEqual(fs.getProperty("exec"), b"on")
def test_recv_incr_across_clone_branch_point_no_origin(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-32", None)
+ origfs, b"snap1", b"send-origin-32", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-32")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-32")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
- recvfs = ZFSTest.pool.makeName("fs1/recv-clone-32")
- recvsnap1 = recvfs + "@snap1"
- recvsnap2 = recvfs + "@snap2"
+ recvfs = ZFSTest.pool.makeName(b"fs1/recv-clone-32")
+ recvsnap1 = recvfs + b"@snap1"
+ recvsnap2 = recvfs + b"@snap2"
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(fromsnap, None, stream.fileno())
stream.seek(0)
@@ -2850,19 +2880,19 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(recvsnap2, stream.fileno())
def test_recv_incr_across_clone_branch_point(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-31", None)
+ origfs, b"snap1", b"send-origin-31", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-31")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-31")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
- recvfs = ZFSTest.pool.makeName("fs1/recv-clone-31")
- recvsnap1 = recvfs + "@snap1"
- recvsnap2 = recvfs + "@snap2"
+ recvfs = ZFSTest.pool.makeName(b"fs1/recv-clone-31")
+ recvsnap1 = recvfs + b"@snap1"
+ recvsnap2 = recvfs + b"@snap2"
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(fromsnap, None, stream.fileno())
stream.seek(0)
@@ -2874,20 +2904,20 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(recvsnap2, stream.fileno(), origin=recvsnap1)
def test_recv_incr_across_clone_branch_point_new_fs(self):
- origfs = ZFSTest.pool.makeName("fs2")
+ origfs = ZFSTest.pool.makeName(b"fs2")
(_, (fromsnap, origsnap, _)) = make_snapshots(
- origfs, "snap1", "send-origin-33", None)
+ origfs, b"snap1", b"send-origin-33", None)
- clonefs = ZFSTest.pool.makeName("fs1/fs/send-clone-33")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/send-clone-33")
lzc.lzc_clone(clonefs, origsnap)
- (_, (_, tosnap, _)) = make_snapshots(clonefs, None, "snap", None)
+ (_, (_, tosnap, _)) = make_snapshots(clonefs, None, b"snap", None)
- recvfs1 = ZFSTest.pool.makeName("fs1/recv-clone-33")
- recvsnap1 = recvfs1 + "@snap"
- recvfs2 = ZFSTest.pool.makeName("fs1/recv-clone-33_2")
- recvsnap2 = recvfs2 + "@snap"
+ recvfs1 = ZFSTest.pool.makeName(b"fs1/recv-clone-33")
+ recvsnap1 = recvfs1 + b"@snap"
+ recvfs2 = ZFSTest.pool.makeName(b"fs1/recv-clone-33_2")
+ recvsnap2 = recvfs2 + b"@snap"
with tempfile.TemporaryFile(suffix='.ztream') as stream:
lzc.lzc_send(fromsnap, None, stream.fileno())
stream.seek(0)
@@ -2898,8 +2928,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_receive(recvsnap2, stream.fileno(), origin=recvsnap1)
def test_recv_bad_stream(self):
- dstfs = ZFSTest.pool.makeName("fs2/received")
- dst_snap = dstfs + '@snap'
+ dstfs = ZFSTest.pool.makeName(b"fs2/received")
+ dst_snap = dstfs + b'@snap'
with dev_zero() as fd:
with self.assertRaises(lzc_exc.BadStream):
@@ -2907,12 +2937,12 @@ class ZFSTest(unittest.TestCase):
@needs_support(lzc.lzc_promote)
def test_promote(self):
- origfs = ZFSTest.pool.makeName("fs2")
- snap = "@promote-snap-1"
+ origfs = ZFSTest.pool.makeName(b"fs2")
+ snap = b"@promote-snap-1"
origsnap = origfs + snap
lzc.lzc_snap([origsnap])
- clonefs = ZFSTest.pool.makeName("fs1/fs/promote-clone-1")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/promote-clone-1")
lzc.lzc_clone(clonefs, origsnap)
lzc.lzc_promote(clonefs)
@@ -2922,11 +2952,11 @@ class ZFSTest(unittest.TestCase):
@needs_support(lzc.lzc_promote)
def test_promote_too_long_snapname(self):
# origfs name must be shorter than clonefs name
- origfs = ZFSTest.pool.makeName("fs2")
- clonefs = ZFSTest.pool.makeName("fs1/fs/promote-clone-2")
- snapprefix = "@promote-snap-2-"
+ origfs = ZFSTest.pool.makeName(b"fs2")
+ clonefs = ZFSTest.pool.makeName(b"fs1/fs/promote-clone-2")
+ snapprefix = b"@promote-snap-2-"
pad_len = 1 + lzc.MAXNAMELEN - len(clonefs) - len(snapprefix)
- snap = snapprefix + 'x' * pad_len
+ snap = snapprefix + b'x' * pad_len
origsnap = origfs + snap
lzc.lzc_snap([origsnap])
@@ -2939,7 +2969,7 @@ class ZFSTest(unittest.TestCase):
@needs_support(lzc.lzc_promote)
def test_promote_not_cloned(self):
- fs = ZFSTest.pool.makeName("fs2")
+ fs = ZFSTest.pool.makeName(b"fs2")
with self.assertRaises(lzc_exc.NotClone):
lzc.lzc_promote(fs)
@@ -2952,7 +2982,7 @@ class ZFSTest(unittest.TestCase):
bad_fd = tmp.fileno()
with self.assertRaises(lzc_exc.BadHoldCleanupFD):
- lzc.lzc_hold({snap: 'tag'}, bad_fd)
+ lzc.lzc_hold({snap: b'tag'}, bad_fd)
@unittest.skipIf(*illumos_bug_6379())
def test_hold_bad_fd_2(self):
@@ -2960,7 +2990,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with self.assertRaises(lzc_exc.BadHoldCleanupFD):
- lzc.lzc_hold({snap: 'tag'}, -2)
+ lzc.lzc_hold({snap: b'tag'}, -2)
@unittest.skipIf(*illumos_bug_6379())
def test_hold_bad_fd_3(self):
@@ -2970,7 +3000,7 @@ class ZFSTest(unittest.TestCase):
(soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE)
bad_fd = hard + 1
with self.assertRaises(lzc_exc.BadHoldCleanupFD):
- lzc.lzc_hold({snap: 'tag'}, bad_fd)
+ lzc.lzc_hold({snap: b'tag'}, bad_fd)
@unittest.skipIf(*illumos_bug_6379())
def test_hold_wrong_fd(self):
@@ -2980,14 +3010,14 @@ class ZFSTest(unittest.TestCase):
with tempfile.TemporaryFile() as tmp:
fd = tmp.fileno()
with self.assertRaises(lzc_exc.BadHoldCleanupFD):
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
def test_hold_fd(self):
snap = ZFSTest.pool.getRoot().getSnap()
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
def test_hold_empty(self):
with cleanup_fd() as fd:
@@ -3001,7 +3031,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
with self.assertRaises(lzc_exc.SnapshotDestructionFailure) as ctx:
lzc.lzc_destroy_snaps([snap], defer=False)
@@ -3019,8 +3049,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag1'}, fd)
- lzc.lzc_hold({snap: 'tag2'}, fd)
+ lzc.lzc_hold({snap: b'tag1'}, fd)
+ lzc.lzc_hold({snap: b'tag2'}, fd)
def test_hold_many_snaps(self):
snap1 = ZFSTest.pool.getRoot().getSnap()
@@ -3029,7 +3059,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap2])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap1: 'tag', snap2: 'tag'}, fd)
+ lzc.lzc_hold({snap1: b'tag', snap2: b'tag'}, fd)
def test_hold_many_with_one_missing(self):
snap1 = ZFSTest.pool.getRoot().getSnap()
@@ -3037,7 +3067,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap1])
with cleanup_fd() as fd:
- missing = lzc.lzc_hold({snap1: 'tag', snap2: 'tag'}, fd)
+ missing = lzc.lzc_hold({snap1: b'tag', snap2: b'tag'}, fd)
self.assertEqual(len(missing), 1)
self.assertEqual(missing[0], snap2)
@@ -3046,7 +3076,7 @@ class ZFSTest(unittest.TestCase):
snap2 = ZFSTest.pool.getRoot().getSnap()
with cleanup_fd() as fd:
- missing = lzc.lzc_hold({snap1: 'tag', snap2: 'tag'}, fd)
+ missing = lzc.lzc_hold({snap1: b'tag', snap2: b'tag'}, fd)
self.assertEqual(len(missing), 2)
self.assertEqual(sorted(missing), sorted([snap1, snap2]))
@@ -3059,7 +3089,7 @@ class ZFSTest(unittest.TestCase):
ZFSTest.pool.getRoot().getFilesystem()
snap = ZFSTest.pool.getRoot().getFilesystem().getSnap()
- snaps = lzc.lzc_hold({snap: 'tag'})
+ snaps = lzc.lzc_hold({snap: b'tag'})
self.assertEqual([snap], snaps)
def test_hold_missing_fs_auto_cleanup(self):
@@ -3072,7 +3102,7 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getFilesystem().getSnap()
with cleanup_fd() as fd:
- snaps = lzc.lzc_hold({snap: 'tag'}, fd)
+ snaps = lzc.lzc_hold({snap: b'tag'}, fd)
self.assertEqual([snap], snaps)
def test_hold_duplicate(self):
@@ -3080,9 +3110,9 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.HoldExists)
@@ -3094,13 +3124,13 @@ class ZFSTest(unittest.TestCase):
with cleanup_fd() as fd:
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap1: 'tag', snap2: 'tag'}, fd)
+ lzc.lzc_hold({snap1: b'tag', snap2: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.PoolsDiffer)
def test_hold_too_long_tag(self):
snap = ZFSTest.pool.getRoot().getSnap()
- tag = 't' * 256
+ tag = b't' * 256
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
@@ -3117,7 +3147,7 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getTooLongSnap(False)
with cleanup_fd() as fd:
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameTooLong)
self.assertEqual(e.name, snap)
@@ -3126,16 +3156,16 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getTooLongSnap(True)
with cleanup_fd() as fd:
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameTooLong)
self.assertEqual(e.name, snap)
def test_hold_invalid_snap_name(self):
- snap = ZFSTest.pool.getRoot().getSnap() + '@bad'
+ snap = ZFSTest.pool.getRoot().getSnap() + b'@bad'
with cleanup_fd() as fd:
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameInvalid)
self.assertEqual(e.name, snap)
@@ -3144,7 +3174,7 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getFilesystem().getName()
with cleanup_fd() as fd:
with self.assertRaises(lzc_exc.HoldFailure) as ctx:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameInvalid)
self.assertEqual(e.name, snap)
@@ -3154,22 +3184,22 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag1'}, fd)
- lzc.lzc_hold({snap: 'tag2'}, fd)
+ lzc.lzc_hold({snap: b'tag1'}, fd)
+ lzc.lzc_hold({snap: b'tag2'}, fd)
holds = lzc.lzc_get_holds(snap)
self.assertEqual(len(holds), 2)
- self.assertIn('tag1', holds)
- self.assertIn('tag2', holds)
- self.assertIsInstance(holds['tag1'], (int, int))
+ self.assertIn(b'tag1', holds)
+ self.assertIn(b'tag2', holds)
+ self.assertIsInstance(holds[b'tag1'], (int, int))
def test_get_holds_after_auto_cleanup(self):
snap = ZFSTest.pool.getRoot().getSnap()
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag1'}, fd)
- lzc.lzc_hold({snap: 'tag2'}, fd)
+ lzc.lzc_hold({snap: b'tag1'}, fd)
+ lzc.lzc_hold({snap: b'tag2'}, fd)
holds = lzc.lzc_get_holds(snap)
self.assertEqual(len(holds), 0)
@@ -3191,7 +3221,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_get_holds(snap)
def test_get_holds_invalid_snap_name(self):
- snap = ZFSTest.pool.getRoot().getSnap() + '@bad'
+ snap = ZFSTest.pool.getRoot().getSnap() + b'@bad'
with self.assertRaises(lzc_exc.NameInvalid):
lzc.lzc_get_holds(snap)
@@ -3207,8 +3237,8 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getSnap()
lzc.lzc_snapshot([snap])
- lzc.lzc_hold({snap: 'tag'})
- ret = lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_hold({snap: b'tag'})
+ ret = lzc.lzc_release({snap: [b'tag']})
self.assertEqual(len(ret), 0)
def test_release_hold_empty(self):
@@ -3222,11 +3252,11 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap1])
lzc.lzc_snapshot([snap2, snap3])
- lzc.lzc_hold({snap1: 'tag1'})
- lzc.lzc_hold({snap1: 'tag2'})
- lzc.lzc_hold({snap2: 'tag'})
- lzc.lzc_hold({snap3: 'tag1'})
- lzc.lzc_hold({snap3: 'tag2'})
+ lzc.lzc_hold({snap1: b'tag1'})
+ lzc.lzc_hold({snap1: b'tag2'})
+ lzc.lzc_hold({snap2: b'tag'})
+ lzc.lzc_hold({snap3: b'tag1'})
+ lzc.lzc_hold({snap3: b'tag2'})
holds = lzc.lzc_get_holds(snap1)
self.assertEqual(len(holds), 2)
@@ -3236,9 +3266,9 @@ class ZFSTest(unittest.TestCase):
self.assertEqual(len(holds), 2)
release = {
- snap1: ['tag1', 'tag2'],
- snap2: ['tag'],
- snap3: ['tag2'],
+ snap1: [b'tag1', b'tag2'],
+ snap2: [b'tag'],
+ snap3: [b'tag2'],
}
ret = lzc.lzc_release(release)
self.assertEqual(len(ret), 0)
@@ -3250,7 +3280,7 @@ class ZFSTest(unittest.TestCase):
holds = lzc.lzc_get_holds(snap3)
self.assertEqual(len(holds), 1)
- ret = lzc.lzc_release({snap3: ['tag1']})
+ ret = lzc.lzc_release({snap3: [b'tag1']})
self.assertEqual(len(ret), 0)
holds = lzc.lzc_get_holds(snap3)
self.assertEqual(len(holds), 0)
@@ -3260,8 +3290,8 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag'}, fd)
- ret = lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_hold({snap: b'tag'}, fd)
+ ret = lzc.lzc_release({snap: [b'tag']})
self.assertEqual(len(ret), 0)
def test_release_hold_and_snap_destruction(self):
@@ -3269,16 +3299,16 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag1'}, fd)
- lzc.lzc_hold({snap: 'tag2'}, fd)
+ lzc.lzc_hold({snap: b'tag1'}, fd)
+ lzc.lzc_hold({snap: b'tag2'}, fd)
lzc.lzc_destroy_snaps([snap], defer=True)
self.assertExists(snap)
- lzc.lzc_release({snap: ['tag1']})
+ lzc.lzc_release({snap: [b'tag1']})
self.assertExists(snap)
- lzc.lzc_release({snap: ['tag2']})
+ lzc.lzc_release({snap: [b'tag2']})
self.assertNotExists(snap)
def test_release_hold_and_multiple_snap_destruction(self):
@@ -3286,7 +3316,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap: 'tag'}, fd)
+ lzc.lzc_hold({snap: b'tag'}, fd)
lzc.lzc_destroy_snaps([snap], defer=True)
self.assertExists(snap)
@@ -3294,28 +3324,28 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_destroy_snaps([snap], defer=True)
self.assertExists(snap)
- lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_release({snap: [b'tag']})
self.assertNotExists(snap)
def test_release_hold_missing_tag(self):
snap = ZFSTest.pool.getRoot().getSnap()
lzc.lzc_snapshot([snap])
- ret = lzc.lzc_release({snap: ['tag']})
+ ret = lzc.lzc_release({snap: [b'tag']})
self.assertEqual(len(ret), 1)
- self.assertEqual(ret[0], snap + '#tag')
+ self.assertEqual(ret[0], snap + b'#tag')
def test_release_hold_missing_snap(self):
snap = ZFSTest.pool.getRoot().getSnap()
- ret = lzc.lzc_release({snap: ['tag']})
+ ret = lzc.lzc_release({snap: [b'tag']})
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0], snap)
def test_release_hold_missing_snap_2(self):
snap = ZFSTest.pool.getRoot().getSnap()
- ret = lzc.lzc_release({snap: ['tag', 'another']})
+ ret = lzc.lzc_release({snap: [b'tag', b'another']})
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0], snap)
@@ -3326,10 +3356,10 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_snapshot([snap2])
with cleanup_fd() as fd:
- lzc.lzc_hold({snap1: 'tag'}, fd)
- lzc.lzc_hold({snap2: 'tag'}, fd)
+ lzc.lzc_hold({snap1: b'tag'}, fd)
+ lzc.lzc_hold({snap2: b'tag'}, fd)
with self.assertRaises(lzc_exc.HoldReleaseFailure) as ctx:
- lzc.lzc_release({snap1: ['tag'], snap2: ['tag']})
+ lzc.lzc_release({snap1: [b'tag'], snap2: [b'tag']})
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.PoolsDiffer)
@@ -3338,7 +3368,7 @@ class ZFSTest(unittest.TestCase):
@unittest.expectedFailure
def test_release_hold_too_long_tag(self):
snap = ZFSTest.pool.getRoot().getSnap()
- tag = 't' * 256
+ tag = b't' * 256
lzc.lzc_snapshot([snap])
with self.assertRaises(lzc_exc.HoldReleaseFailure):
@@ -3351,20 +3381,20 @@ class ZFSTest(unittest.TestCase):
snap = ZFSTest.pool.getRoot().getTooLongSnap(False)
with self.assertRaises(lzc_exc.HoldReleaseFailure):
- lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_release({snap: [b'tag']})
def test_release_hold_too_long_snap_name_2(self):
snap = ZFSTest.pool.getRoot().getTooLongSnap(True)
with self.assertRaises(lzc_exc.HoldReleaseFailure) as ctx:
- lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_release({snap: [b'tag']})
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameTooLong)
self.assertEqual(e.name, snap)
def test_release_hold_invalid_snap_name(self):
- snap = ZFSTest.pool.getRoot().getSnap() + '@bad'
+ snap = ZFSTest.pool.getRoot().getSnap() + b'@bad'
with self.assertRaises(lzc_exc.HoldReleaseFailure) as ctx:
- lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_release({snap: [b'tag']})
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameInvalid)
self.assertEqual(e.name, snap)
@@ -3372,13 +3402,13 @@ class ZFSTest(unittest.TestCase):
def test_release_hold_invalid_snap_name_2(self):
snap = ZFSTest.pool.getRoot().getFilesystem().getName()
with self.assertRaises(lzc_exc.HoldReleaseFailure) as ctx:
- lzc.lzc_release({snap: ['tag']})
+ lzc.lzc_release({snap: [b'tag']})
for e in ctx.exception.errors:
self.assertIsInstance(e, lzc_exc.NameInvalid)
self.assertEqual(e.name, snap)
def test_sync_missing_pool(self):
- pool = "nonexistent"
+ pool = b"nonexistent"
with self.assertRaises(lzc_exc.PoolNotFound):
lzc.lzc_sync(pool)
@@ -3387,7 +3417,7 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_sync(pool, True)
def test_reopen_missing_pool(self):
- pool = "nonexistent"
+ pool = b"nonexistent"
with self.assertRaises(lzc_exc.PoolNotFound):
lzc.lzc_reopen(pool)
@@ -3396,15 +3426,15 @@ class ZFSTest(unittest.TestCase):
lzc.lzc_reopen(pool, False)
def test_channel_program_missing_pool(self):
- pool = "nonexistent"
+ pool = b"nonexistent"
with self.assertRaises(lzc_exc.PoolNotFound):
- lzc.lzc_channel_program(pool, "return {}")
+ lzc.lzc_channel_program(pool, b"return {}")
def test_channel_program_timeout(self):
pool = ZFSTest.pool.getRoot().getName()
- zcp = """
+ zcp = b"""
for i = 1,10000 do
- zfs.sync.snapshot('""" + pool + """@zcp' .. i)
+ zfs.sync.snapshot('""" + pool + b"""@zcp' .. i)
end
"""
with self.assertRaises(lzc_exc.ZCPTimeout):
@@ -3412,9 +3442,9 @@ end
def test_channel_program_memory_limit(self):
pool = ZFSTest.pool.getRoot().getName()
- zcp = """
+ zcp = b"""
for i = 1,10000 do
- zfs.sync.snapshot('""" + pool + """@zcp' .. i)
+ zfs.sync.snapshot('""" + pool + b"""@zcp' .. i)
end
"""
with self.assertRaises(lzc_exc.ZCPSpaceError):
@@ -3422,7 +3452,7 @@ end
def test_channel_program_invalid_limits(self):
pool = ZFSTest.pool.getRoot().getName()
- zcp = """
+ zcp = b"""
return {}
"""
with self.assertRaises(lzc_exc.ZCPLimitInvalid):
@@ -3432,18 +3462,18 @@ return {}
def test_channel_program_syntax_error(self):
pool = ZFSTest.pool.getRoot().getName()
- zcp = """
+ zcp = b"""
inv+val:id
"""
with self.assertRaises(lzc_exc.ZCPSyntaxError) as ctx:
lzc.lzc_channel_program(pool, zcp)
- self.assertTrue("syntax error" in ctx.exception.details)
+ self.assertTrue(b"syntax error" in ctx.exception.details)
def test_channel_program_sync_snapshot(self):
pool = ZFSTest.pool.getRoot().getName()
- snapname = ZFSTest.pool.makeName("@zcp")
- zcp = """
-zfs.sync.snapshot('""" + snapname + """')
+ snapname = ZFSTest.pool.makeName(b"@zcp")
+ zcp = b"""
+zfs.sync.snapshot('""" + snapname + b"""')
"""
lzc.lzc_channel_program(pool, zcp)
self.assertExists(snapname)
@@ -3453,38 +3483,38 @@ zfs.sync.snapshot('""" + snapname + """')
# failing an assertion raises a runtime error
with self.assertRaises(lzc_exc.ZCPRuntimeError) as ctx:
- lzc.lzc_channel_program(pool, "assert(1 == 2)")
+ lzc.lzc_channel_program(pool, b"assert(1 == 2)")
self.assertTrue(
- "assertion failed" in ctx.exception.details)
+ b"assertion failed" in ctx.exception.details)
# invoking the error() function raises a runtime error
with self.assertRaises(lzc_exc.ZCPRuntimeError) as ctx:
- lzc.lzc_channel_program(pool, "error()")
+ lzc.lzc_channel_program(pool, b"error()")
def test_channel_program_nosync_runtime_error(self):
pool = ZFSTest.pool.getRoot().getName()
- zcp = """
-zfs.sync.snapshot('""" + pool + """@zcp')
+ zcp = b"""
+zfs.sync.snapshot('""" + pool + b"""@zcp')
"""
# lzc_channel_program_nosync() allows only "read-only" operations
with self.assertRaises(lzc_exc.ZCPRuntimeError) as ctx:
lzc.lzc_channel_program_nosync(pool, zcp)
self.assertTrue(
- "running functions from the zfs.sync" in ctx.exception.details)
+ b"running functions from the zfs.sync" in ctx.exception.details)
def test_change_key_new(self):
with encrypted_filesystem() as (fs, _):
lzc.lzc_change_key(
fs, 'new_key',
- props={"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
+ props={b"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
key=os.urandom(lzc.WRAPPING_KEY_LEN))
def test_change_key_missing_fs(self):
- name = "nonexistent"
+ name = b"nonexistent"
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_change_key(
name, 'new_key',
- props={"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
+ props={b"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
key=os.urandom(lzc.WRAPPING_KEY_LEN))
def test_change_key_not_loaded(self):
@@ -3493,13 +3523,13 @@ zfs.sync.snapshot('""" + pool + """@zcp')
with self.assertRaises(lzc_exc.EncryptionKeyNotLoaded):
lzc.lzc_change_key(
fs, 'new_key',
- props={"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
+ props={b"keyformat": lzc.zfs_keyformat.ZFS_KEYFORMAT_RAW},
key=os.urandom(lzc.WRAPPING_KEY_LEN))
def test_change_key_invalid_property(self):
with encrypted_filesystem() as (fs, _):
with self.assertRaises(lzc_exc.PropertyInvalid):
- lzc.lzc_change_key(fs, 'new_key', props={"invalid": "prop"})
+ lzc.lzc_change_key(fs, 'new_key', props={b"invalid": b"prop"})
def test_change_key_invalid_crypt_command(self):
with encrypted_filesystem() as (fs, _):
@@ -3525,7 +3555,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_load_key(fs, False, key)
def test_load_key_missing_fs(self):
- name = "nonexistent"
+ name = b"nonexistent"
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_load_key(name, False, key=os.urandom(lzc.WRAPPING_KEY_LEN))
@@ -3535,7 +3565,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_unload_key(fs)
def test_unload_key_missing_fs(self):
- name = "nonexistent"
+ name = b"nonexistent"
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_unload_key(name)
@@ -3553,14 +3583,14 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_unload_key(fs)
def test_remap_missing_fs(self):
- name = "nonexistent"
+ name = b"nonexistent"
with self.assertRaises(lzc_exc.DatasetNotFound):
lzc.lzc_remap(name)
def test_remap_invalid_fs(self):
- ds = ZFSTest.pool.makeName("fs1")
- snap = ds + "@snap1"
+ ds = ZFSTest.pool.makeName(b"fs1")
+ snap = ds + b"@snap1"
lzc.lzc_snapshot([snap])
with self.assertRaises(lzc_exc.NameInvalid):
@@ -3573,7 +3603,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_remap(name)
def test_remap(self):
- name = ZFSTest.pool.makeName("fs1")
+ name = ZFSTest.pool.makeName(b"fs1")
lzc.lzc_remap(name)
@@ -3583,7 +3613,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_pool_checkpoint(pool)
def test_checkpoint_missing_pool(self):
- pool = "nonexistent"
+ pool = b"nonexistent"
with self.assertRaises(lzc_exc.PoolNotFound):
lzc.lzc_pool_checkpoint(pool)
@@ -3602,7 +3632,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
lzc.lzc_pool_checkpoint_discard(pool)
def test_checkpoint_discard_missing_pool(self):
- pool = "nonexistent"
+ pool = b"nonexistent"
with self.assertRaises(lzc_exc.PoolNotFound):
lzc.lzc_pool_checkpoint_discard(pool)
@@ -3615,12 +3645,12 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_list_children)
def test_list_children(self):
- name = ZFSTest.pool.makeName("fs1/fs")
- names = [ZFSTest.pool.makeName("fs1/fs/test1"),
- ZFSTest.pool.makeName("fs1/fs/test2"),
- ZFSTest.pool.makeName("fs1/fs/test3"), ]
+ name = ZFSTest.pool.makeName(b"fs1/fs")
+ names = [ZFSTest.pool.makeName(b"fs1/fs/test1"),
+ ZFSTest.pool.makeName(b"fs1/fs/test2"),
+ ZFSTest.pool.makeName(b"fs1/fs/test3"), ]
# and one snap to see that it is not listed
- snap = ZFSTest.pool.makeName("fs1/fs@test")
+ snap = ZFSTest.pool.makeName(b"fs1/fs@test")
for fs in names:
lzc.lzc_create(fs)
@@ -3631,14 +3661,14 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_list_children)
def test_list_children_nonexistent(self):
- fs = ZFSTest.pool.makeName("nonexistent")
+ fs = ZFSTest.pool.makeName(b"nonexistent")
with self.assertRaises(lzc_exc.DatasetNotFound):
list(lzc.lzc_list_children(fs))
@needs_support(lzc.lzc_list_children)
def test_list_children_of_snap(self):
- snap = ZFSTest.pool.makeName("@newsnap")
+ snap = ZFSTest.pool.makeName(b"@newsnap")
lzc.lzc_snapshot([snap])
children = list(lzc.lzc_list_children(snap))
@@ -3646,12 +3676,12 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_list_snaps)
def test_list_snaps(self):
- name = ZFSTest.pool.makeName("fs1/fs")
- names = [ZFSTest.pool.makeName("fs1/fs@test1"),
- ZFSTest.pool.makeName("fs1/fs@test2"),
- ZFSTest.pool.makeName("fs1/fs@test3"), ]
+ name = ZFSTest.pool.makeName(b"fs1/fs")
+ names = [ZFSTest.pool.makeName(b"fs1/fs@test1"),
+ ZFSTest.pool.makeName(b"fs1/fs@test2"),
+ ZFSTest.pool.makeName(b"fs1/fs@test3"), ]
# and one filesystem to see that it is not listed
- fs = ZFSTest.pool.makeName("fs1/fs/test")
+ fs = ZFSTest.pool.makeName(b"fs1/fs/test")
for snap in names:
lzc.lzc_snapshot([snap])
@@ -3662,14 +3692,14 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_list_snaps)
def test_list_snaps_nonexistent(self):
- fs = ZFSTest.pool.makeName("nonexistent")
+ fs = ZFSTest.pool.makeName(b"nonexistent")
with self.assertRaises(lzc_exc.DatasetNotFound):
list(lzc.lzc_list_snaps(fs))
@needs_support(lzc.lzc_list_snaps)
def test_list_snaps_of_snap(self):
- snap = ZFSTest.pool.makeName("@newsnap")
+ snap = ZFSTest.pool.makeName(b"@newsnap")
lzc.lzc_snapshot([snap])
snaps = list(lzc.lzc_list_snaps(snap))
@@ -3677,8 +3707,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_get_props)
def test_get_fs_props(self):
- fs = ZFSTest.pool.makeName("new")
- props = {"user:foo": "bar"}
+ fs = ZFSTest.pool.makeName(b"new")
+ props = {b"user:foo": b"bar"}
lzc.lzc_create(fs, props=props)
actual_props = lzc.lzc_get_props(fs)
@@ -3686,10 +3716,10 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_get_props)
def test_get_fs_props_with_child(self):
- parent = ZFSTest.pool.makeName("parent")
- child = ZFSTest.pool.makeName("parent/child")
- parent_props = {"user:foo": "parent"}
- child_props = {"user:foo": "child"}
+ parent = ZFSTest.pool.makeName(b"parent")
+ child = ZFSTest.pool.makeName(b"parent/child")
+ parent_props = {b"user:foo": b"parent"}
+ child_props = {b"user:foo": b"child"}
lzc.lzc_create(parent, props=parent_props)
lzc.lzc_create(child, props=child_props)
@@ -3700,9 +3730,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_get_props)
def test_get_snap_props(self):
- snapname = ZFSTest.pool.makeName("@snap")
+ snapname = ZFSTest.pool.makeName(b"@snap")
snaps = [snapname]
- props = {"user:foo": "bar"}
+ props = {b"user:foo": b"bar"}
lzc.lzc_snapshot(snaps, props)
actual_props = lzc.lzc_get_props(snapname)
@@ -3710,7 +3740,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_get_props)
def test_get_props_nonexistent(self):
- fs = ZFSTest.pool.makeName("nonexistent")
+ fs = ZFSTest.pool.makeName(b"nonexistent")
with self.assertRaises(lzc_exc.DatasetNotFound):
lzc.lzc_get_props(fs)
@@ -3722,9 +3752,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
value is returned as `bytes` "none".
Also, a child filesystem inherits that value.
'''
- fs = ZFSTest.pool.makeName("new")
- child = ZFSTest.pool.makeName("new/child")
- props = {"mountpoint": "none"}
+ fs = ZFSTest.pool.makeName(b"new")
+ child = ZFSTest.pool.makeName(b"new/child")
+ props = {b"mountpoint": b"none"}
lzc.lzc_create(fs, props=props)
lzc.lzc_create(child)
@@ -3741,9 +3771,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
value is returned as `bytes` "legacy".
Also, a child filesystem inherits that value.
'''
- fs = ZFSTest.pool.makeName("new")
- child = ZFSTest.pool.makeName("new/child")
- props = {"mountpoint": "legacy"}
+ fs = ZFSTest.pool.makeName(b"new")
+ child = ZFSTest.pool.makeName(b"new/child")
+ props = {b"mountpoint": b"legacy"}
lzc.lzc_create(fs, props=props)
lzc.lzc_create(child)
@@ -3761,9 +3791,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
value is that of the parent filesystem with the child's
name appended using the '/' separator.
'''
- fs = ZFSTest.pool.makeName("new")
- child = ZFSTest.pool.makeName("new/child")
- props = {"mountpoint": "/mnt"}
+ fs = ZFSTest.pool.makeName(b"new")
+ child = ZFSTest.pool.makeName(b"new/child")
+ props = {b"mountpoint": b"/mnt"}
lzc.lzc_create(fs, props=props)
lzc.lzc_create(child)
@@ -3772,14 +3802,14 @@ zfs.sync.snapshot('""" + pool + """@zcp')
# check that mountpoint value is correctly inherited
child_props = lzc.lzc_get_props(child)
self.assertDictContainsSubset(
- {"mountpoint": "/mnt/child"}, child_props)
+ {b"mountpoint": b"/mnt/child"}, child_props)
@needs_support(lzc.lzc_get_props)
def test_get_snap_clones(self):
- fs = ZFSTest.pool.makeName("new")
- snap = ZFSTest.pool.makeName("@snap")
- clone1 = ZFSTest.pool.makeName("clone1")
- clone2 = ZFSTest.pool.makeName("clone2")
+ fs = ZFSTest.pool.makeName(b"new")
+ snap = ZFSTest.pool.makeName(b"@snap")
+ clone1 = ZFSTest.pool.makeName(b"clone1")
+ clone2 = ZFSTest.pool.makeName(b"clone2")
lzc.lzc_create(fs)
lzc.lzc_snapshot([snap])
@@ -3791,8 +3821,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_rename)
def test_rename(self):
- src = ZFSTest.pool.makeName("source")
- tgt = ZFSTest.pool.makeName("target")
+ src = ZFSTest.pool.makeName(b"source")
+ tgt = ZFSTest.pool.makeName(b"target")
lzc.lzc_create(src)
lzc.lzc_rename(src, tgt)
@@ -3801,16 +3831,16 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_rename)
def test_rename_nonexistent(self):
- src = ZFSTest.pool.makeName("source")
- tgt = ZFSTest.pool.makeName("target")
+ src = ZFSTest.pool.makeName(b"source")
+ tgt = ZFSTest.pool.makeName(b"target")
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_rename(src, tgt)
@needs_support(lzc.lzc_rename)
def test_rename_existing_target(self):
- src = ZFSTest.pool.makeName("source")
- tgt = ZFSTest.pool.makeName("target")
+ src = ZFSTest.pool.makeName(b"source")
+ tgt = ZFSTest.pool.makeName(b"target")
lzc.lzc_create(src)
lzc.lzc_create(tgt)
@@ -3819,8 +3849,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_rename)
def test_rename_nonexistent_target_parent(self):
- src = ZFSTest.pool.makeName("source")
- tgt = ZFSTest.pool.makeName("parent/target")
+ src = ZFSTest.pool.makeName(b"source")
+ tgt = ZFSTest.pool.makeName(b"parent/target")
lzc.lzc_create(src)
with self.assertRaises(lzc_exc.FilesystemNotFound):
@@ -3828,7 +3858,7 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_destroy)
def test_destroy(self):
- fs = ZFSTest.pool.makeName("test-fs")
+ fs = ZFSTest.pool.makeName(b"test-fs")
lzc.lzc_create(fs)
lzc.lzc_destroy(fs)
@@ -3836,18 +3866,18 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_destroy)
def test_destroy_nonexistent(self):
- fs = ZFSTest.pool.makeName("test-fs")
+ fs = ZFSTest.pool.makeName(b"test-fs")
with self.assertRaises(lzc_exc.FilesystemNotFound):
lzc.lzc_destroy(fs)
@needs_support(lzc.lzc_inherit_prop)
def test_inherit_prop(self):
- parent = ZFSTest.pool.makeName("parent")
- child = ZFSTest.pool.makeName("parent/child")
- the_prop = "user:foo"
- parent_props = {the_prop: "parent"}
- child_props = {the_prop: "child"}
+ parent = ZFSTest.pool.makeName(b"parent")
+ child = ZFSTest.pool.makeName(b"parent/child")
+ the_prop = b"user:foo"
+ parent_props = {the_prop: b"parent"}
+ child_props = {the_prop: b"child"}
lzc.lzc_create(parent, props=parent_props)
lzc.lzc_create(child, props=child_props)
@@ -3857,8 +3887,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_inherit_prop)
def test_inherit_missing_prop(self):
- parent = ZFSTest.pool.makeName("parent")
- child = ZFSTest.pool.makeName("parent/child")
+ parent = ZFSTest.pool.makeName(b"parent")
+ child = ZFSTest.pool.makeName(b"parent/child")
the_prop = "user:foo"
child_props = {the_prop: "child"}
@@ -3870,9 +3900,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_inherit_prop)
def test_inherit_readonly_prop(self):
- parent = ZFSTest.pool.makeName("parent")
- child = ZFSTest.pool.makeName("parent/child")
- the_prop = "createtxg"
+ parent = ZFSTest.pool.makeName(b"parent")
+ child = ZFSTest.pool.makeName(b"parent/child")
+ the_prop = b"createtxg"
lzc.lzc_create(parent)
lzc.lzc_create(child)
@@ -3881,9 +3911,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_inherit_prop)
def test_inherit_unknown_prop(self):
- parent = ZFSTest.pool.makeName("parent")
- child = ZFSTest.pool.makeName("parent/child")
- the_prop = "nosuchprop"
+ parent = ZFSTest.pool.makeName(b"parent")
+ child = ZFSTest.pool.makeName(b"parent/child")
+ the_prop = b"nosuchprop"
lzc.lzc_create(parent)
lzc.lzc_create(child)
@@ -3892,11 +3922,11 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_inherit_prop)
def test_inherit_prop_on_snap(self):
- fs = ZFSTest.pool.makeName("new")
- snapname = ZFSTest.pool.makeName("new@snap")
- prop = "user:foo"
- fs_val = "fs"
- snap_val = "snap"
+ fs = ZFSTest.pool.makeName(b"new")
+ snapname = ZFSTest.pool.makeName(b"new@snap")
+ prop = b"user:foo"
+ fs_val = b"fs"
+ snap_val = b"snap"
lzc.lzc_create(fs, props={prop: fs_val})
lzc.lzc_snapshot([snapname], props={prop: snap_val})
@@ -3910,9 +3940,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_fs_prop(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "user:foo"
- val = "bar"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"user:foo"
+ val = b"bar"
lzc.lzc_create(fs)
lzc.lzc_set_prop(fs, prop, val)
@@ -3921,9 +3951,9 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_snap_prop(self):
- snapname = ZFSTest.pool.makeName("@snap")
- prop = "user:foo"
- val = "bar"
+ snapname = ZFSTest.pool.makeName(b"@snap")
+ prop = b"user:foo"
+ val = b"bar"
lzc.lzc_snapshot([snapname])
lzc.lzc_set_prop(snapname, prop, val)
@@ -3932,17 +3962,17 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_prop_nonexistent(self):
- fs = ZFSTest.pool.makeName("nonexistent")
- prop = "user:foo"
- val = "bar"
+ fs = ZFSTest.pool.makeName(b"nonexistent")
+ prop = b"user:foo"
+ val = b"bar"
with self.assertRaises(lzc_exc.DatasetNotFound):
lzc.lzc_set_prop(fs, prop, val)
@needs_support(lzc.lzc_set_prop)
def test_set_sys_prop(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "recordsize"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"recordsize"
val = 4096
lzc.lzc_create(fs)
@@ -3952,8 +3982,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_invalid_prop(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "nosuchprop"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"nosuchprop"
val = 0
lzc.lzc_create(fs)
@@ -3962,8 +3992,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_invalid_value_prop(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "atime"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"atime"
val = 100
lzc.lzc_create(fs)
@@ -3972,8 +4002,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_invalid_value_prop_2(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "readonly"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"readonly"
val = 100
lzc.lzc_create(fs)
@@ -3982,8 +4012,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_prop_too_small_quota(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "refquota"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"refquota"
val = 1
lzc.lzc_create(fs)
@@ -3992,8 +4022,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
@needs_support(lzc.lzc_set_prop)
def test_set_readonly_prop(self):
- fs = ZFSTest.pool.makeName("new")
- prop = "creation"
+ fs = ZFSTest.pool.makeName(b"new")
+ prop = b"creation"
val = 0
lzc.lzc_create(fs)
@@ -4004,8 +4034,8 @@ zfs.sync.snapshot('""" + pool + """@zcp')
class _TempPool(object):
- SNAPSHOTS = ['snap', 'snap1', 'snap2']
- BOOKMARKS = ['bmark', 'bmark1', 'bmark2']
+ SNAPSHOTS = [b'snap', b'snap1', b'snap2']
+ BOOKMARKS = [b'bmark', b'bmark1', b'bmark2']
_cachefile_suffix = ".cachefile"
@@ -4016,7 +4046,11 @@ class _TempPool(object):
def __init__(self, size=128 * 1024 * 1024, readonly=False, filesystems=[]):
self._filesystems = filesystems
self._readonly = readonly
- self._pool_name = 'pool.' + bytes(uuid.uuid4())
+ if sys.version_info < (3, 0):
+ self._pool_name = b'pool.' + bytes(uuid.uuid4())
+ else:
+ self._pool_name = b'pool.' + bytes(str(uuid.uuid4()),
+ encoding='utf-8')
self._root = _Filesystem(self._pool_name)
(fd, self._pool_file_path) = tempfile.mkstemp(
suffix='.zpool', prefix='tmp-')
@@ -4060,7 +4094,7 @@ class _TempPool(object):
except subprocess.CalledProcessError as e:
self.cleanUp()
- if 'permission denied' in e.output:
+ if b'permission denied' in e.output:
raise unittest.SkipTest(
'insufficient privileges to run libzfs_core tests')
print('command failed: ', e.output)
@@ -4104,7 +4138,7 @@ class _TempPool(object):
self._zpool_create, stderr=subprocess.STDOUT)
break
except subprocess.CalledProcessError as e:
- if 'pool is busy' in e.output and retry < 5:
+ if b'pool is busy' in e.output and retry < 5:
retry += 1
time.sleep(1)
continue
@@ -4139,22 +4173,22 @@ class _TempPool(object):
def makeName(self, relative=None):
if not relative:
return self._pool_name
- if relative.startswith(('@', '#')):
+ if relative.startswith((b'@', b'#')):
return self._pool_name + relative
- return self._pool_name + '/' + relative
+ return self._pool_name + b'/' + relative
def makeTooLongName(self, prefix=None):
if not prefix:
- prefix = 'x'
+ prefix = b'x'
prefix = self.makeName(prefix)
pad_len = lzc.MAXNAMELEN + 1 - len(prefix)
if pad_len > 0:
- return prefix + 'x' * pad_len
+ return prefix + b'x' * pad_len
else:
return prefix
def makeTooLongComponent(self, prefix=None):
- padding = 'x' * (lzc.MAXNAMELEN + 1)
+ padding = b'x' * (lzc.MAXNAMELEN + 1)
if not prefix:
prefix = padding
else:
@@ -4165,7 +4199,7 @@ class _TempPool(object):
return self._root
def getFilesystem(self, fsname):
- return _Filesystem(self._pool_name + '/' + fsname)
+ return _Filesystem(self._pool_name + b'/' + fsname)
def isPoolFeatureAvailable(self, feature):
output = subprocess.check_output(
@@ -4177,7 +4211,7 @@ class _TempPool(object):
output = subprocess.check_output(
['zpool', 'get', '-H', 'feature@' + feature, self._pool_name])
output = output.split()[2]
- return output in ['active', 'enabled']
+ return output in [b'active', b'enabled']
class _Filesystem(object):
@@ -4197,7 +4231,7 @@ class _Filesystem(object):
def getFilesystem(self):
self._fs_id += 1
- fsname = self._name + '/fs' + bytes(self._fs_id)
+ fsname = self._name + b'/fs' + str(self._fs_id).encode()
fs = _Filesystem(fsname)
self._children.append(fs)
return fs
@@ -4212,14 +4246,14 @@ class _Filesystem(object):
return output.strip()
def _makeSnapName(self, i):
- return self._name + '@snap' + bytes(i)
+ return self._name + b'@snap' + str(i).encode()
def getSnap(self):
self._snap_id += 1
return self._makeSnapName(self._snap_id)
def _makeBookmarkName(self, i):
- return self._name + '#bmark' + bytes(i)
+ return self._name + b'#bmark' + bytes(i)
def getBookmark(self):
self._bmark_id += 1
@@ -4227,23 +4261,23 @@ class _Filesystem(object):
def _makeTooLongName(self, too_long_component):
if too_long_component:
- return 'x' * (lzc.MAXNAMELEN + 1)
+ return b'x' * (lzc.MAXNAMELEN + 1)
# Note that another character is used for one of '/', '@', '#'.
comp_len = lzc.MAXNAMELEN - len(self._name)
if comp_len > 0:
- return 'x' * comp_len
+ return b'x' * comp_len
else:
- return 'x'
+ return b'x'
def getTooLongFilesystemName(self, too_long_component):
- return self._name + '/' + self._makeTooLongName(too_long_component)
+ return self._name + b'/' + self._makeTooLongName(too_long_component)
def getTooLongSnap(self, too_long_component):
- return self._name + '@' + self._makeTooLongName(too_long_component)
+ return self._name + b'@' + self._makeTooLongName(too_long_component)
def getTooLongBookmark(self, too_long_component):
- return self._name + '#' + self._makeTooLongName(too_long_component)
+ return self._name + b'#' + self._makeTooLongName(too_long_component)
def _visitFilesystems(self, visitor):
for child in self._children:
diff --git a/contrib/pyzfs/libzfs_core/test/test_nvlist.py b/contrib/pyzfs/libzfs_core/test/test_nvlist.py
index 03fc95a87..c3c61142d 100644
--- a/contrib/pyzfs/libzfs_core/test/test_nvlist.py
+++ b/contrib/pyzfs/libzfs_core/test/test_nvlist.py
@@ -44,25 +44,25 @@ class TestNVList(unittest.TestCase):
def _assertIntDictsEqual(self, dict1, dict2):
self.assertEqual(
len(dict1), len(dict1),
- "resulting dictionary is of different size")
+ b"resulting dictionary is of different size")
for key in dict1.keys():
self.assertEqual(int(dict1[key]), int(dict2[key]))
def _assertIntArrayDictsEqual(self, dict1, dict2):
self.assertEqual(
len(dict1), len(dict1),
- "resulting dictionary is of different size")
+ b"resulting dictionary is of different size")
for key in dict1.keys():
val1 = dict1[key]
val2 = dict2[key]
self.assertEqual(
- len(val1), len(val2), "array values of different sizes")
+ len(val1), len(val2), b"array values of different sizes")
for x, y in zip(val1, val2):
self.assertEqual(int(x), int(y))
def test_empty(self):
res = self._dict_to_nvlist_to_dict({})
- self.assertEqual(len(res), 0, "expected empty dict")
+ self.assertEqual(len(res), 0, b"expected empty dict")
def test_invalid_key_type(self):
with self.assertRaises(TypeError):
@@ -70,564 +70,564 @@ class TestNVList(unittest.TestCase):
def test_invalid_val_type__tuple(self):
with self.assertRaises(TypeError):
- self._dict_to_nvlist_to_dict({"key": (1, 2)})
+ self._dict_to_nvlist_to_dict({b"key": (1, 2)})
def test_invalid_val_type__set(self):
with self.assertRaises(TypeError):
- self._dict_to_nvlist_to_dict({"key": set(1, 2)})
+ self._dict_to_nvlist_to_dict({b"key": set(1, 2)})
def test_invalid_array_val_type(self):
with self.assertRaises(TypeError):
- self._dict_to_nvlist_to_dict({"key": [(1, 2), (3, 4)]})
+ self._dict_to_nvlist_to_dict({b"key": [(1, 2), (3, 4)]})
def test_invalid_array_of_arrays_val_type(self):
with self.assertRaises(TypeError):
- self._dict_to_nvlist_to_dict({"key": [[1, 2], [3, 4]]})
+ self._dict_to_nvlist_to_dict({b"key": [[1, 2], [3, 4]]})
def test_string_value(self):
- props = {"key": "value"}
+ props = {b"key": b"value"}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_implicit_boolean_value(self):
- props = {"key": None}
+ props = {b"key": None}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_boolean_values(self):
- props = {"key1": True, "key2": False}
+ props = {b"key1": True, b"key2": False}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_explicit_boolean_true_value(self):
- props = {"key": boolean_t(1)}
+ props = {b"key": boolean_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_boolean_false_value(self):
- props = {"key": boolean_t(0)}
+ props = {b"key": boolean_t(0)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_boolean_invalid_value(self):
with self.assertRaises(OverflowError):
- props = {"key": boolean_t(2)}
+ props = {b"key": boolean_t(2)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_boolean_another_invalid_value(self):
with self.assertRaises(OverflowError):
- props = {"key": boolean_t(-1)}
+ props = {b"key": boolean_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_uint64_value(self):
- props = {"key": 1}
+ props = {b"key": 1}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_uint64_max_value(self):
- props = {"key": 2 ** 64 - 1}
+ props = {b"key": 2 ** 64 - 1}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_uint64_too_large_value(self):
- props = {"key": 2 ** 64}
+ props = {b"key": 2 ** 64}
with self.assertRaises(OverflowError):
self._dict_to_nvlist_to_dict(props)
def test_uint64_negative_value(self):
- props = {"key": -1}
+ props = {b"key": -1}
with self.assertRaises(OverflowError):
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint64_value(self):
- props = {"key": uint64_t(1)}
+ props = {b"key": uint64_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint64_max_value(self):
- props = {"key": uint64_t(2 ** 64 - 1)}
+ props = {b"key": uint64_t(2 ** 64 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint64_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint64_t(2 ** 64)}
+ props = {b"key": uint64_t(2 ** 64)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint64_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint64_t(-1)}
+ props = {b"key": uint64_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint32_value(self):
- props = {"key": uint32_t(1)}
+ props = {b"key": uint32_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint32_max_value(self):
- props = {"key": uint32_t(2 ** 32 - 1)}
+ props = {b"key": uint32_t(2 ** 32 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint32_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint32_t(2 ** 32)}
+ props = {b"key": uint32_t(2 ** 32)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint32_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint32_t(-1)}
+ props = {b"key": uint32_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint16_value(self):
- props = {"key": uint16_t(1)}
+ props = {b"key": uint16_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint16_max_value(self):
- props = {"key": uint16_t(2 ** 16 - 1)}
+ props = {b"key": uint16_t(2 ** 16 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint16_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint16_t(2 ** 16)}
+ props = {b"key": uint16_t(2 ** 16)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint16_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint16_t(-1)}
+ props = {b"key": uint16_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint8_value(self):
- props = {"key": uint8_t(1)}
+ props = {b"key": uint8_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint8_max_value(self):
- props = {"key": uint8_t(2 ** 8 - 1)}
+ props = {b"key": uint8_t(2 ** 8 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_uint8_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint8_t(2 ** 8)}
+ props = {b"key": uint8_t(2 ** 8)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_uint8_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uint8_t(-1)}
+ props = {b"key": uint8_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_byte_value(self):
- props = {"key": uchar_t(1)}
+ props = {b"key": uchar_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_byte_max_value(self):
- props = {"key": uchar_t(2 ** 8 - 1)}
+ props = {b"key": uchar_t(2 ** 8 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_byte_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uchar_t(2 ** 8)}
+ props = {b"key": uchar_t(2 ** 8)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_byte_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": uchar_t(-1)}
+ props = {b"key": uchar_t(-1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int64_value(self):
- props = {"key": int64_t(1)}
+ props = {b"key": int64_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int64_max_value(self):
- props = {"key": int64_t(2 ** 63 - 1)}
+ props = {b"key": int64_t(2 ** 63 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int64_min_value(self):
- props = {"key": int64_t(-(2 ** 63))}
+ props = {b"key": int64_t(-(2 ** 63))}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int64_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int64_t(2 ** 63)}
+ props = {b"key": int64_t(2 ** 63)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int64_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int64_t(-(2 ** 63) - 1)}
+ props = {b"key": int64_t(-(2 ** 63) - 1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int32_value(self):
- props = {"key": int32_t(1)}
+ props = {b"key": int32_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int32_max_value(self):
- props = {"key": int32_t(2 ** 31 - 1)}
+ props = {b"key": int32_t(2 ** 31 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int32_min_value(self):
- props = {"key": int32_t(-(2 ** 31))}
+ props = {b"key": int32_t(-(2 ** 31))}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int32_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int32_t(2 ** 31)}
+ props = {b"key": int32_t(2 ** 31)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int32_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int32_t(-(2 ** 31) - 1)}
+ props = {b"key": int32_t(-(2 ** 31) - 1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int16_value(self):
- props = {"key": int16_t(1)}
+ props = {b"key": int16_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int16_max_value(self):
- props = {"key": int16_t(2 ** 15 - 1)}
+ props = {b"key": int16_t(2 ** 15 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int16_min_value(self):
- props = {"key": int16_t(-(2 ** 15))}
+ props = {b"key": int16_t(-(2 ** 15))}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int16_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int16_t(2 ** 15)}
+ props = {b"key": int16_t(2 ** 15)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int16_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int16_t(-(2 ** 15) - 1)}
+ props = {b"key": int16_t(-(2 ** 15) - 1)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int8_value(self):
- props = {"key": int8_t(1)}
+ props = {b"key": int8_t(1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int8_max_value(self):
- props = {"key": int8_t(2 ** 7 - 1)}
+ props = {b"key": int8_t(2 ** 7 - 1)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int8_min_value(self):
- props = {"key": int8_t(-(2 ** 7))}
+ props = {b"key": int8_t(-(2 ** 7))}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_explicit_int8_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int8_t(2 ** 7)}
+ props = {b"key": int8_t(2 ** 7)}
self._dict_to_nvlist_to_dict(props)
def test_explicit_int8_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": int8_t(-(2 ** 7) - 1)}
+ props = {b"key": int8_t(-(2 ** 7) - 1)}
self._dict_to_nvlist_to_dict(props)
def test_nested_dict(self):
- props = {"key": {}}
+ props = {b"key": {}}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_nested_nested_dict(self):
- props = {"key": {"key": {}}}
+ props = {b"key": {b"key": {}}}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_mismatching_values_array(self):
- props = {"key": [1, "string"]}
+ props = {b"key": [1, b"string"]}
with self.assertRaises(TypeError):
self._dict_to_nvlist_to_dict(props)
def test_mismatching_values_array2(self):
- props = {"key": [True, 10]}
+ props = {b"key": [True, 10]}
with self.assertRaises(TypeError):
self._dict_to_nvlist_to_dict(props)
def test_mismatching_values_array3(self):
- props = {"key": [1, False]}
+ props = {b"key": [1, False]}
with self.assertRaises(TypeError):
self._dict_to_nvlist_to_dict(props)
def test_string_array(self):
- props = {"key": ["value", "value2"]}
+ props = {b"key": [b"value", b"value2"]}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_boolean_array(self):
- props = {"key": [True, False]}
+ props = {b"key": [True, False]}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_explicit_boolean_array(self):
- props = {"key": [boolean_t(False), boolean_t(True)]}
+ props = {b"key": [boolean_t(False), boolean_t(True)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_uint64_array(self):
- props = {"key": [0, 1, 2 ** 64 - 1]}
+ props = {b"key": [0, 1, 2 ** 64 - 1]}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_uint64_array_too_large_value(self):
- props = {"key": [0, 2 ** 64]}
+ props = {b"key": [0, 2 ** 64]}
with self.assertRaises(OverflowError):
self._dict_to_nvlist_to_dict(props)
def test_uint64_array_negative_value(self):
- props = {"key": [0, -1]}
+ props = {b"key": [0, -1]}
with self.assertRaises(OverflowError):
self._dict_to_nvlist_to_dict(props)
def test_mixed_explict_int_array(self):
with self.assertRaises(TypeError):
- props = {"key": [uint64_t(0), uint32_t(0)]}
+ props = {b"key": [uint64_t(0), uint32_t(0)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint64_array(self):
- props = {"key": [uint64_t(0), uint64_t(1), uint64_t(2 ** 64 - 1)]}
+ props = {b"key": [uint64_t(0), uint64_t(1), uint64_t(2 ** 64 - 1)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_uint64_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint64_t(0), uint64_t(2 ** 64)]}
+ props = {b"key": [uint64_t(0), uint64_t(2 ** 64)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint64_array_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint64_t(0), uint64_t(-1)]}
+ props = {b"key": [uint64_t(0), uint64_t(-1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint32_array(self):
- props = {"key": [uint32_t(0), uint32_t(1), uint32_t(2 ** 32 - 1)]}
+ props = {b"key": [uint32_t(0), uint32_t(1), uint32_t(2 ** 32 - 1)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_uint32_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint32_t(0), uint32_t(2 ** 32)]}
+ props = {b"key": [uint32_t(0), uint32_t(2 ** 32)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint32_array_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint32_t(0), uint32_t(-1)]}
+ props = {b"key": [uint32_t(0), uint32_t(-1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint16_array(self):
- props = {"key": [uint16_t(0), uint16_t(1), uint16_t(2 ** 16 - 1)]}
+ props = {b"key": [uint16_t(0), uint16_t(1), uint16_t(2 ** 16 - 1)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_uint16_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint16_t(0), uint16_t(2 ** 16)]}
+ props = {b"key": [uint16_t(0), uint16_t(2 ** 16)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint16_array_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint16_t(0), uint16_t(-1)]}
+ props = {b"key": [uint16_t(0), uint16_t(-1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint8_array(self):
- props = {"key": [uint8_t(0), uint8_t(1), uint8_t(2 ** 8 - 1)]}
+ props = {b"key": [uint8_t(0), uint8_t(1), uint8_t(2 ** 8 - 1)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_uint8_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint8_t(0), uint8_t(2 ** 8)]}
+ props = {b"key": [uint8_t(0), uint8_t(2 ** 8)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_uint8_array_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uint8_t(0), uint8_t(-1)]}
+ props = {b"key": [uint8_t(0), uint8_t(-1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_byte_array(self):
- props = {"key": [uchar_t(0), uchar_t(1), uchar_t(2 ** 8 - 1)]}
+ props = {b"key": [uchar_t(0), uchar_t(1), uchar_t(2 ** 8 - 1)]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_byte_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uchar_t(0), uchar_t(2 ** 8)]}
+ props = {b"key": [uchar_t(0), uchar_t(2 ** 8)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_byte_array_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [uchar_t(0), uchar_t(-1)]}
+ props = {b"key": [uchar_t(0), uchar_t(-1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int64_array(self):
- props = {"key": [
+ props = {b"key": [
int64_t(0), int64_t(1), int64_t(2 ** 63 - 1), int64_t(-(2 ** 63))]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_int64_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int64_t(0), int64_t(2 ** 63)]}
+ props = {b"key": [int64_t(0), int64_t(2 ** 63)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int64_array_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int64_t(0), int64_t(-(2 ** 63) - 1)]}
+ props = {b"key": [int64_t(0), int64_t(-(2 ** 63) - 1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int32_array(self):
- props = {"key": [
+ props = {b"key": [
int32_t(0), int32_t(1), int32_t(2 ** 31 - 1), int32_t(-(2 ** 31))]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_int32_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int32_t(0), int32_t(2 ** 31)]}
+ props = {b"key": [int32_t(0), int32_t(2 ** 31)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int32_array_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int32_t(0), int32_t(-(2 ** 31) - 1)]}
+ props = {b"key": [int32_t(0), int32_t(-(2 ** 31) - 1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int16_array(self):
- props = {"key": [
+ props = {b"key": [
int16_t(0), int16_t(1), int16_t(2 ** 15 - 1), int16_t(-(2 ** 15))]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_int16_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int16_t(0), int16_t(2 ** 15)]}
+ props = {b"key": [int16_t(0), int16_t(2 ** 15)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int16_array_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int16_t(0), int16_t(-(2 ** 15) - 1)]}
+ props = {b"key": [int16_t(0), int16_t(-(2 ** 15) - 1)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int8_array(self):
- props = {"key": [
+ props = {b"key": [
int8_t(0), int8_t(1), int8_t(2 ** 7 - 1), int8_t(-(2 ** 7))]}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntArrayDictsEqual(props, res)
def test_explict_int8_array_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int8_t(0), int8_t(2 ** 7)]}
+ props = {b"key": [int8_t(0), int8_t(2 ** 7)]}
self._dict_to_nvlist_to_dict(props)
def test_explict_int8_array_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"key": [int8_t(0), int8_t(-(2 ** 7) - 1)]}
+ props = {b"key": [int8_t(0), int8_t(-(2 ** 7) - 1)]}
self._dict_to_nvlist_to_dict(props)
def test_dict_array(self):
- props = {"key": [{"key": 1}, {"key": None}, {"key": {}}]}
+ props = {b"key": [{b"key": 1}, {b"key": None}, {b"key": {}}]}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)
def test_implicit_uint32_value(self):
- props = {"rewind-request": 1}
+ props = {b"rewind-request": 1}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_implicit_uint32_max_value(self):
- props = {"rewind-request": 2 ** 32 - 1}
+ props = {b"rewind-request": 2 ** 32 - 1}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_implicit_uint32_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"rewind-request": 2 ** 32}
+ props = {b"rewind-request": 2 ** 32}
self._dict_to_nvlist_to_dict(props)
def test_implicit_uint32_negative_value(self):
with self.assertRaises(OverflowError):
- props = {"rewind-request": -1}
+ props = {b"rewind-request": -1}
self._dict_to_nvlist_to_dict(props)
def test_implicit_int32_value(self):
- props = {"pool_context": 1}
+ props = {b"pool_context": 1}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_implicit_int32_max_value(self):
- props = {"pool_context": 2 ** 31 - 1}
+ props = {b"pool_context": 2 ** 31 - 1}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_implicit_int32_min_value(self):
- props = {"pool_context": -(2 ** 31)}
+ props = {b"pool_context": -(2 ** 31)}
res = self._dict_to_nvlist_to_dict(props)
self._assertIntDictsEqual(props, res)
def test_implicit_int32_too_large_value(self):
with self.assertRaises(OverflowError):
- props = {"pool_context": 2 ** 31}
+ props = {b"pool_context": 2 ** 31}
self._dict_to_nvlist_to_dict(props)
def test_implicit_int32_too_small_value(self):
with self.assertRaises(OverflowError):
- props = {"pool_context": -(2 ** 31) - 1}
+ props = {b"pool_context": -(2 ** 31) - 1}
self._dict_to_nvlist_to_dict(props)
def test_complex_dict(self):
props = {
- "key1": "str",
- "key2": 10,
- "key3": {
- "skey1": True,
- "skey2": None,
- "skey3": [
+ b"key1": b"str",
+ b"key2": 10,
+ b"key3": {
+ b"skey1": True,
+ b"skey2": None,
+ b"skey3": [
True,
False,
True
]
},
- "key4": [
- "ab",
- "bc"
+ b"key4": [
+ b"ab",
+ b"bc"
],
- "key5": [
+ b"key5": [
2 ** 64 - 1,
1,
2,
3
],
- "key6": [
+ b"key6": [
{
- "skey71": "a",
- "skey72": "b",
+ b"skey71": b"a",
+ b"skey72": b"b",
},
{
- "skey71": "c",
- "skey72": "d",
+ b"skey71": b"c",
+ b"skey72": b"d",
},
{
- "skey71": "e",
- "skey72": "f",
+ b"skey71": b"e",
+ b"skey72": b"f",
}
],
- "type": 2 ** 32 - 1,
- "pool_context": -(2 ** 31)
+ b"type": 2 ** 32 - 1,
+ b"pool_context": -(2 ** 31)
}
res = self._dict_to_nvlist_to_dict(props)
self.assertEqual(props, res)