|
@@ -71,6 +71,7 @@ public class TestGpuResourceHandler {
|
|
|
private GpuResourceHandlerImpl gpuResourceHandler;
|
|
|
private NMStateStoreService mockNMStateStore;
|
|
|
private ConcurrentHashMap<ContainerId, Container> runningContainersMap;
|
|
|
+ private GpuDiscoverer gpuDiscoverer;
|
|
|
|
|
|
@Before
|
|
|
public void setup() {
|
|
@@ -88,8 +89,9 @@ public class TestGpuResourceHandler {
|
|
|
runningContainersMap = new ConcurrentHashMap<>();
|
|
|
when(nmctx.getContainers()).thenReturn(runningContainersMap);
|
|
|
|
|
|
+ gpuDiscoverer = new GpuDiscoverer();
|
|
|
gpuResourceHandler = new GpuResourceHandlerImpl(nmctx, mockCGroupsHandler,
|
|
|
- mockPrivilegedExecutor);
|
|
|
+ mockPrivilegedExecutor, gpuDiscoverer);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -97,7 +99,7 @@ public class TestGpuResourceHandler {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0");
|
|
|
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
|
verify(mockCGroupsHandler, times(1)).initializeCGroupController(
|
|
@@ -161,7 +163,7 @@ public class TestGpuResourceHandler {
|
|
|
throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4");
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
|
Assert.assertEquals(4,
|
|
@@ -250,7 +252,7 @@ public class TestGpuResourceHandler {
|
|
|
throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4");
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
|
Assert.assertEquals(4,
|
|
@@ -279,7 +281,7 @@ public class TestGpuResourceHandler {
|
|
|
public void testAllocationWithoutAllowedGpus() throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, " ");
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
try {
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
@@ -314,7 +316,7 @@ public class TestGpuResourceHandler {
|
|
|
public void testAllocationStored() throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4");
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
|
Assert.assertEquals(4,
|
|
@@ -360,9 +362,9 @@ public class TestGpuResourceHandler {
|
|
|
|
|
|
GpuResourceHandlerImpl gpuNULLStateResourceHandler =
|
|
|
new GpuResourceHandlerImpl(nmnctx, mockCGroupsHandler,
|
|
|
- mockPrivilegedExecutor);
|
|
|
+ mockPrivilegedExecutor, gpuDiscoverer);
|
|
|
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuNULLStateResourceHandler.bootstrap(conf);
|
|
|
Assert.assertEquals(4,
|
|
@@ -382,7 +384,7 @@ public class TestGpuResourceHandler {
|
|
|
public void testRecoverResourceAllocation() throws Exception {
|
|
|
Configuration conf = new YarnConfiguration();
|
|
|
conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4");
|
|
|
- GpuDiscoverer.getInstance().initialize(conf);
|
|
|
+ gpuDiscoverer.initialize(conf);
|
|
|
|
|
|
gpuResourceHandler.bootstrap(conf);
|
|
|
Assert.assertEquals(4,
|