Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16744: fix flaky RandomizedTaggerTest (#1736)

Pierre Salagnacb104f9174b8b
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
index 2b366f11311..e0d11111a7b 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
@@ -69,6 +69,13 @@ public class RandomizedTaggerTest extends TaggerTestCase {
} else { // existing word (possible multi-word from prev iteration)
buf.append(RandomPicks.randomFrom(R, names));
}
+
+ // This loop has an exponential effect, because we add existing an name to a new name. In
+ // case we generate a too long name, the test will fail because of a too big automaton.
+ // Stop at 500 chars to prevent this.
+ if (buf.length() > 500) {
+ break;
+ }
}
names.add(buf.toString());
}