[
https://issues.apache.org/jira/browse/LUCENE-5896?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14104616#comment-14104616
]
Hoss Man commented on LUCENE-5896:
----------------------------------
bq. ...I went over the file to spot others but we might need to think about a
more automated way to spot those...
bq. It should just use the randomized context's randomness consistently instead
of accepting an external Random. It would be consistent (and is not leading to
any thread related randomization races).
Ironically, the best way (i can think of) to "test the test utils" and verify
the reproducibility of these methods (along hte lines of simon's question about
a "more automated way to spot" these types of bugs) goes out the window if you
remove the Random param from these types of methods.
As things stand right now, we can at least write a test that does this...
{code}
long localSeed = random().randomLong();
assertEquals(newIndexWriterConfig(new Random(localSeed), XXX),
newIndexWriterConfig(new Random(localSeed), XXX));
{code}
..and be fairly confident that we have a test which will fail if anyone
introduces similar bugs into {{newIndexWriterConfig}} in the future.
----
I havne't thought this through very hard, but...
Is it worth refactoring these methods into some special package w/restricted
visibility (and w/o direct access to {{LuceneTestCase.random()}} so we can test
them with explicit random instances, but then wrap them in instances w/o the
{{Random}} arg so test cases can't exploit them?
maybe something like...
{code}
package org.apache.lucene.test-internals; // put some test-the-test test's in
same package
public final class HuperDuperRandomizedObjFactories {
// package protected, test-the-test test's in same package can vet directly
// but most code can never call this
static IndexWriterConfig newIndexWriterConfig(long localSeed, Analyzer a) {
Random localRandom = new Random(localSeed);
...
}
public static IndexWriterConfig newIndexWriterConfig(random r, Analyzer a) {
return newIndexWriterConfig(r.nextLong(), a) {
}
...
}
// - - -
package org.apache.lucene;
public class LuceneTestCase {
...
public static IndexWriterConfig newIndexWriterConfig(Analyzer a) {
return HuperDuperRandomizedObjFactories.newIndexWriterConfig(random(),a);
}
}
{code}
> A few potential reproducibility issues
> --------------------------------------
>
> Key: LUCENE-5896
> URL: https://issues.apache.org/jira/browse/LUCENE-5896
> Project: Lucene - Core
> Issue Type: Test
> Components: general/test
> Affects Versions: 4.9
> Reporter: Simon Willnauer
> Fix For: 5.0, 4.10
>
> Attachments: LUCENE-5896.patch
>
>
> I realized that passing the same seeded random instance to LuceneTestCase#
> newIndewWriterConfig doesn't necessarily produce the same IWC and I found a
> bunch of issues in that class using global random rather than local random.
> Yet, I went over the file to spot others but we might need to think about a
> more automated way to spot those...
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]