Skip to content

Commit a3482e8

Browse files
authored
Address UUIDTests#testCompression failures. (elastic#50093)
Those were due to codec randomization. Closes elastic#50048
1 parent e4b9044 commit a3482e8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/src/test/java/org/elasticsearch/common/UUIDTests.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222

2323
import org.apache.logging.log4j.LogManager;
2424
import org.apache.logging.log4j.Logger;
25+
import org.apache.lucene.codecs.Codec;
2526
import org.apache.lucene.document.Document;
2627
import org.apache.lucene.document.Field.Store;
2728
import org.apache.lucene.document.StringField;
2829
import org.apache.lucene.index.IndexWriter;
2930
import org.apache.lucene.index.IndexWriterConfig;
3031
import org.apache.lucene.index.SerialMergeScheduler;
3132
import org.apache.lucene.store.Directory;
33+
import org.apache.lucene.util.TestUtil;
34+
import org.elasticsearch.common.lucene.Lucene;
3235
import org.elasticsearch.common.unit.ByteSizeValue;
3336
import org.elasticsearch.common.unit.TimeValue;
3437
import org.elasticsearch.test.ESTestCase;
@@ -116,7 +119,6 @@ public void testUUIDThreaded(UUIDGenerator uuidSource) {
116119
assertEquals(count*uuids, globalSet.size());
117120
}
118121

119-
@AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/50048")
120122
public void testCompression() throws Exception {
121123
Logger logger = LogManager.getLogger(UUIDTests.class);
122124
// Low number so that the test runs quickly, but the results are more interesting with larger numbers
@@ -135,7 +137,7 @@ private static double testCompression(int numDocs, int numDocsPerSecond, int num
135137
random().nextBytes(macAddresses[i]);
136138
}
137139
UUIDGenerator generator = new TimeBasedUUIDGenerator() {
138-
double currentTimeMillis = System.currentTimeMillis();
140+
double currentTimeMillis = TestUtil.nextLong(random(), 0L, 10000000000L);
139141

140142
@Override
141143
protected long currentTimeMillis() {
@@ -152,6 +154,7 @@ protected byte[] macAddress() {
152154
// the quality of this test
153155
Directory dir = newFSDirectory(createTempDir());
154156
IndexWriterConfig config = new IndexWriterConfig()
157+
.setCodec(Codec.forName(Lucene.LATEST_CODEC))
155158
.setMergeScheduler(new SerialMergeScheduler()); // for reproducibility
156159
IndexWriter w = new IndexWriter(dir, config);
157160
Document doc = new Document();

0 commit comments

Comments
 (0)