Пример #1
0
 def status(self):
     sample = self._disk_sample
     if sample > self._max_disk:
         self._kill_event.set()
         return StatusResult(
             'Disk limit exceeded.  Reserved %s bytes vs used %s bytes.' %
             (self._max_disk, sample), mesos_pb2.TASK_FAILED)
Пример #2
0
def test_chained_health_interface():
    hi = ChainedStatusChecker([])
    assert hi.status is None

    hi = ChainedStatusChecker([Healthy()])
    assert hi.status is None

    si1 = EventHealth()
    si2 = EventHealth()
    chained_si = ChainedStatusChecker([si1, si2])

    for si in (si1, si2):
        assert not si.started.is_set()
    chained_si.start()
    for si in (si1, si2):
        assert si.started.is_set()

    assert chained_si.status is None
    reason = StatusResult('derp', TaskState.Value('TASK_FAILED'))
    si2.set_status(reason)
    assert chained_si.status == reason
    assert chained_si.status.reason == 'derp'
    assert TaskState.Name(chained_si.status.status) == 'TASK_FAILED'

    for si in (si1, si2):
        assert not si.stopped.is_set()
    chained_si.stop()
    for si in (si1, si2):
        assert si.stopped.is_set()
Пример #3
0
  def __start(self):
    self.__connect_event.wait(timeout=self.__timeout_secs)
    if not self.__connect_event.is_set():
      self.__status = StatusResult("Creating Announcer Serverset timed out.", mesos_pb2.TASK_FAILED)
    else:
      self.__announcer.start()

    self.start_event.set()
 def status(self):
     if (self.TIMES_CALLED >= 3):
         return StatusResult('Test task mock status',
                             mesos_pb2.TASK_KILLED)
     self.TIMES_CALLED += 1
Пример #5
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import threading

import pytest
from mesos.interface.mesos_pb2 import TaskState

from apache.aurora.executor.common.status_checker import (ChainedStatusChecker,
                                                          Healthy,
                                                          StatusChecker,
                                                          StatusResult)

TASK_STARTING = StatusResult(None, TaskState.Value('TASK_STARTING'))
TASK_RUNNING = StatusResult(None, TaskState.Value('TASK_RUNNING'))
TASK_FAILED = StatusResult(None, TaskState.Value('TASK_FAILED'))


class EventHealth(StatusChecker):
    def __init__(self, status=None):
        self.started = threading.Event()
        self.stopped = threading.Event()
        self._status = status

    @property
    def status(self):
        return self._status

    def set_status(self, status):
Пример #6
0
 def running_callback(result):
     assert result == StatusResult(None,
                                   TaskState.Value('TASK_RUNNING'))
     self.running_callback_called += 1
Пример #7
0
 def unhealthy_callback(result):
     assert result == StatusResult('Fake reason',
                                   TaskState.Value('TASK_KILLED'))
     self.unhealthy_callback_called = True
Пример #8
0
 def test_run_with_running_status(self):
     self.do_test_run_with_status(
         StatusResult(None, TaskState.Value('TASK_RUNNING')), 1)
Пример #9
0
 def test_run_with_starting_status(self):
     self.do_test_run_with_status(
         StatusResult(None, TaskState.Value('TASK_STARTING')), 0)
Пример #10
0
 def status(self):
     if self.call_count == 2:
         return StatusResult('Fake reason', TaskState.Value('TASK_KILLED'))
     self.call_count += 1
     return self._status