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
// A separate media driver process need to run prior to running this application
private Aeron.Context ctx;
private AtomicBoolean running = new AtomicBoolean(true);
private AtomicBoolean running;
private final AtomicBoolean init = new AtomicBoolean(false);
private NDArrayCallback ndArrayCallback;

View File

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

View File

@ -18,6 +18,7 @@
* *****************************************************************************
*
*/
apply from: "${project.rootProject.projectDir}/createTestBackends.gradle"
dependencies {
implementation "com.fasterxml.jackson.core:jackson-databind"
@ -29,4 +30,5 @@ dependencies {
implementation "org.apache.commons:commons-compress"
implementation "commons-codec:commons-codec"
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.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.nd4j.common.io.ClassPathResource;
import java.io.File;
import java.nio.file.Path;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -36,13 +38,12 @@ public class ClassPathResourceTest {
@Test
public void testDirExtractingIntelliJ() throws Exception {
public void testDirExtractingIntelliJ(@TempDir Path tempDir) throws Exception {
//https://github.com/deeplearning4j/deeplearning4j/issues/6483
ClassPathResource cpr = new ClassPathResource("somedir");
File f = new File(FileUtils.getTempDirectoryPath()+File.separatorChar+ UUID.randomUUID().toString());
FileUtils.forceMkdir(f);
File f = tempDir.toFile();
cpr.copyDirectory(f);
File[] files = f.listFiles();

View File

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

View File

@ -1,22 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ /* ******************************************************************************
~ *
~ *
~ * This program and the accompanying materials are made available under the
~ * terms of the Apache License, Version 2.0 which is available at
~ * https://www.apache.org/licenses/LICENSE-2.0.
~ *
~ * See the NOTICE file distributed with this work for additional
~ * information regarding copyright ownership.
~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ * License for the specific language governing permissions and limitations
~ * under the License.
~ *
~ * SPDX-License-Identifier: Apache-2.0
~ ******************************************************************************/
~
~ ******************************************************************************
~ *
~ * This program and the accompanying materials are made available under the
~ * terms of the Apache License, Version 2.0 which is available at
~ * https://www.apache.org/licenses/LICENSE-2.0.
~ *
~ * See the NOTICE file distributed with this work for additional
~ * information regarding copyright ownership.
~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ * License for the specific language governing permissions and limitations
~ * under the License.
~ *
~ * SPDX-License-Identifier: Apache-2.0
~ *****************************************************************************
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"