def testIntervals(self):
        self.assertEqual([], iter_utils.IntersectIntervals([]))
        self.assertEqual([(1, 2)], iter_utils.IntersectIntervals([[(1, 2)]]))

        test_group_0 = [(1, 10)]
        test_group_1 = [(2, 5), (7, 10)]
        test_group_2 = [(2, 8), (9, 12)]
        self.assertEqual([(2, 5), (7, 8), (9, 10)],
                         iter_utils.IntersectIntervals(
                             [test_group_0, test_group_1, test_group_2]))

        test_group_0 = [(1, 3), (10, 12)]
        test_group_1 = [(2, 5)]
        self.assertEqual([(2, 3)],
                         iter_utils.IntersectIntervals(
                             [test_group_0, test_group_1]))
Пример #2
0
def GetPreCQTime(change, action_history):
    """Returns the time spent waiting for the pre-cq to finish."""
    ready_intervals = _GetReadyIntervals(change, action_history)
    start = (constants.CL_ACTION_SCREENED_FOR_PRE_CQ, )
    stop = (constants.CL_ACTION_PRE_CQ_FULLY_VERIFIED, )
    precq_intervals = _GetIntervals(change, action_history, start, stop)
    return _MeasureTimestampIntervals(
        iter_utils.IntersectIntervals([ready_intervals, precq_intervals]))
Пример #3
0
def GetCQRunTime(change, action_history):
  """Returns the time spent testing a CL in the CQ."""
  ready_intervals = _GetReadyIntervals(change, action_history)
  relevant_configs = (constants.CQ_MASTER,)
  relevant_config_actions = [a for a in action_history
                             if a.build_config in relevant_configs]
  start = (constants.CL_ACTION_PICKED_UP,)
  stop = (constants.CL_ACTION_FORGIVEN, constants.CL_ACTION_KICKED_OUT,
          constants.CL_ACTION_SUBMITTED)
  testing_intervals = _GetIntervals(change, relevant_config_actions, start,
                                    stop)
  return _MeasureTimestampIntervals(
      iter_utils.IntersectIntervals([ready_intervals, testing_intervals]))
Пример #4
0
def GetCQWaitTime(change, action_history):
  """Returns the time spent waiting for a CL to be picked up by the CQ."""
  ready_intervals = _GetReadyIntervals(change, action_history)
  precq_passed_interval = _GetIntervals(
      change, action_history, (constants.CL_ACTION_PRE_CQ_PASSED,), ())
  relevant_configs = (constants.PRE_CQ_LAUNCHER_CONFIG, constants.CQ_MASTER)
  relevant_config_actions = [a for a in action_history
                             if a.build_config in relevant_configs]
  start = (constants.CL_ACTION_REQUEUED, constants.CL_ACTION_FORGIVEN)
  stop = (constants.CL_ACTION_PICKED_UP,)
  waiting_intervals = _GetIntervals(change, relevant_config_actions, start,
                                    stop, True)
  return _MeasureTimestampIntervals(
      iter_utils.IntersectIntervals(
          [ready_intervals, waiting_intervals, precq_passed_interval]))