@mock.patch.object(Hombre, '__init__', return_value=None)
@mock.patch.object(Hombre, 'advance')
@mock.patch.object(ru.Profiler, 'prof')
@mock.patch('radical.utils.raise_on')
def test_mpi_task_withhombre_scheduler(mocked_init, mocked_method, mocked_profiler, mocked_raise_on):
    (cfg, session) = setUp()
    component = Hombre(cfg=dict(), session=session)
    component._log = ru.Logger('radical.pilot.test')
    component._configured = False
    component._cfg = cfg
    component._lrms_info = cfg['lrms_info']
    component._lrms_lm_info = cfg['lrms_info']['lm_info']
    component._lrms_n_nodes = cfg['lrms_info']['n_nodes']
    component._lrms_node_list = cfg['lrms_info']['node_list']
    component._lrms_cores_per_node = cfg['lrms_info']['cores_per_node']
    component._lrms_gpus_per_node = cfg['lrms_info']['gpus_per_node']
    component.nodes = list()
    for node in component._lrms_node_list:
        component.nodes.append({'uid': node[0], 'name': node[1]})
    component._configure()
    component._oversubscribe = True
    all_slots = [{'lm_info': 'INFO', 'cores_per_node': 4, 'gpus_per_node': 2, 'nodes': [[0, '0', [[0], [1], [2]], [[0]]]]}, {'lm_info': 'INFO', 'cores_per_node': 4, 'gpus_per_node': 2, 'nodes': [[1, '1', [[0], [1], [2]], [[0]]]]}]
    td = cud_mpi()
    slot = component._allocate_slot(td)
    chk = all_slots[(- 1)]
    assert (slot == chk)
    td = cud_mpi()
    slot = component._allocate_slot(td)
    assert (slot == all_slots[(- 2)])
    with pytest.raises(ValueError):
        td = cud_mpi()
        td['gpu_processes'] = 2
        slot = component._allocate_slot(td)
    td = cud_mpi()
    noslot = component._allocate_slot(td)
    assert (noslot is None)
    component._release_slot(slot)
    td = cud_mpi()
    newslot = component._allocate_slot(td)
    assert (newslot == slot)
    tearDown(session)
@mock.patch.object(Hombre, '__init__', return_value=None)
@mock.patch.object(Hombre, 'advance')
@mock.patch.object(ru.Profiler, 'prof')
@mock.patch('radical.utils.raise_on')
def test_mpi_task_withhombre_scheduler(mocked_init, mocked_method, mocked_profiler, mocked_raise_on):
    (cfg, session) = setUp()
    component = Hombre(cfg=dict(), session=session)
    component._log = ru.Logger('radical.pilot.test')
    component._configured = False
    component._cfg = cfg
    component._lrms_info = cfg['lrms_info']
    component._lrms_lm_info = cfg['lrms_info']['lm_info']
    component._lrms_n_nodes = cfg['lrms_info']['n_nodes']
    component._lrms_node_list = cfg['lrms_info']['node_list']
    component._lrms_cores_per_node = cfg['lrms_info']['cores_per_node']
    component._lrms_gpus_per_node = cfg['lrms_info']['gpus_per_node']
    component.nodes = list()
    for node in component._lrms_node_list:
        component.nodes.append({'uid': node[0], 'name': node[1]})
    component._configure()
    component._oversubscribe = True
    all_slots = [{'lm_info': 'INFO', 'cores_per_node': 4, 'gpus_per_node': 2, 'nodes': [[0, '0', [[0], [1], [2]], [[0]]]]}, {'lm_info': 'INFO', 'cores_per_node': 4, 'gpus_per_node': 2, 'nodes': [[1, '1', [[0], [1], [2]], [[0]]]]}]
    td = cud_mpi()
    slot = component._allocate_slot(td)
    chk = all_slots[(- 1)]
    assert (slot == chk)
    td = cud_mpi()
    slot = component._allocate_slot(td)
    assert (slot == all_slots[(- 2)])
    with pytest.raises(ValueError):
        td = cud_mpi()
        td['gpu_processes'] = 2
        slot = component._allocate_slot(td)
    td = cud_mpi()
    noslot = component._allocate_slot(td)
    assert (noslot is None)
    component._release_slot(slot)
    td = cud_mpi()
    newslot = component._allocate_slot(td)
    assert (newslot == slot)
    tearDown(session)