コード例 #1
0
    def exercise_filesystem(self,
                            client_address,
                            filesystem,
                            mdt_indexes=[0],
                            no_of_files_per_mdt=None):
        """
        Verify we can actually exercise a filesystem.

        Currently this only verifies that we can write to a filesystem as a
        sanity check that it was configured correctly.
        """

        if not no_of_files_per_mdt:
            no_of_files_per_mdt = [10] * len(mdt_indexes)

        threads = []

        for index, mdt_index in enumerate(mdt_indexes):
            thread = ExceptionThrowingThread(
                target=self.exercise_filesystem_mdt,
                args=(client_address, filesystem, mdt_index,
                      no_of_files_per_mdt[index]),
            )

            thread.start()
            threads.append(thread)

        ExceptionThrowingThread.wait_for_threads(
            threads
        )  # This will raise an exception if any of the threads raise an exception
コード例 #2
0
    def test_host_long_polling_ddos(self):
        def fetch_like_hell(self_, test_uri):
            while not self_.exit:
                self_.get_by_uri(test_uri,
                                 args={'limit': 0},
                                 verify_successful=True)

        threads = []
        self.exit = False

        # Hardly ddos but for today we only allow 100 connections to the db.
        # TODO: Increase the connections so we can have realistic numbers.
        for index in range(0, 64):
            thread = ExceptionThrowingThread(target=fetch_like_hell,
                                             args=(self, '/api/host'),
                                             use_threads=True)
            thread.start()
            threads.append(thread)

        # Just let them run for 30 seconds.
        time.sleep(1)

        self.exit = True

        ExceptionThrowingThread.wait_for_threads(threads)
コード例 #3
0
    def test_corosync_state_change_2(self):
        """Test state changes on the corosync/pacemaker through a faily random set.
        """

        self._add_corosync_hosts(2)

        def run_states(server):
            states = ['unconfigured', 'stopped', 'started']

            for corosync_state in states:
                self.set_state(
                    server['corosync_configuration'], corosync_state,
                    '%s Corosync for %s' % (corosync_state, server['fqdn']))

                for pacemaker_state in states:
                    self.set_state(
                        server['pacemaker_configuration'], pacemaker_state,
                        '%s Pacemaker for %s' %
                        (pacemaker_state, server['fqnd']))

        threads = []

        for server in self.server_configs:
            thread = ExceptionThrowingThread(target=run_states,
                                             args=(server, ))
            thread.start()
            threads.append(thread)

        ExceptionThrowingThread.wait_for_threads(
            threads
        )  # This will raise an exception if any of the threads raise an exception
コード例 #4
0
    def exercise_filesystem_mdt(self, client_address, filesystem, mdt_index,
                                files_to_create):
        """
        Verify we can actually exercise a filesystem on a specific mdt.

        Currently this only verifies that we can write to a filesystem as a
        sanity check that it was configured correctly.
        """
        # TODO: Expand on entire function. Perhaps use existing lustre client tests.

        if not filesystem.get("bytes_free"):
            self._test_case.wait_until_true(
                lambda: self._test_case.get_filesystem(filesystem["id"]).get(
                    "bytes_free"))
            filesystem = self._test_case.get_filesystem(filesystem["id"])

        bytes_free = filesystem.get("bytes_free")
        assert bytes_free > 0, "Expected bytes_free to be > 0"
        logger.debug("exercise_filesystem: API reports %s has %s bytes free" %
                     (filesystem["name"], bytes_free))

        test_root = "/mnt/%s/mdt%s" % (filesystem["name"], mdt_index)

        if mdt_index:
            self._ssh_address(client_address,
                              "lfs mkdir -i %s %s" % (mdt_index, test_root))
        else:
            self._ssh_address(client_address, "mkdir -p %s" % test_root)

        def actual_exercise(client_address, test_root, file_no,
                            bytes_to_write):
            self._ssh_address(client_address,
                              "mkdir -p %s/%s" % (test_root, file_no))

            self._ssh_address(
                client_address,
                "dd if=/dev/zero of=%s/%s/exercisetest-%s.dat bs=1000 count=%s"
                % (test_root, file_no, file_no, bytes_to_write),
            )

        threads = []

        for file_no in range(0, files_to_create):
            thread = ExceptionThrowingThread(
                target=actual_exercise,
                args=(client_address, test_root, file_no,
                      min((bytes_free * 0.4), 512000) / 1000),
                use_threads=False,
            )
            thread.start()
            threads.append(thread)

        ExceptionThrowingThread.wait_for_threads(
            threads
        )  # This will raise an exception if any of the threads raise an exception

        self._ssh_address(client_address, "rm -rf %s" % test_root)
コード例 #5
0
    def _run(self):
        threads = []

        for plugin_name in self._client.device_plugins.get_plugins():
            thread = ExceptionThrowingThread(target=self._run_plugin,
                                             args=(plugin_name, ))
            threads.append(thread)
            thread.start()

        while not self._stopping.is_set():
            while not (self._messages.empty()
                       and self._retry_messages.empty()):
                self.send()

            self._messages_waiting.wait()
            self._messages_waiting.clear()

        ExceptionThrowingThread.wait_for_threads(threads)