commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject commons-rng git commit: RNG-60: Use random seeds (unit test).
Date Fri, 16 Nov 2018 02:24:58 GMT
Repository: commons-rng
Updated Branches:
  refs/heads/master 8c927dc65 -> 0fdcd9007


RNG-60: Use random seeds (unit test).

By using random seeds, it is expected that the unit tests will fail
with some probability; Junit is thus configured to rerun such a test,
marking it as "flaky" when it succeeds within the allotted number of
retries), and letting the build pass.


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/0fdcd900
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/0fdcd900
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/0fdcd900

Branch: refs/heads/master
Commit: 0fdcd9007c708aa48f1989cb2211ea56c1fcd702
Parents: 8c927dc
Author: Gilles <erans@apache.org>
Authored: Fri Nov 16 03:17:59 2018 +0100
Committer: Gilles <erans@apache.org>
Committed: Fri Nov 16 03:17:59 2018 +0100

----------------------------------------------------------------------
 commons-rng-core/pom.xml                        | 12 +++++++
 .../apache/commons/rng/core/ProvidersList.java  | 36 +++++++++++---------
 src/changes/changes.xml                         | 10 ++++++
 3 files changed, 42 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/0fdcd900/commons-rng-core/pom.xml
----------------------------------------------------------------------
diff --git a/commons-rng-core/pom.xml b/commons-rng-core/pom.xml
index 6fe5243..9cf54a5 100644
--- a/commons-rng-core/pom.xml
+++ b/commons-rng-core/pom.xml
@@ -55,4 +55,16 @@
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.22.0</version>
+        <configuration>
+          <rerunFailingTestsCount>2</rerunFailingTestsCount>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/0fdcd900/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java
----------------------------------------------------------------------
diff --git a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java
b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java
index 7831940..767074a 100644
--- a/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java
+++ b/commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.security.SecureRandom;
 
 import org.apache.commons.rng.core.source32.JDKRandom;
 import org.apache.commons.rng.core.source32.Well512a;
@@ -59,27 +60,30 @@ public class ProvidersList {
         new ArrayList<RestorableUniformRandomProvider[]>();
 
     static {
+        // External generator for creating a random seed.
+        final SecureRandom g = new SecureRandom();
+
         try {
             // "int"-based RNGs.
-            add(LIST32, new JDKRandom(-122333444455555L));
-            add(LIST32, new MersenneTwister(new int[] { -123, -234, -345 }));
-            add(LIST32, new Well512a(new int[] { -23, -34, -45 }));
-            add(LIST32, new Well1024a(new int[] { -1234, -2345, -3456 }));
-            add(LIST32, new Well19937a(new int[] { -2123, -3234, -4345 }));
-            add(LIST32, new Well19937c(new int[] { -123, -234, -345, -456 }));
-            add(LIST32, new Well44497a(new int[] { -12345, -23456, -34567 }));
-            add(LIST32, new Well44497b(new int[] { 123, 234, 345 }));
-            add(LIST32, new ISAACRandom(new int[] { 123, -234, 345, -456 }));
-            add(LIST32, new MultiplyWithCarry256(new int[] { 12, -1234, -3456, 45679 }));
-            add(LIST32, new KISSRandom(new int[] { 12, 1234, 23456, 345678 }));
+            add(LIST32, new JDKRandom(g.nextLong()));
+            add(LIST32, new MersenneTwister(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new Well512a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
+            add(LIST32, new Well1024a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
+            add(LIST32, new Well19937a(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new Well19937c(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new Well44497a(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new Well44497b(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new ISAACRandom(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new MultiplyWithCarry256(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
+            add(LIST32, new KISSRandom(new int[] { g.nextInt(), g.nextInt(), g.nextInt()
}));
             // ... add more here.
 
             // "long"-based RNGs.
-            add(LIST64, new SplitMix64(-98877766544333L));
-            add(LIST64, new XorShift1024Star(new long[] { 123456L, 234567L, -345678L }));
-            add(LIST64, new TwoCmres(55443322));
-            add(LIST64, new TwoCmres(-987654321, 5, 8));
-            add(LIST64, new MersenneTwister64(new long[] { 1234567L, 2345678L, -3456789L
}));
+            add(LIST64, new SplitMix64(g.nextLong()));
+            add(LIST64, new XorShift1024Star(new long[] { g.nextLong(), g.nextLong(), g.nextLong(),
g.nextLong() }));
+            add(LIST64, new TwoCmres(g.nextInt()));
+            add(LIST64, new TwoCmres(g.nextInt(), 5, 8));
+            add(LIST64, new MersenneTwister64(new long[] { g.nextLong(), g.nextLong(), g.nextLong(),
g.nextLong() }));
             // ... add more here.
 
             // Do not modify the remaining statements.

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/0fdcd900/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9e249c5..c2fc2ec 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,7 +66,17 @@ Additional code is provided in the following module:
   commons-rng-examples (requires Java 9)
 It is however not part of the official API and no compatibility
 should be expected in subsequent releases.
+
+It must be noted that, due to the nature of random number
+generation, some of unit tests are bound to fail with some
+probability.  The 'maven-surefire-plugin' is configured to
+re-run tests that fail, and pass the build if they succeed
+within the allotted number of reruns (the test will be marked
+as 'flaky' in the report).
 ">
+      <action dev="erans" type="update" issue="RNG-60">
+        Use random seeds for unit testing.
+      </action>
       <action dev="erans" type="update" issue="RNG-52">
         Set conservative upper bound in "LargePoissonSampler" to avoid truncation.
       </action>


Mime
View raw message