More test fixes

Signed-off-by: brian <brian@brutex.de>
master
Brian Rosenberger 2022-10-06 13:22:06 +02:00
parent 7bcfa76df4
commit 6856b154b1
6 changed files with 50 additions and 34 deletions

View File

@ -51,7 +51,7 @@ public class AeronNDArraySubscriber implements AutoCloseable {
// Create a context, needed for client connection to media driver // Create a context, needed for client connection to media driver
// A separate media driver process need to run prior to running this application // A separate media driver process need to run prior to running this application
private Aeron.Context ctx; private Aeron.Context ctx;
private AtomicBoolean running = new AtomicBoolean(true); private AtomicBoolean running;
private final AtomicBoolean init = new AtomicBoolean(false); private final AtomicBoolean init = new AtomicBoolean(false);
private NDArrayCallback ndArrayCallback; private NDArrayCallback ndArrayCallback;

View File

@ -72,7 +72,8 @@ public class LargeNdArrayIpcTest extends BaseND4JTest {
INDArray arr = Nd4j.ones(length); INDArray arr = Nd4j.ones(length);
AeronNDArrayPublisher publisher; AeronNDArrayPublisher publisher;
ctx = new Aeron.Context() ctx = new Aeron.Context()
.driverTimeoutMs(10000).availableImageHandler(AeronUtil::printAvailableImage) .driverTimeoutMs(10000)
.availableImageHandler(AeronUtil::printAvailableImage)
.unavailableImageHandler(AeronUtil::printUnavailableImage) .unavailableImageHandler(AeronUtil::printUnavailableImage)
.aeronDirectoryName(mediaDriver.aeronDirectoryName()) .aeronDirectoryName(mediaDriver.aeronDirectoryName())
.errorHandler(err -> err.printStackTrace()); .errorHandler(err -> err.printStackTrace());
@ -82,8 +83,12 @@ public class LargeNdArrayIpcTest extends BaseND4JTest {
int numSubscribers = 1; int numSubscribers = 1;
AeronNDArraySubscriber[] subscribers = new AeronNDArraySubscriber[numSubscribers]; AeronNDArraySubscriber[] subscribers = new AeronNDArraySubscriber[numSubscribers];
for (int i = 0; i < numSubscribers; i++) { for (int i = 0; i < numSubscribers; i++) {
AeronNDArraySubscriber subscriber = AeronNDArraySubscriber.builder().streamId(streamId).ctx(getContext()) AeronNDArraySubscriber subscriber = AeronNDArraySubscriber.builder()
.channel(channel).aeron(aeron).running(running).ndArrayCallback(new NDArrayCallback() { .streamId(streamId).ctx(getContext())
.channel(channel)
.aeron(aeron)
.running(running)
.ndArrayCallback(new NDArrayCallback() {
/** /**
* A listener for ndarray message * A listener for ndarray message
* *
@ -110,7 +115,8 @@ public class LargeNdArrayIpcTest extends BaseND4JTest {
try { try {
subscriber.launch(); subscriber.launch();
} catch (Exception e) { } catch (Exception e) {
log.error("",e); System.out.println(e.getMessage());
e.printStackTrace();
} }
}); });
@ -122,17 +128,23 @@ public class LargeNdArrayIpcTest extends BaseND4JTest {
Thread.sleep(1000); Thread.sleep(1000);
publisher = AeronNDArrayPublisher.builder().publishRetryTimeOut(3000).streamId(streamId).channel(channel) publisher = AeronNDArrayPublisher.builder()
.aeron(aeron).build(); .publishRetryTimeOut(3000)
.streamId(streamId)
.channel(channel)
.aeron(aeron)
.build();
for (int i = 0; i < 1 && running.get(); i++) { for (int i = 0; i < 1; i++) {
log.info("About to send array."); System.out.println("About to send array.");
publisher.publish(arr); publisher.publish(arr);
log.info("Sent array"); System.out.println("Sent array");
} }
Thread.sleep( 5000);
for (int i = 0; i < numSubscribers; i++) for (int i = 0; i < numSubscribers; i++)
CloseHelper.close(subscribers[i]); CloseHelper.close(subscribers[i]);
CloseHelper.close(aeron); CloseHelper.close(aeron);

View File

@ -18,6 +18,7 @@
* ***************************************************************************** * *****************************************************************************
* *
*/ */
apply from: "${project.rootProject.projectDir}/createTestBackends.gradle"
dependencies { dependencies {
implementation "com.fasterxml.jackson.core:jackson-databind" implementation "com.fasterxml.jackson.core:jackson-databind"
@ -29,4 +30,5 @@ dependencies {
implementation "org.apache.commons:commons-compress" implementation "org.apache.commons:commons-compress"
implementation "commons-codec:commons-codec" implementation "commons-codec:commons-codec"
testImplementation projects.cavisNd4j.cavisNd4jCommonTests testImplementation projects.cavisNd4j.cavisNd4jCommonTests
testRuntimeOnly "net.brutex.ai:dl4j-test-resources:1.0.1-SNAPSHOT"
} }

View File

@ -24,9 +24,11 @@ package org.nd4j.common.io;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.nd4j.common.io.ClassPathResource; import org.nd4j.common.io.ClassPathResource;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.util.UUID; import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -36,13 +38,12 @@ public class ClassPathResourceTest {
@Test @Test
public void testDirExtractingIntelliJ() throws Exception { public void testDirExtractingIntelliJ(@TempDir Path tempDir) throws Exception {
//https://github.com/deeplearning4j/deeplearning4j/issues/6483 //https://github.com/deeplearning4j/deeplearning4j/issues/6483
ClassPathResource cpr = new ClassPathResource("somedir"); ClassPathResource cpr = new ClassPathResource("somedir");
File f = new File(FileUtils.getTempDirectoryPath()+File.separatorChar+ UUID.randomUUID().toString()); File f = tempDir.toFile();
FileUtils.forceMkdir(f);
cpr.copyDirectory(f); cpr.copyDirectory(f);
File[] files = f.listFiles(); File[] files = f.listFiles();

View File

@ -325,7 +325,7 @@ public class ParameterServerSubscriber implements AutoCloseable {
int tries=0; int tries=0;
while (!subscriber.launched() && tries<12) { while (!subscriber.launched() && tries<12) {
tries++; tries++;
LockSupport.parkNanos(100000); Thread.sleep(1000);
} }
if(!subscriber.launched()) { if(!subscriber.launched()) {
throw new Exception("Subscriber did not start in time."); throw new Exception("Subscriber did not start in time.");

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ /* ****************************************************************************** ~
~ * ~ ******************************************************************************
~ * ~ *
~ * This program and the accompanying materials are made available under the ~ * This program and the accompanying materials are made available under the
~ * terms of the Apache License, Version 2.0 which is available at ~ * terms of the Apache License, Version 2.0 which is available at
@ -16,7 +16,8 @@
~ * under the License. ~ * under the License.
~ * ~ *
~ * SPDX-License-Identifier: Apache-2.0 ~ * SPDX-License-Identifier: Apache-2.0
~ ******************************************************************************/ ~ *****************************************************************************
~
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"