def test_filesystem_udev_symlink_fsrename_poolrename(self): """ Test the udev symlink creation for filesystem devices after fs and pool rename. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() filesystem_path = make_test_filesystem(pool_path, fs_name) fs_name_rename = fs_n() self._unittest_command( StratisDbus.fs_rename(pool_name, fs_name, fs_name_rename), dbus.UInt16(0)) # Settle after rename, to allow udev to recognize the filesystem rename exec_command(["udevadm", "settle"]) pool_name_rename = p_n() self._unittest_command( StratisDbus.pool_rename(pool_name, pool_name_rename), dbus.UInt16(0)) # Settle after rename, to allow udev to recognize the pool rename exec_command(["udevadm", "settle"]) fsdevdest, fsdevmapperlinkdest = acquire_filesystem_symlink_targets( pool_name_rename, fs_name_rename, pool_path, filesystem_path) self.assertEqual(fsdevdest, fsdevmapperlinkdest)
def test_pool_create_permissions(self): """ Test that creating a pool fails when root permissions are dropped. """ pool_name = p_n() self._test_permissions(StratisDbus.pool_create, [pool_name, StratisCertify.DISKS], True)
def test_pool_list_not_empty(self): """ Test listing an non-existent pool. """ pool_name = p_n() make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._inequality_test(StratisDbus.pool_list(), [])
def test_pool_destroy_permissions(self): """ Test that destroying a pool fails when root permissions are dropped. """ pool_name = p_n() make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._test_permissions(StratisDbus.pool_destroy, [pool_name], True)
def test_pool_add_data_permissions(self): """ Test that adding data to a pool fails when root permissions are dropped. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:2]) self._test_permissions(StratisDbus.pool_add_data, [pool_path, StratisCertify.DISKS[2:3]], True)
def test_pool_set_fs_limit_too_low(self): """ Test setting the pool filesystem limit too low fails. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_set_param(pool_path, StratisDbus.POOL_IFACE, "FsLimit", dbus.UInt64(0), False)
def test_pool_create(self): """ Test creating a pool. """ pool_name = p_n() self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS), dbus.UInt16(0), )
def test_filesystem_create_permissions(self): """ Test that creating a filesystem fails when root permissions are dropped. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() self._test_permissions(StratisDbus.fs_create, [pool_path, fs_name], True)
def test_pool_destroy(self): """ Test destroying a pool. """ pool_name = p_n() make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command(StratisDbus.pool_destroy(pool_name), dbus.UInt16(0)) self.assertEqual(StratisDbus.fs_list(), {})
def test_pool_create_same_name_and_devices(self): """ Test creating a pool that already exists with the same devices. """ pool_name = p_n() make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS[0:1], None), dbus.UInt16(0), )
def test_filesystem_list_not_empty(self): """ Test listing an existent filesystem. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() make_test_filesystem(pool_path, fs_name) self._inequality_test(StratisDbus.fs_list(), {})
def test_pool_create_encrypted(self): """ Test creating an encrypted pool. """ with KernelKey("test-password") as key_desc: pool_name = p_n() self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS, key_desc), dbus.UInt16(0), )
def test_filesystem_create(self): """ Test creating a filesystem. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() self._unittest_command(StratisDbus.fs_create(pool_path, fs_name), dbus.UInt16(0))
def test_pool_add_data(self): """ Test adding data to a pool. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:2]) self._unittest_command( StratisDbus.pool_add_data(pool_path, StratisCertify.DISKS[2:3]), dbus.UInt16(0), )
def test_pool_create_same_name_different_devices(self): """ Test creating a pool that already exists with different devices. """ pool_name = p_n() make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS[1:3]), dbus.UInt16(1), )
def test_filesystem_create_specified_size(self): """ Test creating a filesystem with a specified size. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() self._unittest_command( StratisDbus.fs_create(pool_path, fs_name, fs_size="8796093022208"), dbus.UInt16(0), )
def test_pool_create_permissions(self): """ Test creating a pool fails with dropped permissions. """ pool_name = p_n() self._test_permissions( [ _STRATIS_CLI, "pool", "create", pool_name, StratisCertify.DISKS[0] ], True, True, )
def test_pool_create_invalid_redundancy(self): """ Test that creating a pool with an invalid redundancy value fails. """ pool_name = p_n() redundancy = 20000 self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS, redundancy=redundancy), dbus.UInt16(1), )
def test_pool_add_cache_permissions(self): """ Test that adding cache to pool fails when root permissions are dropped. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._test_permissions( StratisDbus.pool_init_cache, [pool_path, StratisCertify.DISKS[1:2]], True ) self._test_permissions( StratisDbus.pool_add_cache, [pool_path, StratisCertify.DISKS[2:3]], True )
def test_filesystem_udev_symlink_create(self): """ Test the udev symlink creation for filesystem devices. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() filesystem_path = make_test_filesystem(pool_path, fs_name) fsdevdest, fsdevmapperlinkdest = acquire_filesystem_symlink_targets( pool_name, fs_name, pool_path, filesystem_path) self.assertEqual(fsdevdest, fsdevmapperlinkdest)
def test_filesystem_create_specified_size_toosmall(self): """ Test creating a filesystem with a specified size that is too small. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() self._unittest_command( StratisDbus.fs_create(pool_path, fs_name, fs_size="536866816"), dbus.UInt16(1), )
def test_pool_create(self): """ Test creating a pool. """ pool_name = p_n() self.unittest_command( [ _STRATIS_CLI, "pool", "create", pool_name, StratisCertify.DISKS[0] ], 0, True, True, )
def test_pool_create_no_overprovisioning(self): """ Test creating a pool with no overprovisioning """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_set_param( pool_path, StratisDbus.POOL_IFACE, "Overprovisioning", dbus.Boolean(False), True, )
def test_filesystem_destroy(self): """ Test destroying a filesystem. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() make_test_filesystem(pool_path, fs_name) self._unittest_command(StratisDbus.fs_destroy(pool_name, fs_name), dbus.UInt16(0)) self.assertEqual(StratisDbus.fs_list(), {})
def test_pool_add_data_relative_path(self): """ Test adding data to a pool with a relative device path. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:2]) add_device = StratisCertify.DISKS[2] relative_device = create_relative_device_path(add_device) relative_device_list = [add_device, relative_device] self._unittest_command( StratisDbus.pool_add_data(pool_path, relative_device_list), dbus.UInt16(0), )
def test_filesystem_snapshot_permissions(self): """ Test snapshotting a filesystem fails when root permissions are dropped. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() fs_path = make_test_filesystem(pool_path, fs_name) snapshot_name = fs_n() self._test_permissions(StratisDbus.fs_snapshot, [pool_path, fs_path, snapshot_name], True)
def test_pool_create_after_cache(self): """ Test creating existing pool after cache was added """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command( StratisDbus.pool_init_cache(pool_path, StratisCertify.DISKS[1:2]), dbus.UInt16(0), ) self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS[0:1]), dbus.UInt16(0), )
def test_filesystem_snapshot(self): """ Test snapshotting a filesystem. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) fs_name = fs_n() fs_path = make_test_filesystem(pool_path, fs_name) snapshot_name = fs_n() self._unittest_command( StratisDbus.fs_snapshot(pool_path, fs_path, snapshot_name), dbus.UInt16(0))
def test_pool_add_different_data_after_cache(self): """ Test adding a different data device after a cache is created. """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command( StratisDbus.pool_init_cache(pool_path, StratisCertify.DISKS[1:2]), dbus.UInt16(0), ) self._unittest_command( StratisDbus.pool_add_data(pool_path, StratisCertify.DISKS[2:3]), dbus.UInt16(0), )
def test_pool_create_with_cache(self): """ Test creating existing pool with device already used by cache fails """ pool_name = p_n() pool_path = make_test_pool(pool_name, StratisCertify.DISKS[0:1]) self._unittest_command( StratisDbus.pool_init_cache(pool_path, StratisCertify.DISKS[1:2]), dbus.UInt16(0), ) self._unittest_command( StratisDbus.pool_create(pool_name, StratisCertify.DISKS[0:2]), dbus.UInt16(1), )