@Test
public void testBootstrap() throws ResourceHandlerException {

  // Case 1. auto
  String allowed = "auto";
  configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
  fpgaResourceHandler.bootstrap(configuration);
  // initPlugin() was also called in setup()
  verify(mockVendorPlugin, times(2)).initPlugin(configuration);
  verify(mockCGroupsHandler, times(1)).initializeCGroupController(
      CGroupsHandler.CGroupController.DEVICES);
  Assert.assertEquals(5, fpgaResourceHandler.getFpgaAllocator()
      .getAvailableFpgaCount());
  Assert.assertEquals(5, fpgaResourceHandler.getFpgaAllocator()
      .getAllowedFpga().size());
  // Case 2. subset of devices
  fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
      mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
      fpgaDiscoverer);
  allowed = "0,1,2";
  configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
  fpgaResourceHandler.bootstrap(configuration);
  Assert.assertEquals(3,
      fpgaResourceHandler.getFpgaAllocator().getAllowedFpga().size());
  List<FpgaDevice> allowedDevices =
      fpgaResourceHandler.getFpgaAllocator().getAllowedFpga();
  for (String s : allowed.split(",")) {
    boolean check = false;
    for (FpgaDevice device : allowedDevices) {
      if (String.valueOf(device.getMinor()).equals(s)) {
        check = true;
      }
    }
    Assert.assertTrue("Minor:" + s +" found", check);
  }
  Assert.assertEquals(3,
      fpgaResourceHandler.getFpgaAllocator().getAvailableFpgaCount());
  // Case 3. User configuration contains invalid minor device number
  fpgaResourceHandler = new FpgaResourceHandlerImpl(mockContext,
      mockCGroupsHandler, mockPrivilegedExecutor, mockVendorPlugin,
      fpgaDiscoverer);
  allowed = "0,1,7";
  configuration.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, allowed);
  fpgaResourceHandler.bootstrap(configuration);
  Assert.assertEquals(2,
      fpgaResourceHandler.getFpgaAllocator().getAvailableFpgaCount());
  Assert.assertEquals(2,
      fpgaResourceHandler.getFpgaAllocator().getAllowedFpga().size());
}