diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/GpuResourceHandlerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/GpuResourceHandlerImpl.java index 0bedf63df14..f8adbe743f2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/GpuResourceHandlerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/GpuResourceHandlerImpl.java @@ -67,8 +67,7 @@ public GpuResourceHandlerImpl(Context nmContext, throws ResourceHandlerException { List usableGpus; try { - usableGpus = GpuDiscoverer.getInstance() - .getGpusUsableByYarn(); + usableGpus = GpuDiscoverer.getInstance().getGpusUsableByYarn(); if (usableGpus == null || usableGpus.isEmpty()) { String message = "GPU is enabled on the NodeManager, but couldn't find " + "any usable GPU devices, please double check configuration."; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java index 6e3cf1315ce..c5131a3a350 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java @@ -58,7 +58,10 @@ // command should not run more than 10 sec. private static final int MAX_EXEC_TIMEOUT_MS = 10 * 1000; private static final int MAX_REPEATED_ERROR_ALLOWED = 10; - private static GpuDiscoverer instance; + + @VisibleForTesting + //TODO this should be an simple non-static field, see: YARN-9121 + public static GpuDiscoverer instance; static { instance = new GpuDiscoverer(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/TestGpuResourceHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/TestGpuResourceHandler.java index 3b1f2a9fb49..f4b0d347401 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/TestGpuResourceHandler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/gpu/TestGpuResourceHandler.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.gpu; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; @@ -27,6 +29,7 @@ import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.ResourceInformation; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.nodemanager.Context; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ResourceMappings; @@ -41,27 +44,31 @@ import org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService; import org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService; import org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider; +import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import java.io.IOException; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyList; +import static org.mockito.Matchers.anyListOf; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -72,6 +79,9 @@ private NMStateStoreService mockNMStateStore; private ConcurrentHashMap runningContainersMap; + @Rule + public ExpectedException expected = ExpectedException.none(); + @Before public void setup() { CustomResourceTypesConfigurationProvider. @@ -93,55 +103,67 @@ public void setup() { mockPrivilegedExecutor); } + @After + public void cleanUp() { + GpuDiscoverer.instance = new GpuDiscoverer(); + } + @Test - public void testBootStrap() throws Exception { + public void testBootstrapWithRealGpuDiscoverer() throws Exception { Configuration conf = new YarnConfiguration(); conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0"); - GpuDiscoverer.getInstance().initialize(conf); gpuResourceHandler.bootstrap(conf); - verify(mockCGroupsHandler, times(1)).initializeCGroupController( + + List allowedGpus = + gpuResourceHandler.getGpuAllocator().getAllowedGpusCopy(); + assertEquals(1, allowedGpus.size()); + assertEquals(new GpuDevice(0, 0), allowedGpus.get(0)); + verify(mockCGroupsHandler).initializeCGroupController( CGroupsHandler.CGroupController.DEVICES); } + @Test + public void testBootstrapWithMockGpuDiscoverer() throws Exception { + GpuDiscoverer.instance = mock(GpuDiscoverer.class); + Configuration conf = new YarnConfiguration(); + GpuDiscoverer.getInstance().initialize(conf); + + expected.expect(ResourceHandlerException.class); + gpuResourceHandler.bootstrap(conf); + } + private static ContainerId getContainerId(int id) { return ContainerId.newContainerId(ApplicationAttemptId .newInstance(ApplicationId.newInstance(1234L, 1), 1), id); } - private static Container mockContainerWithGpuRequest(int id, int numGpuRequest, - boolean dockerContainerEnabled) { + private static Container mockContainerWithGpuRequest(int id, Resource res, + ContainerLaunchContext launchContext) { Container c = mock(Container.class); when(c.getContainerId()).thenReturn(getContainerId(id)); + when(c.getResource()).thenReturn(res); + when(c.getResourceMappings()).thenReturn(new ResourceMappings()); + when(c.getLaunchContext()).thenReturn(launchContext); + return c; + } + private static Resource createResourceRequest(int numGpuRequest) { Resource res = Resource.newInstance(1024, 1); - ResourceMappings resMapping = new ResourceMappings(); - res.setResourceValue(ResourceInformation.GPU_URI, numGpuRequest); - when(c.getResource()).thenReturn(res); - when(c.getResourceMappings()).thenReturn(resMapping); - - ContainerLaunchContext clc = mock(ContainerLaunchContext.class); - Map env = new HashMap<>(); - if (dockerContainerEnabled) { - env.put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, - ContainerRuntimeConstants.CONTAINER_RUNTIME_DOCKER); - } - when(clc.getEnvironment()).thenReturn(env); - when(c.getLaunchContext()).thenReturn(clc); - return c; + return res; } private static Container mockContainerWithGpuRequest(int id, - int numGpuRequest) { - return mockContainerWithGpuRequest(id, numGpuRequest, false); + Resource res) { + return mockContainerWithGpuRequest(id, res, createLaunchContext()); } private void verifyDeniedDevices(ContainerId containerId, List deniedDevices) throws ResourceHandlerException, PrivilegedOperationException { - verify(mockCGroupsHandler, times(1)).createCGroup( + verify(mockCGroupsHandler).createCGroup( CGroupsHandler.CGroupController.DEVICES, containerId.toString()); if (null != deniedDevices && !deniedDevices.isEmpty()) { @@ -149,7 +171,7 @@ private void verifyDeniedDevices(ContainerId containerId, for (GpuDevice deniedDevice : deniedDevices) { deniedDevicesMinorNumber.add(deniedDevice.getMinorNumber()); } - verify(mockPrivilegedExecutor, times(1)).executePrivilegedOperation( + verify(mockPrivilegedExecutor).executePrivilegedOperation( new PrivilegedOperation(PrivilegedOperation.OperationType.GPU, Arrays .asList(GpuResourceHandlerImpl.CONTAINER_ID_CLI_OPTION, containerId.toString(), @@ -158,122 +180,161 @@ private void verifyDeniedDevices(ContainerId containerId, } } - private void commonTestAllocation(boolean dockerContainerEnabled) - 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); + private static ContainerLaunchContext createLaunchContextDocker() { + ContainerLaunchContext launchContext = mock(ContainerLaunchContext.class); + ImmutableMap env = ImmutableMap.builder() + .put(ContainerRuntimeConstants.ENV_CONTAINER_TYPE, + ContainerRuntimeConstants.CONTAINER_RUNTIME_DOCKER) + .build(); + when(launchContext.getEnvironment()).thenReturn(env); + return launchContext; + } - gpuResourceHandler.bootstrap(conf); - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + private static ContainerLaunchContext createLaunchContext() { + ContainerLaunchContext launchContext = mock(ContainerLaunchContext.class); + when(launchContext.getEnvironment()).thenReturn(Maps.newHashMap()); + return launchContext; + } - /* Start container 1, asks 3 containers */ - gpuResourceHandler.preStart( - mockContainerWithGpuRequest(1, 3, dockerContainerEnabled)); + private void testAllocationWithDocker() + throws Exception { + initializeGpus(); - // Only device=4 will be blocked. - if (dockerContainerEnabled) { - verifyDeniedDevices(getContainerId(1), Collections.emptyList()); - } else{ - verifyDeniedDevices(getContainerId(1), Arrays.asList(new GpuDevice(3,4))); - } + startContainerWithGpuRequestsDocker(1, 3); + verifyDeniedDevices(getContainerId(1), Collections.emptyList()); /* Start container 2, asks 2 containers. Excepted to fail */ boolean failedToAllocate = false; try { - gpuResourceHandler.preStart( - mockContainerWithGpuRequest(2, 2, dockerContainerEnabled)); + startContainerWithGpuRequestsDocker(2, 2); } catch (ResourceHandlerException e) { failedToAllocate = true; } Assert.assertTrue(failedToAllocate); - /* Start container 3, ask 1 container, succeeded */ - gpuResourceHandler.preStart( - mockContainerWithGpuRequest(3, 1, dockerContainerEnabled)); + startContainerWithGpuRequestsDocker(3, 1); + verifyDeniedDevices(getContainerId(3), Collections.emptyList()); - // devices = 0/1/3 will be blocked - if (dockerContainerEnabled) { - verifyDeniedDevices(getContainerId(3), Collections.emptyList()); - } else { - verifyDeniedDevices(getContainerId(3), Arrays - .asList(new GpuDevice(0, 0), new GpuDevice(1, 1), - new GpuDevice(2, 3))); - } + startContainerWithGpuRequestsDocker(4, 0); + verifyDeniedDevices(getContainerId(4), Collections.emptyList()); + + gpuResourceHandler.postComplete(getContainerId(1)); + verifyCgroupsDeletedForContainer(1); + verifyNumberOfAvailableGpus(3, gpuResourceHandler); + gpuResourceHandler.postComplete(getContainerId(3)); + verifyCgroupsDeletedForContainer(3); + verifyNumberOfAvailableGpus(4, gpuResourceHandler); + } - /* Start container 4, ask 0 container, succeeded */ + private void startContainerWithGpuRequestsDocker(int id, int gpus) + throws ResourceHandlerException { gpuResourceHandler.preStart( - mockContainerWithGpuRequest(4, 0, dockerContainerEnabled)); - - if (dockerContainerEnabled) { - verifyDeniedDevices(getContainerId(4), Collections.emptyList()); - } else{ - // All devices will be blocked - verifyDeniedDevices(getContainerId(4), Arrays - .asList(new GpuDevice(0, 0), new GpuDevice(1, 1), new GpuDevice(2, 3), - new GpuDevice(3, 4))); + mockContainerWithGpuRequest(id, createResourceRequest(gpus), + createLaunchContextDocker())); + } + + private void startContainerWithGpuRequests(int id, int gpus) + throws ResourceHandlerException { + gpuResourceHandler.preStart( + mockContainerWithGpuRequest(id, createResourceRequest(gpus), + createLaunchContext())); + } + + private void testAllocationWithoutDocker() + throws Exception { + initializeGpus(); + + //Start container 1, asks 3 containers --> Only device=4 will be blocked. + startContainerWithGpuRequests(1, 3); + verifyDeniedDevices(getContainerId(1), + Collections.singletonList(new GpuDevice(3, 4))); + + /* Start container 2, asks 2 containers. Excepted to fail */ + boolean failedToAllocate = false; + try { + startContainerWithGpuRequests(2, 2); + } catch (ResourceHandlerException e) { + failedToAllocate = true; } + Assert.assertTrue(failedToAllocate); - /* Release container-1, expect cgroups deleted */ - gpuResourceHandler.postComplete(getContainerId(1)); + // Start container 3, ask 1 container, succeeded + // devices = 0/1/3 will be blocked + startContainerWithGpuRequests(3, 1); + verifyDeniedDevices(getContainerId(3), Arrays.asList(new GpuDevice(0, 0), + new GpuDevice(1, 1), new GpuDevice(2, 3))); - verify(mockCGroupsHandler, times(1)).createCGroup( - CGroupsHandler.CGroupController.DEVICES, getContainerId(1).toString()); - Assert.assertEquals(3, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + // Start container 4, ask 0 container, succeeded + // --> All devices will be blocked + startContainerWithGpuRequests(4, 0); + verifyDeniedDevices(getContainerId(4), Arrays.asList(new GpuDevice(0, 0), + new GpuDevice(1, 1), new GpuDevice(2, 3), new GpuDevice(3, 4))); + + gpuResourceHandler.postComplete(getContainerId(1)); + verifyCgroupsDeletedForContainer(1); + verifyNumberOfAvailableGpus(3, gpuResourceHandler); - /* Release container-3, expect cgroups deleted */ gpuResourceHandler.postComplete(getContainerId(3)); + verifyCgroupsDeletedForContainer(3); + verifyNumberOfAvailableGpus(4, gpuResourceHandler); + } + + private void verifyNumberOfAvailableGpus(int i, + GpuResourceHandlerImpl resourceHandler) { + assertEquals(i, + resourceHandler.getGpuAllocator().getAvailableGpus()); + } - verify(mockCGroupsHandler, times(1)).createCGroup( - CGroupsHandler.CGroupController.DEVICES, getContainerId(3).toString()); - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + private void verifyCgroupsDeletedForContainer(int i) + throws ResourceHandlerException { + verify(mockCGroupsHandler).createCGroup( + CGroupsHandler.CGroupController.DEVICES, getContainerId(i).toString()); + } + + private void initializeGpus() throws YarnException { + Configuration conf = new YarnConfiguration(); + conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4"); + GpuDiscoverer.getInstance().initialize(conf); + + gpuResourceHandler.bootstrap(conf); + verifyNumberOfAvailableGpus(4, gpuResourceHandler); } @Test public void testAllocationWhenDockerContainerEnabled() throws Exception { // When docker container is enabled, no devices should be written to // devices.deny. - commonTestAllocation(true); + testAllocationWithDocker(); } @Test public void testAllocation() throws Exception { - commonTestAllocation(false); + testAllocationWithoutDocker(); } - @SuppressWarnings("unchecked") @Test - public void testAssignedGpuWillBeCleanedupWhenStoreOpFails() + public void testAssignedGpuWillBeCleanedUpWhenStoreOpFails() 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); - - gpuResourceHandler.bootstrap(conf); - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + initializeGpus(); doThrow(new IOException("Exception ...")).when(mockNMStateStore) .storeAssignedResources( - any(Container.class), anyString(), anyList()); + any(Container.class), anyString(), anyListOf(Serializable.class)); boolean exception = false; /* Start container 1, asks 3 containers */ try { - gpuResourceHandler.preStart(mockContainerWithGpuRequest(1, 3)); + gpuResourceHandler.preStart(mockContainerWithGpuRequest(1, + createResourceRequest(3))); } catch (ResourceHandlerException e) { exception = true; } Assert.assertTrue("preStart should throw exception", exception); - // After preStart, we still have 4 available GPU since the store op fails. - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + // After preStart, we still have 4 available GPU since the store op failed. + verifyNumberOfAvailableGpus(4, gpuResourceHandler); } @Test @@ -290,13 +351,15 @@ public void testAllocationWithoutAllowedGpus() throws Exception { } /* Start container 1, asks 0 containers */ - gpuResourceHandler.preStart(mockContainerWithGpuRequest(1, 0)); + gpuResourceHandler.preStart(mockContainerWithGpuRequest(1, + createResourceRequest(0))); verifyDeniedDevices(getContainerId(1), Collections.emptyList()); /* Start container 2, asks 1 containers. Excepted to fail */ boolean failedToAllocate = false; try { - gpuResourceHandler.preStart(mockContainerWithGpuRequest(2, 1)); + gpuResourceHandler.preStart(mockContainerWithGpuRequest(2, + createResourceRequest(1))); } catch (ResourceHandlerException e) { failedToAllocate = true; } @@ -305,24 +368,17 @@ public void testAllocationWithoutAllowedGpus() throws Exception { /* Release container 1, expect cgroups deleted */ gpuResourceHandler.postComplete(getContainerId(1)); - verify(mockCGroupsHandler, times(1)).createCGroup( - CGroupsHandler.CGroupController.DEVICES, getContainerId(1).toString()); - Assert.assertEquals(0, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + verifyCgroupsDeletedForContainer(1); + verifyNumberOfAvailableGpus(0, gpuResourceHandler); } @Test 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); - - gpuResourceHandler.bootstrap(conf); - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + initializeGpus(); /* Start container 1, asks 3 containers */ - Container container = mockContainerWithGpuRequest(1, 3); + Container container = mockContainerWithGpuRequest(1, + createResourceRequest(3)); gpuResourceHandler.preStart(container); verify(mockNMStateStore).storeAssignedResources(container, @@ -334,13 +390,13 @@ public void testAllocationStored() throws Exception { verifyDeniedDevices(getContainerId(1), Arrays.asList(new GpuDevice(3, 4))); /* Start container 2, ask 0 container, succeeded */ - container = mockContainerWithGpuRequest(2, 0); + container = mockContainerWithGpuRequest(2, createResourceRequest(0)); gpuResourceHandler.preStart(container); verifyDeniedDevices(getContainerId(2), Arrays .asList(new GpuDevice(0, 0), new GpuDevice(1, 1), new GpuDevice(2, 3), new GpuDevice(3, 4))); - Assert.assertEquals(0, container.getResourceMappings() + assertEquals(0, container.getResourceMappings() .getAssignedResources(ResourceInformation.GPU_URI).size()); // Store assigned resource will not be invoked. @@ -350,7 +406,8 @@ public void testAllocationStored() throws Exception { @Test public void testAllocationStoredWithNULLStateStore() throws Exception { - NMNullStateStoreService mockNMNULLStateStore = mock(NMNullStateStoreService.class); + NMNullStateStoreService mockNMNULLStateStore = + mock(NMNullStateStoreService.class); Configuration conf = new YarnConfiguration(); conf.set(YarnConfiguration.NM_GPU_ALLOWED_DEVICES, "0:0,1:1,2:3,3:4"); @@ -366,11 +423,11 @@ public void testAllocationStoredWithNULLStateStore() throws Exception { GpuDiscoverer.getInstance().initialize(conf); gpuNULLStateResourceHandler.bootstrap(conf); - Assert.assertEquals(4, - gpuNULLStateResourceHandler.getGpuAllocator().getAvailableGpus()); + verifyNumberOfAvailableGpus(4, gpuNULLStateResourceHandler); /* Start container 1, asks 3 containers */ - Container container = mockContainerWithGpuRequest(1, 3); + Container container = mockContainerWithGpuRequest(1, + createResourceRequest(3)); gpuNULLStateResourceHandler.preStart(container); verify(nmnctx.getNMStateStore()).storeAssignedResources(container, @@ -381,13 +438,7 @@ public void testAllocationStoredWithNULLStateStore() throws Exception { @Test 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); - - gpuResourceHandler.bootstrap(conf); - Assert.assertEquals(4, - gpuResourceHandler.getGpuAllocator().getAvailableGpus()); + initializeGpus(); Container nmContainer = mock(Container.class); ResourceMappings rmap = new ResourceMappings(); @@ -406,12 +457,12 @@ public void testRecoverResourceAllocation() throws Exception { Map deviceAllocationMapping = gpuResourceHandler.getGpuAllocator().getDeviceAllocationMappingCopy(); - Assert.assertEquals(2, deviceAllocationMapping.size()); + assertEquals(2, deviceAllocationMapping.size()); Assert.assertTrue( deviceAllocationMapping.keySet().contains(new GpuDevice(1, 1))); Assert.assertTrue( deviceAllocationMapping.keySet().contains(new GpuDevice(2, 3))); - Assert.assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), + assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), getContainerId(1)); // TEST CASE @@ -440,10 +491,10 @@ public void testRecoverResourceAllocation() throws Exception { // Make sure internal state not changed. deviceAllocationMapping = gpuResourceHandler.getGpuAllocator().getDeviceAllocationMappingCopy(); - Assert.assertEquals(2, deviceAllocationMapping.size()); + assertEquals(2, deviceAllocationMapping.size()); Assert.assertTrue(deviceAllocationMapping.keySet() .containsAll(Arrays.asList(new GpuDevice(1, 1), new GpuDevice(2, 3)))); - Assert.assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), + assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), getContainerId(1)); // TEST CASE @@ -472,10 +523,10 @@ public void testRecoverResourceAllocation() throws Exception { // Make sure internal state not changed. deviceAllocationMapping = gpuResourceHandler.getGpuAllocator().getDeviceAllocationMappingCopy(); - Assert.assertEquals(2, deviceAllocationMapping.size()); + assertEquals(2, deviceAllocationMapping.size()); Assert.assertTrue(deviceAllocationMapping.keySet() .containsAll(Arrays.asList(new GpuDevice(1, 1), new GpuDevice(2, 3)))); - Assert.assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), + assertEquals(deviceAllocationMapping.get(new GpuDevice(1, 1)), getContainerId(1)); } }