Ejemplo n.º 1
0
 def test_create_status_running(self):
     driver = tu.FakeMesosExecutorDriver()
     task_id = tu.get_random_task_id()
     status_updater = ce.StatusUpdater(driver, task_id)
     actual_status = status_updater.create_status(cook.TASK_RUNNING)
     expected_status = {
         'task_id': {
             'value': task_id
         },
         'state': cook.TASK_RUNNING
     }
     tu.assert_status(self, expected_status, actual_status)
Ejemplo n.º 2
0
    def test_os_error_handler_no_permission(self):
        driver = tu.FakeMesosExecutorDriver()
        task_id = tu.get_random_task_id()
        status_updater = ce.StatusUpdater(driver, task_id)
        stop_signal = Event()
        os_error = OSError(errno.EPERM, 'No Permission')

        ce.os_error_handler(stop_signal, status_updater, os_error)

        self.assertTrue(stop_signal.isSet())
        expected_statuses = [{
            'task_id': {
                'value': task_id
            },
            'state': cook.TASK_FAILED
        }]
        tu.assert_statuses(self, expected_statuses, driver.statuses)
Ejemplo n.º 3
0
    def test_os_error_handler_no_memory(self):
        driver = tu.FakeMesosExecutorDriver()
        task_id = tu.get_random_task_id()
        status_updater = ce.StatusUpdater(driver, task_id)
        stop_signal = Event()
        os_error = OSError(errno.ENOMEM, 'No Memory')

        ce.os_error_handler(stop_signal, status_updater, os_error)

        self.assertTrue(stop_signal.isSet())
        expected_statuses = [{
            'task_id': {
                'value': task_id
            },
            'reason': cook.REASON_CONTAINER_LIMITATION_MEMORY,
            'state': cook.TASK_FAILED
        }]
        tu.assert_statuses(self, expected_statuses, driver.statuses)
Ejemplo n.º 4
0
    def test_update_status(self):
        driver = tu.FakeMesosExecutorDriver()
        task_id = tu.get_random_task_id()
        status_updater = ce.StatusUpdater(driver, task_id)
        task_state = "TEST_TASK_STATE"

        self.assertTrue(status_updater.update_status(cook.TASK_STARTING))
        self.assertTrue(status_updater.update_status(task_state))
        self.assertTrue(
            status_updater.update_status(cook.TASK_RUNNING, reason='Running'))
        self.assertTrue(
            status_updater.update_status(cook.TASK_FAILED,
                                         reason='Termination'))
        self.assertFalse(status_updater.update_status(cook.TASK_FINISHED))

        expected_statuses = [{
            'task_id': {
                'value': task_id
            },
            'state': cook.TASK_STARTING
        }, {
            'task_id': {
                'value': task_id
            },
            'state': task_state
        }, {
            'task_id': {
                'value': task_id
            },
            'reason': 'Running',
            'state': cook.TASK_RUNNING
        }, {
            'task_id': {
                'value': task_id
            },
            'reason': 'Termination',
            'state': cook.TASK_FAILED
        }]
        tu.assert_statuses(self, expected_statuses, driver.statuses)