def test_heartbeat_completed(self): self.test_build.status = model.BuildStatus.COMPLETED self.test_build.result = model.BuildResult.CANCELED self.test_build.cancelation_reason = ( model.CancelationReason.CANCELED_EXPLICITLY) self.test_build.put() new_expiration_date = utils.utcnow() + datetime.timedelta(minutes=1) with self.assertRaises(errors.BuildIsCompletedError): service.heartbeat( self.test_build.key.id(), 0, lease_expiration_date=new_expiration_date)
def test_heartbeat_timeout(self): build = self.classic_build( id=1, status=common_pb2.INFRA_FAILURE, status_details=dict(timeout=dict()), ) build.put() new_expiration_date = utils.utcnow() + datetime.timedelta(minutes=1) exc_regex = ('Build was marked as timed out ' 'because it did not complete for 2 days') with self.assertRaisesRegexp(errors.BuildIsCompletedError, exc_regex): service.heartbeat(1, 0, lease_expiration_date=new_expiration_date)
def test_heartbeat(self): build = self.new_leased_build(id=1) new_expiration_date = utils.utcnow() + datetime.timedelta(minutes=1) build = service.heartbeat(1, build.lease_key, lease_expiration_date=new_expiration_date) self.assertEqual(build.lease_expiration_date, new_expiration_date)
def test_heartbeat(self): self.lease() new_expiration_date = utils.utcnow() + datetime.timedelta(minutes=1) build = service.heartbeat( self.test_build.key.id(), self.test_build.lease_key, lease_expiration_date=new_expiration_date) self.assertEqual(build.lease_expiration_date, new_expiration_date)
def heartbeat(self, request): """Updates build lease.""" build = service.heartbeat( request.id, request.lease_key, parse_datetime(request.lease_expiration_ts) ) return build_to_response_message(build)
def test_heartbeat_without_expiration_date(self): build = self.new_leased_build(id=1) with self.assertRaises(errors.InvalidInputError): service.heartbeat(1, build.lease_key, lease_expiration_date=None)
def test_heartbeat_completed(self): self.classic_build(id=1, status=common_pb2.CANCELED).put() new_expiration_date = utils.utcnow() + datetime.timedelta(minutes=1) with self.assertRaises(errors.BuildIsCompletedError): service.heartbeat(1, 0, lease_expiration_date=new_expiration_date)
def heartbeat(self, request): """Updates build lease.""" build = service.heartbeat( request.id, request.lease_key, parse_datetime(request.lease_expiration_ts)) return build_to_response_message(build)
def test_heartbeat_without_expiration_date(self): self.lease() with self.assertRaises(errors.InvalidInputError): service.heartbeat( self.test_build.key.id(), self.test_build.lease_key, lease_expiration_date=None)