You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by spmallette <gi...@git.apache.org> on 2018/06/21 14:23:36 UTC
[GitHub] tinkerpop pull request #881: TINKERPOP-1365 Refactored use of Random in test...
GitHub user spmallette opened a pull request:
https://github.com/apache/tinkerpop/pull/881
TINKERPOP-1365 Refactored use of Random in tests
Each test suite now uses the same instance of Random which prints the seed given to it so that if there is a failure, we can easily try to recreate it by taking the seed and passing it in as a system property with -DtestSeed. The output logs as:
```text
[INFO] org.apache.tinkerpop.gremlin.TestHelper - *** THE RANDOM TEST SEED IS 1529585621517 ***
```
I didn't replace all of the old use of `Random` - there were a couple places where I felt like a true `Random` was still necessary and just left it alone despite the horror it might cause. Going forward we'll want to use the `TestHelper.RANDOM` whenever possible (or, better, just not use a `Random` at all).
All tests pass with `docker/build.sh -t -n -i`
VOTE +1
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/tinkerpop TINKERPOP-1365
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tinkerpop/pull/881.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #881
----
commit 12d9c793dda7b4cd98122756331916362055f389
Author: Stephen Mallette <sp...@...>
Date: 2018-06-21T14:11:58Z
TINKERPOP-1365 Refactored use of Random in tests
Each test suite now uses the same instance of Random which prints the seed given to it so that if there is a failure, we can easily try to recreate it by taking the seed and passing it in as a system property with -DtestSeed.
----
---
[GitHub] tinkerpop pull request #881: TINKERPOP-1365 Refactored use of Random in test...
Posted by dkuppitz <gi...@git.apache.org>.
Github user dkuppitz commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/881#discussion_r197826190
--- Diff: gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java ---
@@ -51,11 +52,19 @@
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public final class TestHelper {
+ private static final Logger logger = LoggerFactory.getLogger(TestHelper.class);
+ public static final Random RANDOM;
private static final String SEP = File.separator;
private static final char URL_SEP = '/';
public static final String TEST_DATA_RELATIVE_DIR = "test-case-data";
+ static {
+ final long seed = Long.parseLong(System.getProperty("testSeed", String.valueOf(System.currentTimeMillis())));
+ logger.info("*** THE RANDOM TEST SEED IS {} ***", seed);
+ RANDOM = new Random();
--- End diff --
This should be `RANDOM = new Random(seed);`.
---
[GitHub] tinkerpop pull request #881: TINKERPOP-1365 Refactored use of Random in test...
Posted by spmallette <gi...@git.apache.org>.
Github user spmallette commented on a diff in the pull request:
https://github.com/apache/tinkerpop/pull/881#discussion_r197827356
--- Diff: gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java ---
@@ -51,11 +52,19 @@
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public final class TestHelper {
+ private static final Logger logger = LoggerFactory.getLogger(TestHelper.class);
+ public static final Random RANDOM;
private static final String SEP = File.separator;
private static final char URL_SEP = '/';
public static final String TEST_DATA_RELATIVE_DIR = "test-case-data";
+ static {
+ final long seed = Long.parseLong(System.getProperty("testSeed", String.valueOf(System.currentTimeMillis())));
+ logger.info("*** THE RANDOM TEST SEED IS {} ***", seed);
+ RANDOM = new Random();
--- End diff --
wow - the whole point of the PR and i didn't even do it right :disappointed: :rage4:
---
[GitHub] tinkerpop pull request #881: TINKERPOP-1365 Refactored use of Random in test...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/tinkerpop/pull/881
---