Exemplo n.º 1
0
 def test_no_args(self):
     """
     Ref. https://github.com/stratis-storage/stratis-cli/issues/248
     :return: None
     """
     exec_command([STRATIS_CLI], 2)
     exec_command([STRATIS_CLI, "daemon"], 2)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def make_test_filesystem(pool_path, fs_name):
    """
    Create a test filesystem that will later get destroyed
    :param str pool_path: Object path of a test pool
    :param str fs_name: Name of the filesystem to be created
    :return: Object path of the created filesystem
    """
    (
        (filesystems_created, (array_of_tuples_with_obj_paths_and_names),),
        return_code,
        msg,
    ) = StratisDbus.fs_create(pool_path, fs_name)

    _raise_error_exception(return_code, msg, filesystems_created)
    exec_command(["udevadm", "settle"])
    return array_of_tuples_with_obj_paths_and_names[0][0]
Exemplo n.º 4
0
    def setUp(self):
        """
        Ensure we are ready, which includes stratisd process is up and running
        and we have an empty configuration.  If not we will attempt to make
        the configuration empty.
        :return: None
        """
        self.addCleanup(self._clean_up)

        # The daemon should already be running, if not lets starts it and wait
        # a bit
        if process_exists('stratisd') is None:
            exec_command(["systemctl", "start", "stratisd"])
            time.sleep(20)

        StratisCli.destroy_all()
        self.assertEqual(0, len(StratisCli.pool_list()))
Exemplo n.º 5
0
    def setUp(self):
        """
        Setup for an individual test.
        * Register a cleanup action, to be run if the test fails.
        * Ensure that stratisd is running via systemd.
        * Use the running stratisd instance to destroy any existing
        Stratis filesystems, pools, etc.
        :return: None
        """
        self.addCleanup(clean_up)

        if process_exists("stratisd") is None:
            exec_command(["systemctl", "start", "stratisd"])
            time.sleep(20)

        StratisDbus.destroy_all()
        assert StratisDbus.pool_list() == []
Exemplo n.º 6
0
    def setUp(self):
        """
        Setup for an individual test.
        * Register a cleanup action, to be run if the test fails.
        * Ensure that stratisd is running via systemd.
        * Use the running stratisd instance to destroy any existing
        Stratis filesystems, pools, etc.
        * Call "udevadm settle" so udev database can be updated with changes
        to Stratis devices.
        :return: None
        """
        self.addCleanup(clean_up)

        if process_exists("stratisd") is None:
            exec_command(["systemctl", "start", "stratisd"])
            time.sleep(20)

        clean_up()

        time.sleep(1)
        exec_command(["udevadm", "settle"])

        if StratisCertify.monitor_dbus is True:
            command = [
                MONITOR_DBUS_SIGNALS,
                StratisDbus.BUS_NAME,
                StratisDbus.TOP_OBJECT,
                f"--top-interface={StratisDbus.MNGR_IFACE}",
            ]
            command.extend(f"--top-interface={intf}"
                           for intf in StratisDbus.legacy_manager_interfaces())
            # pylint: disable=consider-using-with
            try:
                self.trace = subprocess.Popen(
                    command,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    shell=False,
                )
            except FileNotFoundError as err:
                raise RuntimeError(
                    "monitor_dbus_signals script not found.") from err
Exemplo n.º 7
0
    def setUp(self):
        """
        Setup for an individual test.
        * Register a cleanup action, to be run if the test fails.
        * Ensure that stratisd is running via systemd.
        * Use the running stratisd instance to destroy any existing
        Stratis filesystems, pools, etc.
        * Call "udevadm settle" so udev database can be updated with changes
        to Stratis devices.
        :return: None
        """
        self.addCleanup(clean_up)

        if process_exists("stratisd") is None:
            exec_command(["systemctl", "start", "stratisd"])
            time.sleep(20)

        clean_up()

        exec_command(["udevadm", "settle"])
Exemplo n.º 8
0
    def test_simple_data_io(self):
        """
        Create a pool and fs, create some files on it and validate them to
        ensure very basic data path is working.
        :return: None
        """
        mount_path = None
        try:
            pool_name = p_n()
            fs_name = fs_n()
            StratisCli.pool_create(pool_name, block_devices=DISKS)
            StratisCli.fs_create(pool_name, fs_name)

            # mount the fs
            mount_path = os.path.join(os.path.sep + "mnt", rs(16))
            os.mkdir(mount_path)
            exec_command(
                ["mount",
                 stratis_link(pool_name, fs_name), mount_path])

            files = {}
            total_size = 0
            # Do some simple IO to it, creating at most about ~100MiB data
            while total_size < 1024 * 1024 * 100:
                fn, signature, size = file_create(mount_path)
                total_size += size
                files[fn] = signature

            # Validate them
            for name, signature in files.items():
                self.assertTrue(file_signature(name), signature)

        finally:
            # Make sure we un-mount the fs before we bail as we can't clean up
            # Stratis when the FS is mounted.
            if mount_path:
                exec_command(["umount", mount_path])
                os.rmdir(mount_path)
Exemplo n.º 9
0
    def test_create_pool_used_dev(self):
        """
        Ref. https://bugzilla.redhat.com/show_bug.cgi?id=1686852
        :return: None
        """
        pool_name = p_n()
        new_name = p_n()
        StratisCli.pool_create(pool_name, [DISKS[0]])

        stdout, _ = exec_command(
            [STRATIS_CLI, "pool", "create", new_name, DISKS[0]],
            expected_exit_code=1)

        # Users want the pool name in the error output
        self.assertTrue(pool_name in stdout)