elasticsearch/elasticsearch — pull request #5233 by dweiss (2014-02-24 12:54:11+00:00)
Title: Remove nanoTime in global cluster randomization in favor of deriving the

seed from the main master seed.

The problem here is that if you don't give cluster's seed then test times
fluctuate oddly, even for a fixed -Dtests.seed=... This shouldn't be the
case -- ideally, the test ran with the same master seed should reproduce
pretty much with the same execution time (and internal logic, obviously).

From the code point of view "global" variables are indeed a problem
because JUnit has no notion of before-suite hooks. And RandomizedRunner
doesn't support context accesses in static class initializers (this is
intentional because there is no way to determine when such initializers
will be executed). A workaround is to move such static global variables to
lazily-initialized methods and invoke them (once) in @BeforeClass hooks.

I've changed the code slightly so that nanoTime is *not* used if
tests.cluster_seed is not provided. Instead, tests.cluster_seed becomes
the current master seed. This will work both from IDEs and from Maven. I
felt tempted to remove the entire tests.cluster_seed layer (because any
static seed should/ could be derived from the master seed) but I don't
know what you guys are doing with it so I leave this decision to a
follow-up commit.