Small number of test fixes (#220)

* Workaround for apache solr RNG algorithm enforcement in tests

Signed-off-by: AlexDBlack <blacka101@gmail.com>

* DeepWalk gradient check spam reduction

Signed-off-by: AlexDBlack <blacka101@gmail.com>

* Timeout increase

Signed-off-by: AlexDBlack <blacka101@gmail.com>
master
Alex Black 2020-02-07 18:38:50 +11:00 committed by GitHub
parent ce6848c9fe
commit 937a27ae27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 8 deletions

View File

@ -18,6 +18,8 @@ package org.deeplearning4j.nn.dataimport.solr.client.solrj.io.stream;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
import com.carrotsearch.randomizedtesting.ThreadFilter;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -44,6 +46,18 @@ import org.nd4j.rng.deallocator.NativeRandomDeallocator;
})
public class TupleStreamDataSetIteratorTest extends SolrCloudTestCase {
static {
/*
This is a hack around the backend-dependent nature of secure random implementations
though we can set the secure random algorithm in our pom.xml files (via maven surefire and test.solr.allowed.securerandom)
there isn't a mechanism that is completely platform independent.
By setting it there (for example, to NativePRNG) that makes it pass on some platforms like Linux but fails on some JVMs on Windows
For testing purposes, we don't need strict guarantees around RNG, hence we don't want to enforce the RNG algorithm
*/
String algorithm = new SecureRandom().getAlgorithm();
System.setProperty("test.solr.allowed.securerandom", algorithm);
}
public static class PrivateDeallocatorThreadsFilter implements ThreadFilter {
/**
* Reject deallocator threads over whose cleanup this test has no control.

View File

@ -66,7 +66,7 @@ public class DeepWalkGradientCheck extends BaseDL4JTest {
for (int i = 0; i < 7; i++) {
INDArray vector = deepWalk.getVertexVector(i);
assertArrayEquals(new long[] {vectorSize}, vector.shape());
System.out.println(Arrays.toString(vector.dup().data().asFloat()));
// System.out.println(Arrays.toString(vector.dup().data().asFloat()));
}
GraphWalkIterator<String> iter = new RandomWalkIterator<>(graph, 8);
@ -182,10 +182,10 @@ public class DeepWalkGradientCheck extends BaseDL4JTest {
if (relError > MAX_REL_ERROR && absErr > MIN_ABS_ERROR)
fail(msg);
else
System.out.println(msg);
// else
// System.out.println(msg);
}
System.out.println();
// System.out.println();
}
}
@ -216,7 +216,7 @@ public class DeepWalkGradientCheck extends BaseDL4JTest {
for (int i = 0; i < nVertices; i++) {
INDArray vector = deepWalk.getVertexVector(i);
assertArrayEquals(new long[] {vectorSize}, vector.shape());
System.out.println(Arrays.toString(vector.dup().data().asFloat()));
// System.out.println(Arrays.toString(vector.dup().data().asFloat()));
}
GraphWalkIterator<String> iter = new RandomWalkIterator<>(graph, 10);
@ -295,8 +295,8 @@ public class DeepWalkGradientCheck extends BaseDL4JTest {
if (relError > MAX_REL_ERROR && absErr > minAbsError)
fail(msg);
else
System.out.println(msg);
// else
// System.out.println(msg);
}
}

View File

@ -18,6 +18,7 @@ package org.deeplearning4j.nn.modelexport.solr.handler;
import java.io.File;
import java.nio.file.Path;
import java.security.SecureRandom;
import com.carrotsearch.randomizedtesting.ThreadFilter;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
@ -49,6 +50,19 @@ import org.nd4j.rng.deallocator.NativeRandomDeallocator;
})
public class ModelTupleStreamIntegrationTest extends SolrCloudTestCase {
static {
/*
This is a hack around the backend-dependent nature of secure random implementations
though we can set the secure random algorithm in our pom.xml files (via maven surefire and test.solr.allowed.securerandom)
there isn't a mechanism that is completely platform independent.
By setting it there (for example, to NativePRNG) that makes it pass on some platforms like Linux but fails on some JVMs on Windows
For testing purposes, we don't need strict guarantees around RNG, hence we don't want to enforce the RNG algorithm
*/
String algorithm = new SecureRandom().getAlgorithm();
System.setProperty("test.solr.allowed.securerandom", algorithm);
}
public static class PrivateDeallocatorThreadsFilter implements ThreadFilter {
/**
* Reject deallocator threads over whose cleanup this test has no control.

View File

@ -19,6 +19,7 @@ package org.deeplearning4j.nn.modelexport.solr.handler;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -58,6 +59,18 @@ import org.nd4j.linalg.lossfunctions.LossFunctions;
public class ModelTupleStreamTest {
static {
/*
This is a hack around the backend-dependent nature of secure random implementations
though we can set the secure random algorithm in our pom.xml files (via maven surefire and test.solr.allowed.securerandom)
there isn't a mechanism that is completely platform independent.
By setting it there (for example, to NativePRNG) that makes it pass on some platforms like Linux but fails on some JVMs on Windows
For testing purposes, we don't need strict guarantees around RNG, hence we don't want to enforce the RNG algorithm
*/
String algorithm = new SecureRandom().getAlgorithm();
System.setProperty("test.solr.allowed.securerandom", algorithm);
}
protected List<float[]> floatsList(int numFloats) {
final List<float[]> floatsList = new ArrayList<float[]>();
final float[] floats0 = new float[numFloats];

View File

@ -34,7 +34,7 @@ public class MiscTests extends BaseDL4JTest {
@Override
public long getTimeoutMilliseconds() {
return 120000L;
return 240000L;
}
@Test