def test_task_system_failure(): with TemporaryConfiguration(os.path.join( os.path.dirname(os.path.realpath(__file__)), '../../../common/configs/local.config'), internal_overrides={ 'image': 'myflyteimage:{}'.format( os.environ.get('IMAGE_VERSION', 'sha')), 'project': 'myflyteproject', 'domain': 'development' }): m = MagicMock() m.execute = _raise_system_exception with utils.AutoDeletingTempDir("test") as tmp: engine.FlyteTask(m).execute(None, {'output_prefix': tmp.name}) doc = errors.ErrorDocument.from_flyte_idl( utils.load_proto_from_file( errors_pb2.ErrorDocument, os.path.join(tmp.name, constants.ERROR_FILE_NAME))) assert doc.error.code == "SYSTEM:Unknown" assert doc.error.kind == errors.ContainerError.Kind.RECOVERABLE assert "errorERRORerror" in doc.error.message
def test_task_user_failure(): m = MagicMock() m.execute = _raise_user_exception with utils.AutoDeletingTempDir("test") as tmp: engine.FlyteTask(m).execute(None, {'output_prefix': tmp.name}) doc = errors.ErrorDocument.from_flyte_idl( utils.load_proto_from_file(errors_pb2.ErrorDocument, os.path.join(tmp.name, constants.ERROR_FILE_NAME)) ) assert doc.error.code == "USER:Unknown" assert doc.error.kind == errors.ContainerError.Kind.NON_RECOVERABLE assert "userUSERuser" in doc.error.message