Skip to content

Commit 3655dc3

Browse files
committed
feedback
1 parent eb05d57 commit 3655dc3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/TSDBSyntheticIdsIT.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void testSyntheticId() throws Exception {
109109
final var docs = new HashMap<String, String>();
110110
final var unit = randomFrom(ChronoUnit.SECONDS, ChronoUnit.MINUTES);
111111
final var timestamp = Instant.now();
112+
logger.info("timestamp is " + timestamp);
112113

113114
// Index 10 docs in datastream
114115
//
@@ -200,6 +201,34 @@ enum Operation {
200201
assertThat(deleteResponse.getVersion(), equalTo(2L));
201202
}
202203

204+
// Index more random docs
205+
if (randomBoolean()) {
206+
int nbDocs = randomIntBetween(1, 100);
207+
final var arrayOfDocs = new XContentBuilder[nbDocs];
208+
209+
var t = timestamp.plus(4, unit); // t + 4s, no overlap with previous docs
210+
while (nbDocs > 0) {
211+
var hosts = randomSubsetOf(List.of("vm-dev01", "vm-dev02", "vm-dev03"));
212+
for (var host : hosts) {
213+
if (--nbDocs < 0) {
214+
break;
215+
}
216+
arrayOfDocs[nbDocs] = document(t, host, "cpu-load", randomInt(10));
217+
}
218+
// always use seconds, otherwise the doc might fell outside of the timestamps window of the datastream
219+
t = t.plus(1, ChronoUnit.SECONDS);
220+
}
221+
222+
results = createDocuments(dataStreamName, arrayOfDocs);
223+
224+
// Verify that documents are created
225+
for (var result : results) {
226+
assertThat(result.getResponse().getResult(), equalTo(DocWriteResponse.Result.CREATED));
227+
assertThat(result.getVersion(), equalTo(1L));
228+
docs.put(result.getId(), result.getIndex());
229+
}
230+
}
231+
203232
refresh(dataStreamName);
204233

205234
assertCheckedResponse(client().prepareSearch(dataStreamName).setTrackTotalHits(true).setSize(100), searchResponse -> {

server/src/main/java/org/elasticsearch/index/codec/tsdb/TSDBSyntheticIdCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public FieldInfos read(Directory directory, SegmentInfo segmentInfo, String segm
225225

226226
/**
227227
* {@link PostingsFormat} that throws an {@link IllegalArgumentException} if a Lucene field with the name {@code _id} has postings
228-
* produces during indexing.
228+
* produced during indexing.
229229
*/
230230
private static class EnsureNoPostingsFormat extends PostingsFormat {
231231

0 commit comments

Comments
 (0)