@Test
public void testAssignedGpuWillBeCleanedUpWhenStoreOpFails()
    throws Exception {

  initializeGpus();
  doThrow(new IOException("Exception ...")).when(mockNMStateStore)
      .storeAssignedResources(
      any(Container.class), anyString(), anyList());
  boolean exception = false;
  /* Start container 1, asks 3 containers */
  try {
    gpuResourceHandler.preStart(mockContainerWithGpuRequest(1,
        createResourceRequest(3)));
  } catch (ResourceHandlerException e) {
    exception = true;
  }
  assertTrue("preStart should throw exception", exception);
  // After preStart, we still have 4 available GPU since the store op failed.
  verifyNumberOfAvailableGpus(4, gpuResourceHandler);
}