diff --git a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java index d4a0a96..2e865cd 100644 --- a/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java +++ b/src/main/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCL.java @@ -111,6 +111,7 @@ int getFreeThreads() { @Override public void releaseProducer() { super.releaseProducer(); + resultReaderThreadPoolExecutor.shutdown(); if (openCLContext != null) { openCLContext.release(); openCLContext = null; diff --git a/src/test/java/net/ladenthin/bitcoinaddressfinder/LogLevelChange.java b/src/test/java/net/ladenthin/bitcoinaddressfinder/LogLevelChange.java index df19080..68cd7d2 100644 --- a/src/test/java/net/ladenthin/bitcoinaddressfinder/LogLevelChange.java +++ b/src/test/java/net/ladenthin/bitcoinaddressfinder/LogLevelChange.java @@ -27,4 +27,8 @@ public void turnOff() { final Logger logger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); logger.setLevel(Level.OFF); } + public void setLevel(Level newLevel) { + final Logger logger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + logger.setLevel(newLevel); + } } diff --git a/src/test/java/net/ladenthin/bitcoinaddressfinder/MainTest.java b/src/test/java/net/ladenthin/bitcoinaddressfinder/MainTest.java index 7715e8a..455f500 100644 --- a/src/test/java/net/ladenthin/bitcoinaddressfinder/MainTest.java +++ b/src/test/java/net/ladenthin/bitcoinaddressfinder/MainTest.java @@ -18,6 +18,7 @@ // @formatter:on package net.ladenthin.bitcoinaddressfinder; +import ch.qos.logback.classic.Level; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -49,6 +50,8 @@ public class MainTest { private final Path config_LMDBToAddressFile_js = testRoundtripDirectory.resolve("config_LMDBToAddressFile.js"); private final Path config_Find_SecretsFile_js = testRoundtripDirectory.resolve("config_Find_SecretsFile.js"); + private final Path config_Find_1OpenCLDevice_js = testRoundtripDirectory.resolve("config_Find_1OpenCLDevice.js"); + private final Path config_OpenCLInfo_js = testOpenCLInfoDirectory.resolve("config_OpenCLInfo.js"); // @@ -66,6 +69,23 @@ public void testRoundtrip_configurationsGiven_lmdbCreatedExportedAndRunFindSecre } // + + // + @Test + @OpenCLTest + public void testRoundtripOpenCLProducer_configurationsGiven_lmdbCreatedAndRunFindOpenCLDevice() throws IOException, InterruptedException { + new OpenCLPlatformAssume().assumeOpenCLLibraryLoadableAndOneOpenCL2_0OrGreaterDeviceAvailable(); + // arrange + Main mainAddressFilesToLMDB = Main.createFromConfigurationFile(config_AddressFilesToLMDB_js); + mainAddressFilesToLMDB.run(); + + new LogLevelChange().setLevel(Level.INFO); + + Main mainFind_1OpenCLDevice = Main.createFromConfigurationFile(config_Find_1OpenCLDevice_js); + mainFind_1OpenCLDevice.run(); + } + // + // @Test @OpenCLTest diff --git a/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java b/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java index f3d9c6a..074fef0 100644 --- a/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java +++ b/src/test/java/net/ladenthin/bitcoinaddressfinder/ProducerOpenCLTest.java @@ -62,7 +62,7 @@ public void initProducer_configurationGiven_stateInitializedAndLogged() throws I // @OpenCLTest @Test - public void releaseProducer_configurationGiven_stateInitializedAndLogged() throws IOException, InterruptedException { + public void releaseProducer_configurationGiven_stateInitializedAndLoggedAndExecuterServiceShutdown() throws IOException, InterruptedException { new OpenCLPlatformAssume().assumeOpenCLLibraryLoadableAndOneOpenCL2_0OrGreaterDeviceAvailable(); CProducerOpenCL cProducerOpenCL = new CProducerOpenCL(); MockConsumer mockConsumer = new MockConsumer(); @@ -71,6 +71,7 @@ public void releaseProducer_configurationGiven_stateInitializedAndLogged() throw ProducerOpenCL producerOpenCL = new ProducerOpenCL(cProducerOpenCL, mockConsumer, keyUtility, mockSecretFactory); AbstractProducerTest.verifyReleaseProducer(producerOpenCL); + assertThat(producerOpenCL.resultReaderThreadPoolExecutor.isShutdown(), is(equalTo(Boolean.TRUE))); } // diff --git a/src/test/resources/testRoundtrip/config_Find_1OpenCLDevice.js b/src/test/resources/testRoundtrip/config_Find_1OpenCLDevice.js new file mode 100644 index 0000000..bc81ea2 --- /dev/null +++ b/src/test/resources/testRoundtrip/config_Find_1OpenCLDevice.js @@ -0,0 +1,33 @@ +{ + "command": "Find", + "finder" : { + "consumerJava" : { + "lmdbConfigurationReadOnly" : { + "lmdbDirectory" : "src/test/resources/testRoundtrip/lmdb", + "useProxyOptimal" : true, + "logStatsOnInit" : true, + "logStatsOnClose" : false + }, + "threads" : 8, + "delayEmptyConsumer" : 50, + "printStatisticsEveryNSeconds" : 10, + "queueSize" : 4, + "runtimePublicKeyCalculationCheck" : false, + "enableVanity" : false, + "vanityPattern" : "1[Ee][Mm][Ii][Ll].*" + }, + "producerOpenCL" : [ + { + "privateKeyMaxNumBits" : 256, + "platformIndex" : 0, + "deviceType" : -1, + "deviceIndex" : 0, + "gridNumBits" : 18, + "maxResultReaderThreads" : 4, + "delayBlockedReader" : 50 + } + ], + "producerJava" : [ + ] + } +}