@Override
  public synchronized NMResourceInfo getNMResourceInfo() throws YarnException {
    final GpuDeviceInformation gpuDeviceInformation;

    if (gpuDiscoverer.isAutoDiscoveryEnabled()) {
      //At this point the gpu plugin is already enabled
      checkGpuResourceHandler();

      checkErrorCount();
      try{
        gpuDeviceInformation = gpuDiscoverer.getGpuDeviceInformation();
        numOfErrorExecutionSinceLastSucceed = 0;
      } catch (YarnException e) {
        LOG.error(e.getMessage(), e);
        numOfErrorExecutionSinceLastSucceed++;
        throw e;
      }
    } else {
      gpuDeviceInformation = null;
    }
    GpuResourceAllocator gpuResourceAllocator =
        gpuResourceHandler.getGpuAllocator();
    List<GpuDevice> totalGpus = gpuResourceAllocator.getAllowedGpus();
    List<AssignedGpuDevice> assignedGpuDevices =
        gpuResourceAllocator.getAssignedGpus();
    return new NMGpuResourceInfo(gpuDeviceInformation, totalGpus,
        assignedGpuDevices);
  }
@Test(expected = YarnException.class)
  public void testResourceHandlerNotInitialized() throws YarnException {
    GpuDiscoverer gpuDiscoverer = createMockDiscoverer();
    GpuNodeResourceUpdateHandler gpuNodeResourceUpdateHandler =
        mock(GpuNodeResourceUpdateHandler.class);

    GpuResourcePlugin target =
        new GpuResourcePlugin(gpuNodeResourceUpdateHandler, gpuDiscoverer);

    target.getNMResourceInfo();
  }