Ejemplo n.º 1
0
 def test_pool_create(self):
     """
     Test creating a pool.
     """
     pool_name = p_n()
     (_, return_code, _) = StratisDbus.pool_create(pool_name, DISKS)
     self.assertEqual(return_code, dbus.UInt16(0))
Ejemplo n.º 2
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, DISKS[0:1])

        (_, return_code, _) = StratisDbus.pool_create(pool_name, DISKS[1:3])
        self.assertEqual(return_code, dbus.UInt16(1))
Ejemplo n.º 3
0
    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),
        )
Ejemplo n.º 4
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),
        )
Ejemplo n.º 5
0
    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),
        )
Ejemplo n.º 6
0
    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),
            )
Ejemplo n.º 7
0
    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),
        )
Ejemplo n.º 8
0
def make_test_pool(pool_name, pool_disks):
    """
    Create a test pool that will later get destroyed
    :param str pool_name: Name of the pool to be created
    :param list pool_disks: List of disks with which the pool will be created
    :return: Object path of the created pool
    """
    (obj_path_exists, (obj_path, _)), return_code, msg = StratisDbus.pool_create(
        pool_name, pool_disks, None
    )

    _raise_error_exception(return_code, msg, obj_path_exists)
    return obj_path
Ejemplo n.º 9
0
def make_test_pool(pool_name, pool_disks):
    """
    Create a test pool that will later get destroyed
    :param str pool_name: Name of the pool to be created
    :param list pool_disks: List of disks with which the pool will be created
    :return: Object path of the created pool
    """
    (obj_path_exists,
     (obj_path,
      _)), return_code, msg = StratisDbus.pool_create(pool_name, pool_disks)
    assert return_code == 0, "return_code: %s, error_msg: %s" % (return_code,
                                                                 msg)
    assert obj_path_exists, "obj_path_exists: %s" % obj_path_exists
    return obj_path
Ejemplo n.º 10
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),
        )
Ejemplo n.º 11
0
    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),
        )