FpgaDiscoverer extends Configured { public void initialize(Configuration config) throws YarnException { setConf(config); this.plugin.initPlugin(config); LOG.info("Trying to diagnose FPGA information ..."); if (!diagnose()) { LOG.warn("Failed to pass FPGA devices diagnose"); } }  List<FpgaDevice> getCurrentFpgaInfo(); void setResourceHanderPlugin(AbstractFpgaVendorPlugin vendorPlugin); boolean diagnose(); void initialize(Configuration config); List<FpgaDevice> discover(); static final int MAX_EXEC_TIMEOUT_MS; }
@Test public void testExecutablePathWithoutExplicitConfig() throws YarnException { fpgaDiscoverer.initialize(conf); assertEquals("No configuration(no environment ALTERAOCLSDKROOT set)" + " should return just a single binary name", "aocl", openclPlugin.getPathToExecutable()); }
@Test public void testExecutablePathWithCorrectConfig() throws IOException, YarnException { fakeBinary = new File(getTestParentFolder() + "/aocl"); conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, getTestParentFolder() + "/aocl"); touchFile(fakeBinary); fpgaDiscoverer.initialize(conf); assertEquals("Correct configuration should return user setting", getTestParentFolder() + "/aocl", openclPlugin.getPathToExecutable()); }
@Test public void testExecutablePathWhenFileDoesNotExist() throws YarnException { conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, getTestParentFolder() + "/aocl"); fpgaDiscoverer.initialize(conf); assertEquals("File doesn't exists - expected a single binary name", "aocl", openclPlugin.getPathToExecutable()); }
@Test public void testExecutablePathWhenFileIsEmpty() throws YarnException { conf.set(YarnConfiguration.NM_FPGA_PATH_TO_EXEC, ""); fpgaDiscoverer.initialize(conf); assertEquals("configuration with empty string value, should use aocl", "aocl", openclPlugin.getPathToExecutable()); }
@Test public void testExecutablePathWithSdkRootSet() throws IOException, YarnException { fakeBinary = new File(getTestParentFolder() + "/bin/aocl"); fakeBinary.getParentFile().mkdirs(); touchFile(fakeBinary); Map<String, String> newEnv = new HashMap<String, String>(); newEnv.put("ALTERAOCLSDKROOT", getTestParentFolder()); openclPlugin.setEnvProvider(s -> { return newEnv.get(s); }); fpgaDiscoverer.initialize(conf); assertEquals("No configuration but with environment ALTERAOCLSDKROOT set", getTestParentFolder() + "/bin/aocl", openclPlugin.getPathToExecutable()); }