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 92792b7ba64..2cfe6943586 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
@@ -41,6 +41,8 @@
import java.util.Map;
import java.util.Set;
+import static org.apache.hadoop.yarn.server.nodemanager.webapp.dao.gpu.GpuDeviceInformationParser.GPU_SCRIPT_REFERENCE;
+
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class GpuDiscoverer {
@@ -79,6 +81,27 @@ private void validateConfOrThrowException() throws YarnException {
}
}
+ private String getErrorMessageOfScriptExecution(String msg) {
+ return getFailedToExecuteScriptMessage() +
+ "! Exception message: " + msg;
+ }
+
+ private String getErrorMessageOfScriptExecutionThresholdReached() {
+ return getFailedToExecuteScriptMessage() + " for " +
+ MAX_REPEATED_ERROR_ALLOWED + " times, " +
+ "skipping following executions!";
+ }
+
+ private String getFailedToExecuteScriptMessage() {
+ return "Failed to execute " + GPU_SCRIPT_REFERENCE +
+ " (" + pathOfGpuBinary + ")";
+ }
+
+ private String getFailedToParseErrorMessage(String msg) {
+ return "Failed to parse XML output of " + GPU_SCRIPT_REFERENCE
+ + "( " + pathOfGpuBinary + ")" + msg;
+ }
+
/**
* Get GPU device information from system.
* This need to be called after initialize.
@@ -100,10 +123,7 @@ synchronized GpuDeviceInformation getGpuDeviceInformation()
}
if (numOfErrorExecutionSinceLastSucceed == MAX_REPEATED_ERROR_ALLOWED) {
- String msg =
- "Failed to execute GPU device information detection script for "
- + MAX_REPEATED_ERROR_ALLOWED
- + " times, skip following executions.";
+ final String msg = getErrorMessageOfScriptExecutionThresholdReached();
LOG.error(msg);
throw new YarnException(msg);
}
@@ -117,16 +137,14 @@ synchronized GpuDeviceInformation getGpuDeviceInformation()
return lastDiscoveredGpuInformation;
} catch (IOException e) {
numOfErrorExecutionSinceLastSucceed++;
- String msg =
- "Failed to execute " + pathOfGpuBinary + " exception message:" + e
- .getMessage() + ", continue ...";
+ final String msg = getErrorMessageOfScriptExecution(e.getMessage());
if (LOG.isDebugEnabled()) {
LOG.debug(msg);
}
- throw new YarnException(e);
+ throw new YarnException(msg, e);
} catch (YarnException e) {
numOfErrorExecutionSinceLastSucceed++;
- String msg = "Failed to parse xml output" + e.getMessage();
+ String msg = getFailedToParseErrorMessage(e.getMessage());
if (LOG.isDebugEnabled()) {
LOG.warn(msg, e);
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/gpu/GpuDeviceInformationParser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/gpu/GpuDeviceInformationParser.java
index 1bd92f63a88..894cb70ca61 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/gpu/GpuDeviceInformationParser.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/gpu/GpuDeviceInformationParser.java
@@ -43,6 +43,8 @@
public class GpuDeviceInformationParser {
private static final Logger LOG = LoggerFactory.getLogger(
GpuDeviceInformationParser.class);
+ public static final String GPU_SCRIPT_REFERENCE = "GPU device detection " +
+ "script";
private Unmarshaller unmarshaller = null;
private XMLReader xmlReader = null;
@@ -70,7 +72,9 @@ public synchronized GpuDeviceInformation parseXml(String xmlContent)
try {
init();
} catch (SAXException | ParserConfigurationException | JAXBException e) {
- LOG.error("Exception while initialize parser", e);
+ String msg = "Exception while initializing parser for " +
+ GPU_SCRIPT_REFERENCE;
+ LOG.error(msg, e);
throw new YarnException(e);
}
}
@@ -80,8 +84,10 @@ public synchronized GpuDeviceInformation parseXml(String xmlContent)
try {
return (GpuDeviceInformation) unmarshaller.unmarshal(source);
} catch (JAXBException e) {
- LOG.error("Exception while parsing xml", e);
- throw new YarnException(e);
+ String msg = "Failed to parse XML output of " +
+ GPU_SCRIPT_REFERENCE + "!";
+ LOG.error(msg, e);
+ throw new YarnException(msg, e);
}
}
}
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/resourceplugin/gpu/TestGpuDiscoverer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java
index cbbfded374d..4dad37ff12d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java
@@ -20,6 +20,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.util.Shell;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.nodemanager.webapp.dao.gpu.GpuDeviceInformation;
@@ -28,34 +29,49 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.List;
+import java.util.function.Consumer;
+import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
+import static org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.gpu.GpuDiscoverer.DEFAULT_BINARY_NAME;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class TestGpuDiscoverer {
- @Rule
- public ExpectedException exception = ExpectedException.none();
+ private static final Logger LOG = LoggerFactory.getLogger(
+ TestGpuDiscoverer.class);
- private String getTestParentFolder() {
- File f = new File("target/temp/" + TestGpuDiscoverer.class.getName());
- return f.getAbsolutePath();
- }
+ private static final String PATH = "PATH";
+ private static final String NVIDIA = "nvidia";
+ private static final String EXEC_PERMISSION = "u+x";
+ private static final String BASH_SHEBANG = "#!/bin/bash\n\n";
+ private static final String TEST_PARENT_DIR = new File("target/temp/" +
+ TestGpuDiscoverer.class.getName()).getAbsolutePath();
private void touchFile(File f) throws IOException {
new FileOutputStream(f).close();
}
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
@Before
public void before() throws IOException {
- String folder = getTestParentFolder();
- File f = new File(folder);
+ assumeNotWindows();
+ File f = new File(TEST_PARENT_DIR);
FileUtils.deleteDirectory(f);
f.mkdirs();
}
@@ -66,6 +82,55 @@ private Configuration createConfigWithAllowedDevices(String s) {
return conf;
}
+ private void createNvidiaSmiScript(File file) {
+ writeToFile(file, BASH_SHEBANG +
+ "echo ''");
+ }
+
+ private void createFaultyNvidiaSmiScript(File file) {
+ writeToFile(file, BASH_SHEBANG + "echo <<'");
+ }
+
+ private void createNvidiaSmiScriptWithInvalidXml(File file) {
+ writeToFile(file, BASH_SHEBANG + "echo ''");
+ }
+
+ private static void writeToFile(File file, String contents) {
+ try {
+ PrintWriter fileWriter = new PrintWriter(file);
+ fileWriter.write(contents);
+ fileWriter.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Error while writing nvidia-smi script file!",
+ e);
+ }
+ }
+
+ private void assertNvidiaIsOnPath(GpuDiscoverer testSubject) {
+ String path = testSubject.getEnvironmentToRunCommand().get(PATH);
+ assertNotNull(path);
+ assertTrue(path.contains(NVIDIA));
+ }
+
+ private File createFakeNvidiaSmiScriptAsRunnableFile(
+ Consumer scriptFileCreator) throws IOException {
+ File fakeBinary = new File(TEST_PARENT_DIR, DEFAULT_BINARY_NAME);
+ touchFile(fakeBinary);
+ scriptFileCreator.accept(fakeBinary);
+ Shell.execCommand(Shell.getSetPermissionCommand(EXEC_PERMISSION, false,
+ fakeBinary.getAbsolutePath()));
+
+ return fakeBinary;
+ }
+
+ private GpuDiscoverer createTestSubjectWithGpuPathDefined(
+ Configuration conf) {
+ conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, TEST_PARENT_DIR);
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ return testSubject;
+ }
+
@Test
public void testLinuxGpuResourceDiscoverPluginConfig() throws Exception {
// Only run this on demand.
@@ -74,34 +139,152 @@ public void testLinuxGpuResourceDiscoverPluginConfig() throws Exception {
// test case 1, check default setting.
Configuration conf = new Configuration(false);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- assertEquals(GpuDiscoverer.DEFAULT_BINARY_NAME,
- plugin.getPathOfGpuBinary());
- assertNotNull(plugin.getEnvironmentToRunCommand().get("PATH"));
- assertTrue(
- plugin.getEnvironmentToRunCommand().get("PATH").contains("nvidia"));
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ assertEquals(DEFAULT_BINARY_NAME, testSubject.getPathOfGpuBinary());
+ assertNvidiaIsOnPath(testSubject);
// test case 2, check mandatory set path.
- File fakeBinary = new File(getTestParentFolder(),
- GpuDiscoverer.DEFAULT_BINARY_NAME);
+ File fakeBinary = new File(TEST_PARENT_DIR, DEFAULT_BINARY_NAME);
touchFile(fakeBinary);
- conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, getTestParentFolder());
- plugin = new GpuDiscoverer();
- plugin.initialize(conf);
+ conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, TEST_PARENT_DIR);
+ testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
assertEquals(fakeBinary.getAbsolutePath(),
- plugin.getPathOfGpuBinary());
- assertNull(plugin.getEnvironmentToRunCommand().get("PATH"));
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
- // test case 3, check mandatory set path, but binary doesn't exist so default
- // path will be used.
+ // test case 3, check mandatory set path,
+ // but binary doesn't exist so default path will be used.
fakeBinary.delete();
- plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- assertEquals(GpuDiscoverer.DEFAULT_BINARY_NAME,
- plugin.getPathOfGpuBinary());
- assertTrue(
- plugin.getEnvironmentToRunCommand().get("PATH").contains("nvidia"));
+ testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ assertEquals(DEFAULT_BINARY_NAME,
+ testSubject.getPathOfGpuBinary());
+ assertNvidiaIsOnPath(testSubject);
+ }
+
+ @Test
+ public void testGetGpuDeviceInformationValidNvidiaSmiScript()
+ throws YarnException, IOException {
+ Configuration conf = new Configuration(false);
+
+ File fakeBinary = createFakeNvidiaSmiScriptAsRunnableFile(
+ this::createNvidiaSmiScript);
+
+ GpuDiscoverer testSubject = createTestSubjectWithGpuPathDefined(conf);
+ assertEquals(fakeBinary.getAbsolutePath(),
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
+
+ GpuDeviceInformation result =
+ testSubject.getGpuDeviceInformation();
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetGpuDeviceInformationFakeNvidiaSmiScriptConsecutiveRun()
+ throws YarnException, IOException {
+ Configuration conf = new Configuration(false);
+
+ File fakeBinary = createFakeNvidiaSmiScriptAsRunnableFile(
+ this::createNvidiaSmiScript);
+
+ GpuDiscoverer testSubject = createTestSubjectWithGpuPathDefined(conf);
+ assertEquals(fakeBinary.getAbsolutePath(),
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
+
+ for (int i = 0; i < 5; i++) {
+ GpuDeviceInformation result = testSubject.getGpuDeviceInformation();
+ assertNotNull(result);
+ }
+ }
+
+ @Test
+ public void testGetGpuDeviceInformationFaultyNvidiaSmiScript()
+ throws YarnException, IOException {
+ Configuration conf = new Configuration(false);
+
+ File fakeBinary = createFakeNvidiaSmiScriptAsRunnableFile(
+ this::createFaultyNvidiaSmiScript);
+
+ GpuDiscoverer testSubject = createTestSubjectWithGpuPathDefined(conf);
+ assertEquals(fakeBinary.getAbsolutePath(),
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
+
+ exception.expect(YarnException.class);
+ exception.expectMessage("Failed to execute GPU device detection script");
+ testSubject.getGpuDeviceInformation();
+ }
+
+ @Test
+ public void testGetGpuDeviceInformationFaultyNvidiaSmiScriptConsecutiveRun()
+ throws YarnException, IOException {
+ Configuration conf = new Configuration(false);
+
+ File fakeBinary = createFakeNvidiaSmiScriptAsRunnableFile(
+ this::createNvidiaSmiScript);
+
+ GpuDiscoverer testSubject = createTestSubjectWithGpuPathDefined(conf);
+ assertEquals(fakeBinary.getAbsolutePath(),
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
+
+ LOG.debug("Querying nvidia-smi correctly, once...");
+ testSubject.getGpuDeviceInformation();
+
+ //replace script with faulty one
+ createFaultyNvidiaSmiScript(fakeBinary);
+
+ final String terminateMsg = "Failed to execute GPU device " +
+ "detection script (" + fakeBinary.getAbsolutePath() + ") for 10 times";
+ final String msg = "Failed to execute GPU device detection script";
+
+ for (int i = 0; i < 10; i++) {
+ try {
+ LOG.debug("Executing faulty nvidia-smi script...");
+ testSubject.getGpuDeviceInformation();
+ fail("Query of GPU device info via nvidia-smi should fail as " +
+ "script should be faulty: " + fakeBinary);
+ } catch (YarnException e) {
+ assertThat(e.getMessage(), containsString(msg));
+ assertThat(e.getMessage(), not(containsString(terminateMsg)));
+ }
+ }
+
+ try {
+ LOG.debug("Executing faulty nvidia-smi script again..." +
+ "We should reach the error threshold now!");
+ testSubject.getGpuDeviceInformation();
+ fail("Query of GPU device info via nvidia-smi should fail as " +
+ "script should be faulty: " + fakeBinary);
+ } catch (YarnException e) {
+ assertThat(e.getMessage(), containsString(terminateMsg));
+ }
+
+ //verify if GPUs are still hold the value of first successful query
+ assertNotNull(testSubject.getGpusUsableByYarn());
+ }
+
+ @Test
+ public void testGetGpuDeviceInformationNvidiaSmiScriptWithInvalidXml()
+ throws YarnException, IOException {
+ Configuration conf = new Configuration(false);
+
+ File fakeBinary = createFakeNvidiaSmiScriptAsRunnableFile(
+ this::createNvidiaSmiScriptWithInvalidXml);
+
+ GpuDiscoverer testSubject = createTestSubjectWithGpuPathDefined(conf);
+ assertEquals(fakeBinary.getAbsolutePath(),
+ testSubject.getPathOfGpuBinary());
+ assertNull(testSubject.getEnvironmentToRunCommand().get(PATH));
+
+ exception.expect(YarnException.class);
+ exception.expectMessage("Failed to parse XML output of " +
+ "GPU device detection script");
+ testSubject.getGpuDeviceInformation();
}
@Test
@@ -111,12 +294,12 @@ public void testGpuDiscover() throws YarnException {
Assume.assumeTrue(
Boolean.valueOf(System.getProperty("runGpuDiscoverUnitTest")));
Configuration conf = new Configuration(false);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- GpuDeviceInformation info = plugin.getGpuDeviceInformation();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ GpuDeviceInformation info = testSubject.getGpuDeviceInformation();
assertTrue(info.getGpus().size() > 0);
- assertEquals(plugin.getGpusUsableByYarn().size(),
+ assertEquals(testSubject.getGpusUsableByYarn().size(),
info.getGpus().size());
}
@@ -125,9 +308,9 @@ public void testGetNumberOfUsableGpusFromConfigSingleDevice()
throws YarnException {
Configuration conf = createConfigWithAllowedDevices("1:2");
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- List usableGpuDevices = plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ List usableGpuDevices = testSubject.getGpusUsableByYarn();
assertEquals(1, usableGpuDevices.size());
assertEquals(1, usableGpuDevices.get(0).getIndex());
@@ -140,18 +323,18 @@ public void testGetNumberOfUsableGpusFromConfigIllegalFormat()
Configuration conf = createConfigWithAllowedDevices("0:0,1:1,2:2,3");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
public void testGetNumberOfUsableGpusFromConfig() throws YarnException {
Configuration conf = createConfigWithAllowedDevices("0:0,1:1,2:2,3:4");
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
- List usableGpuDevices = plugin.getGpusUsableByYarn();
+ List usableGpuDevices = testSubject.getGpusUsableByYarn();
assertEquals(4, usableGpuDevices.size());
assertEquals(0, usableGpuDevices.get(0).getIndex());
@@ -173,9 +356,9 @@ public void testGetNumberOfUsableGpusFromConfigDuplicateValues()
Configuration conf = createConfigWithAllowedDevices("0:0,1:1,2:2,1:1");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -184,9 +367,9 @@ public void testGetNumberOfUsableGpusFromConfigDuplicateValues2()
Configuration conf = createConfigWithAllowedDevices("0:0,1:1,2:2,1:1,2:2");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -195,9 +378,9 @@ public void testGetNumberOfUsableGpusFromConfigIncludingSpaces()
Configuration conf = createConfigWithAllowedDevices("0 : 0,1 : 1");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -206,9 +389,9 @@ public void testGetNumberOfUsableGpusFromConfigIncludingGibberish()
Configuration conf = createConfigWithAllowedDevices("0:@$1,1:1");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -217,9 +400,9 @@ public void testGetNumberOfUsableGpusFromConfigIncludingLetters()
Configuration conf = createConfigWithAllowedDevices("x:0, 1:y");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -228,9 +411,9 @@ public void testGetNumberOfUsableGpusFromConfigWithoutIndexNumber()
Configuration conf = createConfigWithAllowedDevices(":0, :1");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -239,9 +422,9 @@ public void testGetNumberOfUsableGpusFromConfigEmptyString()
Configuration conf = createConfigWithAllowedDevices("");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -250,9 +433,9 @@ public void testGetNumberOfUsableGpusFromConfigValueWithoutComma()
Configuration conf = createConfigWithAllowedDevices("0:0 0:1");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -261,9 +444,9 @@ public void testGetNumberOfUsableGpusFromConfigValueWithoutComma2()
Configuration conf = createConfigWithAllowedDevices("0.1 0.2");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
@Test
@@ -272,8 +455,8 @@ public void testGetNumberOfUsableGpusFromConfigValueWithoutColonSeparator()
Configuration conf = createConfigWithAllowedDevices("0.1,0.2");
exception.expect(GpuDeviceSpecificationException.class);
- GpuDiscoverer plugin = new GpuDiscoverer();
- plugin.initialize(conf);
- plugin.getGpusUsableByYarn();
+ GpuDiscoverer testSubject = new GpuDiscoverer();
+ testSubject.initialize(conf);
+ testSubject.getGpusUsableByYarn();
}
}