Example #1
0
    def wait_until_mounted(self):
        """
        Check to make sure that fuse is mounted on mountpoint.  If not,
        sleep for 5 seconds and check again.
        """

        while not self.check_mounted_state():
            # Even if it's not mounted, it should at least
            # be running: catch simple failures where it has terminated.
            assert not self.fuse_daemon.poll()

            time.sleep(5)

        self.mounted = True

        # Now that we're mounted, set permissions so that the rest of the test will have
        # unrestricted access to the filesystem mount.
        for retry in range(10):
            try:
                stderr = StringIO()
                self.client_remote.run(
                    args=['sudo', 'chmod', '1777', self.mountpoint],
                    timeout=(15 * 60),
                    cwd=self.test_dir,
                    stderr=stderr)
                break
            except run.CommandFailedError:
                stderr = stderr.getvalue()
                if "Read-only file system".lower() in stderr.lower():
                    break
                elif "Permission denied".lower() in stderr.lower():
                    time.sleep(5)
                else:
                    raise