From 75cc6e2ed7e44767f3c70fb7bf19a126ae1bb579 Mon Sep 17 00:00:00 2001 From: Alex Black Date: Thu, 23 Apr 2020 10:46:42 +1000 Subject: [PATCH] Increase default timeouts [WIP] (#407) * Increase default test timeout to 60 sec due to slow PPC CI machines Signed-off-by: Alex Black * Fix flaky NLP test (randomly fails due to no RNG seed set) Signed-off-by: Alex Black --- .../java/org/deeplearning4j/BaseDL4JTest.java | 2 +- .../walkers/impl/NearestVertexWalker.java | 2 +- .../graph/walkers/impl/RandomWalker.java | 2 +- .../graph/walkers/impl/RandomWalkerTest.java | 30 +++++------ .../src/test/resources/logback-test.xml | 50 +++++++++++++++++++ .../src/main/java/org/nd4j/BaseND4JTest.java | 2 +- 6 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/resources/logback-test.xml diff --git a/deeplearning4j/deeplearning4j-common-tests/src/main/java/org/deeplearning4j/BaseDL4JTest.java b/deeplearning4j/deeplearning4j-common-tests/src/main/java/org/deeplearning4j/BaseDL4JTest.java index 6ce978ec5..22bdd19ae 100644 --- a/deeplearning4j/deeplearning4j-common-tests/src/main/java/org/deeplearning4j/BaseDL4JTest.java +++ b/deeplearning4j/deeplearning4j-common-tests/src/main/java/org/deeplearning4j/BaseDL4JTest.java @@ -68,7 +68,7 @@ public abstract class BaseDL4JTest { * Override this method to set the default timeout for methods in the test class */ public long getTimeoutMilliseconds(){ - return 30000; + return 60_000; } /** diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/NearestVertexWalker.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/NearestVertexWalker.java index a84cd8d4c..fe7f117af 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/NearestVertexWalker.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/NearestVertexWalker.java @@ -70,7 +70,7 @@ public class NearestVertexWalker implements GraphWalk public void reset(boolean shuffle) { position.set(0); if (shuffle) { - log.debug("Calling shuffle() on entries..."); + log.trace("Calling shuffle() on entries..."); // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm for (int i = order.length - 1; i > 0; i--) { int j = rng.nextInt(i + 1); diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalker.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalker.java index b422a52d1..a033a4a81 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalker.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalker.java @@ -249,7 +249,7 @@ public class RandomWalker implements GraphWalker { public void reset(boolean shuffle) { this.position.set(0); if (shuffle) { - logger.debug("Calling shuffle() on entries..."); + logger.trace("Calling shuffle() on entries..."); // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm for (int i = order.length - 1; i > 0; i--) { int j = rng.nextInt(i + 1); diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalkerTest.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalkerTest.java index 1bfe47c41..1d03ac033 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalkerTest.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/graph/walkers/impl/RandomWalkerTest.java @@ -101,7 +101,7 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom1() throws Exception { RandomWalker walker = (RandomWalker) new RandomWalker.Builder<>(graph) - .setNoEdgeHandling(NoEdgeHandling.SELF_LOOP_ON_DISCONNECTED).setWalkLength(3).build(); + .setNoEdgeHandling(NoEdgeHandling.SELF_LOOP_ON_DISCONNECTED).setWalkLength(3).build(); int cnt = 0; while (walker.hasNext()) { @@ -123,9 +123,10 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom2() throws Exception { RandomWalker walker = (RandomWalker) new RandomWalker.Builder<>(graph) - .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) - .setWalkDirection(WalkDirection.FORWARD_UNIQUE) - .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); + .setSeed(12345) + .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) + .setWalkDirection(WalkDirection.FORWARD_UNIQUE) + .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); int cnt = 0; while (walker.hasNext()) { @@ -147,9 +148,9 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom3() throws Exception { RandomWalker walker = (RandomWalker) new RandomWalker.Builder<>(graph) - .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) - .setWalkDirection(WalkDirection.FORWARD_UNIQUE) - .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).build(); + .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) + .setWalkDirection(WalkDirection.FORWARD_UNIQUE) + .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).build(); try { while (walker.hasNext()) { @@ -169,9 +170,10 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom4() throws Exception { RandomWalker walker = (RandomWalker) new RandomWalker.Builder<>(graphBig) - .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) - .setWalkDirection(WalkDirection.FORWARD_UNIQUE) - .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); + .setSeed(12345) + .setNoEdgeHandling(NoEdgeHandling.EXCEPTION_ON_DISCONNECTED).setWalkLength(20) + .setWalkDirection(WalkDirection.FORWARD_UNIQUE) + .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); Sequence sequence1 = walker.next(); @@ -185,8 +187,8 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom5() throws Exception { RandomWalker walker = (RandomWalker) new RandomWalker.Builder<>(graphBig) - .setWalkLength(20).setWalkDirection(WalkDirection.FORWARD_UNIQUE) - .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); + .setWalkLength(20).setWalkDirection(WalkDirection.FORWARD_UNIQUE) + .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); Sequence sequence1 = walker.next(); @@ -200,8 +202,8 @@ public class RandomWalkerTest extends BaseDL4JTest { @Test public void testGraphTraverseRandom6() throws Exception { GraphWalker walker = new RandomWalker.Builder<>(graphDirected).setWalkLength(20) - .setWalkDirection(WalkDirection.FORWARD_UNIQUE) - .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); + .setWalkDirection(WalkDirection.FORWARD_UNIQUE) + .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); Sequence sequence = walker.next(); assertEquals("0", sequence.getElements().get(0).getLabel()); diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/resources/logback-test.xml b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/resources/logback-test.xml new file mode 100644 index 000000000..69246755b --- /dev/null +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/resources/logback-test.xml @@ -0,0 +1,50 @@ + + + + + + logs/application.log + + %logger{15} - %message%n%xException{5} + + + + + + + %logger{15} - %message%n%xException{5} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nd4j/nd4j-common-tests/src/main/java/org/nd4j/BaseND4JTest.java b/nd4j/nd4j-common-tests/src/main/java/org/nd4j/BaseND4JTest.java index 40b331ad5..34dd0f832 100644 --- a/nd4j/nd4j-common-tests/src/main/java/org/nd4j/BaseND4JTest.java +++ b/nd4j/nd4j-common-tests/src/main/java/org/nd4j/BaseND4JTest.java @@ -55,7 +55,7 @@ public abstract class BaseND4JTest { * Override this method to set the default timeout for methods in the test class */ public long getTimeoutMilliseconds(){ - return 30000; + return 60_000; } /**