Example #1
0
    def test_send_message_max_length_exceeded(self):
        driver = object()
        task_id = get_random_task_id()
        message = json.dumps({'task-id': task_id, 'message': 'test-message'})
        max_message_length = 1

        result = ce.send_message(driver, message, max_message_length)
        self.assertFalse(result)
Example #2
0
    def test_send_message(self):
        driver = tu.FakeMesosExecutorDriver()
        task_id = tu.get_random_task_id()
        expected_message = {'task-id': task_id, 'message': 'test-message'}

        result = ce.send_message(driver, tu.fake_os_error_handler,
                                 expected_message)

        self.assertTrue(result)
        self.assertEqual(1, len(driver.messages))
        actual_encoded_message = driver.messages[0]
        tu.assert_message(self, expected_message, actual_encoded_message)
Example #3
0
    def test_send_message(self):
        driver = FakeMesosExecutorDriver()
        task_id = get_random_task_id()
        expected_message = {'task-id': task_id, 'message': 'test-message'}
        message = json.dumps(expected_message)
        max_message_length = 512

        result = ce.send_message(driver, message, max_message_length)

        self.assertTrue(result)
        self.assertEqual(1, len(driver.messages))
        actual_encoded_message = driver.messages[0]
        assert_message(self, expected_message, actual_encoded_message)
Example #4
0
    def test_send_message_handles_generic_exception(self):
        exception_handler_calls = []
        exception_handler = functools.partial(tu.store_exception_handler,
                                              exception_handler_calls)
        exception = Exception('Generic Exception')
        driver = tu.ErrorMesosExecutorDriver(exception)
        task_id = tu.get_random_task_id()
        message = {'task-id': task_id, 'message': 'test-message'}

        result = ce.send_message(driver, exception_handler, message)

        self.assertEqual([], exception_handler_calls)
        self.assertFalse(result)
        self.assertEqual(1, len(driver.messages))
Example #5
0
    def test_send_message_handles_os_error_non_memory(self):
        exception_handler_calls = []
        exception_handler = functools.partial(tu.store_exception_handler,
                                              exception_handler_calls)
        exception = OSError(errno.EACCES, 'Permission denied')
        driver = tu.ErrorMesosExecutorDriver(exception)
        task_id = tu.get_random_task_id()
        message = {'task-id': task_id, 'message': 'test-message'}

        result = ce.send_message(driver, exception_handler, message)

        self.assertEqual([], exception_handler_calls)
        self.assertFalse(result)
        self.assertEqual(1, len(driver.messages))
Example #6
0
 def send_progress_message(message):
     ce.send_message(driver, tu.fake_os_error_handler, message)
     self.assertTrue('progress-message' in message)
     self.assertLessEqual(len(message['progress-message']),
                          max_message_length)
     return len(message['progress-message']) <= max_message_length