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,18 +72,23 @@ 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)
.unavailableImageHandler(AeronUtil::printUnavailableImage) .availableImageHandler(AeronUtil::printAvailableImage)
.aeronDirectoryName(mediaDriver.aeronDirectoryName()) .unavailableImageHandler(AeronUtil::printUnavailableImage)
.errorHandler(err -> err.printStackTrace()); .aeronDirectoryName(mediaDriver.aeronDirectoryName())
.errorHandler(err -> err.printStackTrace());
final AtomicBoolean running = new AtomicBoolean(true); final AtomicBoolean running = new AtomicBoolean(true);
Aeron aeron = Aeron.connect(ctx); Aeron aeron = Aeron.connect(ctx);
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,22 +1,23 @@
<?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
~ * https://www.apache.org/licenses/LICENSE-2.0. ~ * https://www.apache.org/licenses/LICENSE-2.0.
~ * ~ *
~ * See the NOTICE file distributed with this work for additional ~ * See the NOTICE file distributed with this work for additional
~ * information regarding copyright ownership. ~ * information regarding copyright ownership.
~ * Unless required by applicable law or agreed to in writing, software ~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ~ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ~ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ * License for the specific language governing permissions and limitations ~ * License for the specific language governing permissions and limitations
~ * 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"