Пример #1
0
    def _wait_on_task_execution(self, max_wait=5):
        """Wait until all the tasks have finished execution and are in
        state of success or failure.
        """

        start = timeutils.utcnow()

        # wait for maximum of seconds defined by max_wait
        while timeutils.delta_seconds(start, timeutils.utcnow()) < max_wait:
            wait = False
            # Verify that no task is in status of pending or processing
            path = "/v2/tasks"
            res, content = self.http.request(path, 'GET',
                                             headers=minimal_task_headers())
            content_dict = json.loads(content)

            self.assertEqual(http_client.OK, res.status)
            res_tasks = content_dict['tasks']
            if len(res_tasks) != 0:
                for task in res_tasks:
                    if task['status'] in ('pending', 'processing'):
                        wait = True
                        break

            if wait:
                # Bug #1541487: we must give time to the server to execute the
                # task, but the server is run in the same process than the
                # test. Use eventlet to give the control to the pending server
                # task.
                eventlet.sleep(0.05)
                continue
            else:
                break
    def _wait_on_task_execution(self):
        """Wait until all the tasks have finished execution and are in
        state of success or failure.
        """

        start = timeutils.utcnow()

        # wait for maximum of 5 seconds
        while timeutils.delta_seconds(start, timeutils.utcnow()) < 5:
            wait = False
            # Verify that no task is in status of pending or processing
            path = "/v2/tasks"
            res, content = self.http.request(path, 'GET',
                                             headers=minimal_task_headers())
            content_dict = json.loads(content)

            self.assertEqual(200, res.status)
            res_tasks = content_dict['tasks']
            if len(res_tasks) != 0:
                for task in res_tasks:
                    if task['status'] in ('pending', 'processing'):
                        wait = True
                        break

            if wait:
                time.sleep(0.05)
                continue
            else:
                break
Пример #3
0
    def _wait_on_task_execution(self, max_wait=5):
        """Wait until all the tasks have finished execution and are in
        state of success or failure.
        """

        start = timeutils.utcnow()

        # wait for maximum of seconds defined by max_wait
        while timeutils.delta_seconds(start, timeutils.utcnow()) < max_wait:
            wait = False
            # Verify that no task is in status of pending or processing
            path = "/v2/tasks"
            res, content = self.http.request(path,
                                             'GET',
                                             headers=minimal_task_headers())
            content_dict = json.loads(content)

            self.assertEqual(http_client.OK, res.status)
            res_tasks = content_dict['tasks']
            if len(res_tasks) != 0:
                for task in res_tasks:
                    if task['status'] in ('pending', 'processing'):
                        wait = True
                        break

            if wait:
                # Bug #1541487: we must give time to the server to execute the
                # task, but the server is run in the same process than the
                # test. Use eventlet to give the control to the pending server
                # task.
                eventlet.sleep(0.05)
                continue
            else:
                break
Пример #4
0
    def _wait_on_task_execution(self):
        """Wait until all the tasks have finished execution and are in
        state of success or failure.
        """

        start = timeutils.utcnow()

        # wait for maximum of 5 seconds
        while timeutils.delta_seconds(start, timeutils.utcnow()) < 5:
            wait = False
            # Verify that no task is in status of pending or processing
            path = "/v2/tasks"
            res, content = self.http.request(path,
                                             'GET',
                                             headers=minimal_task_headers())
            content_dict = json.loads(content)

            self.assertEqual(200, res.status)
            res_tasks = content_dict['tasks']
            if len(res_tasks) != 0:
                for task in res_tasks:
                    if task['status'] in ('pending', 'processing'):
                        wait = True
                        break

            if wait:
                time.sleep(0.05)
                continue
            else:
                break
Пример #5
0
 def test_delta_seconds(self):
     before = timeutils.utcnow()
     after = before + datetime.timedelta(
         days=7, seconds=59, microseconds=123456)
     self.assertAlmostEquals(604859.123456,
                             timeutils.delta_seconds(before, after))
Пример #6
0
 def test_delta_seconds(self):
     before = timeutils.utcnow()
     after = before + datetime.timedelta(days=7, seconds=59,
                                         microseconds=123456)
     self.assertAlmostEquals(604859.123456,
                             timeutils.delta_seconds(before, after))