[TEST] select timestamp differently for test documents
Original commit: elastic/x-pack-elasticsearch@679273012c
This commit is contained in:
parent
215410e93f
commit
29451bb7e3
|
@ -119,7 +119,7 @@ public class DatafeedJobsIT extends ESIntegTestCase {
|
||||||
.get();
|
.get();
|
||||||
long numDocs1 = randomIntBetween(32, 2048);
|
long numDocs1 = randomIntBetween(32, 2048);
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long lastWeek = System.currentTimeMillis() - 604800000;
|
long lastWeek = now - 604800000;
|
||||||
indexDocs("data", numDocs1, lastWeek, now);
|
indexDocs("data", numDocs1, lastWeek, now);
|
||||||
|
|
||||||
Job.Builder job = createJob();
|
Job.Builder job = createJob();
|
||||||
|
@ -177,14 +177,14 @@ public class DatafeedJobsIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indexDocs(String index, long numDocs, long start, long end) {
|
private void indexDocs(String index, long numDocs, long start, long end) {
|
||||||
int maxIncrement = (int) ((end - start) / numDocs);
|
int maxDelta = (int) (end - start - 1);
|
||||||
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
|
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
|
||||||
long timestamp = start;
|
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
IndexRequest indexRequest = new IndexRequest(index, "type");
|
IndexRequest indexRequest = new IndexRequest(index, "type");
|
||||||
|
long timestamp = start + randomIntBetween(0, maxDelta);
|
||||||
|
assert timestamp >= start && timestamp < end;
|
||||||
indexRequest.source("time", timestamp);
|
indexRequest.source("time", timestamp);
|
||||||
bulkRequestBuilder.add(indexRequest);
|
bulkRequestBuilder.add(indexRequest);
|
||||||
timestamp += randomIntBetween(1, maxIncrement);
|
|
||||||
}
|
}
|
||||||
BulkResponse bulkResponse = bulkRequestBuilder
|
BulkResponse bulkResponse = bulkRequestBuilder
|
||||||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
||||||
|
|
Loading…
Reference in New Issue