Example #1
0
    def test_failing_call(self):
        with self._create_client() as client:
            with self.assertRaises(ServerError) as ex:
                client.Test.failingCall()

            self.assertEqual(ex.exception.code,
                             exception.GeneralException().code)
            self.assertIn("Test failure", str(ex.exception))
Example #2
0
    def test_job_get_error(self):
        job = TestingJob()
        self.assertIsNone(job.error)
        self.assertNotIn('error', job.info())

        error = exception.GeneralException()
        job._error = error
        self.assertEqual(job.error, error)
        self.assertEqual(error.info(), job.info()['error'])
Example #3
0
File: jobs.py Project: xin49/vdsm
 def _run_failed(self, e):
     """
     The job's _run method failed and raised an exception.  If we were in
     the process of aborting we consider the abort operation finished.
     Otherwise, move the job to failed state.
     """
     with self._status_lock:
         if self.status == STATUS.ABORTING:
             self._status = STATUS.ABORTED
             logging.exception("Exception while aborting job %r", self.id)
         else:
             self._status = STATUS.FAILED
             logging.exception("Job %r failed", self.id)
         if not isinstance(e, exception.VdsmException):
             e = exception.GeneralException(str(e))
         self._error = e
Example #4
0
 def failingCall(self):
     raise exception.GeneralException("Test failure")
Example #5
0
 def lease_info(self, lease):
     key = (lease["sd_id"], lease["lease_id"])
     if key not in self.leases:
         return exception.GeneralException().response()
     return response.success(result=self.leases[key])
Example #6
0
 def test_fail_with_general_exception(self):
     exc = ValueError()
     res = self.vm.fail(exc)
     expected = exception.GeneralException(str(exc)).response()
     self.assertEqual(res, expected)