Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,6 @@ tests:
- class: org.elasticsearch.gradle.internal.transport.TransportVersionValidationFuncTest
method: definitions have primary ids which cannot change
issue: https://github.com/elastic/elasticsearch/issues/133131
- class: org.elasticsearch.xpack.esql.action.RandomizedTimeSeriesIT
method: testGroupBySubset
issue: https://github.com/elastic/elasticsearch/issues/133220
- class: org.elasticsearch.xpack.esql.action.RandomizedTimeSeriesIT
method: testGroupByNothing
issue: https://github.com/elastic/elasticsearch/issues/133225
- class: org.elasticsearch.gradle.internal.transport.TransportVersionValidationFuncTest
method: named and unreferenced definitions cannot have the same name
issue: https://github.com/elastic/elasticsearch/issues/133255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ public void populateIndex() throws IOException {
if (documents == null) {
documents = new ArrayList<>();
}
documents.add(document);
var indexRequest = client().prepareIndex(DATASTREAM_NAME).setOpType(DocWriteRequest.OpType.CREATE).setSource(document);
indexRequest.setRefreshPolicy(org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE);
indexRequest.get();
documents.add(document);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.IOException;
import java.time.Instant;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -65,6 +66,29 @@ private static Object randomDimensionValue(String dimensionName) {
return dimensionsInMetric.stream().map(attr -> new Tuple<>(attr, randomDimensionValue(attr))).collect(Collectors.toList());
}).toList();

// We want to ensure that all documents have different timestamps.
var now = Instant.now();
var timestampSet = new HashSet<Instant>();
var regens = 0;
for (int i = 0; i < numDocs; i++) {
// Random timestamps within the last 90 days.
while (true) {
var randomIns = Instant.ofEpochMilli(
ESTestCase.randomLongBetween(now.minusSeconds(60 * 60 * 2).toEpochMilli(), now.toEpochMilli())
);
if (timestampSet.add(randomIns)) {
break;
}
regens++;
if (regens > numDocs) {
throw new IllegalStateException("Too many collisions when generating timestamps");
}
}
}
// Timestampset should have exactly numDocs entries - this works as long as the random number generator
// does not cycle early.
assert timestampSet.size() == numDocs : "Expected [" + numDocs + "] timestamps but got [" + timestampSet.size() + "]";
var timestampsIter = timestampSet.iterator();
spec = DataGeneratorSpecification.builder()
.withMaxFieldCountPerLevel(0)
.withPredefinedFields(
Expand All @@ -73,7 +97,7 @@ private static Object randomDimensionValue(String dimensionName) {
"@timestamp",
FieldType.DATE,
Map.of("type", "date"),
fieldMapping -> ESTestCase.randomInstantBetween(Instant.now().minusSeconds(2 * 60 * 60), Instant.now())
fieldMapping -> timestampsIter.next()
),
new PredefinedField.WithGenerator(
"attributes",
Expand Down