Beispiel #1
0
    def testHandleCommitQueueFailureWithClosedTree(self):
        """Test _HandleCommitQueueFailure with closed tree."""
        stage = self.ConstructStage()
        self._MockPartialSubmit(stage)
        self.PatchObject(tree_status,
                         'WaitForTreeStatus',
                         side_effect=timeout_util.TimeoutError())
        self.PatchObject(generic_stages.BuilderStage,
                         'GetScheduledSlaveBuildbucketIds',
                         return_value=[])

        stage._HandleCommitQueueFailure(set(['test1']), set(), set(), False)
        stage.sync_stage.pool.handle_failure_mock.assert_called_once_with(
            mock.ANY,
            sanity=False,
            no_stat=set(),
            changes=self.changes,
            failed_hwtests=None)
Beispiel #2
0
    def _RunHWTestSuite(self,
                        debug=False,
                        fails=False,
                        warns=False,
                        cmd_fail_mode=None):
        """Verify the stage behavior in various circumstances.

    Args:
      debug: Whether the HWTest suite should be run in debug mode.
      fails: Whether the stage should fail.
      warns: Whether the stage should warn.
      cmd_fail_mode: How commands.RunHWTestSuite() should fail.
        If None, don't fail.
    """
        # We choose to define these mocks in setUp() because they are
        # useful for tests that do not call this method. However, this
        # means we have to reset the mocks before each run.
        self.run_suite_mock.reset_mock()
        self.warning_mock.reset_mock()
        self.failure_mock.reset_mock()

        to_raise = None

        if cmd_fail_mode == None:
            to_raise = None
        elif cmd_fail_mode == 'timeout':
            to_raise = timeout_util.TimeoutError('Timed out')
        elif cmd_fail_mode == 'suite_timeout':
            to_raise = failures_lib.SuiteTimedOut('Suite timed out')
        elif cmd_fail_mode == 'board_not_available':
            to_raise = failures_lib.BoardNotAvailable('Board not available')
        elif cmd_fail_mode == 'lab_fail':
            to_raise = failures_lib.TestLabFailure('Test lab failure')
        elif cmd_fail_mode == 'test_warn':
            to_raise = failures_lib.TestWarning('Suite passed with warnings')
        elif cmd_fail_mode == 'test_fail':
            to_raise = failures_lib.TestFailure('HWTest failed.')
        else:
            raise ValueError('cmd_fail_mode %s not supported' % cmd_fail_mode)

        if cmd_fail_mode == 'timeout':
            self.run_suite_mock.side_effect = to_raise
        else:
            self.run_suite_mock.return_value = commands.HWTestSuiteResult(
                to_raise, None)

        if fails:
            self.assertRaises(failures_lib.StepFailure, self.RunStage)
        else:
            self.RunStage()

        self.run_suite_mock.assert_called_once()
        self.assertEqual(self.run_suite_mock.call_args[1].get('debug'), debug)

        # Make sure we print the buildbot failure/warning messages correctly.
        if fails:
            self.failure_mock.assert_called_once()
        else:
            self.assertFalse(self.failure_mock.called)

        if warns:
            self.warning_mock.assert_called_once()
        else:
            self.assertFalse(self.warning_mock.called)
Beispiel #3
0
 def testUploadTimeoutIgnore(self):
     """We don't propagate timeouts during upload."""
     self.CheckSuppressException(
         timeout_util.TimeoutError(), stats.StatsUploader.TIMEOUT_ERROR %
         (stats.StatsUploader.UPLOAD_TIMEOUT, ))